From: Florian Fainelli <f.fainelli@gmail.com>
To: Vladimir Oltean <olteanv@gmail.com>
Cc: Andrew Lunn <andrew@lunn.ch>,
Vivien Didelot <vivien.didelot@gmail.com>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: Circular dependency between DSA switch driver and tagging protocol driver
Date: Wed, 8 Sep 2021 16:36:00 -0700 [thread overview]
Message-ID: <0ce35724-336d-572e-4ba3-e5a014d035fc@gmail.com> (raw)
In-Reply-To: <20210908221958.cjwuag6oz2fmnd2n@skbuf>
On 9/8/2021 3:19 PM, Vladimir Oltean wrote:
> On Wed, Sep 08, 2021 at 03:14:51PM -0700, Florian Fainelli wrote:
>> On 9/8/2021 3:08 PM, Vladimir Oltean wrote:
>>> Hi,
>>>
>>> Since commits 566b18c8b752 ("net: dsa: sja1105: implement TX
>>> timestamping for SJA1110") and 994d2cbb08ca ("net: dsa: tag_sja1105: be
>>> dsa_loop-safe"), net/dsa/tag_sja1105.ko has gained a build and insmod
>>> time dependency on drivers/net/dsa/sja1105.ko, due to several symbols
>>> exported by the latter and used by the former.
>>>
>>> So first one needs to insmod sja1105.ko, then insmod tag_sja1105.ko.
>>>
>>> But dsa_port_parse_cpu returns -EPROBE_DEFER when dsa_tag_protocol_get
>>> returns -ENOPROTOOPT. It means, there is no DSA_TAG_PROTO_SJA1105 in the
>>> list of tagging protocols known by DSA, try again later. There is a
>>> runtime dependency for DSA to have the tagging protocol loaded. Combined
>>> with the symbol dependency, this is a de facto circular dependency.
>>>
>>> So when we first insmod sja1105.ko, nothing happens, probing is deferred.
>>>
>>> Then when we insmod tag_sja1105.ko, we expect the DSA probing to kick
>>> off where it left from, and probe the switch too.
>>>
>>> However this does not happen because the deferred probing list in the
>>> device core is reconsidered for a new attempt only if a driver is bound
>>> to a new device. But DSA tagging protocols are drivers with no struct
>>> device.
>>>
>>> One can of course manually kick the driver after the two insmods:
>>>
>>> echo spi0.1 > /sys/bus/spi/drivers/sja1105/bind
>>>
>>> and this works, but automatic module loading based on modaliases will be
>>> broken if both tag_sja1105.ko and sja1105.ko are modules, and sja1105 is
>>> the last device to get a driver bound to it.
>>>
>>> Where is the problem?
>>
>> I'd say with 994d2cbb08ca, since the tagger now requires visibility into
>> sja1105_switch_ops which is not great, to say the least. You could solve
>> this by:
>>
>> - splitting up the sja1150 between a library that contains
>> sja1105_switch_ops and does not contain the driver registration code
>>
>> - finding a different way to do a dsa_switch_ops pointer comparison, by
>> e.g.: maintaining a boolean in dsa_port that tracks whether a particular
>> driver is backing that port
>
> What about 566b18c8b752 ("net: dsa: sja1105: implement TX timestamping for SJA1110")?
> It is essentially the same problem from a symbol usage perspective, plus
> the fact that an skb queue belonging to the driver is accessed.
I believe we will have to accept that another indirect function call
must be made in order to avoid creating a direct symbol dependency with
sja1110_rcv_meta() would that be acceptable performance wise?
--
Florian
next prev parent reply other threads:[~2021-09-08 23:36 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-08 22:08 Circular dependency between DSA switch driver and tagging protocol driver Vladimir Oltean
2021-09-08 22:14 ` Florian Fainelli
2021-09-08 22:19 ` Vladimir Oltean
2021-09-08 23:36 ` Florian Fainelli [this message]
2021-09-29 14:07 ` Vladimir Oltean
2021-09-09 0:26 ` Vladimir Oltean
2021-09-09 0:49 ` Florian Fainelli
2021-09-09 1:08 ` Vladimir Oltean
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=0ce35724-336d-572e-4ba3-e5a014d035fc@gmail.com \
--to=f.fainelli@gmail.com \
--cc=andrew@lunn.ch \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=vivien.didelot@gmail.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