Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp2722168pxv; Sun, 11 Jul 2021 23:50:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy4Z84fqNDlP3dqgahYQe35afeUFFwLaQFVW7q/xBBqMqsLDVcGM+xyiWGkZyuXRBVn6qJg X-Received: by 2002:a05:6402:1911:: with SMTP id e17mr62849508edz.36.1626072648252; Sun, 11 Jul 2021 23:50:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626072648; cv=none; d=google.com; s=arc-20160816; b=ap398T8EEOBXza7Ghaclr05+Me/z+tKNVnAuDWfSnvmh62+3/C3srB5HuzUy1PTguD z6yZYxi7kysUlCYBe0AHQwpkfykUbD5nkdefXE0m+36vZ/Xxq59ELswwPRBMnmWxlSkG BY36pOqByGRbLr5nqOhVRfqYXGZu/eRewSPHcKbRY9CPRuUOaDFewPv+hCCB43YqLW4L B0WhbJ7f5owWcsx1wABCATBBMK9w7ciidkNaRxENknNZXDF9B9n9LJHW976HOnfPWBsA hgHJYvbvKb2N96RkAA/Hxk3IMBuVdvX0OsQfji5WMe3l2f2civymPsr/G8Y4wDJ0T0Uu sqQg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=lOeFXNE6fiHdB3MBcsdMSj6ym3YO1vvsKZiYwqq9jkw=; b=GdSPIpiLiAP4sSHkFkkdR87CRwaicIfz0nQ4gxSI8lu0MYAKWn0BcM8OeF/PGtxcrT pnqdIqb6mzIACJZEmFdiZj3oxtmihrPbiQ2Ir5jDS9NVla3lqxlAwvKCPpGKFyLLZCvk MOcXJcK/r7/o/rPTiRIf7HqE7Q7xfQc/rPDnpZ2XRi36KwgAcGQ5OcbyfAvren4RnwK/ 3wbSF8hZsHRF79QLW35rhlC+jwuUgX1QJOq7jZaD2XvdEvOe43AP/fxGgsnlSKElhCxt PEpkaIp2JRFnlY1l1hvMko+g8LX0b/kfXr9BIzUJnhvhYNDFY7yG403MZOV0yIW3lX7T B+dQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=I1Xkjhf7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ds7si20157068ejc.692.2021.07.11.23.50.25; Sun, 11 Jul 2021 23:50:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=I1Xkjhf7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238961AbhGLGtZ (ORCPT + 99 others); Mon, 12 Jul 2021 02:49:25 -0400 Received: from mail.kernel.org ([198.145.29.99]:33552 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237459AbhGLGj2 (ORCPT ); Mon, 12 Jul 2021 02:39:28 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5A5DB61132; Mon, 12 Jul 2021 06:35:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626071714; bh=UbSqRmPUS/rnpfuTauuDPfRftV60XW2KR7pGLS8h1Bg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=I1Xkjhf7Eh2yNfa8pQ7faHRMLWQXTiqrTK4bDRUzTmRdcTweyQSgeIn9G7JbvXteG jE147zaePDnR96uJdtz1PROC3HbC5wSawrpQJfQhp6lRtfhH1LDYnHLh6Nf1S5U6dY cfImEf5Drlcnz/ugdiFIWLt7sjau/f1kCwBQk/iM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Rafael J. Wysocki" , Manuel Krause , Hui Wang , Sasha Levin Subject: [PATCH 5.10 187/593] ACPI: resources: Add checks for ACPI IRQ override Date: Mon, 12 Jul 2021 08:05:47 +0200 Message-Id: <20210712060903.591188609@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210712060843.180606720@linuxfoundation.org> References: <20210712060843.180606720@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Hui Wang [ Upstream commit 0ec4e55e9f571f08970ed115ec0addc691eda613 ] The laptop keyboard doesn't work on many MEDION notebooks, but the keyboard works well under Windows and Unix. Through debugging, we found this log in the dmesg: ACPI: IRQ 1 override to edge, high pnp 00:03: Plug and Play ACPI device, IDs PNP0303 (active) And we checked the IRQ definition in the DSDT, it is: IRQ (Level, ActiveLow, Exclusive, ) {1} So the BIOS defines the keyboard IRQ to Level_Low, but the Linux kernel override it to Edge_High. If the Linux kernel is modified to skip the IRQ override, the keyboard will work normally. >From the existing comment in acpi_dev_get_irqresource(), the override function only needs to be called when IRQ() or IRQNoFlags() is used to populate the resource descriptor, and according to Section 6.4.2.1 of ACPI 6.4 [1], if IRQ() is empty or IRQNoFlags() is used, the IRQ is High true, edge sensitive and non-shareable. ACPICA also assumes that to be the case (see acpi_rs_set_irq[] in rsirq.c). In accordance with the above, check 3 additional conditions (EdgeSensitive, ActiveHigh and Exclusive) when deciding whether or not to treat an ACPI_RESOURCE_TYPE_IRQ resource as "legacy", in which case the IRQ override is applicable to it. Link: https://uefi.org/specs/ACPI/6.4/06_Device_Configuration/Device_Configuration.html#irq-descriptor # [1] BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=213031 BugLink: http://bugs.launchpad.net/bugs/1909814 Suggested-by: Rafael J. Wysocki Reported-by: Manuel Krause Tested-by: Manuel Krause Signed-off-by: Hui Wang [ rjw: Subject rewrite, changelog edits ] Signed-off-by: Rafael J. Wysocki Signed-off-by: Sasha Levin --- drivers/acpi/resource.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/acpi/resource.c b/drivers/acpi/resource.c index f2f5f1dc7c61..9d82440a1d75 100644 --- a/drivers/acpi/resource.c +++ b/drivers/acpi/resource.c @@ -430,6 +430,13 @@ static void acpi_dev_get_irqresource(struct resource *res, u32 gsi, } } +static bool irq_is_legacy(struct acpi_resource_irq *irq) +{ + return irq->triggering == ACPI_EDGE_SENSITIVE && + irq->polarity == ACPI_ACTIVE_HIGH && + irq->shareable == ACPI_EXCLUSIVE; +} + /** * acpi_dev_resource_interrupt - Extract ACPI interrupt resource information. * @ares: Input ACPI resource object. @@ -468,7 +475,7 @@ bool acpi_dev_resource_interrupt(struct acpi_resource *ares, int index, } acpi_dev_get_irqresource(res, irq->interrupts[index], irq->triggering, irq->polarity, - irq->shareable, true); + irq->shareable, irq_is_legacy(irq)); break; case ACPI_RESOURCE_TYPE_EXTENDED_IRQ: ext_irq = &ares->data.extended_irq; -- 2.30.2