[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20191125152312.GJ6602@lunn.ch>
Date: Mon, 25 Nov 2019 16:23:12 +0100
From: Andrew Lunn <andrew@...n.ch>
To: Vladimir Oltean <olteanv@...il.com>
Cc: Oleksij Rempel <o.rempel@...gutronix.de>, mkl@...gutronix.de,
Vivien Didelot <vivien.didelot@...il.com>,
Florian Fainelli <f.fainelli@...il.com>,
"David S. Miller" <davem@...emloft.net>, kernel@...gutronix.de,
netdev <netdev@...r.kernel.org>,
lkml <linux-kernel@...r.kernel.org>, david@...tonic.nl
Subject: Re: [PATCH v1 1/2] net: dsa: sja1105: print info about probet chip
only after every thing was done.
> If you want to actually fix something, there is also a memory leak
> related to this. It is present in most DSA drivers. When
> dsa_register_switch returns -EPROBE_DEFER, anything allocated with
> devm_kzalloc will be overwritten and the old memory will leak.
There is a rather unfortunate chicken/egg problem here for any switch
using MDIO. At the moment i don't know how to solve it. As a result
the first probe is pretty much guaranteed to return -EPROBE_DEFER. The
problem is that the MAC driver registers its MDIO bus. That causes the
DT to be walked for the bus and the switch probed. The switch probe
registers the switch with the DSA core. It then tries to get a handle
on the master device. But the MAC driver has not called
netdev_register() yet, it is busy registering its MDIO bus. So the
master device is not there, and so we get a -EPROBE_DEFER and the
switch driver needs to unwind.
So for an MDIO switch, i suggest the probe it kept to a minimum, and
all the real work is done in the setup callback. Setup is called when
all resources the DSA core needs are available.
I've got a patch somewhere for mv88e6xxx which does this move, and it
cut boot time by a noticeable amount.
Andrew
Powered by blists - more mailing lists