linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vladimir Oltean <olteanv@gmail.com>
To: Florian Fainelli <f.fainelli@gmail.com>
Cc: Michael Walle <michael@walle.cc>,
	"moderated list:ARM/Mediatek SoC support" 
	<linux-arm-kernel@lists.infradead.org>,
	devicetree@vger.kernel.org, lkml <linux-kernel@vger.kernel.org>,
	netdev <netdev@vger.kernel.org>,
	"David S . Miller" <davem@davemloft.net>,
	Vivien Didelot <vivien.didelot@gmail.com>,
	Andrew Lunn <andrew@lunn.ch>,
	Claudiu Manoil <claudiu.manoil@nxp.com>,
	Vladimir Oltean <vladimir.oltean@nxp.com>,
	Rob Herring <robh+dt@kernel.org>, Li Yang <leoyang.li@nxp.com>,
	Shawn Guo <shawnguo@kernel.org>
Subject: Re: [PATCH 1/2] net: dsa: felix: allow the device to be disabled
Date: Fri, 13 Mar 2020 00:07:37 +0200	[thread overview]
Message-ID: <CA+h21hrHGJxV8zbG4NSsHEAUucA8s+P6eyFAtWn-C6yk=52ehA@mail.gmail.com> (raw)
In-Reply-To: <55374edd-2698-6841-569c-cccf1151cfb1@gmail.com>

On Thu, 12 Mar 2020 at 23:45, Florian Fainelli <f.fainelli@gmail.com> wrote:
>
> On 3/12/20 2:35 PM, Vladimir Oltean wrote:
> > On Thu, 12 Mar 2020 at 18:44, Michael Walle <michael@walle.cc> wrote:
> >>
> >> If there is no specific configuration of the felix switch in the device
> >> tree, but only the default configuration (ie. given by the SoCs dtsi
> >> file), the probe fails because no CPU port has been set. On the other
> >> hand you cannot set a default CPU port because that depends on the
> >> actual board using the switch.
> >>
> >> [    2.701300] DSA: tree 0 has no CPU port
> >> [    2.705167] mscc_felix 0000:00:00.5: Failed to register DSA switch: -22
> >> [    2.711844] mscc_felix: probe of 0000:00:00.5 failed with error -22
> >>
> >> Thus let the device tree disable this device entirely, like it is also
> >> done with the enetc driver of the same SoC.
> >>
> >> Signed-off-by: Michael Walle <michael@walle.cc>
> >> ---
> >>  drivers/net/dsa/ocelot/felix.c | 5 +++++
> >>  1 file changed, 5 insertions(+)
> >>
> >> diff --git a/drivers/net/dsa/ocelot/felix.c b/drivers/net/dsa/ocelot/felix.c
> >> index 69546383a382..531c7710063f 100644
> >> --- a/drivers/net/dsa/ocelot/felix.c
> >> +++ b/drivers/net/dsa/ocelot/felix.c
> >> @@ -699,6 +699,11 @@ static int felix_pci_probe(struct pci_dev *pdev,
> >>         struct felix *felix;
> >>         int err;
> >>
> >> +       if (pdev->dev.of_node && !of_device_is_available(pdev->dev.of_node)) {
> >> +               dev_info(&pdev->dev, "device is disabled, skipping\n");
> >> +               return -ENODEV;
> >> +       }
> >> +
> >
> > IMHO since DSA is already dependent on device tree for PHY bindings,
> > it would make more sense to move this there:
>
> Michael's solution makes more sense, as this is a driver specific
> problem whereby you have a pci_dev instance that is created and does not
> honor the status property provided in Device Tree. If you were to look
> for a proper solution it would likely be within the PCI core actually.
>
> No other DSA switch has that problem because they use the
> I2C/SPI/platform_device/GPIO/whatever entry points into the driver model.

True, my problem with doing it in the PCI core is that "the book" [0]
doesn't actually say anything about the "status" property, so this
patch might get some pushback from the PCI maintainers (but I don't
actually know):

diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 512cb4312ddd..50c2b3da134a 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -2281,6 +2281,12 @@ static struct pci_dev *pci_scan_device(struct
pci_bus *bus, int devfn)

        pci_set_of_node(dev);

+       if (dev->dev.of_node && !of_device_is_available(dev->dev.of_node)) {
+               pci_bus_put(dev->bus);
+               kfree(dev);
+               return NULL;
+       }
+
        if (pci_setup_device(dev)) {
                pci_bus_put(dev->bus);
                kfree(dev);

OF bindings are completely optional with PCI, as you probably already
know. But there's nothing "driver" specific in disabling (i.e. not
probing) a device.

> --
>

[0] https://www.openfirmware.info/data/docs/bus.pci.pdf

Thanks,
-Vladimir

  reply	other threads:[~2020-03-12 22:07 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-12 16:43 [PATCH 1/2] net: dsa: felix: allow the device to be disabled Michael Walle
2020-03-12 16:43 ` [PATCH 2/2] arm64: dts: ls1028a: disable the felix switch by default Michael Walle
2020-03-12 16:50   ` Michael Walle
2020-03-16  2:33   ` Shawn Guo
2020-03-12 21:35 ` [PATCH 1/2] net: dsa: felix: allow the device to be disabled Vladimir Oltean
2020-03-12 21:45   ` Florian Fainelli
2020-03-12 22:07     ` Vladimir Oltean [this message]
2020-03-13 10:01   ` Andrew Lunn
2020-03-15  3:53 ` David Miller
2020-03-20 11:03   ` Michael Walle

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CA+h21hrHGJxV8zbG4NSsHEAUucA8s+P6eyFAtWn-C6yk=52ehA@mail.gmail.com' \
    --to=olteanv@gmail.com \
    --cc=andrew@lunn.ch \
    --cc=claudiu.manoil@nxp.com \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=f.fainelli@gmail.com \
    --cc=leoyang.li@nxp.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michael@walle.cc \
    --cc=netdev@vger.kernel.org \
    --cc=robh+dt@kernel.org \
    --cc=shawnguo@kernel.org \
    --cc=vivien.didelot@gmail.com \
    --cc=vladimir.oltean@nxp.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).