From patchwork Tue Feb 16 13:53:39 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Nowicki X-Patchwork-Id: 8326291 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 99130C02AA for ; Tue, 16 Feb 2016 13:59:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 99AE920268 for ; Tue, 16 Feb 2016 13:59:23 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9B3D820263 for ; Tue, 16 Feb 2016 13:59:22 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aVg8B-0005j8-1H; Tue, 16 Feb 2016 13:57:31 +0000 Received: from mail-wm0-x22b.google.com ([2a00:1450:400c:c09::22b]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aVg5G-0002CN-HZ for linux-arm-kernel@lists.infradead.org; Tue, 16 Feb 2016 13:54:33 +0000 Received: by mail-wm0-x22b.google.com with SMTP id g62so108507306wme.1 for ; Tue, 16 Feb 2016 05:54:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=cbSzbvUjzQh1ITtPyc758OYSJZ++3lCakEMOdwndfQs=; b=0w3g6+Q3G4HRDjUNzr3Iilq4evX4D2BMzMiI2Uwow0PjEL5BT3+ZrRWmzBAQbVl/wx sQS3UvX058D3NWnsaLGyxDjOWzNbqjsP9B/KoSr133M6umsYVLy3n9tEuqYjOZH8Q1Ki gzX1lP22qWSH2Ws615vYmbMaJT5kml0Uw2FBCCMl1YRBkfYF0TL9MTnnNMMLJOoEggWS XE9c2UiOjOQ/4Mq7PNdBEOG2clJgH4vWxhpkbEDOKtXdPMjACefuMda3b/rCXZR31z5x 1vp3gwt2/RqQRX3UnmWBldB7q4A1wDnr8GZZRDggZ9CubpCD/1iM9YQlxBqEWUp9zPDL CZPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=cbSzbvUjzQh1ITtPyc758OYSJZ++3lCakEMOdwndfQs=; b=Hj6YAPiImWv8Ky3hsPMxjgXlr65p4SXKloXigIETmWHAiFBCzWiK3qjLAEQNTbKZSX G7sCzGaKosyvWJkbWAVgDM4UnnklY9m7oug+E8/oQS+RQsgSA3tB8H3sEmizK1L4Br4a dCpY6JCG5XJQdVo3mg9PFyMUJ3WOh4P87jehqa/oOkiqpmEUAxiSuA8SV5akAI6nmZPW TOBoKSwPM053a+s3bql0ZSRVAVQHblbjCdFPeHTWQE0nX7ed/pHFY3cobD8CaFRRiP4v DRrGfqoW+BSVm5NgT8MtAvG5hyCAyLIE+bOFbcrXL5xrIoMbgektGbMOj5hLqjeXbfuR 4RBg== X-Gm-Message-State: AG10YOS6rEvmvR7tYU1uGgETuhpSOqyzwaEtvgbep2IfHrIomJj9ISl9xPqfkj9/Scafnw== X-Received: by 10.28.136.139 with SMTP id k133mr19689213wmd.103.1455630849682; Tue, 16 Feb 2016 05:54:09 -0800 (PST) Received: from tn-HP-4.semihalf.local ([80.82.22.190]) by smtp.gmail.com with ESMTPSA id q129sm20833462wmd.14.2016.02.16.05.54.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 16 Feb 2016 05:54:08 -0800 (PST) From: Tomasz Nowicki To: helgaas@kernel.org, arnd@arndb.de, will.deacon@arm.com, catalin.marinas@arm.com, rafael@kernel.org, hanjun.guo@linaro.org, Lorenzo.Pieralisi@arm.com, okaya@codeaurora.org, jiang.liu@linux.intel.com, jchandra@broadcom.com, Stefano.Stabellini@eu.citrix.com Subject: [PATCH V5 09/15] acpi, mcfg: Add default PCI config accessors implementation and initial support for related quirks. Date: Tue, 16 Feb 2016 14:53:39 +0100 Message-Id: <1455630825-27253-10-git-send-email-tn@semihalf.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1455630825-27253-1-git-send-email-tn@semihalf.com> References: <1455630825-27253-1-git-send-email-tn@semihalf.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160216_055430_898423_706249F6 X-CRM114-Status: GOOD ( 12.32 ) X-Spam-Score: -2.6 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jcm@redhat.com, linaro-acpi@lists.linaro.org, linux-pci@vger.kernel.org, Liviu.Dudau@arm.com, ddaney@caviumnetworks.com, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, robert.richter@caviumnetworks.com, Suravee.Suthikulpanit@amd.com, msalter@redhat.com, wangyijing@huawei.com, Tomasz Nowicki , mw@semihalf.com, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We use generic accessors from access.c by default. However, we already know platforms that need special handling while accessing to PCI config space. These platforms will need different accessors set matched against platform ID, domain, bus touple. Therefore we are going to add (in future) DECLARE_ACPI_MCFG_FIXUP which will register platform specific custom accessors. For now, we let pci_mcfg_get_ops to take acpi_pci_root structure as an arguments and left some space for quirk matching algorithm. Signed-off-by: Tomasz Nowicki Tested-by: Duc Dang Tested-by: Dongdong Liu Tested-by: Hanjun Guo Tested-by: Graeme Gregory Tested-by: Sinan Kaya Reviewed-by: Lorenzo Pieralisi --- drivers/acpi/pci_mcfg.c | 30 ++++++++++++++++++++++++++++++ include/linux/pci-acpi.h | 12 ++++++++++++ 2 files changed, 42 insertions(+) diff --git a/drivers/acpi/pci_mcfg.c b/drivers/acpi/pci_mcfg.c index 3282f2a..0062257 100644 --- a/drivers/acpi/pci_mcfg.c +++ b/drivers/acpi/pci_mcfg.c @@ -41,6 +41,36 @@ int __weak raw_pci_write(unsigned int domain, unsigned int bus, return PCIBIOS_DEVICE_NOT_FOUND; } +void __iomem * +pci_mcfg_dev_base(struct pci_bus *bus, unsigned int devfn, int offset) +{ + struct pci_mmcfg_region *cfg; + + cfg = pci_mmconfig_lookup(pci_domain_nr(bus), bus->number); + if (cfg && cfg->virt) + return cfg->virt + + (PCI_MMCFG_BUS_OFFSET(bus->number) | (devfn << 12)) + + offset; + return NULL; +} + +/* Default generic PCI config accessors */ +static struct pci_ops default_pci_mcfg_ops = { + .map_bus = pci_mcfg_dev_base, + .read = pci_generic_config_read, + .write = pci_generic_config_write, +}; + +struct pci_ops *pci_mcfg_get_ops(struct acpi_pci_root *root) +{ + /* + * TODO: Match against platform specific quirks and return + * corresponding PCI config space accessor set. + */ + + return &default_pci_mcfg_ops; +} + static void list_add_sorted(struct pci_mmcfg_region *new) { struct pci_mmcfg_region *cfg; diff --git a/include/linux/pci-acpi.h b/include/linux/pci-acpi.h index b4f87ba9..3dc6a8c 100644 --- a/include/linux/pci-acpi.h +++ b/include/linux/pci-acpi.h @@ -141,6 +141,18 @@ extern struct list_head pci_mmcfg_list; #define PCI_MMCFG_BUS_OFFSET(bus) ((bus) << 20) #define PCI_MMCFG_OFFSET(bus, devfn) ((bus) << 20 | (devfn) << 12) +#ifdef CONFIG_PCI_MMCONFIG +extern struct pci_ops *pci_mcfg_get_ops(struct acpi_pci_root *root); +extern void __iomem *pci_mcfg_dev_base(struct pci_bus *bus, unsigned int devfn, + int offset); +#else +static inline struct pci_ops *pci_mcfg_get_ops(struct acpi_pci_root *root) +{ return NULL; } +static inline void __iomem *pci_mcfg_dev_base(struct pci_bus *bus, + unsigned int devfn, int offset) +{ return NULL; } +#endif + #else /* CONFIG_ACPI */ static inline void acpi_pci_add_bus(struct pci_bus *bus) { } static inline void acpi_pci_remove_bus(struct pci_bus *bus) { }