From patchwork Thu Oct 4 23:24:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Logan Gunthorpe X-Patchwork-Id: 10626991 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-2.web.codeaurora.org (Postfix) with ESMTP id 80E631515 for ; Thu, 4 Oct 2018 23:25:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 70C41294A7 for ; Thu, 4 Oct 2018 23:25:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 62CB8294B7; Thu, 4 Oct 2018 23:25:07 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham 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 C8B85294A7 for ; Thu, 4 Oct 2018 23:25:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727880AbeJEGUv (ORCPT ); Fri, 5 Oct 2018 02:20:51 -0400 Received: from ale.deltatee.com ([207.54.116.67]:54226 "EHLO ale.deltatee.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725998AbeJEGUv (ORCPT ); Fri, 5 Oct 2018 02:20:51 -0400 Received: from cgy1-donard.priv.deltatee.com ([172.16.1.31]) by ale.deltatee.com with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1g8CzP-00044W-6F; Thu, 04 Oct 2018 17:25:04 -0600 Received: from gunthorp by cgy1-donard.priv.deltatee.com with local (Exim 4.89) (envelope-from ) id 1g8CzO-0000tx-8g; Thu, 04 Oct 2018 17:25:02 -0600 From: Logan Gunthorpe To: linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org Cc: Logan Gunthorpe , Doug Meyer , Bjorn Helgaas , Kurt Schwemmer Date: Thu, 4 Oct 2018 17:24:59 -0600 Message-Id: <20181004232459.3421-1-logang@deltatee.com> X-Mailer: git-send-email 2.19.0 MIME-Version: 1.0 X-SA-Exim-Connect-IP: 172.16.1.31 X-SA-Exim-Rcpt-To: linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, logang@deltatee.com, dmeyer@gigaio.com, bhelgaas@google.com, kurt.schwemmer@microsemi.com X-SA-Exim-Mail-From: gunthorp@deltatee.com Subject: [PATCH] PCI: Fix Switchtec DMA aliasing quirk dmesg noise X-SA-Exim-Version: 4.2.1 (built Tue, 02 Aug 2016 21:08:31 +0000) X-SA-Exim-Scanned: Yes (on ale.deltatee.com) 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 Currently the Switchtec quirk runs on all endpoints in the Switch which includes all the upstream and downstream ports. Seeing these other functions do not contain BARs the quirk fails when trying to map the BAR and prints the error "Cannot iomap Switchtec device". The user will see a few of these useless and scary errors, one for each port in the switch. At most, the quirk should only run on either a management endpoint (class=PCI_CLASS_MEMORY_OTHER) or an NTB endpoint (PCI_CLASS_BRIDGE_OTHER). However, seeing the quirk is useless except in NTB applications, we will only run it when the class is PCI_CLASS_BRIDGE_OTHER. Thus, switch to using DECLARE_PCI_FIXUP_CLASS_FINAL and clean up the list with a define (so we don't have to change as much code if we ever have to adjust the list). Reported-by: Stephen Bates Cc: Doug Meyer Cc: Bjorn Helgaas Cc: Kurt Schwemmer Fixes: ad281ecf1c7d ("PCI: Add DMA alias quirk for Microsemi Switchtec NTB") Signed-off-by: Logan Gunthorpe --- drivers/pci/quirks.c | 90 +++++++++++++++++--------------------------- 1 file changed, 34 insertions(+), 56 deletions(-) diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c index 6bc27b7fd452..853c9cfa2a41 100644 --- a/drivers/pci/quirks.c +++ b/drivers/pci/quirks.c @@ -5057,59 +5057,37 @@ static void quirk_switchtec_ntb_dma_alias(struct pci_dev *pdev) pci_iounmap(pdev, mmio); pci_disable_device(pdev); } -DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_MICROSEMI, 0x8531, - quirk_switchtec_ntb_dma_alias); -DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_MICROSEMI, 0x8532, - quirk_switchtec_ntb_dma_alias); -DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_MICROSEMI, 0x8533, - quirk_switchtec_ntb_dma_alias); -DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_MICROSEMI, 0x8534, - quirk_switchtec_ntb_dma_alias); -DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_MICROSEMI, 0x8535, - quirk_switchtec_ntb_dma_alias); -DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_MICROSEMI, 0x8536, - quirk_switchtec_ntb_dma_alias); -DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_MICROSEMI, 0x8543, - quirk_switchtec_ntb_dma_alias); -DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_MICROSEMI, 0x8544, - quirk_switchtec_ntb_dma_alias); -DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_MICROSEMI, 0x8545, - quirk_switchtec_ntb_dma_alias); -DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_MICROSEMI, 0x8546, - quirk_switchtec_ntb_dma_alias); -DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_MICROSEMI, 0x8551, - quirk_switchtec_ntb_dma_alias); -DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_MICROSEMI, 0x8552, - quirk_switchtec_ntb_dma_alias); -DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_MICROSEMI, 0x8553, - quirk_switchtec_ntb_dma_alias); -DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_MICROSEMI, 0x8554, - quirk_switchtec_ntb_dma_alias); -DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_MICROSEMI, 0x8555, - quirk_switchtec_ntb_dma_alias); -DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_MICROSEMI, 0x8556, - quirk_switchtec_ntb_dma_alias); -DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_MICROSEMI, 0x8561, - quirk_switchtec_ntb_dma_alias); -DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_MICROSEMI, 0x8562, - quirk_switchtec_ntb_dma_alias); -DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_MICROSEMI, 0x8563, - quirk_switchtec_ntb_dma_alias); -DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_MICROSEMI, 0x8564, - quirk_switchtec_ntb_dma_alias); -DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_MICROSEMI, 0x8565, - quirk_switchtec_ntb_dma_alias); -DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_MICROSEMI, 0x8566, - quirk_switchtec_ntb_dma_alias); -DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_MICROSEMI, 0x8571, - quirk_switchtec_ntb_dma_alias); -DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_MICROSEMI, 0x8572, - quirk_switchtec_ntb_dma_alias); -DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_MICROSEMI, 0x8573, - quirk_switchtec_ntb_dma_alias); -DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_MICROSEMI, 0x8574, - quirk_switchtec_ntb_dma_alias); -DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_MICROSEMI, 0x8575, - quirk_switchtec_ntb_dma_alias); -DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_MICROSEMI, 0x8576, - quirk_switchtec_ntb_dma_alias); + +#define SWITCHTEC_QUIRK(vid) \ + DECLARE_PCI_FIXUP_CLASS_FINAL(PCI_VENDOR_ID_MICROSEMI, vid, \ + PCI_CLASS_BRIDGE_OTHER, 8, quirk_switchtec_ntb_dma_alias) +SWITCHTEC_QUIRK(0x8531); //PFX 24xG3 +SWITCHTEC_QUIRK(0x8532); //PFX 32xG3 +SWITCHTEC_QUIRK(0x8533); //PFX 48xG3 +SWITCHTEC_QUIRK(0x8534); //PFX 64xG3 +SWITCHTEC_QUIRK(0x8535); //PFX 80xG3 +SWITCHTEC_QUIRK(0x8536); //PFX 96xG3 +SWITCHTEC_QUIRK(0x8541); //PSX 24xG3 +SWITCHTEC_QUIRK(0x8542); //PSX 32xG3 +SWITCHTEC_QUIRK(0x8543); //PSX 48xG3 +SWITCHTEC_QUIRK(0x8544); //PSX 64xG3 +SWITCHTEC_QUIRK(0x8545); //PSX 80xG3 +SWITCHTEC_QUIRK(0x8546); //PSX 96xG3 +SWITCHTEC_QUIRK(0x8551); //PAX 24XG3 +SWITCHTEC_QUIRK(0x8552); //PAX 32XG3 +SWITCHTEC_QUIRK(0x8553); //PAX 48XG3 +SWITCHTEC_QUIRK(0x8554); //PAX 64XG3 +SWITCHTEC_QUIRK(0x8555); //PAX 80XG3 +SWITCHTEC_QUIRK(0x8556); //PAX 96XG3 +SWITCHTEC_QUIRK(0x8561); //PFXL 24XG3 +SWITCHTEC_QUIRK(0x8562); //PFXL 32XG3 +SWITCHTEC_QUIRK(0x8563); //PFXL 48XG3 +SWITCHTEC_QUIRK(0x8564); //PFXL 64XG3 +SWITCHTEC_QUIRK(0x8565); //PFXL 80XG3 +SWITCHTEC_QUIRK(0x8566); //PFXL 96XG3 +SWITCHTEC_QUIRK(0x8571); //PFXI 24XG3 +SWITCHTEC_QUIRK(0x8572); //PFXI 32XG3 +SWITCHTEC_QUIRK(0x8573); //PFXI 48XG3 +SWITCHTEC_QUIRK(0x8574); //PFXI 64XG3 +SWITCHTEC_QUIRK(0x8575); //PFXI 80XG3 +SWITCHTEC_QUIRK(0x8576); //PFXI 96XG3