From patchwork Thu Feb 16 12:23:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Orlando Chamberlain X-Patchwork-Id: 58012 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp275317wrn; Thu, 16 Feb 2023 04:38:28 -0800 (PST) X-Google-Smtp-Source: AK7set+0HT1ni7kGdl31HZ34BOuKky2cVinX59slbYIsrRkz/OqofKVdGL+7xLa3xbjM+9sXuVvV X-Received: by 2002:a17:906:5946:b0:8b1:3038:e81f with SMTP id g6-20020a170906594600b008b13038e81fmr5897549ejr.50.1676551108223; Thu, 16 Feb 2023 04:38:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676551108; cv=none; d=google.com; s=arc-20160816; b=xi4M/apTKKzZ/3uVCdCzUr1jgV9wo0ZW0slxyoV5tBntmhLdln4rVfEUP2aAwVTaRH z42daji+nnBEJcfZlrcbtSxcg00mkA8HFk1MNrRTOVxEM8qd2pHmxXeybHSWWPkX9P0s DswRwWMwcbe+fOlEwU2JFVTiJe02T1EKCNNxhOiH3WC24c2DmpzjMoH1dIjsm6qTfMQe CfSU9bxVUbzSVaDGmNZZ3i+JTpLAlI3gPnK+2P1YlsdM1spNS3c5ba9MeIt99DDhuIR9 BHuQopRpMuWXaHnMxmk6lOc8zWNV8YyXc0HOW5ex2rUVC2TKXjfnqgPk3fHoPxPU524O XcdA== 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 :dkim-signature; bh=cV5gSZbAk+OK4o2s0sGW4RLDMGE24woGtYndT0R/1so=; b=HqJHMjr/8n9dhoCHAqx0QmUNzd83mOdEgZuK9cJYDXUqhTALXuI9uWIp7IY6lI8fAs aP49HdbgQMdFpwzFNy5CxikClUpBlbSiPkaW6gxH3h6yE3a4sgtTZGvzwtzJh/VzTVOW HP1J+816LgT7siTRlJXmAsal14166bhxjZs0yYIvTOFiK9XauuVzBpDp5UaT2gpzYdsd FnKe/NFEao+qBmlN9gAxflmVWOPHWF9G6zoDYFCmmTNkSNTtxNaQxsYqLaiKGhgclg+H ldxeCbQvAIiZsiDFljtcy/nZJDUgVUBA30Mehqz7vtDgJCWGf7X8TcENu4As+ZFdi2IF BaAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=aiP8Gui+; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id uj28-20020a170907c99c00b0088bba5ae982si1818142ejc.140.2023.02.16.04.38.05; Thu, 16 Feb 2023 04:38:28 -0800 (PST) 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=@gmail.com header.s=20210112 header.b=aiP8Gui+; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230204AbjBPMZ2 (ORCPT + 99 others); Thu, 16 Feb 2023 07:25:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35088 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230166AbjBPMZX (ORCPT ); Thu, 16 Feb 2023 07:25:23 -0500 Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 439A92D150; Thu, 16 Feb 2023 04:25:22 -0800 (PST) Received: by mail-pl1-x62a.google.com with SMTP id ja21so1814624plb.13; Thu, 16 Feb 2023 04:25:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=cV5gSZbAk+OK4o2s0sGW4RLDMGE24woGtYndT0R/1so=; b=aiP8Gui+ZfrGDh/k74j4XykYop7KbIq6K+9dHNcBJ0e+9iMDfxlkDF+31txhH6GLxY iQujF3TsQgE9ve0hvj0GX+bF+ncNsIDFx18qNQfm0S+ldzG341W17q1pm+IvCghRNzWp KzTDhMWO6WTO9ooW8CKJfo/yC5ESUD76658oGpEPXHQLq/6EdwktEyvZK1nxEhg//rcz vHiJmUOdBI41ZxL2PTrJtkDcMkQMnVme7poxaq/UEFjLiPGVHiI59LBQgiCe+f/jWRXj zUpo7snaDK81yK5vlTWoB5LccLGcIGN1o4DTGA9E3wzidcJTOBA1m98HB67zw47jlx9I PcVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cV5gSZbAk+OK4o2s0sGW4RLDMGE24woGtYndT0R/1so=; b=QNxKU6QtCZjzXXUxeQv01w8/RpJad2GXtGylldod60HdCmjWKYBPBHpl77Wf9r0kUK sL41XVnyndxbBost1YdKcjoQFUcbuU7/snH4HHosTS35/ZE/7RX5VASZD9vXLU9BJBeU 4M94OVTxKUju8Cme6qWJbptGtuEBtFj4eyQZnCyGWSZVJXYEJikaYjH7cgF6DqZnHfMo LVKJuS2BT8sW2LUtUXAvfNv4tESQwYYOksDhZUZyOVmJCP4nsRiAI995A3muHbXkVVRe tuQlwZsR7DARHctKgFaVl/7UjU2rJ0CwdvLhbA39xtGUuhaHITvoteTYKgHR16xSSfMv rsnQ== X-Gm-Message-State: AO0yUKUgoHt0bX41HYdOAmBjE7bYdKIuUPUFWM9Nt4q+tNGn4scGyTrA f+RGQ4i4YHE/hUDAj83KA8w= X-Received: by 2002:a05:6a20:728f:b0:bc:ce49:798d with SMTP id o15-20020a056a20728f00b000bcce49798dmr6571360pzk.41.1676550321820; Thu, 16 Feb 2023 04:25:21 -0800 (PST) Received: from localhost.localdomain ([202.53.32.211]) by smtp.gmail.com with ESMTPSA id c10-20020aa781ca000000b005a909290425sm1224055pfn.172.2023.02.16.04.25.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Feb 2023 04:25:21 -0800 (PST) From: Orlando Chamberlain To: Hans de Goede Cc: Mark Gross , platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, Lukas Wunner , Seth Forshee , Aditya Garg , Aun-Ali Zaidi , Kerem Karabay , Orlando Chamberlain Subject: [PATCH v2 3/5] apple-gmux: Use GMSP acpi method for interrupt clear Date: Thu, 16 Feb 2023 23:23:41 +1100 Message-Id: <20230216122342.5918-4-orlandoch.dev@gmail.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230216122342.5918-1-orlandoch.dev@gmail.com> References: <20230216122342.5918-1-orlandoch.dev@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS 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?1757991255120079749?= X-GMAIL-MSGID: =?utf-8?q?1757991255120079749?= This is needed for interrupts to be cleared correctly on MMIO based gmux's. It is untested if this helps/hinders other gmux types, so currently this is only enabled for the MMIO gmux's. There is also a "GMLV" acpi method, and the "GMSP" method can be called with 1 as its argument, but the purposes of these aren't known and they don't seem to be needed. Signed-off-by: Orlando Chamberlain --- v1->v2: Only enable this on MMIO gmux's drivers/platform/x86/apple-gmux.c | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/drivers/platform/x86/apple-gmux.c b/drivers/platform/x86/apple-gmux.c index 36208e93d745..12a93fc49c36 100644 --- a/drivers/platform/x86/apple-gmux.c +++ b/drivers/platform/x86/apple-gmux.c @@ -76,6 +76,7 @@ struct apple_gmux_config { enum vga_switcheroo_handler_flags_t handler_flags; unsigned long resource_type; bool read_version_as_u32; + bool use_acpi_gmsp; char *name; }; @@ -488,6 +489,7 @@ static const struct apple_gmux_config apple_gmux_pio = { .handler_flags = VGA_SWITCHEROO_CAN_SWITCH_DDC, .resource_type = IORESOURCE_IO, .read_version_as_u32 = false, + .use_acpi_gmsp = false, .name = "classic" }; @@ -500,6 +502,7 @@ static const struct apple_gmux_config apple_gmux_index = { .handler_flags = VGA_SWITCHEROO_NEEDS_EDP_CONFIG, .resource_type = IORESOURCE_IO, .read_version_as_u32 = true, + .use_acpi_gmsp = false, .name = "indexed" }; @@ -511,8 +514,29 @@ static const struct apple_gmux_config apple_gmux_index = { * MCP79, on all following generations it's GPIO pin 6 of the Intel PCH. * The GPE merely signals that an interrupt occurred, the actual type of event * is identified by reading a gmux register. + * + * On MMIO gmux's, we also need to call the acpi method GMSP to properly clear + * interrupts. */ +static int gmux_call_acpi_gmsp(struct apple_gmux_data *gmux_data, int arg) +{ + acpi_status status = AE_OK; + union acpi_object arg0 = { ACPI_TYPE_INTEGER }; + struct acpi_object_list arg_list = { 1, &arg0 }; + + arg0.integer.value = arg; + + status = acpi_evaluate_object(gmux_data->dhandle, "GMSP", &arg_list, NULL); + if (ACPI_FAILURE(status)) { + pr_err("GMSP call failed: %s\n", + acpi_format_exception(status)); + return -ENODEV; + } + + return 0; +} + static inline void gmux_disable_interrupts(struct apple_gmux_data *gmux_data) { gmux_write8(gmux_data, GMUX_PORT_INTERRUPT_ENABLE, @@ -536,7 +560,11 @@ static void gmux_clear_interrupts(struct apple_gmux_data *gmux_data) /* to clear interrupts write back current status */ status = gmux_interrupt_get_status(gmux_data); - gmux_write8(gmux_data, GMUX_PORT_INTERRUPT_STATUS, status); + if (status) { + gmux_write8(gmux_data, GMUX_PORT_INTERRUPT_STATUS, status); + if (gmux_data->config->use_acpi_gmsp) + gmux_call_acpi_gmsp(gmux_data, 0); + } } static void gmux_notify_handler(acpi_handle device, u32 value, void *context)