Message ID | 20221114074346.23008-1-liupeibao@loongson.cn |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2019996wru; Sun, 13 Nov 2022 23:52:21 -0800 (PST) X-Google-Smtp-Source: AA0mqf4bFSXPerTKuo7NZ3PJ+6eGgcLgXdvcW2Hk6+7EAsSnnzuTSwc3GzFwFKch3d/tGcEajBPT X-Received: by 2002:a17:90b:8c2:b0:1fb:825c:af8a with SMTP id ds2-20020a17090b08c200b001fb825caf8amr12390931pjb.104.1668412341661; Sun, 13 Nov 2022 23:52:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668412341; cv=none; d=google.com; s=arc-20160816; b=tB6whtGO3u9RRm9ereMRbbXgR0gemTQAO5OdTHCJn+upakFcW1IgNSbKDTMYaTxf8E UZ/mC+P3V2BQSpivGuc7pnFkgn5aib2SsdWMpM4y9NElaC1SVaq8D3mm0XhRTZL8KdWI syCqqcHiizl7vHs640BCYQWvykxAxtFV9B5EFeFfJc0mdo7Yrntlk9VCOR70tMQ2AoRb ygwcl+HB5076qStAJaV0QVZ3Kci2+HaA0chb8WsP4dqDeW9NtAWrQoGhjaE2uvZBVXpY 3D/j8S2FqsLb54x6pwtqj/9U167uTehu2ZC2deWMW2CrHP7tEMfypeW2j16ouGss5U+h 8OfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=ayuK8joMnmQ7CrTEZsQTwUZzAwxGPoEMJ6r76DLSRrw=; b=agc+vB6TsE7En+0k3FTSk87oA95aPU/Pbsb/y30aLiAKCIqvKECUlTJBrmyvua2LIN vhgNzXU6JNc5qlL+RSLBjDpr+77aFX9Xc1//AkVKeXe5bT2qQg54f0nSUzLOk/QsNPel jO6fEpXpbG7GxahEEK2PQycB/AY6ONQ+T2RWYQQlrme76JNB/DvdLlSUdc5SrBtEk+Sa uHZsLcYK+bFL5jjMgYqDkZlVRPCrz7BCQrjnLlmHBbGXjNeL+Fn2Y0A3cVvQisK3ujRz 3jFuhg0aJwl848TqtvxsIKnhAjp4gfx7dti3EUgNO10IcjGx6/nyT0MVTcFSw2iW+/hL W+NQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r13-20020a63e50d000000b00448c6dd8fa9si8841424pgh.444.2022.11.13.23.52.08; Sun, 13 Nov 2022 23:52:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235980AbiKNHoP (ORCPT <rfc822;winker.wchi@gmail.com> + 99 others); Mon, 14 Nov 2022 02:44:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39322 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236052AbiKNHoC (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 14 Nov 2022 02:44:02 -0500 Received: from loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E75F118E23; Sun, 13 Nov 2022 23:43:59 -0800 (PST) Received: from loongson.cn (unknown [10.20.42.77]) by gateway (Coremail) with SMTP id _____8AxzNi+8XFjRNUGAA--.20591S3; Mon, 14 Nov 2022 15:43:58 +0800 (CST) Received: from loongson-PC.loongson.cn (unknown [10.20.42.77]) by localhost.localdomain (Coremail) with SMTP id AQAAf8Axf+Cy8XFjOWISAA--.49681S2; Mon, 14 Nov 2022 15:43:57 +0800 (CST) From: Liu Peibao <liupeibao@loongson.cn> To: Bjorn Helgaas <bhelgaas@google.com>, Rob Herring <robh+dt@kernel.org>, Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>, Lorenzo Pieralisi <lpieralisi@kernel.org>, =?utf-8?q?Krzysztof_Wilczy=C5=84?= =?utf-8?q?ski?= <kw@linux.com>, Jiaxun Yang <jiaxun.yang@flygoat.com>, Christophe JAILLET <christophe.jaillet@wanadoo.fr> Cc: Huacai Chen <chenhuacai@loongson.cn>, Jianmin Lv <lvjianmin@loongson.cn>, Yinbo Zhu <zhuyinbo@loongson.cn>, wanghongliang <wanghongliang@loongson.cn>, Liu Peibao <liupeibao@loongson.cn>, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH V5] PCI: loongson: Skip scanning unavailable child devices Date: Mon, 14 Nov 2022 15:43:46 +0800 Message-Id: <20221114074346.23008-1-liupeibao@loongson.cn> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: AQAAf8Axf+Cy8XFjOWISAA--.49681S2 X-CM-SenderInfo: xolx1vpled0qxorr0wxvrqhubq/1tbiAQAKCmNw3mQNdwAAsS X-Coremail-Antispam: 1Uk129KBjvJXoW7Kr4fWw48Gw48JFyfZw4kXrb_yoW8ZFykpF W3JFWakrWkKFyIkanIq348C3Wa9anrK395Jrs7CrnF93ZxC345Wr97CFyFq343trW8A3WY vF1jgr18GF4UJF7anT9S1TB71UUUUUJqnTZGkaVYY2UrUUUUj1kv1TuYvTs0mT0YCTnIWj qI5I8CrVACY4xI64kE6c02F40Ex7xfYxn0WfASr-VFAUDa7-sFnT9fnUUIcSsGvfJTRUUU b3AYFVCjjxCrM7AC8VAFwI0_Jr0_Gr1l1xkIjI8I6I8E6xAIw20EY4v20xvaj40_Wr0E3s 1l1IIY67AEw4v_JrI_Jryl8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxSw2x7M28EF7xv wVC0I7IYx2IY67AKxVW8JVW5JwA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxVW8JVWxJwA2z4 x0Y4vEx4A2jsIE14v26r4UJVWxJr1l84ACjcxK6I8E87Iv6xkF7I0E14v26r4UJVWxJr1l n4kS14v26r1Y6r17M2AIxVAIcxkEcVAq07x20xvEncxIr21l57IF6xkI12xvs2x26I8E6x ACxx1l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r1Y6r17McIj6I8E 87Iv67AKxVW8JVWxJwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41l42xK82 IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1l4IxYO2xFxVAFwI0_Jrv_JF1lx2Iq xVAqx4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r 1q6r43MIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY 6xkF7I0E14v26r1j6r4UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67 AKxVW8JVWxJwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuY vjxU4oGQDUUUU X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748909796253591869?= X-GMAIL-MSGID: =?utf-8?q?1749457139515941337?= |
Series |
[V5] PCI: loongson: Skip scanning unavailable child devices
|
|
Commit Message
Liu Peibao
Nov. 14, 2022, 7:43 a.m. UTC
The PCI Controller of 2K1000 could not mask devices by setting vender ID or
device ID in configuration space header as invalid values. When there are
pins shareable between the platform device and the on chip PCI device, if
the platform device is preferred, we should not scan this PCI device. In
the above scene, add `status = "disabled"` property in DT node of this PCI
device.
Before this patch, to solve the above problem, we treat the on chip PCI
devices as platform devices with fixed address assigned by the BIOS. When
there is device not preferred, add the `status = "disabled"` property in DT
node. In kernel, the PCI host bridge only scans slot 9/A/B/C/D/E that are
bridges. Overall, this looks not much elegant.
Signed-off-by: Liu Peibao <liupeibao@loongson.cn>
---
V4 -> V5: make the issue we are facing clear in commit log.
V3 -> V4: 1. get rid of the masklist and search the status property
directly.
2. check the status property only when accessing the vendor ID.
V2 -> V3: 1. use list_for_each_entry() for more clearly.
2. fix wrong use of sizeof().
V1 -> V2: use existing property "status" instead of adding new property.
drivers/pci/controller/pci-loongson.c | 11 +++++++++++
1 file changed, 11 insertions(+)
Comments
Hi, Peibao, > -----原始邮件----- > 发件人: "Liu Peibao" <liupeibao@loongson.cn> > 发送时间:2022-11-14 15:43:46 (星期一) > 收件人: "Bjorn Helgaas" <bhelgaas@google.com>, "Rob Herring" <robh+dt@kernel.org>, "Krzysztof Kozlowski" <krzysztof.kozlowski+dt@linaro.org>, "Lorenzo Pieralisi" <lpieralisi@kernel.org>, "Krzysztof Wilczyński" <kw@linux.com>, "Jiaxun Yang" <jiaxun.yang@flygoat.com>, "Christophe JAILLET" <christophe.jaillet@wanadoo.fr> > 抄送: "Huacai Chen" <chenhuacai@loongson.cn>, "Jianmin Lv" <lvjianmin@loongson.cn>, "Yinbo Zhu" <zhuyinbo@loongson.cn>, wanghongliang <wanghongliang@loongson.cn>, "Liu Peibao" <liupeibao@loongson.cn>, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org > 主题: [PATCH V5] PCI: loongson: Skip scanning unavailable child devices > > The PCI Controller of 2K1000 could not mask devices by setting vender ID or I think this patch is needed by both LS2K500 and LS2K1000, so replace 2K1000 with "LS2K" or "Loongson-2K" or "LS2K500/LS2K1000" maybe better. If new version is needed, please change this, thanks. Huacai > device ID in configuration space header as invalid values. When there are > pins shareable between the platform device and the on chip PCI device, if > the platform device is preferred, we should not scan this PCI device. In > the above scene, add `status = "disabled"` property in DT node of this PCI > device. > > Before this patch, to solve the above problem, we treat the on chip PCI > devices as platform devices with fixed address assigned by the BIOS. When > there is device not preferred, add the `status = "disabled"` property in DT > node. In kernel, the PCI host bridge only scans slot 9/A/B/C/D/E that are > bridges. Overall, this looks not much elegant. > > Signed-off-by: Liu Peibao <liupeibao@loongson.cn> > --- > V4 -> V5: make the issue we are facing clear in commit log. > V3 -> V4: 1. get rid of the masklist and search the status property > directly. > 2. check the status property only when accessing the vendor ID. > V2 -> V3: 1. use list_for_each_entry() for more clearly. > 2. fix wrong use of sizeof(). > V1 -> V2: use existing property "status" instead of adding new property. > > drivers/pci/controller/pci-loongson.c | 11 +++++++++++ > 1 file changed, 11 insertions(+) > > diff --git a/drivers/pci/controller/pci-loongson.c b/drivers/pci/controller/pci-loongson.c > index 05c50408f13b..efca0b3b5a29 100644 > --- a/drivers/pci/controller/pci-loongson.c > +++ b/drivers/pci/controller/pci-loongson.c > @@ -194,6 +194,17 @@ static void __iomem *pci_loongson_map_bus(struct pci_bus *bus, > return NULL; > } > > +#ifdef CONFIG_OF > + /* Don't access disabled devices. */ > + if (pci_is_root_bus(bus) && where == PCI_VENDOR_ID) { > + struct device_node *dn; > + > + dn = of_pci_find_child_device(bus->dev.of_node, devfn); > + if (dn && !of_device_is_available(dn)) > + return NULL; > + } > +#endif > + > /* CFG0 can only access standard space */ > if (where < PCI_CFG_SPACE_SIZE && priv->cfg0_base) > return cfg0_map(priv, bus, devfn, where); > -- > 2.20.1 本邮件及其附件含有龙芯中科的商业秘密信息,仅限于发送给上面地址中列出的个人或群组。禁止任何其他人以任何形式使用(包括但不限于全部或部分地泄露、复制或散发)本邮件及其附件中的信息。如果您错收本邮件,请您立即电话或邮件通知发件人并删除本邮件。 This email and its attachments contain confidential information from Loongson Technology , which is intended only for the person or entity whose address is listed above. Any use of the information contained herein in any way (including, but not limited to, total or partial disclosure, reproduction or dissemination) by persons other than the intended recipient(s) is prohibited. If you receive this email in error, please notify the sender by phone or email immediately and delete it.
On 11/14/22 4:14 PM, 陈华才 wrote: > Hi, Peibao, > > >> -----原始邮件----- >> 发件人: "Liu Peibao" <liupeibao@loongson.cn> >> 发送时间:2022-11-14 15:43:46 (星期一) >> 收件人: "Bjorn Helgaas" <bhelgaas@google.com>, "Rob Herring" <robh+dt@kernel.org>, "Krzysztof Kozlowski" <krzysztof.kozlowski+dt@linaro.org>, "Lorenzo Pieralisi" <lpieralisi@kernel.org>, "Krzysztof Wilczyński" <kw@linux.com>, "Jiaxun Yang" <jiaxun.yang@flygoat.com>, "Christophe JAILLET" <christophe.jaillet@wanadoo.fr> >> 抄送: "Huacai Chen" <chenhuacai@loongson.cn>, "Jianmin Lv" <lvjianmin@loongson.cn>, "Yinbo Zhu" <zhuyinbo@loongson.cn>, wanghongliang <wanghongliang@loongson.cn>, "Liu Peibao" <liupeibao@loongson.cn>, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org >> 主题: [PATCH V5] PCI: loongson: Skip scanning unavailable child devices >> >> The PCI Controller of 2K1000 could not mask devices by setting vender ID or > I think this patch is needed by both LS2K500 and LS2K1000, so replace 2K1000 with "LS2K" or "Loongson-2K" or "LS2K500/LS2K1000" maybe better. If new version is needed, please change this, thanks. > LS2K500 does not need this as there are no on chip PCI devices. BR, Peibao
Hi Liu, On Mon, Nov 14, 2022 at 03:43:46PM +0800, Liu Peibao wrote: > The PCI Controller of 2K1000 could not mask devices by setting vender ID or > device ID in configuration space header as invalid values. I don't think this 2K1000 information is really relevant. I understand that some chipsets might support this, and they might use that to avoid this issue, but there's no PCI requirement that the Vendor/Device ID be writable by anything. > When there are > pins shareable between the platform device and the on chip PCI device, if What does "pins shareable between the platform device and the on chip PCI device" mean? I assume there's a single device in the hardware, and both the "platform device" and the PCI device" refer to that single device? And there's some reason you prefer to use the platform device interface to enumerate that device? > the platform device is preferred, we should not scan this PCI device. In > the above scene, add `status = "disabled"` property in DT node of this PCI > device. > > Before this patch, to solve the above problem, we treat the on chip PCI > devices as platform devices with fixed address assigned by the BIOS. This says "before this patch". But the rest of the sentence sounds like what happens *after* this patch. > When > there is device not preferred, add the `status = "disabled"` property in DT > node. > In kernel, the PCI host bridge only scans slot 9/A/B/C/D/E that are > bridges. I guess this has something to do with pdev_may_exist() [1], but why do you mention it here? Do you intend to remove pdev_may_exist() and use this DT mechanism instead? Bjorn [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/pci/controller/pci-loongson.c?id=v6.0#n168 > Overall, this looks not much elegant. > > Signed-off-by: Liu Peibao <liupeibao@loongson.cn> > --- > V4 -> V5: make the issue we are facing clear in commit log. > V3 -> V4: 1. get rid of the masklist and search the status property > directly. > 2. check the status property only when accessing the vendor ID. > V2 -> V3: 1. use list_for_each_entry() for more clearly. > 2. fix wrong use of sizeof(). > V1 -> V2: use existing property "status" instead of adding new property. > > drivers/pci/controller/pci-loongson.c | 11 +++++++++++ > 1 file changed, 11 insertions(+) > > diff --git a/drivers/pci/controller/pci-loongson.c b/drivers/pci/controller/pci-loongson.c > index 05c50408f13b..efca0b3b5a29 100644 > --- a/drivers/pci/controller/pci-loongson.c > +++ b/drivers/pci/controller/pci-loongson.c > @@ -194,6 +194,17 @@ static void __iomem *pci_loongson_map_bus(struct pci_bus *bus, > return NULL; > } > > +#ifdef CONFIG_OF > + /* Don't access disabled devices. */ > + if (pci_is_root_bus(bus) && where == PCI_VENDOR_ID) { > + struct device_node *dn; > + > + dn = of_pci_find_child_device(bus->dev.of_node, devfn); > + if (dn && !of_device_is_available(dn)) > + return NULL; > + } > +#endif > + > /* CFG0 can only access standard space */ > if (where < PCI_CFG_SPACE_SIZE && priv->cfg0_base) > return cfg0_map(priv, bus, devfn, where); > -- > 2.20.1 >
On 11/15/22 1:11 AM, Bjorn Helgaas wrote: > Hi Liu, > > On Mon, Nov 14, 2022 at 03:43:46PM +0800, Liu Peibao wrote: >> The PCI Controller of 2K1000 could not mask devices by setting vender ID or >> device ID in configuration space header as invalid values. > > I don't think this 2K1000 information is really relevant. I > understand that some chipsets might support this, and they might use > that to avoid this issue, but there's no PCI requirement that the > Vendor/Device ID be writable by anything. > OK, I think I got it. >> When there are >> pins shareable between the platform device and the on chip PCI device, if > > What does "pins shareable between the platform device and the on chip > PCI device" mean? > > I assume there's a single device in the hardware, and both the > "platform device" and the PCI device" refer to that single device? > > And there's some reason you prefer to use the platform device > interface to enumerate that device? > No, they are not the same device. For example, GMAC1(on chip PCI device) and GPIO(platform device, not PCI device) 14 use the same pin. The function for this pin can be configured by one bit in general register, eg, 0 for GPIO 14, 1 for GMAC1. Sometimes, GPIO 14 is preferred, so configure the pin with function GPIO 14 and disable GMAC1. >> the platform device is preferred, we should not scan this PCI device. In >> the above scene, add `status = "disabled"` property in DT node of this PCI >> device. >> >> Before this patch, to solve the above problem, we treat the on chip PCI >> devices as platform devices with fixed address assigned by the BIOS. > > This says "before this patch". But the rest of the sentence sounds > like what happens *after* this patch. > In fact, I want to describe an solution. But it seems that I described a little confusing and please check the refactored commit log in the following comments. >> When >> there is device not preferred, add the `status = "disabled"` property in DT >> node. > >> In kernel, the PCI host bridge only scans slot 9/A/B/C/D/E that are >> bridges. > > I guess this has something to do with pdev_may_exist() [1], but why do > you mention it here? Do you intend to remove pdev_may_exist() and use > this DT mechanism instead? > > Bjorn > > [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/pci/controller/pci-loongson.c?id=v6.0#n168 > You are right and I did something ugly in pdev_may_exist() in my kernel. I really don't want to continue doing this, so I am developing this patch. Also I don't want to remove pdev_may_exist(). This patch could replace pdev_may_exist() only in DT, but pdev_may_exist() matters in both ACPI and DT. Overall, how about the following refactored commit log: "This patch adds a mechanism to disable on chip PCI devices by DT. Typically, when there are pins shareable between the platform device and the on chip PCI device, if the PCI device is not preferred, add `status = "disabled"` property to this PCI device DT node. For example, on LS2K1000, GMAC1(on chip PCI device) and GPIO(platform device, not PCI device) 14 share the same pin. If GMAC1 is not preferred, add `status = "disabled"` property in GMAC1 DT node." BR, Peibao
On Wed, Nov 16, 2022 at 05:57:46PM +0800, Liu Peibao wrote: > On 11/15/22 1:11 AM, Bjorn Helgaas wrote: > > On Mon, Nov 14, 2022 at 03:43:46PM +0800, Liu Peibao wrote: > > I assume there's a single device in the hardware, and both the > > "platform device" and the PCI device" refer to that single device? > > > > And there's some reason you prefer to use the platform device > > interface to enumerate that device? > > No, they are not the same device. For example, GMAC1(on chip PCI device) and > GPIO(platform device, not PCI device) 14 use the same pin. The function for > this pin can be configured by one bit in general register, eg, 0 for GPIO 14, > 1 for GMAC1. Sometimes, GPIO 14 is preferred, so configure the pin with > function GPIO 14 and disable GMAC1. Ah, I see, so there's some circuit that can be driven by either the platform (GPIO) device or the PCI (GMAC1) device. > Overall, how about the following refactored commit log: > > "This patch adds a mechanism to disable on chip PCI devices by DT. Typically, > when there are pins shareable between the platform device and the on chip PCI > device, if the PCI device is not preferred, add `status = "disabled"` property > to this PCI device DT node. > > For example, on LS2K1000, GMAC1(on chip PCI device) and GPIO(platform device, > not PCI device) 14 share the same pin. If GMAC1 is not preferred, add > `status = "disabled"` property in GMAC1 DT node." Add a mechanism ... (Instead of "This patch adds ..."; no need to say "this patch" because it's obvious that the commit log applies to *this patch*) Add spaces before "(", e.g., "GMAC1 (on-chip PCI device)". Looks good! Bjorn
On 11/17/22 2:14 AM, Bjorn Helgaas wrote: > On Wed, Nov 16, 2022 at 05:57:46PM +0800, Liu Peibao wrote: >> On 11/15/22 1:11 AM, Bjorn Helgaas wrote: >>> On Mon, Nov 14, 2022 at 03:43:46PM +0800, Liu Peibao wrote: > >>> I assume there's a single device in the hardware, and both the >>> "platform device" and the PCI device" refer to that single device? >>> >>> And there's some reason you prefer to use the platform device >>> interface to enumerate that device? >> >> No, they are not the same device. For example, GMAC1(on chip PCI device) and >> GPIO(platform device, not PCI device) 14 use the same pin. The function for >> this pin can be configured by one bit in general register, eg, 0 for GPIO 14, >> 1 for GMAC1. Sometimes, GPIO 14 is preferred, so configure the pin with >> function GPIO 14 and disable GMAC1. > > Ah, I see, so there's some circuit that can be driven by either the > platform (GPIO) device or the PCI (GMAC1) device. > That is really the point. Sorry for my poor description and English :). >> Overall, how about the following refactored commit log: >> >> "This patch adds a mechanism to disable on chip PCI devices by DT. Typically, >> when there are pins shareable between the platform device and the on chip PCI >> device, if the PCI device is not preferred, add `status = "disabled"` property >> to this PCI device DT node. >> >> For example, on LS2K1000, GMAC1(on chip PCI device) and GPIO(platform device, >> not PCI device) 14 share the same pin. If GMAC1 is not preferred, add >> `status = "disabled"` property in GMAC1 DT node." > > Add a mechanism ... > > (Instead of "This patch adds ..."; no need to say "this patch" because > it's obvious that the commit log applies to *this patch*) > > Add spaces before "(", e.g., "GMAC1 (on-chip PCI device)". > > Looks good! > > Bjorn > I will modify these and send the next version patch. Thanks a lot! BR, Peibao
diff --git a/drivers/pci/controller/pci-loongson.c b/drivers/pci/controller/pci-loongson.c index 05c50408f13b..efca0b3b5a29 100644 --- a/drivers/pci/controller/pci-loongson.c +++ b/drivers/pci/controller/pci-loongson.c @@ -194,6 +194,17 @@ static void __iomem *pci_loongson_map_bus(struct pci_bus *bus, return NULL; } +#ifdef CONFIG_OF + /* Don't access disabled devices. */ + if (pci_is_root_bus(bus) && where == PCI_VENDOR_ID) { + struct device_node *dn; + + dn = of_pci_find_child_device(bus->dev.of_node, devfn); + if (dn && !of_device_is_available(dn)) + return NULL; + } +#endif + /* CFG0 can only access standard space */ if (where < PCI_CFG_SPACE_SIZE && priv->cfg0_base) return cfg0_map(priv, bus, devfn, where);