From patchwork Fri Jun 10 19:55:18 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Nowicki X-Patchwork-Id: 9170403 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 4AA166048F for ; Fri, 10 Jun 2016 19:59:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3BC8A26E5D for ; Fri, 10 Jun 2016 19:59:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3010C28325; Fri, 10 Jun 2016 19:59:10 +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=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=unavailable version=3.3.1 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.wl.linuxfoundation.org (Postfix) with ESMTPS id B58D326E5D for ; Fri, 10 Jun 2016 19:59:09 +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 1bBSYo-0002P4-7v; Fri, 10 Jun 2016 19:57:42 +0000 Received: from mail-lf0-x230.google.com ([2a00:1450:4010:c07::230]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1bBSXY-00014X-5Q for linux-arm-kernel@lists.infradead.org; Fri, 10 Jun 2016 19:56:25 +0000 Received: by mail-lf0-x230.google.com with SMTP id u74so52310313lff.2 for ; Fri, 10 Jun 2016 12:56:08 -0700 (PDT) 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=qMZOCxPM1XtkUNk+SAT+VsI59rVzhSEfxMJH7RE+e9c=; b=O13DCz6BY3eCF1qFFx3CnxzVnbUERrR8OBZvTf/wlKA/nTKMAiy4AdozoLG+KCc+lt fBeEZztVYXRQapj/jB3Msm6XNKAlHBasqvjj8omjpb1F77E2/ONONzkCid95aun/50Ec dXEzGJVhGnOmfhax/pMOVIXL5BCrtFvrTGcGIWDsgt4xkaxJi8Xcjjm5DTejdz0kN/Aw Efmny8L43BhKa3E0mzn7JC7tyn+uOI5CXqlixK7VzzYwgKSmxJiGZDoKLR48K+ur0juT mTEdfsoH/KDz+dJgR4m8EBwJu7W4737VM5V5x+DaTYb/0of6E4kmSDeTFYH4M2e3U2Lc ZsKg== 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=qMZOCxPM1XtkUNk+SAT+VsI59rVzhSEfxMJH7RE+e9c=; b=haTgEHb8lwuAMrygjR9MiDPdOGt3UCmK4nqicxyrCBcWMIAe3Qaa/aoRHTdW9r2aRy 9Gfhb2jMP1K1l3zMJntMrMjb8ojHEUZe5P+sCWX7M574PKDkzjkF+QrDIAjF7zj2vGRN QZpYwNntOo5gZJ33ft4VB/JRFGYo/bT38JhaBPk0TBYD+efv0DEtSSQsyhMh+o62NgHM 1z8+IM3L2PkdhEReP553EzGqIvccF5AYd9Kzpf+4GdwbdxtT9iD/PLmxFkGfvWb7JZp/ Yuw7y6j6vC/4DxKrjow2ymP8Ip1gGDGQwRhj9PkRDH0OSscxCxbK4i+eFq/e/IhcWZ93 LOjQ== X-Gm-Message-State: ALyK8tIuOXrwlNOQ+jAP6A9yTt0nMFaU/V/mfcHQw19Hon6Ke12KHA8s+PYaTYZd+JM4cw== X-Received: by 10.25.90.15 with SMTP id o15mr1163511lfb.67.1465588567300; Fri, 10 Jun 2016 12:56:07 -0700 (PDT) Received: from tn-HP-4.semihalf.local (31-172-191-173.noc.fibertech.net.pl. [31.172.191.173]) by smtp.gmail.com with ESMTPSA id a190sm1377175lfe.21.2016.06.10.12.56.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 10 Jun 2016 12:56:06 -0700 (PDT) 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, jchandra@broadcom.com Subject: [PATCH V9 10/11] ARM64/PCI: Implement ACPI low-level calls to access PCI_Config region from AML Date: Fri, 10 Jun 2016 21:55:18 +0200 Message-Id: <1465588519-11334-11-git-send-email-tn@semihalf.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1465588519-11334-1-git-send-email-tn@semihalf.com> References: <1465588519-11334-1-git-send-email-tn@semihalf.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160610_125624_532890_C257C95C X-CRM114-Status: GOOD ( 12.72 ) 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, dhdang@apm.com, Liviu.Dudau@arm.com, ddaney@caviumnetworks.com, jeremy.linton@arm.com, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, robert.richter@caviumnetworks.com, cov@codeaurora.org, Suravee.Suthikulpanit@amd.com, msalter@redhat.com, wangyijing@huawei.com, Tomasz Nowicki , mw@semihalf.com, andrea.gallo@linaro.org, linux-arm-kernel@lists.infradead.org, liudongdong3@huawei.com MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP ACPI spec6.1 - chapter: 5.5.2.4 defines OperationRegion (Declare Operation Region). Following the spec: " [...] An Operation Region is a specific region of operation within an address space that is declared as a subset of the entire address space using a starting address (offset) and a length. Control methods must have exclusive access to any address accessed via fields declared in Operation Regions. [...]". OperationRegion allows to declare various of operation region address space identifiers including PCI_Config. PCI_Config is meant to access PCI configuration space from the ASL. So every time ASL opcode operates on PCI_Config space region, ASL interpreter dispatches accesses to OS low-level calls - raw_pci_write() and raw_pci_read() for Linux - so-called ACPI RAW accessors. In order to support PCI_Config operation region, implement mentioned raw_pci_write() and raw_pci_read() calls so they find associated bus and call read/write ops. Waiting for clarification in the ACPI specifications in relation to PCI_Config space handling before PCI bus enumeration is completed, current code does not support PCI_Config region accesses before PCI bus enumeration whilst providing full AML PCI_Config access availability when the PCI bus enumeration is completed by the kernel so that RAW accessors can look-up PCI operations through the struct pci_bus associated with a PCI bus. Signed-off-by: Tomasz Nowicki Signed-off-by: Jayachandran C Reviewed-by: Lorenzo Pieralisi --- arch/arm64/kernel/pci.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/arch/arm64/kernel/pci.c b/arch/arm64/kernel/pci.c index b3b8a2c..328f857 100644 --- a/arch/arm64/kernel/pci.c +++ b/arch/arm64/kernel/pci.c @@ -71,13 +71,21 @@ int pcibios_alloc_irq(struct pci_dev *dev) int raw_pci_read(unsigned int domain, unsigned int bus, unsigned int devfn, int reg, int len, u32 *val) { - return -ENXIO; + struct pci_bus *b = pci_find_bus(domain, bus); + + if (!b) + return PCIBIOS_DEVICE_NOT_FOUND; + return b->ops->read(b, devfn, reg, len, val); } int raw_pci_write(unsigned int domain, unsigned int bus, unsigned int devfn, int reg, int len, u32 val) { - return -ENXIO; + struct pci_bus *b = pci_find_bus(domain, bus); + + if (!b) + return PCIBIOS_DEVICE_NOT_FOUND; + return b->ops->write(b, devfn, reg, len, val); } #ifdef CONFIG_NUMA