From patchwork Fri Aug 17 10:26:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 144474 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp600933ljj; Fri, 17 Aug 2018 03:33:05 -0700 (PDT) X-Google-Smtp-Source: AA+uWPxP9djtqrYfuWQ24Hr+2GN1n3AqwEhtcCj+bqp4ja+7elCI4BSARxo96hR56PS5nP4YQsjo X-Received: by 2002:a63:4386:: with SMTP id q128-v6mr32498766pga.353.1534501985587; Fri, 17 Aug 2018 03:33:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534501985; cv=none; d=google.com; s=arc-20160816; b=DevS1Rojmp85NN9TrEmyH5m3kLyw10qGRI+2xZx3qQ6uNmu59QCfeUgshNwLqDXs8x CTCgKwipDX5qew0SvYqNKuq4ZKoap4JA6h58TQK6h4hdPUlvZHAnG55BV0pUa98Y8KiE Gp4F2EStdHFhg9vx92RY0ZNmInzLnCdCXdiQIPB/X0dMYF+bw0ML5XKQ1nfp1BheVBRk yQh+8s8qnVq2DFstQtERShfHlScupLWhbFhjWzUteuqFcUVouFbiSyD5O9s1OHenehdd la4ZjQfY3XPoMLqF0PhHs9AmgLpXcdBKxtbI764cTXwyMz6/v1psuXFH6anmKvTW1X3Q BLCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=g7wxfw76aZWI35Ws4WNA2KhvYos3vv5ZQBFZqyKGqYs=; b=TdFM73V2RPcHMHWjKHnHnFneU8LT4dM4qfQr+OJmuhIZKgWZlkJoRuscDpJq6dbqVD kDILU8uQAo4/axEcRl0FqG70DFR5NYB5Eci/3e9Y3zaFYHX/Z3m6q7b9pOQm7ZbZcIFs lRBuzm6fisTvpv/c74f7nUv/vavJRVIrTFzp4mTRIO/B1WRCSFaELcB0K4jHUy5JCOm2 suK5tw/41rVXGy/4koav6/hjygmmNRbfIgZpQhs2G7em4HMKn/MWE1SWfPBtAD8L6ihE 8O5zqPZQ3eQjQwUTj4CZ083HkxuqznvvK7ZxIxkh+viNQ3ddb+Cd6LMR790KoJWJsEZk RdCA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-acpi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e7-v6si1843308plt.325.2018.08.17.03.33.05; Fri, 17 Aug 2018 03:33:05 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-acpi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-acpi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725992AbeHQNf7 (ORCPT + 9 others); Fri, 17 Aug 2018 09:35:59 -0400 Received: from mout.kundenserver.de ([217.72.192.73]:53879 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726795AbeHQNfe (ORCPT ); Fri, 17 Aug 2018 09:35:34 -0400 Received: from wuerfel.lan ([109.193.40.16]) by mrelayeu.kundenserver.de (mreue101 [212.227.15.145]) with ESMTPA (Nemesis) id 0LopY3-1gNDhj20RX-00glB0; Fri, 17 Aug 2018 12:27:20 +0200 From: Arnd Bergmann To: linux-pci@vger.kernel.org, Bjorn Helgaas Cc: linux-kernel@vger.kernel.org, Christoph Hellwig , Lorenzo Pieralisi , Benjamin Herrenschmidt , linuxppc-dev@lists.ozlabs.org, linux-acpi@vger.kernel.org, Arnd Bergmann Subject: [RFC 13/15] PCI: turn pcibios_alloc_irq into a callback Date: Fri, 17 Aug 2018 12:26:43 +0200 Message-Id: <20180817102645.3839621-14-arnd@arndb.de> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180817102645.3839621-1-arnd@arndb.de> References: <20180817102645.3839621-1-arnd@arndb.de> X-Provags-ID: V03:K1:vGOxD5cso1fRX7vOFpg6264LHD7qp984mQlv5MPT6s07XrS4K2q Ixzfk8bDO/hDFJUEyLUy4cqBFvWycxqJfqu8myqpu+DeGzm1WHg70Dm0VhCWS3UfXdQMZUh vCVDLDNLy0TIi89lHJhy6GxOzRcS4zgTlQr8KfLRoWv/eaypGIooBRH9J0jTanPDmePlu2G yp3nrpbGuNd8g0mqp4zsg== X-UI-Out-Filterresults: notjunk:1; V01:K0:qiT72hH/I1Q=:9Hqj/v305t7b/4GjgDoN/e Ue8HbedIQ953rUOU4QCIrxtJEmq42LgC1lNOW2wV05FwAP1teCMpuw5EXUnwyVPR5Pst0E2oT yFIfuTQMC0KVvRUuZiHkl2xc8AV844sORxrAHRk2FYS6HDx3zKe98/ZfITQolb0YeyfUWSegv 5kgbJb+UtFGVEoCzgiHqOV1URMwqykKggoFu98N5hGdy4ACiAHfwLtrfjAy3XgMtIp34q95eJ OLTSZTGpJWJCzzZGDuH78sPadMJmvRrWhgD/FQsYl9AZcG5gutbR7vaZK5V7TeNW/hfk/xuuG RoKaH+M4ewI+f7cG9bReKVqfGInD2+FlK4EPmJ8ItQmjzgCNAzALHkB8vlXsXRUVgH2lQ+3dI 03VNLSmbzlhW+aTOur1hTEge9XLP6vHyWg+upyxLGH2zy3BedElcJxWQ1BDWFvux20M1regty +mz5A2Rn/dSr6r2aK2KPpTSr1P8DnlMFYoVGvnDwPULJd89k7o8WU2pnHdzi5deZxVHK//YDJ T7ctzSbG72zxqlW3vMSAAnCsQTbSNWnTU+EfZfiJGEBzfynJhquv+1ZugGcBASOSjn11dcq4C Ih6zebi1/g82y4cGXSIckDdAAjN+79Mv4TOkMu+LqPZnFxUnO4dxJgZtZOe1zrPAncRjTJh8F q3AJPPohH8aOM0jIpA5GNzi4LVgq7xnfVj7gjqc08fgObkjbZr8ajiTOFeLT+ajfY5tE= Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Weak functions are a bit confusing, and we can better deal with this using a callback function. pcibios_free_irq() is actually completely unused, but it seems better to treat it the same way as the allocation, unless we want to remove it completely. Signed-off-by: Arnd Bergmann --- arch/arm64/kernel/pci.c | 16 +++------------- drivers/pci/pci-driver.c | 13 +++++++++++-- include/linux/pci.h | 2 ++ 3 files changed, 16 insertions(+), 15 deletions(-) -- 2.18.0 diff --git a/arch/arm64/kernel/pci.c b/arch/arm64/kernel/pci.c index 0e2ea1c78542..3d196c68e362 100644 --- a/arch/arm64/kernel/pci.c +++ b/arch/arm64/kernel/pci.c @@ -22,19 +22,6 @@ #include #include -#ifdef CONFIG_ACPI -/* - * Try to assign the IRQ number when probing a new device - */ -int pcibios_alloc_irq(struct pci_dev *dev) -{ - if (!acpi_disabled) - acpi_pci_irq_enable(dev); - - return 0; -} -#endif - /* * raw_pci_read/write - Platform-specific PCI config space access. */ @@ -93,6 +80,9 @@ int pcibios_root_bridge_prepare(struct pci_host_bridge *bridge) ACPI_COMPANION_SET(&bridge->dev, adev); set_dev_node(bus_dev, acpi_get_node(acpi_device_handle(adev))); + + /* Try to assign the IRQ number when probing a new device */ + bridge->alloc_irq = acpi_pci_irq_enable; } return 0; diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c index bef17c3fca67..c96bc7bd56da 100644 --- a/drivers/pci/pci-driver.c +++ b/drivers/pci/pci-driver.c @@ -387,13 +387,22 @@ static int __pci_device_probe(struct pci_driver *drv, struct pci_dev *pci_dev) return error; } -int __weak pcibios_alloc_irq(struct pci_dev *dev) +int pcibios_alloc_irq(struct pci_dev *dev) { + struct pci_host_bridge *bridge = pci_find_host_bridge(dev->bus); + + if (bridge->alloc_irq) + return bridge->alloc_irq(dev); + return 0; } -void __weak pcibios_free_irq(struct pci_dev *dev) +void pcibios_free_irq(struct pci_dev *dev) { + struct pci_host_bridge *bridge = pci_find_host_bridge(dev->bus); + + if (bridge->free_irq) + bridge->free_irq(dev); } #ifdef CONFIG_PCI_IOV diff --git a/include/linux/pci.h b/include/linux/pci.h index d1072690cb4f..1296d9fcc5da 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -476,6 +476,8 @@ struct pci_host_bridge { int (*map_irq)(const struct pci_dev *, u8, u8); void (*release_fn)(struct pci_host_bridge *); void (*bus_add_device)(struct pci_dev *pdev); + int (*alloc_irq)(struct pci_dev *); + int (*free_irq)(struct pci_dev *); void *release_data; struct msi_controller *msi; unsigned int ignore_reset_delay:1; /* For entire hierarchy */