Message ID | 5745568.DvuYhMxLoT@kreacher |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce62:0:b0:403:3b70:6f57 with SMTP id o2csp3418320vqx; Mon, 27 Nov 2023 11:57:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IFI0LF9502I6TWmOet7Y5K48IO2rlrB1sW6JnosgPoXI5sXTSUrIz4YrNRTqbv+MufB37Bk X-Received: by 2002:a05:6a20:394b:b0:18c:41cd:c761 with SMTP id r11-20020a056a20394b00b0018c41cdc761mr12364745pzg.7.1701115076089; Mon, 27 Nov 2023 11:57:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701115076; cv=none; d=google.com; s=arc-20160816; b=E8qLtXFdzPRf/ToAPeOnfGdsNJeivhkIu396EaGrzYa0z0a1w6ghTda3ijPPOVaiHt oqBF94hSzoUs8bbJhBl86h4VouDcCH8MfOH7uEmJ2k+0hN5RblLeaxHT08nb/datGP1l Uhm2L5CDkMsbuC3HzNMmfZi42ha5GG2J9j8YWX+rQj9MdCEXydnLCbzuaEee3R5gsttK JWRvE+l4jGFsnwlrGIqIB2y67fNpaiut+hlhslba4j38F5DaP5xGqW4V8jZRv7Odbc0U FbmqKkCE/Wt3CQPxfaxGYBA387SOyfOV54V4ZmRuLZzLA9Bm6h6qWTgg5A/uNZBwN1bq ACmQ== 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 :message-id:date:subject:cc:to:from; bh=bfh3b/jxf0VO522/JRO/hwoHWbd9lwruN+NKetO8Xfo=; fh=Xy56yUsN7dnS9aJqFVOKrydaYiEvkn2fuPmAP6j6D88=; b=ZK7CFpk3y54Acp1+n24hEf3ot8/bEIjlGrplkkXSdUO9KIqlmYdTAtAsj5ECjtFh4Q RvcbT5y1TSaakIiCvYCpGgw0BTHm+gsDzywa2z2wgsam7/hNHHrHzKDShk/z0YkQbFuA IMDE9UroEQu8OdbUVGlKQzZbukL8F1mrTq58jcW+eHx+wKqmoaChgBCq9Pr0Vg3DhrtM hnClfApu6XNNigPgG01JvWmMPRW4Y2fgv8nig6D4gXqx6a+GaSYOHcEiTR2+F8G3gVv4 FNCEenoMRVo9+x175dU+PQkLIe+/8TCRldX/w4yr+ZeTAf/+0M+pX/ZJ3mBHdhxnCBFC U6FA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id e20-20020a656494000000b005be01a390b5si9849299pgv.472.2023.11.27.11.57.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Nov 2023 11:57:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 1A7178245A4B; Mon, 27 Nov 2023 11:57:52 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231545AbjK0T5n (ORCPT <rfc822;toshivichauhan@gmail.com> + 99 others); Mon, 27 Nov 2023 14:57:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42866 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229527AbjK0T5m (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 27 Nov 2023 14:57:42 -0500 Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E49FB8; Mon, 27 Nov 2023 11:57:46 -0800 (PST) Received: from localhost (127.0.0.1) (HELO v370.home.net.pl) by /usr/run/smtp (/usr/run/postfix/private/idea_relay_lmtp) via UNIX with SMTP (IdeaSmtpServer 5.4.0) id ee40771b95509fa8; Mon, 27 Nov 2023 20:57:44 +0100 Received: from kreacher.localnet (unknown [195.136.19.94]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by cloudserver094114.home.pl (Postfix) with ESMTPSA id C11986684FB; Mon, 27 Nov 2023 20:57:43 +0100 (CET) From: "Rafael J. Wysocki" <rjw@rjwysocki.net> To: Linux ACPI <linux-acpi@vger.kernel.org> Cc: LKML <linux-kernel@vger.kernel.org>, Zhang Rui <rui.zhang@intel.com>, Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>, Michal Wilczynski <michal.wilczynski@intel.com>, Hans de Goede <hdegoede@redhat.com>, Andy Shevchenko <andriy.shevchenko@linux.intel.com>, Mika Westerberg <mika.westerberg@linux.intel.com>, Heikki Krogerus <heikki.krogerus@linux.intel.com>, Mario Limonciello <mario.limonciello@amd.com> Subject: [RFT][PATCH v1] ACPI: OSL: Use a threaded interrupt handler for SCI Date: Mon, 27 Nov 2023 20:57:43 +0100 Message-ID: <5745568.DvuYhMxLoT@kreacher> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="UTF-8" X-CLIENT-IP: 195.136.19.94 X-CLIENT-HOSTNAME: 195.136.19.94 X-VADE-SPAMSTATE: clean X-VADE-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvkedrudeiuddgudefvdcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfjqffogffrnfdpggftiffpkfenuceurghilhhouhhtmecuudehtdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvvefufffkggfgtgesthfuredttddtjeenucfhrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqeenucggtffrrghtthgvrhhnpeffffffkefgheehffelteeiveeffeevhfelteejvddvieejjeelvdeiheeuveeuffenucfkphepudelhedrudefiedrudelrdelgeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpeduleehrddufeeirdduledrleegpdhhvghlohepkhhrvggrtghhvghrrdhlohgtrghlnhgvthdpmhgrihhlfhhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqpdhnsggprhgtphhtthhopedutddprhgtphhtthhopehlihhnuhigqdgrtghpihesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehruhhirdiihhgrnhhgsehinhhtvghlrdgtohhmpdhrtghpthhtohepshhrihhnihhvrghsrdhprghnughruhhvrggurgeslhhinhhugidrihhnthgvlhdrtgho mhdprhgtphhtthhopehmihgthhgrlhdrfihilhgtiiihnhhskhhisehinhhtvghlrdgtohhmpdhrtghpthhtohephhguvghgohgvuggvsehrvgguhhgrthdrtghomh X-DCC--Metrics: v370.home.net.pl 1024; Body=10 Fuz1=10 Fuz2=10 X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Mon, 27 Nov 2023 11:57:52 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783748441845673270 X-GMAIL-MSGID: 1783748441845673270 |
Series |
[RFT,v1] ACPI: OSL: Use a threaded interrupt handler for SCI
|
|
Commit Message
Rafael J. Wysocki
Nov. 27, 2023, 7:57 p.m. UTC
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com> In the current arrangement, all of the acpi_ev_sci_xrupt_handler() code is run as an interrupt handler for the SCI, in interrupt context. Among other things, this causes it to run with local interrupts off which can be problematic if many GPEs are enabled and they are located in the I/O address space, for example (because in that case local interrupts will be off for the duration of all of the GPE hardware accesses carried out while handling an SCI combined and that may be quite a bit of time in extreme scenarios). However, there is no particular reason why the code in question really needs to run in interrupt context and in particular, it has no specific reason to run with local interrupts off. The only real requirement is to prevent multiple instences of it from running in parallel with each other, but that can be achieved regardless. For this reason, use request_threaded_irq() instead of request_irq() for the ACPI SCI and pass IRQF_ONESHOT to it in flags to indicate that the interrupt needs to be masked while its handling thread is running so as to prevent it from re-triggering while it is being handled (and in particular until the final handled/not handled outcome is determined). While at it, drop a redundant local variable from acpi_irq(). Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> --- The code inspection and (necessarily limited) testing carried out by me are good indications that this should just always work, but there may be still some really odd platform configurations I'm overlooking, so if you have a way to give it a go, please do so. --- drivers/acpi/osl.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
Comments
On 11/27/2023 13:57, Rafael J. Wysocki wrote: > From: Rafael J. Wysocki <rafael.j.wysocki@intel.com> > > In the current arrangement, all of the acpi_ev_sci_xrupt_handler() code > is run as an interrupt handler for the SCI, in interrupt context. Among > other things, this causes it to run with local interrupts off which > can be problematic if many GPEs are enabled and they are located in the > I/O address space, for example (because in that case local interrupts > will be off for the duration of all of the GPE hardware accesses carried > out while handling an SCI combined and that may be quite a bit of time > in extreme scenarios). > > However, there is no particular reason why the code in question really > needs to run in interrupt context and in particular, it has no specific > reason to run with local interrupts off. The only real requirement is > to prevent multiple instences of it from running in parallel with each > other, but that can be achieved regardless. > > For this reason, use request_threaded_irq() instead of request_irq() for > the ACPI SCI and pass IRQF_ONESHOT to it in flags to indicate that the > interrupt needs to be masked while its handling thread is running so as > to prevent it from re-triggering while it is being handled (and in > particular until the final handled/not handled outcome is determined). > > While at it, drop a redundant local variable from acpi_irq(). > > Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> > --- > > The code inspection and (necessarily limited) testing carried out by me > are good indications that this should just always work, but there may > be still some really odd platform configurations I'm overlooking, so if > you have a way to give it a go, please do so. Thanks for looping me in. I tested it on a few different laptops I have on hand from different SoC generations and manufacturers and ensured that SCI was working correctly for usage and wakeup. My base kernel was 6.7-rc3 plus some unrelated RTC timeout handling patches. Tested-by: Mario Limonciello <mario.limonciello@amd.com> > > --- > drivers/acpi/osl.c | 9 +++------ > 1 file changed, 3 insertions(+), 6 deletions(-) > > Index: linux-pm/drivers/acpi/osl.c > =================================================================== > --- linux-pm.orig/drivers/acpi/osl.c > +++ linux-pm/drivers/acpi/osl.c > @@ -544,11 +544,7 @@ acpi_os_predefined_override(const struct > > static irqreturn_t acpi_irq(int irq, void *dev_id) > { > - u32 handled; > - > - handled = (*acpi_irq_handler) (acpi_irq_context); > - > - if (handled) { > + if ((*acpi_irq_handler)(acpi_irq_context)) { > acpi_irq_handled++; > return IRQ_HANDLED; > } else { > @@ -582,7 +578,8 @@ acpi_os_install_interrupt_handler(u32 gs > > acpi_irq_handler = handler; > acpi_irq_context = context; > - if (request_irq(irq, acpi_irq, IRQF_SHARED, "acpi", acpi_irq)) { > + if (request_threaded_irq(irq, NULL, acpi_irq, IRQF_SHARED | IRQF_ONESHOT, > + "acpi", acpi_irq)) { > pr_err("SCI (IRQ%d) allocation failed\n", irq); > acpi_irq_handler = NULL; > return AE_NOT_ACQUIRED; > > >
Hi Rafael, On Mon, Nov 27, 2023 at 08:57:43PM +0100, Rafael J. Wysocki wrote: > From: Rafael J. Wysocki <rafael.j.wysocki@intel.com> > > In the current arrangement, all of the acpi_ev_sci_xrupt_handler() code > is run as an interrupt handler for the SCI, in interrupt context. Among > other things, this causes it to run with local interrupts off which > can be problematic if many GPEs are enabled and they are located in the > I/O address space, for example (because in that case local interrupts > will be off for the duration of all of the GPE hardware accesses carried > out while handling an SCI combined and that may be quite a bit of time > in extreme scenarios). > > However, there is no particular reason why the code in question really > needs to run in interrupt context and in particular, it has no specific > reason to run with local interrupts off. The only real requirement is > to prevent multiple instences of it from running in parallel with each > other, but that can be achieved regardless. > > For this reason, use request_threaded_irq() instead of request_irq() for > the ACPI SCI and pass IRQF_ONESHOT to it in flags to indicate that the > interrupt needs to be masked while its handling thread is running so as > to prevent it from re-triggering while it is being handled (and in > particular until the final handled/not handled outcome is determined). > > While at it, drop a redundant local variable from acpi_irq(). > > Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> > --- > > The code inspection and (necessarily limited) testing carried out by me > are good indications that this should just always work, but there may > be still some really odd platform configurations I'm overlooking, so if > you have a way to give it a go, please do so. Tried this on ADL-S and ADL-P systems that I have here and both work just fine with the patch applied. I can see SCI interrupt count increases in /proc/interrupts as expected. Did a couple of s2idle cycles too, all good. Tested-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Hi Mika, Hi Mario, On Wed, Nov 29, 2023 at 11:39 AM Mika Westerberg <mika.westerberg@linux.intel.com> wrote: > > Hi Rafael, > > On Mon, Nov 27, 2023 at 08:57:43PM +0100, Rafael J. Wysocki wrote: > > From: Rafael J. Wysocki <rafael.j.wysocki@intel.com> > > > > In the current arrangement, all of the acpi_ev_sci_xrupt_handler() code > > is run as an interrupt handler for the SCI, in interrupt context. Among > > other things, this causes it to run with local interrupts off which > > can be problematic if many GPEs are enabled and they are located in the > > I/O address space, for example (because in that case local interrupts > > will be off for the duration of all of the GPE hardware accesses carried > > out while handling an SCI combined and that may be quite a bit of time > > in extreme scenarios). > > > > However, there is no particular reason why the code in question really > > needs to run in interrupt context and in particular, it has no specific > > reason to run with local interrupts off. The only real requirement is > > to prevent multiple instences of it from running in parallel with each > > other, but that can be achieved regardless. > > > > For this reason, use request_threaded_irq() instead of request_irq() for > > the ACPI SCI and pass IRQF_ONESHOT to it in flags to indicate that the > > interrupt needs to be masked while its handling thread is running so as > > to prevent it from re-triggering while it is being handled (and in > > particular until the final handled/not handled outcome is determined). > > > > While at it, drop a redundant local variable from acpi_irq(). > > > > Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> > > --- > > > > The code inspection and (necessarily limited) testing carried out by me > > are good indications that this should just always work, but there may > > be still some really odd platform configurations I'm overlooking, so if > > you have a way to give it a go, please do so. > > Tried this on ADL-S and ADL-P systems that I have here and both work > just fine with the patch applied. I can see SCI interrupt count > increases in /proc/interrupts as expected. Did a couple of s2idle cycles > too, all good. > > Tested-by: Mika Westerberg <mika.westerberg@linux.intel.com> Thanks for your replies and tags! Given the lack of response from anyone else I'm going to move this towards linux-next with 6.8 as the target. Thank you!
On 23/11/30 02:28PM, Rafael J. Wysocki wrote: > Hi Mika, Hi Mario, > Thanks for your replies and tags! > > Given the lack of response from anyone else I'm going to move this > towards linux-next with 6.8 as the target. > > Thank you! I got a stack trace in dmesg with linux6.8-rc1 that seems to be caused by this commit according to my bisection, see the bugzilla report for details / further discussion: https://bugzilla.kernel.org/show_bug.cgi?id=218407 Cheers, Christian
On Tue, Jan 23, 2024 at 5:39 PM Christian Heusel <christian@heusel.eu> wrote: > > On 23/11/30 02:28PM, Rafael J. Wysocki wrote: > > Hi Mika, Hi Mario, > > Thanks for your replies and tags! > > > > Given the lack of response from anyone else I'm going to move this > > towards linux-next with 6.8 as the target. > > > > Thank you! > > I got a stack trace in dmesg with linux6.8-rc1 that seems to be caused > by this commit according to my bisection, see the bugzilla report for > details / further discussion: > > https://bugzilla.kernel.org/show_bug.cgi?id=218407 Mario's suggestion to add IRQF_ONESHOT to pinctrl-amd in amd_gpio_probe() looks right to me.
Index: linux-pm/drivers/acpi/osl.c =================================================================== --- linux-pm.orig/drivers/acpi/osl.c +++ linux-pm/drivers/acpi/osl.c @@ -544,11 +544,7 @@ acpi_os_predefined_override(const struct static irqreturn_t acpi_irq(int irq, void *dev_id) { - u32 handled; - - handled = (*acpi_irq_handler) (acpi_irq_context); - - if (handled) { + if ((*acpi_irq_handler)(acpi_irq_context)) { acpi_irq_handled++; return IRQ_HANDLED; } else { @@ -582,7 +578,8 @@ acpi_os_install_interrupt_handler(u32 gs acpi_irq_handler = handler; acpi_irq_context = context; - if (request_irq(irq, acpi_irq, IRQF_SHARED, "acpi", acpi_irq)) { + if (request_threaded_irq(irq, NULL, acpi_irq, IRQF_SHARED | IRQF_ONESHOT, + "acpi", acpi_irq)) { pr_err("SCI (IRQ%d) allocation failed\n", irq); acpi_irq_handler = NULL; return AE_NOT_ACQUIRED;