From patchwork Tue Jun 20 02:56:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luke Jones X-Patchwork-Id: 110235 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp3386384vqr; Mon, 19 Jun 2023 19:59:27 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4JvDX6XyZDAu2MtihmKIGBiitcL2w+DXc6GWHKNgvHN+TUoXamy/9iIRp6sitEoL5g4dy4 X-Received: by 2002:a05:6808:1a29:b0:39e:c6e4:a4a8 with SMTP id bk41-20020a0568081a2900b0039ec6e4a4a8mr9497429oib.12.1687229967478; Mon, 19 Jun 2023 19:59:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687229967; cv=none; d=google.com; s=arc-20160816; b=z/Yi0+74qyXABZZyER/iImOJWMIYOy3k952Tg1ZBFzkutxRPYYEktWbuHZMa/zsFId DJG45HsGLJ4iixmzA1Ea/afDSebFJaUOcccgCmgasle9UUSCRJiQfnFXXLEPXceVeGqt tMmEnJr/vE6CFhpW00wiHmGY5mV20V/lnSIumX98889Y4C5z1OpqXkioKHZyxSOmKzEL RR4Eff9zM8uGwzyweff+Nn8sk9W056N0O34fkvGdgqpUlF77GL8Umi6fYEs3bC0zOF1S dD8E2jbXjZKNTS4kGt87sBYUQhW6LH8ky5XbTUB2qquAKC/9JnZHTDKZwse0guc8ES2q EdAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :feedback-id:dkim-signature:dkim-signature; bh=bX+yoIucZ9XFfpbnNsMb71SaXrBmiqcLLOezSaDu8sg=; b=Bopk87RWRfk6XRxPzdNVbff353ZHgssX/2IyAiC3SgJfvXUuDJLg7EcuQ2K2g+4J4r j98mCeKWiC8Fy6EpTVZ++YmLppHixkgS2pGEf4DCwOdVIp0UiBfwNAhghdeTWFzXSofX Ymc6TAy5iPywHKsvjSlOhZBw2hQW/Qxee4/cJvg3dJvVUdmo/5d9jQgJEpiscMQwnM70 tpvJDfmdCWKA4tVK7wu1YbyUlrEiP1Ul8M+KZpKaCeaAPL0H++j0fyfIxZ5Gbxj597cr 0J2HG3LxJCiduNj8hyqeRfDnIpgTM7SI6PxIRoJN2dbSfxmhy04+Hsubfb32suVgiD9i jESw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ljones.dev header.s=fm3 header.b=YPD2oF1w; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=VrrogAgt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u15-20020a17090a3fcf00b00256023fabd3si8817762pjm.151.2023.06.19.19.59.15; Mon, 19 Jun 2023 19:59:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@ljones.dev header.s=fm3 header.b=YPD2oF1w; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=VrrogAgt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230099AbjFTC5c (ORCPT + 99 others); Mon, 19 Jun 2023 22:57:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44822 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230102AbjFTC51 (ORCPT ); Mon, 19 Jun 2023 22:57:27 -0400 Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ECD0910C8; Mon, 19 Jun 2023 19:57:23 -0700 (PDT) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 578885C01F9; Mon, 19 Jun 2023 22:57:23 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Mon, 19 Jun 2023 22:57:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ljones.dev; h=cc :cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm3; t=1687229843; x= 1687316243; bh=bX+yoIucZ9XFfpbnNsMb71SaXrBmiqcLLOezSaDu8sg=; b=Y PD2oF1wMxdvxaubUCi8j+10DdV/cmm3W9Hq5nJ+OMnRX2l9gb78DBeTQyQWbZIxv GHDmS0I68q93uae/F5yK5EtGCy2z9Q4ictMcpJ89GAe9mFt2sdCMW01bb4OuFKwE /K5Urku03Whz/DmBhBxLy7Zu8u2JOg54IEGCVYAXyCjQ3gBo9c905v8pdiayUTtn yoOa6PVcdkavmk+X2+dtRBvkiDrXsSbN+ik7DbWInZFc1ZC/UnoqJzuFE2L4qCR/ TaT3TcMTfRJdtvHnmYjAaTgj0bVctu9kVUR/rSn9bSmEu0pAYd0PODg6bqx3BYws qz+esZT5IAOe3IsXyHTpw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1687229843; x= 1687316243; bh=bX+yoIucZ9XFfpbnNsMb71SaXrBmiqcLLOezSaDu8sg=; b=V rrogAgtPW3tlj4PUB7AH6VJ6yt7wJOUOUrupj2Wf+ZY4F+GJ4+xPgLw/x/9a1yX7 3x4OShyleERO8Ygtltsq85CYZyKio5L7AjcqFTJXqspVJnGaAQuCXX/5cv2tphBS zBRKmjGBlASOrargf8ZhEBsr7RBFujU6FGWfEoWvHO4jiHSaRK99aVC8GgqTxC+p UhGXcLKplFQmj+l8lbtH7BK79O5STZALyEc3ExwWOB1zPzY/trHVilzReUiJ9lXG p9qXKcJDgFUKtHxflV0DpzM8CzJ1afS1RzExhJ/Gz1kiFFQNTAvbo38hg/DzcYz6 p94L6GZTR6860QxYN1O/w== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrgeefgedgvddvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvfevufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpedfnfhukhgvucffrdculfhonhgvshdfuceolhhukhgvsehl jhhonhgvshdruggvvheqnecuggftrfgrthhtvghrnhepgfetfedugfetudeuheetjefhue fggfelleetvdevtefhueeujeefvdegleevhefgnecuvehluhhsthgvrhfuihiivgepuden ucfrrghrrghmpehmrghilhhfrhhomheplhhukhgvsehljhhonhgvshdruggvvh X-ME-Proxy: Feedback-ID: i5ec1447f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 19 Jun 2023 22:57:20 -0400 (EDT) From: "Luke D. Jones" To: hdegoede@redhat.com Cc: corentin.chary@gmail.com, acpi4asus-user@lists.sourceforge.net, platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hwmon@vger.kernel.org, markgross@kernel.org, jdelvare@suse.com, linux@roeck-us.net, "Luke D. Jones" Subject: [PATCH 5/8] platform/x86: asus-wmi: don't allow eGPU switching if eGPU not connected Date: Tue, 20 Jun 2023 14:56:38 +1200 Message-Id: <20230620025641.53197-6-luke@ljones.dev> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230620025641.53197-1-luke@ljones.dev> References: <20230620025641.53197-1-luke@ljones.dev> MIME-Version: 1.0 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS, SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769188850732106876?= X-GMAIL-MSGID: =?utf-8?q?1769188850732106876?= Check the ASUS_WMI_DEVID_EGPU_CONNECTED method for eGPU connection before allowing the ASUS_WMI_DEVID_EGPU method to run. Signed-off-by: Luke D. Jones --- drivers/platform/x86/asus-wmi.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c index 0c8a4a46b121..821addb284d7 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c @@ -693,6 +693,15 @@ static ssize_t egpu_enable_store(struct device *dev, if (enable > 1) return -EINVAL; + err = asus_wmi_get_devstate_simple(asus, ASUS_WMI_DEVID_EGPU_CONNECTED); + if (err < 0) + return err; + if (err < 1) { + err = -ENODEV; + pr_warn("Failed to set egpu disable: %d\n", err); + return err; + } + err = asus_wmi_set_devstate(ASUS_WMI_DEVID_EGPU, enable, &result); if (err) { pr_warn("Failed to set egpu disable: %d\n", err);