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: 8326051 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@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 A999EC02AA for ; Tue, 16 Feb 2016 13:56:54 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B9D9D20279 for ; Tue, 16 Feb 2016 13:56:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B576E20263 for ; Tue, 16 Feb 2016 13:56:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932600AbcBPNyN (ORCPT ); Tue, 16 Feb 2016 08:54:13 -0500 Received: from mail-wm0-f48.google.com ([74.125.82.48]:34400 "EHLO mail-wm0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932596AbcBPNyL (ORCPT ); Tue, 16 Feb 2016 08:54:11 -0500 Received: by mail-wm0-f48.google.com with SMTP id b205so111062818wmb.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=MbrlFrAqEvOnydYMedkup/JNJwbUg/x55DJUTpZu3y6PWdKACFaA22oNIv3/kDZ9M2 cXDzuMfAulDLHut6c3P0pOYdewFqR7KXD4Dwjrtt4zrnilWQQk8mLUFjXekqRdAZFaHV icwxRrIDuJ36zG39V8HNcaBETayuPTLiDA495U4hh3SqsjNsYkGObdH0Wpbw+KJlQMcM JcSI61K/VsJgd/KL5AeOSjihjjFhzujkrphycmyfD2UN0TRUQ5B90tFQ0Q97Gn10py/4 yWFk4S5VhlekmOZcJRjyWw7ZrVZHvPBukwgyhJnT5Lb3ecm+1YSyqZk7UCeByzI8QRTl VbeQ== X-Gm-Message-State: AG10YOSIaHj2DxDbEuSAE14xY107sfeRajpICS3dou9/VF7aluHUOup/t6RosJPwITSOGA== 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 Cc: robert.richter@caviumnetworks.com, mw@semihalf.com, Liviu.Dudau@arm.com, ddaney@caviumnetworks.com, wangyijing@huawei.com, Suravee.Suthikulpanit@amd.com, msalter@redhat.com, linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linaro-acpi@lists.linaro.org, jcm@redhat.com, Tomasz Nowicki 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> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,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) { }