From patchwork Sun Nov 29 23:07:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= X-Patchwork-Id: 11939377 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 18A2CC3E8C5 for ; Sun, 29 Nov 2020 23:08:06 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9D7092084C for ; Sun, 29 Nov 2020 23:08:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="p8u7nSnM" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9D7092084C Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=KmijjTFuO4xrQXXSGGwTEfEclB8eYpWqy2werEYa710=; b=p8u7nSnMthBRyrDWOHkwvhwXlG yuEQWoLkTyrKEYcRV9tpQRi4SFM5cxN9sirm1JRq3n0Vka8SeIU0lQDXHqc6ezzhKlGvKUQTSxdTb M/CPSERgWes7jz5IcV8qT1NPZ4FohfYYphy9QKlkTB6XKGTHHZnRqx0HhOor3wKCBLvhn4y9sHYLW 1hC0zjBIbJt9BbDGCrNH2XGST/xvlZPLpGsByVJ05AxI+wZuTE2cdHfFY3v9CY8SJttKrXqz4zinB XW+5TE0Kci89KXiMWCawXTiwxUnG7PLVBg0a9VNsmwhykAekA1ePQyajWRGDdvAKD8GMFkFIU592I 6gvQgVxA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kjVnO-00025P-KQ; Sun, 29 Nov 2020 23:07:54 +0000 Received: from mail-wr1-f68.google.com ([209.85.221.68]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kjVnJ-00022z-63; Sun, 29 Nov 2020 23:07:50 +0000 Received: by mail-wr1-f68.google.com with SMTP id e7so13083062wrv.6; Sun, 29 Nov 2020 15:07:47 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=dIsjLfFDP99Dz5MgIeEC3kYmopeb//2rrPq0h43VXLw=; b=fN7Nm034F3uSuOaJ4jbfpOkUYUIHOCRLX8Q6hTb/KSJXNVStb4UvikKJurLzEV9u41 BA6+1fzXPgwVtXgXObUbQ03WOAqXPV9fenIAka4oCtuLP7cfUt/QivSPrBU9HgtH5qWS f41GfIUHyCiBowaGUeD1w0BuTOGP2eXACI1AmV5uWybvPsmq4nCV7BzYlBHT0GaJbKfb tyJAkwOQ0DtVdys5pR0mRzjzfnHHUIn/FRgSrAnlpIsX85FBVLYYJT2zHqCPW4XZ9O3K PWTpkpzCzVj05KP1WIqCIpDqbuP6rwpcAlXj3LjBazc9DgUk+sxubBS1A/Uk5gBb30/6 V1Kg== X-Gm-Message-State: AOAM533lgLYL3It7JifXhlaBfFcQX1mcU1uzuR1rdvdKifnFYRZWGQb9 D/Znqls/8iRpizgkPiDcFmM= X-Google-Smtp-Source: ABdhPJz/dkK+2g8rJ248iKa8tTMH3iMxLDK3ZiUyWbXRCDA7ANZkmFRz+HppIcBOB0AKWrROKjqraw== X-Received: by 2002:a5d:4892:: with SMTP id g18mr18707990wrq.365.1606691266382; Sun, 29 Nov 2020 15:07:46 -0800 (PST) Received: from workstation.lan ([95.155.85.46]) by smtp.gmail.com with ESMTPSA id d2sm24831005wrn.43.2020.11.29.15.07.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Nov 2020 15:07:45 -0800 (PST) From: =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= To: Bjorn Helgaas Subject: [PATCH v6 0/5] PCI: Unify ECAM constants in native PCI Express drivers Date: Sun, 29 Nov 2020 23:07:38 +0000 Message-Id: <20201129230743.3006978-1-kw@linux.com> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201129_180749_334475_1A319CBF X-CRM114-Status: GOOD ( 17.49 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Heiko Stuebner , Benjamin Herrenschmidt , Shawn Lin , Paul Mackerras , Thomas Petazzoni , Jonathan Chocron , Toan Le , Will Deacon , Rob Herring , Lorenzo Pieralisi , Michael Ellerman , Michal Simek , linux-rockchip@lists.infradead.org, bcm-kernel-feedback-list@broadcom.com, Jonathan Derrick , linux-pci@vger.kernel.org, Ray Jui , Florian Fainelli , linux-rpi-kernel@lists.infradead.org, Jonathan Cameron , linux-arm-kernel@lists.infradead.org, Scott Branden , Zhou Wang , Robert Richter , linuxppc-dev@lists.ozlabs.org, Nicolas Saenz Julienne Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org Unify ECAM-related constants into a single set of standard constants defining memory address shift values for the byte-level address that can be used when accessing the PCI Express Configuration Space, and then move native PCI Express controller drivers to use newly introduced definitions retiring any driver-specific ones. The ECAM ("Enhanced Configuration Access Mechanism") is defined by the PCI Express specification (see PCI Express Base Specification, Revision 5.0, Version 1.0, Section 7.2.2, p. 676), thus most hardware should implement it the same way. Most of the native PCI Express controller drivers define their ECAM-related constants, many of these could be shared, or use open-coded values when setting the ".bus_shift" field of the "struct pci_ecam_ops". All of the newly added constants should remove ambiguity and reduce the number of open-coded values, and also correlate more strongly with the descriptions in the aforementioned specification (see Table 7-1 "Enhanced Configuration Address Mapping", p. 677). Suggested-by: Bjorn Helgaas Signed-off-by: Krzysztof Wilczyński Signed-off-by: Vladimir Oltean Tested-by: Michael Walle --- Changed in v6: Converted single patch into a series. Dropped changes related to PPC 4xx platform. Refactored pci_ecam_map_bus() so that bus, device function and offset are correctly masked, limiting offset to 4K as per the PCI Express Specification. After the refactor this function will now use sensible defaults allowing for removal of the ".bus_shit" initialiser from all the users of the "ecam_ops" structure who do not use a non-standard ECAM bus shit values. Changed in v5: Removed unused constant "PCIE_ECAM_DEV_SHIFT". Refactored ppc4xx_pciex_get_config_base() so that the "offset" parameter can be passed to so that the PCIE_ECAM_OFFSET() macro can be used. Used the ALIGN_DOWN() macro where 32 bit alignment is required instead using the 0xffc mask. Added CFG_ADDR_CFG_TYPE_1 macro to pci/controller/pcie-iproc.c to denote that this is a configuration type 1 address and access type. Refactored boundary check in pci/controller/vmd.c as used by the vmd_cfg_addr() function following addition of the PCIE_ECAM_OFFSET() macro. Changed the "bus->number" to simply pass the "bus" argument in the PCIE_ECAM_OFFSET() macro. Changed in v4: Removed constants related to "CAM". Added more platforms and devices that can use new ECAM macros and constants. Removed unused ".bus_shift" initialisers from pci-xgene.c as xgene_pcie_map_bus() did not use these. Changes in v3: Updated commit message wording. Updated regarding custom ECAM bus shift values and concerning PCI base configuration space access for Type 1 access. Refactored rockchip_pcie_rd_other_conf() and rockchip_pcie_wr_other_conf() and removed the "busdev" variable. Removed surplus "relbus" variable from nwl_pcie_map_bus() and xilinx_pcie_map_bus(). Renamed the PCIE_ECAM_ADDR() macro to PCIE_ECAM_OFFSET(). Changes in v2: Use PCIE_ECAM_ADDR macro when computing ECAM address offset, but drop PCI_SLOT and PCI_FUNC macros from the PCIE_ECAM_ADDR macro in favour of using a single value for the device/function. Krzysztof Wilczyński (5): PCI: Unify ECAM constants in native PCI Express drivers PCI: thunder-pem: Add constant for custom ".bus_shit" initialiser PCI: iproc: Convert to use the new ECAM constants PCI: vmd: Update type of the __iomem pointers PCI: xgene: Removed unused ".bus_shift" initialisers from pci-xgene.c drivers/pci/controller/dwc/pcie-al.c | 12 ++------ drivers/pci/controller/dwc/pcie-hisi.c | 2 -- drivers/pci/controller/pci-aardvark.c | 13 ++------- drivers/pci/controller/pci-host-generic.c | 1 - drivers/pci/controller/pci-thunder-ecam.c | 1 - drivers/pci/controller/pci-thunder-pem.c | 13 +++++++-- drivers/pci/controller/pci-xgene.c | 2 -- drivers/pci/controller/pcie-brcmstb.c | 16 ++--------- drivers/pci/controller/pcie-iproc.c | 31 ++++++--------------- drivers/pci/controller/pcie-rockchip-host.c | 27 +++++++++--------- drivers/pci/controller/pcie-rockchip.h | 8 +----- drivers/pci/controller/pcie-tango.c | 1 - drivers/pci/controller/pcie-xilinx-nwl.c | 9 ++---- drivers/pci/controller/pcie-xilinx.c | 11 ++------ drivers/pci/controller/vmd.c | 19 ++++++------- drivers/pci/ecam.c | 23 ++++++++++----- include/linux/pci-ecam.h | 27 ++++++++++++++++++ 17 files changed, 96 insertions(+), 120 deletions(-)