From: Lars-Peter Clausen <lars@metafoo.de>
To: Robert Jarzmik <robert.jarzmik@free.fr>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>,
Lee Jones <lee.jones@linaro.org>,
Sebastian Reichel <sre@kernel.org>,
Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
Daniel Mack <daniel@zonque.org>,
Haojian Zhuang <haojian.zhuang@gmail.com>,
Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>,
alsa-devel@alsa-project.org, linux-pm@vger.kernel.org,
patches@opensource.wolfsonmicro.com,
linux-kernel@vger.kernel.org, linux-input@vger.kernel.org,
linux-arm-kernel@lists.infradead.org
Subject: Re: [alsa-devel] [PATCH 2/9] ALSA: ac97: add an ac97 bus
Date: Thu, 10 Nov 2016 12:38:40 +0100 [thread overview]
Message-ID: <6b97a129-bd10-b9be-616d-a3ea3b91b103@metafoo.de> (raw)
In-Reply-To: <87mvh8uywm.fsf@belgarion.home>
On 11/09/2016 10:27 PM, Robert Jarzmik wrote:
[...]
>>>>> +int snd_ac97_codec_driver_register(struct ac97_codec_driver *drv)
>>>>> +{
>>>>> + int ret;
>>>>> +
>>>>> + drv->driver.bus = &ac97_bus_type;
>>>>> +
>>>>> + ret = driver_register(&drv->driver);
>>>>> + if (!ret)
>>>>> + ac97_rescan_all_controllers();
>>>>
>>>> Rescanning the bus when a new codec driver is registered should not be
>>>> neccessary. The bus is scanned once when the controller is registered, this
>>>> creates the device. The device driver core will take care of binding the
>>>> device to the driver, if the driver is registered after thed evice.
>>> That's because you suppose the initial scanning found all the ac97 codecs.
>>> But that's an incomplete vision as a codec might be powered off at that time and
>>> not seen by the first scanning, while the new scanning will discover it.
>>
>> But why would the device become suddenly visible when the driver is
>> registered. This seems to be an as arbitrary point in time as any other.
> Because in the meantime, a regulator or something else provided power to the
> AC97 IP, or a clock, and it can answer to requests after that.
>
> And another point if that the clock of controller might be provided by the AC97
> codec, and the scan will only succeed once the codec is actually providing this
> clock, which it might do only once the module_init() is done.
>
>> Also consider that when you build a driver as a module, the module will
>> typically only be auto-loaded after the device has been detected, based on
>> the device ID. On the other hand, if the driver is built-in driver
>> registration will happen either before or shortly after the controller
>> registration.
>> If there is the expectation that the AC97 CODEC might randomly appear on the
>> bus, the core should periodically scan the bus.
> Power wise a periodical scan doesn't look good, at all.
>
> More globally, I don't see if there is an actual issue we're trying to address
> here, ie. that the rescan is a bug, or if it's more an "Occam's razor"
> discussion ?
It's a framework design discussion. In my opinion the driver being
registered and the device becoming visible on the physical bus are two
completely unrelated operations. Especially in the Linux device driver model.
You have a generic driver that calls ac97_codec_driver_register() in its
module_init() section. This generic driver does (at module_init() time) not
know anything about a device instance specific clocks, regulators or other
resources. Resources are handled on a per device instance basis, and you
won't have a device instance until the device has been detected, which
happens in ac97_bus_scan(). So you have a cyclic dependency loop here.
Maybe we can just leave the rescanning out for now and think about how to
best handle it when the need arises.
>
>>>> In my opinion this should return a handle to a ac97 controller which can
>>>> then be passed to snd_ac97_controller_unregister(). This is in my opinion
>>>> the better approach rather than looking up the controller by parent device.
>>> This is another "legacy drivers" issue.
>>>
>>> The legacy driver (the one probed by platform_data or devicetree) doesn't
>>> necessarily have a private structure to store this ac97_controller pointer.
>>
>> I might be missing something, but I'm not convinced by this. Can you point
>> me to such a legacy driver where you think this would not work?
> The first one that popped out:
> - hac_soc_platform_probe()
I think that driver should be able to use platform_set_drvdata() to store
the pointer.
next prev parent reply other threads:[~2016-11-10 11:39 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-26 19:41 [PATCH 0/9] AC97 device/driver model revamp Robert Jarzmik
2016-10-26 19:41 ` [PATCH 1/9] ALSA: ac97: split out the generic ac97 registers Robert Jarzmik
2016-10-26 19:41 ` [PATCH 2/9] ALSA: ac97: add an ac97 bus Robert Jarzmik
2016-11-08 13:37 ` [alsa-devel] " Lars-Peter Clausen
2016-11-08 21:18 ` Robert Jarzmik
2016-11-09 13:11 ` Lars-Peter Clausen
2016-11-09 21:27 ` Robert Jarzmik
2016-11-10 11:38 ` Lars-Peter Clausen [this message]
2016-11-22 18:08 ` Mark Brown
2016-11-25 19:58 ` Robert Jarzmik
2016-10-26 19:41 ` [PATCH 3/9] ASoC: add new ac97 bus support Robert Jarzmik
2016-10-26 19:41 ` [PATCH 4/9] ASoC: wm9713: add ac97 new " Robert Jarzmik
2016-10-27 8:39 ` Charles Keepax
2016-10-26 19:41 ` [PATCH 5/9] ASoC: pxa: switch to new ac97 " Robert Jarzmik
2016-10-31 8:37 ` Robert Jarzmik
2016-11-01 19:55 ` Robert Jarzmik
2016-10-26 19:41 ` [PATCH 6/9] power_supply: wm97xx_battery: use power_supply_get_drvdata Robert Jarzmik
2016-10-27 8:41 ` Charles Keepax
2016-11-23 23:13 ` Sebastian Reichel
2016-11-25 19:54 ` Robert Jarzmik
2017-01-23 18:38 ` Kevin Hilman
2017-01-24 7:31 ` Robert Jarzmik
2017-01-24 20:40 ` Dmitry Torokhov
2017-01-24 23:39 ` Kevin Hilman
2016-10-26 19:41 ` [PATCH 7/9] Input: wm97xx: split out touchscreen registering Robert Jarzmik
2016-10-27 9:02 ` Charles Keepax
2016-10-27 19:27 ` Robert Jarzmik
2016-10-26 19:41 ` [PATCH 8/9] mfd: wm97xx-core: core support for wm97xx Codec Robert Jarzmik
2016-10-27 9:11 ` Charles Keepax
2016-11-18 16:50 ` Lee Jones
2016-11-19 11:39 ` Robert Jarzmik
2016-11-21 10:12 ` Lee Jones
2016-11-26 9:18 ` Robert Jarzmik
2016-12-06 11:13 ` Mark Brown
2017-02-03 8:37 ` Robert Jarzmik
2016-10-26 19:41 ` [PATCH 9/9] Input: wm97xx: add new AC97 bus support Robert Jarzmik
2016-10-27 9:13 ` Charles Keepax
2017-09-19 16:11 ` Applied "Input: wm97xx: add new AC97 bus support" to the asoc tree Mark Brown
2016-11-22 18:13 ` [PATCH 0/9] AC97 device/driver model revamp Mark Brown
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=6b97a129-bd10-b9be-616d-a3ea3b91b103@metafoo.de \
--to=lars@metafoo.de \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=daniel@zonque.org \
--cc=dmitry.torokhov@gmail.com \
--cc=haojian.zhuang@gmail.com \
--cc=lee.jones@linaro.org \
--cc=lgirdwood@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=patches@opensource.wolfsonmicro.com \
--cc=perex@perex.cz \
--cc=robert.jarzmik@free.fr \
--cc=sre@kernel.org \
--cc=tiwai@suse.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).