Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp8020940rwb; Wed, 23 Nov 2022 14:16:45 -0800 (PST) X-Google-Smtp-Source: AA0mqf6W/hloX/Xgmjv5i8bIzzxFVyPOig0YP88RAa8glvgmp/E6K4+wq1qtsQCy9AEvyCLNh6/T X-Received: by 2002:a63:4b07:0:b0:46e:9363:d96e with SMTP id y7-20020a634b07000000b0046e9363d96emr9914642pga.85.1669241804986; Wed, 23 Nov 2022 14:16:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669241804; cv=none; d=google.com; s=arc-20160816; b=HGwKweCGxHZoSG8rhnShXYC7fPo/3gKjIi8X7nzG/0SinSMiFriR7sywIsopfkLNYP lTs0vc/K6gh44NM2wzEAF/pRAqcD4HoaeHBHwQ2KoXb4qVyaLCltDo0eFIqYinGZwjzh EkAUKvzpbO0zNYwxTKEZL3IbOpq8mDlaBVGPdPh3pJ6NIjERsFn2Z2E1pTXeLqDUceUx nJPHCgbMBu+HguX1PI4e6k2RVSv9B9ATNTNhCnVXcxj7NoOpK7q0U2wUXR+l7DQf02/T PB6+sGwgL8Aj5+bLZTLJdiTSjdqEx1dVCl4A7sRrryX/4k2yp8Ttx4x+jJM/gQ12Oa1e 3jJQ== 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:dkim-signature; bh=D/IG6aN7NVTAZ/xMxOsnr2tGYOM0JOYTUCbROLhD6IE=; b=mTrt6SpQnRO21HbAFXc+WXm+HjFGurUc2MWwRdqfI9A5sANWZgAE4mnYlCZzjXrMNv MgElWnD9Em+nwyKB2GlD+ceYFpeRKQ3jex3KcOtk9D0V1I6EpNW/PnZK8S5sZHUZGgZv xOeAmeDO7AOjf6mSfSXTa3QHvJQD5gLKOOYAkWGLwNzztyWEuYkzmJ1gTcHHwGcT3cJi 8yKm3I4u7dCFA7C8EgPF6j/B7CS1aLJknGouxmGDgveLdXsnE+cxFV0wSz8rCePSRtGA bbofQocADH45YpP8Nz+Bn9K6vYDEKoPINFxsH1HrZsqeG+g8vy1hJs8TBcpOh19cI2hW vzlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@o2.pl header.s=1024a header.b=ehkvJLTa; 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=NONE dis=NONE) header.from=o2.pl Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u9-20020a17090341c900b0018690a76b7dsi18388778ple.359.2022.11.23.14.16.33; Wed, 23 Nov 2022 14:16:44 -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 (test mode) header.i=@o2.pl header.s=1024a header.b=ehkvJLTa; 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=NONE dis=NONE) header.from=o2.pl Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238741AbiKWVt0 (ORCPT + 88 others); Wed, 23 Nov 2022 16:49:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58758 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238466AbiKWVtY (ORCPT ); Wed, 23 Nov 2022 16:49:24 -0500 Received: from mx-out.tlen.pl (mx-out.tlen.pl [193.222.135.142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 42F3E391DC for ; Wed, 23 Nov 2022 13:49:21 -0800 (PST) Received: (wp-smtpd smtp.tlen.pl 15356 invoked from network); 23 Nov 2022 22:49:16 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=o2.pl; s=1024a; t=1669240156; bh=D/IG6aN7NVTAZ/xMxOsnr2tGYOM0JOYTUCbROLhD6IE=; h=From:To:Cc:Subject; b=ehkvJLTaw1giNPygoMQQm4TnossN3yKX7pNCmvhADnUf4COHSCstExcu3jdQeB3mD qTMfbHcgL4y/vSf3m/nbMpw7IOhvoOfQt/Oeb1tqD0D4J31DN3JJmypzTdggHdeU3c DBymsGov5byGJyCbttdKsXb0dD+HfFHJUKGkwgEk= Received: from aafn183.neoplus.adsl.tpnet.pl (HELO localhost.localdomain) (mat.jonczyk@o2.pl@[83.4.143.183]) (envelope-sender ) by smtp.tlen.pl (WP-SMTPD) with SMTP for ; 23 Nov 2022 22:49:16 +0100 From: =?UTF-8?q?Mateusz=20Jo=C5=84czyk?= To: linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, linux-acpi@vger.kernel.org, linux-i2c@vger.kernel.org Cc: =?UTF-8?q?Mateusz=20Jo=C5=84czyk?= , Bjorn Helgaas , "Rafael J. Wysocki" , Len Brown , Borislav Petkov , Jean Delvare , Jean Delvare Subject: [PATCH v3] acpi,pci: warn about duplicate IRQ routing entries returned from _PRT Date: Wed, 23 Nov 2022 22:48:44 +0100 Message-Id: <20221123214844.4760-1-mat.jonczyk@o2.pl> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-WP-MailID: af4bfda2c63d7e23bafa6513101a476e X-WP-AV: skaner antywirusowy Poczty o2 X-WP-SPAM: NO 000000A [0VP0] 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,SPF_HELO_NONE, SPF_PASS autolearn=unavailable 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 On some platforms, the ACPI _PRT function returns duplicate interrupt routing entries. Linux uses the first matching entry, but sometimes the second matching entry contains the correct interrupt vector. Print an error to dmesg if duplicate interrupt routing entries are present, so that we could check how many models are affected. This happens on a Dell Latitude E6500 laptop with the i2c-i801 Intel SMBus controller. This controller was nonfunctional unless its interrupt usage was disabled (using the "disable_features=0x10" module parameter). After investigation, it turned out that the driver was using an incorrect interrupt vector: in lspci output for this device there was: Interrupt: pin B routed to IRQ 19 but after running i2cdetect (without using any i2c-i801 module parameters) the following was logged to dmesg: [...] i801_smbus 0000:00:1f.3: Timeout waiting for interrupt! i801_smbus 0000:00:1f.3: Transaction timeout i801_smbus 0000:00:1f.3: Timeout waiting for interrupt! i801_smbus 0000:00:1f.3: Transaction timeout irq 17: nobody cared (try booting with the "irqpoll" option) Existence of duplicate entries in a table returned by the _PRT method was confirmed by disassembling the ACPI DSDT table. Signed-off-by: Mateusz Jończyk Cc: Bjorn Helgaas Cc: "Rafael J. Wysocki" Cc: Len Brown Cc: Borislav Petkov Cc: Jean Delvare Reviewed-by: Jean Delvare Tested-by: Jean Delvare -- v2: - add a newline at the end of the kernel log message, - replace: "if (match == NULL)" -> "if (!match)" - patch description tweaks. v3: - fix C style issues pointed by Jean Delvare, - switch severity from warning to error. To consider: should we print a warning or an error in case of duplicate entries? This may be not serious enough to disturb the user with an error message at boot. On the other hand, hardware vendors should see it and the kernel uses this logging severtity in similar cases. --- drivers/acpi/pci_irq.c | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/drivers/acpi/pci_irq.c b/drivers/acpi/pci_irq.c index 08e15774fb9f..1c846def1ce4 100644 --- a/drivers/acpi/pci_irq.c +++ b/drivers/acpi/pci_irq.c @@ -203,6 +203,8 @@ static int acpi_pci_irq_find_prt_entry(struct pci_dev *dev, struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; struct acpi_pci_routing_table *entry; acpi_handle handle = NULL; + struct acpi_prt_entry *match = NULL; + const char *match_int_source = NULL; if (dev->bus->bridge) handle = ACPI_HANDLE(dev->bus->bridge); @@ -219,13 +221,31 @@ static int acpi_pci_irq_find_prt_entry(struct pci_dev *dev, entry = buffer.pointer; while (entry && (entry->length > 0)) { - if (!acpi_pci_irq_check_entry(handle, dev, pin, - entry, entry_ptr)) - break; + struct acpi_prt_entry *curr; + + if (!acpi_pci_irq_check_entry(handle, dev, pin, entry, &curr)) { + if (!match) { + match = curr; + match_int_source = entry->source; + } else { + pr_err(FW_BUG + "ACPI _PRT returned duplicate IRQ routing entries for device %04x:%02x:%02x[INT%c]: %s[%d] and %s[%d]\n", + curr->id.segment, curr->id.bus, curr->id.device, + pin_name(curr->pin), + match_int_source, match->index, + entry->source, curr->index); + /* We use the first matching entry nonetheless, + * for compatibility with older kernels. + */ + } + } + entry = (struct acpi_pci_routing_table *) ((unsigned long)entry + entry->length); } + *entry_ptr = match; + kfree(buffer.pointer); return 0; } base-commit: eb7081409f94a9a8608593d0fb63a1aa3d6f95d8 -- 2.25.1