From patchwork Sat Oct 15 04:31:07 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sinan Kaya X-Patchwork-Id: 9377709 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DFDCB60865 for ; Sat, 15 Oct 2016 04:42:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CFB232A2CC for ; Sat, 15 Oct 2016 04:42:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C2DCA2A2CF; Sat, 15 Oct 2016 04:42:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 33C952A2D2 for ; Sat, 15 Oct 2016 04:42:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752303AbcJOElz (ORCPT ); Sat, 15 Oct 2016 00:41:55 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:48909 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750762AbcJOElk (ORCPT ); Sat, 15 Oct 2016 00:41:40 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 1CB5E61824; Sat, 15 Oct 2016 04:31:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1476505883; bh=iuyuM1+k69YLtBD+X2WL2G6iodjXDDKCCBYWPKxvICg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lFOCV6TzunPwUVuxaQfiPxAwqsWFpd3ai4d/Cwry0lRQHDsSRXhhyghVJ6HcdIzo3 PgEAuwPlIgcjwl0dnjTL/ta+w30YhufYukk9CrOGBqg9FytGnntqMF49M/h7i2Aeyl BjGiFGDfoWlbsmUrmQ/QNbGTdZZsk+TmsX3IztcM= Received: from drakthul.qualcomm.com (global_nat1_iad_fw.qualcomm.com [129.46.232.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: okaya@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id ADF726170E; Sat, 15 Oct 2016 04:31:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1476505882; bh=iuyuM1+k69YLtBD+X2WL2G6iodjXDDKCCBYWPKxvICg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AMVjVWoKFfsuSKRVdomAxOVwuEP9FkK1q9XmJsU7SbVFQBc3dPHwISPCNkq39oPax Vo0ki8ZnF02yvsw94Q9Ih2+mz8t2vDRD/fkE7dC56QX3va/01lNQ1x+kJ/+NzXT6YL T9s0gqhRjVqpQbj4wVzuS9C5z9OJX28Mk3CsnV4s= DMARC-Filter: OpenDMARC Filter v1.3.1 smtp.codeaurora.org ADF726170E Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=pass smtp.mailfrom=okaya@codeaurora.org From: Sinan Kaya To: linux-acpi@vger.kernel.org, rjw@rjwysocki.net, bhelgaas@google.com, ravikanth.nalla@hpe.com, linux@rainbow-software.org, timur@codeaurora.org, cov@codeaurora.org, jcm@redhat.com, alex.williamson@redhat.com Cc: linux-pci@vger.kernel.org, agross@codeaurora.org, linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, wim@djo.tudelft.nl, Sinan Kaya , Len Brown , linux-kernel@vger.kernel.org Subject: [PATCH V3 3/3] ACPI,PCI,IRQ: correct SCI penalty calculation Date: Sat, 15 Oct 2016 00:31:07 -0400 Message-Id: <1476505867-24599-4-git-send-email-okaya@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1476505867-24599-1-git-send-email-okaya@codeaurora.org> References: <1476505867-24599-1-git-send-email-okaya@codeaurora.org> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP It seems like the problem is that we removed acpi_penalize_sci_irq(), which told us the polarity and trigger mode. We tried to get that information via irq_get_trigger_type(), but that didn't work in this case because we use the acpi_irq_get_penalty() path before the SCI is registered. To fix this problem, we only need to fix the penalty for the SCI interrupt. It seems better to add a single "sci_penalty" variable, set it to PIRQ_PENALTY_PCI_USING if it's level/low or PIRQ_PENALTY_ISA_ALWAYS otherwise, and add "sci_penalty" in when appropriate. That should fix it for *any* SCI IRQ, not just those less than 256, and we don't have to add these extra penalty table entries that are all unused (except possibly for one entry if we have an SCI in the 16-255 range). Signed-off-by: Sinan Kaya --- drivers/acpi/pci_link.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/drivers/acpi/pci_link.c b/drivers/acpi/pci_link.c index 1934e2a..34bf527 100644 --- a/drivers/acpi/pci_link.c +++ b/drivers/acpi/pci_link.c @@ -87,6 +87,7 @@ struct acpi_pci_link { static LIST_HEAD(acpi_link_list); static DEFINE_MUTEX(acpi_link_lock); +static int sci_irq = -1, sci_penalty; /* -------------------------------------------------------------------------- PCI Link Device Management @@ -494,10 +495,15 @@ static int acpi_irq_pci_sharing_penalty(int irq) static int acpi_irq_get_penalty(int irq) { + int penalty = 0; + + if (irq == sci_irq) + penalty += sci_penalty; + if (irq < ACPI_MAX_ISA_IRQS) - return acpi_isa_irq_penalty[irq]; + return penalty + acpi_isa_irq_penalty[irq]; - return acpi_irq_pci_sharing_penalty(irq); + return penalty + acpi_irq_pci_sharing_penalty(irq); } int __init acpi_irq_penalty_init(void) @@ -870,13 +876,13 @@ bool acpi_isa_irq_available(int irq) void acpi_penalize_sci_irq(int irq, int trigger, int polarity) { - if (irq >= 0 && irq < ARRAY_SIZE(acpi_isa_irq_penalty)) { - if (trigger != ACPI_MADT_TRIGGER_LEVEL || - polarity != ACPI_MADT_POLARITY_ACTIVE_LOW) - acpi_isa_irq_penalty[irq] += PIRQ_PENALTY_ISA_ALWAYS; - else - acpi_isa_irq_penalty[irq] += PIRQ_PENALTY_PCI_USING; - } + sci_irq = irq; + + if (trigger == ACPI_MADT_TRIGGER_LEVEL && + polarity == ACPI_MADT_POLARITY_ACTIVE_LOW) + sci_penalty = PIRQ_PENALTY_PCI_USING; + else + sci_penalty = PIRQ_PENALTY_ISA_ALWAYS; } /*