From patchwork Fri Oct 2 18:44:01 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Daney X-Patchwork-Id: 7318421 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 7AC6EBEEA4 for ; Fri, 2 Oct 2015 18:47:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7E25D20806 for ; Fri, 2 Oct 2015 18:47:10 +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 8EA7F20610 for ; Fri, 2 Oct 2015 18:47: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 1Zi5KO-0000Pb-Dk; Fri, 02 Oct 2015 18:45:08 +0000 Received: from mail-io0-x234.google.com ([2607:f8b0:4001:c06::234]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Zi5Jq-00087G-3R for linux-arm-kernel@lists.infradead.org; Fri, 02 Oct 2015 18:44:34 +0000 Received: by ioiz6 with SMTP id z6so129528585ioi.2 for ; Fri, 02 Oct 2015 11:44:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=9u58+vcVmPFv0NYz76gAX7rHehc/PcZHUCTVfhDqIHs=; b=gu7ez1ydBlx4f26qeckumZGASvrsCbrN842NOHmBZq/Bx6oX44uQoAKslepNUf9F2X S0dhQn81EZavNq877Ek+xOC0zcjQc0ZD6E89nCIh1KBuJCl8rxgUepPl71+EKyRIHS+d M+Iap10qypkISLFETUw0gIzDgafWz3/NhnE6Lei29pqIH/KOOhxAjcyqwE/Vdyr5mJqY B2OF8zgSNkfbCwQnendCdV582MovC/oe8eQqD5FLHiduiuMQmEEyE53bXWDDD2MZ2Uef ajYAXXgff8Sl6aK/jpNL5hV4q8qPHg/iBK32pjq7UqYmEH/wJcU5OANOfeVla8cBrWq9 6Cwg== X-Received: by 10.107.131.134 with SMTP id n6mr17873869ioi.192.1443811453361; Fri, 02 Oct 2015 11:44:13 -0700 (PDT) Received: from dl.caveonetworks.com (64.2.3.194.ptr.us.xo.net. [64.2.3.194]) by smtp.gmail.com with ESMTPSA id p4sm125144igj.8.2015.10.02.11.44.08 (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 02 Oct 2015 11:44:10 -0700 (PDT) Received: from dl.caveonetworks.com (localhost.localdomain [127.0.0.1]) by dl.caveonetworks.com (8.14.5/8.14.5) with ESMTP id t92Ii7O8018929; Fri, 2 Oct 2015 11:44:07 -0700 Received: (from ddaney@localhost) by dl.caveonetworks.com (8.14.5/8.14.5/Submit) id t92Ii7jT018928; Fri, 2 Oct 2015 11:44:07 -0700 From: David Daney To: linux-kernel@vger.kernel.org, Bjorn Helgaas , linux-pci@vger.kernel.org, Will Deacon , Rob Herring , Pawel Moll , Mark Rutland , Ian Campbell , Kumar Gala , linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, Marc Zyngier Subject: [PATCH v4 3/5] PCI: generic: Quit clobbering our pci_ops. Date: Fri, 2 Oct 2015 11:44:01 -0700 Message-Id: <1443811443-18878-4-git-send-email-ddaney.cavm@gmail.com> X-Mailer: git-send-email 1.7.11.7 In-Reply-To: <1443811443-18878-1-git-send-email-ddaney.cavm@gmail.com> References: <1443811443-18878-1-git-send-email-ddaney.cavm@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151002_114434_213675_0715FBE1 X-CRM114-Status: GOOD ( 16.61 ) X-Spam-Score: -2.7 (--) 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: David Daney 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_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, 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 From: David Daney The pci-host-generic driver keeps a global struct pci_ops which it then patches with the .map_bus method appropriate for the bus device. A problem arises when the driver is used for two different types of bus devices, the .map_bus method for the last device probed clobbers the method for all previous devices. The result, only the last bus device probed has the proper .map_bus, and the others fail. Move the struct pci_ops into the bus specific structure, and initialize a pointer to it when the bus device is probed. Acked-by: Will Deacon Signed-off-by: David Daney Reviewed-by: Arnd Bergmann --- Change from v3: Use pointer to ops rather than make a copy. drivers/pci/host/pci-host-generic.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/drivers/pci/host/pci-host-generic.c b/drivers/pci/host/pci-host-generic.c index 9e9f1c3..216ded5 100644 --- a/drivers/pci/host/pci-host-generic.c +++ b/drivers/pci/host/pci-host-generic.c @@ -27,7 +27,7 @@ struct gen_pci_cfg_bus_ops { u32 bus_shift; - void __iomem *(*map_bus)(struct pci_bus *, unsigned int, int); + struct pci_ops ops; }; struct gen_pci_cfg_windows { @@ -35,7 +35,7 @@ struct gen_pci_cfg_windows { struct resource *bus_range; void __iomem **win; - const struct gen_pci_cfg_bus_ops *ops; + struct gen_pci_cfg_bus_ops *ops; }; /* @@ -65,7 +65,11 @@ static void __iomem *gen_pci_map_cfg_bus_cam(struct pci_bus *bus, static struct gen_pci_cfg_bus_ops gen_pci_cfg_cam_bus_ops = { .bus_shift = 16, - .map_bus = gen_pci_map_cfg_bus_cam, + .ops = { + .map_bus = gen_pci_map_cfg_bus_cam, + .read = pci_generic_config_read, + .write = pci_generic_config_write, + } }; static void __iomem *gen_pci_map_cfg_bus_ecam(struct pci_bus *bus, @@ -80,12 +84,11 @@ static void __iomem *gen_pci_map_cfg_bus_ecam(struct pci_bus *bus, static struct gen_pci_cfg_bus_ops gen_pci_cfg_ecam_bus_ops = { .bus_shift = 20, - .map_bus = gen_pci_map_cfg_bus_ecam, -}; - -static struct pci_ops gen_pci_ops = { - .read = pci_generic_config_read, - .write = pci_generic_config_write, + .ops = { + .map_bus = gen_pci_map_cfg_bus_ecam, + .read = pci_generic_config_read, + .write = pci_generic_config_write, + } }; static const struct of_device_id gen_pci_of_match[] = { @@ -234,8 +237,7 @@ static int gen_pci_probe(struct platform_device *pdev) } of_id = of_match_node(gen_pci_of_match, np); - pci->cfg.ops = of_id->data; - gen_pci_ops.map_bus = pci->cfg.ops->map_bus; + pci->cfg.ops = (struct gen_pci_cfg_bus_ops *)of_id->data; pci->host.dev.parent = dev; INIT_LIST_HEAD(&pci->host.windows); INIT_LIST_HEAD(&pci->resources); @@ -256,7 +258,8 @@ static int gen_pci_probe(struct platform_device *pdev) if (!pci_has_flag(PCI_PROBE_ONLY)) pci_add_flags(PCI_REASSIGN_ALL_RSRC | PCI_REASSIGN_ALL_BUS); - bus = pci_scan_root_bus(dev, 0, &gen_pci_ops, pci, &pci->resources); + bus = pci_scan_root_bus(dev, 0, + &pci->cfg.ops->ops, pci, &pci->resources); if (!bus) { dev_err(dev, "Scanning rootbus failed"); return -ENODEV;