linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V6] PCI: loongson: Skip scanning disabled child devices
@ 2022-11-17  2:09 Liu Peibao
  2023-02-08  3:00 ` Binbin Zhou
  2023-02-10 16:49 ` Rob Herring
  0 siblings, 2 replies; 4+ messages in thread
From: Liu Peibao @ 2022-11-17  2:09 UTC (permalink / raw)
  To: Bjorn Helgaas, Rob Herring, Krzysztof Kozlowski,
	Lorenzo Pieralisi, Krzysztof Wilczyński, Jiaxun Yang,
	Christophe JAILLET
  Cc: Huacai Chen, Jianmin Lv, Yinbo Zhu, wanghongliang, Liu Peibao,
	linux-pci, linux-kernel

Add 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.

Signed-off-by: Liu Peibao <liupeibao@loongson.cn>
---
V5 -> V6: 1. rewrite the commit log to make things clear.
	  2. replace "unavailable" as "disabled" in patch subject.
V4 -> V5: clear the issue we are facing 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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH V6] PCI: loongson: Skip scanning disabled child devices
  2022-11-17  2:09 [PATCH V6] PCI: loongson: Skip scanning disabled child devices Liu Peibao
@ 2023-02-08  3:00 ` Binbin Zhou
  2023-02-09  6:12   ` Huacai Chen
  2023-02-10 16:49 ` Rob Herring
  1 sibling, 1 reply; 4+ messages in thread
From: Binbin Zhou @ 2023-02-08  3:00 UTC (permalink / raw)
  To: Liu Peibao, Bjorn Helgaas, Rob Herring, Krzysztof Kozlowski,
	Lorenzo Pieralisi, Krzysztof Wilczyński, Jiaxun Yang,
	Christophe JAILLET
  Cc: Huacai Chen, Jianmin Lv, Yinbo Zhu, wanghongliang, linux-pci,
	linux-kernel, chenhuacai


在 2022/11/17 10:09, Liu Peibao 写道:
> Add 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.
>
> Signed-off-by: Liu Peibao <liupeibao@loongson.cn>
Tested-by: Binbin Zhou <zhoubinbin@loongson.cn>
> ---
> V5 -> V6: 1. rewrite the commit log to make things clear.
> 	  2. replace "unavailable" as "disabled" in patch subject.
> V4 -> V5: clear the issue we are facing 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);


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH V6] PCI: loongson: Skip scanning disabled child devices
  2023-02-08  3:00 ` Binbin Zhou
@ 2023-02-09  6:12   ` Huacai Chen
  0 siblings, 0 replies; 4+ messages in thread
From: Huacai Chen @ 2023-02-09  6:12 UTC (permalink / raw)
  To: Binbin Zhou
  Cc: Liu Peibao, Bjorn Helgaas, Rob Herring, Krzysztof Kozlowski,
	Lorenzo Pieralisi, Krzysztof Wilczyński, Jiaxun Yang,
	Christophe JAILLET, Huacai Chen, Jianmin Lv, Yinbo Zhu,
	wanghongliang, linux-pci, linux-kernel

On Wed, Feb 8, 2023 at 11:00 AM Binbin Zhou <zhoubinbin@loongson.cn> wrote:
>
>
> 在 2022/11/17 10:09, Liu Peibao 写道:
> > Add 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.
> >
> > Signed-off-by: Liu Peibao <liupeibao@loongson.cn>
> Tested-by: Binbin Zhou <zhoubinbin@loongson.cn>
Acked-by: Huacai Chen <chenhuacai@loongson.cn>


> > ---
> > V5 -> V6: 1. rewrite the commit log to make things clear.
> >         2. replace "unavailable" as "disabled" in patch subject.
> > V4 -> V5: clear the issue we are facing 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);
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH V6] PCI: loongson: Skip scanning disabled child devices
  2022-11-17  2:09 [PATCH V6] PCI: loongson: Skip scanning disabled child devices Liu Peibao
  2023-02-08  3:00 ` Binbin Zhou
@ 2023-02-10 16:49 ` Rob Herring
  1 sibling, 0 replies; 4+ messages in thread
From: Rob Herring @ 2023-02-10 16:49 UTC (permalink / raw)
  To: Liu Peibao
  Cc: Bjorn Helgaas, Krzysztof Kozlowski, Lorenzo Pieralisi,
	Krzysztof Wilczyński, Jiaxun Yang, Christophe JAILLET,
	Huacai Chen, Jianmin Lv, Yinbo Zhu, wanghongliang, linux-pci,
	linux-kernel

On Wed, Nov 16, 2022 at 8:09 PM Liu Peibao <liupeibao@loongson.cn> wrote:
>
> Add 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.
>
> Signed-off-by: Liu Peibao <liupeibao@loongson.cn>
> ---
> V5 -> V6: 1. rewrite the commit log to make things clear.
>           2. replace "unavailable" as "disabled" in patch subject.
> V4 -> V5: clear the issue we are facing 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

This should not be controller specific as a disabled node should be
honored on any platform. It also makes assumptions about how the PCI
scanning code works that PCI_VENDOR_ID read failing is enough to stop
scanning. Can you please test this patch I just sent[1].

Rob

[1] https://lore.kernel.org/all/20230210164351.2687475-1-robh@kernel.org/

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-02-10 16:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-17  2:09 [PATCH V6] PCI: loongson: Skip scanning disabled child devices Liu Peibao
2023-02-08  3:00 ` Binbin Zhou
2023-02-09  6:12   ` Huacai Chen
2023-02-10 16:49 ` Rob Herring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).