Message ID | 20220819125430.4920-1-povik+lin@cutebit.org |
---|---|
Headers | show |
Series | ASoC platform driver for Apple MCA | expand |
On Fri, Aug 19, 2022 at 02:54:29PM +0200, Martin Povišer wrote: This all looks good, one style nit and a couple of requests for clarification below but basically this is fine. > +++ b/sound/soc/apple/mca.c > @@ -0,0 +1,1149 @@ > +// SPDX-License-Identifier: GPL-2.0-only > +/* > + * Apple SoCs MCA driver > + * > + * Copyright (C) The Asahi Linux Contributors > + * > + * The MCA peripheral is made up of a number of identical units called clusters. Please make the entire comment block a C++ one so things look more intentional. > +#define USE_RXB_FOR_CAPTURE What's this all about? > +static int mca_fe_enable_clocks(struct mca_cluster *cl) > +{ > + struct mca_data *mca = cl->host; > + int ret; > + > + ret = clk_prepare_enable(cl->clk_parent); > + if (ret) { > + dev_err(mca->dev, > + "cluster %d: unable to enable clock parent: %d\n", > + cl->no, ret); > + return ret; > + } > + > + /* > + * We can't power up the device earlier than this because > + * the power state driver would error out on seeing the device > + * as clock-gated. > + */ > + cl->pd_link = device_link_add(mca->dev, cl->pd_dev, > + DL_FLAG_STATELESS | DL_FLAG_PM_RUNTIME | > + DL_FLAG_RPM_ACTIVE); I'm not clear on this dynamically adding and removing device links stuff - it looks like the main (only?) purpose is to take a runtime PM reference to the target device which is fine but it's not clear why device links are involved given that the links are created and destroyed every time the DAI is used, AFAICT always in the same fixed relationship. It's not a problem, it's just unclear.
On Fri, Aug 19, 2022 at 05:17:17PM +0300, Krzysztof Kozlowski wrote: > On 19/08/2022 17:14, Martin Povišer wrote: > >>> Since it was brought up last time but I didn’t respond: the > >>> nonalphabetical order is as the chips were introduced (and > >>> matches other schemas). > >> > >> Sure, just keep that order for future compatibles as well - so always > >> put them according to verifiable time of market introduction... > >> > >> This is very poor reason, instead of alphabetical order. Even worse > >> reason is repeating wrong pattern just because someone else did it. > >> > >> Best regards, > >> Krzysztof > >> > > > > I don’t see it nearly as clear-cut. Adding to the end seems pretty > > foolproof too, but OK, next submission will have it alphabet. ordered. > > The concept is the same everywhere, be it Kconfig, Makefile or other > lists. If everyone adds at the end, you increase the chances of > conflicts. Having alphabetical order usually means simultaneous edits > will happen in different places. The difference for those cases is there is 0 control of when things are added with the source being all independent (different companies). For these, it's all one platform family and there's limits as to when one source can produce new entries. I'd kind of like to know timeline order, but alphabetical is the only thing we can ever check easily and possibly automate (hint). Rob
> On 22. 8. 2022, at 19:39, Mark Brown <broonie@kernel.org> wrote: > > On Fri, Aug 19, 2022 at 02:54:29PM +0200, Martin Povišer wrote: > > This all looks good, one style nit and a couple of requests for > clarification below but basically this is fine. > >> +++ b/sound/soc/apple/mca.c >> @@ -0,0 +1,1149 @@ >> +// SPDX-License-Identifier: GPL-2.0-only >> +/* >> + * Apple SoCs MCA driver >> + * >> + * Copyright (C) The Asahi Linux Contributors >> + * >> + * The MCA peripheral is made up of a number of identical units called clusters. > > Please make the entire comment block a C++ one so things look more > intentional. Is this so that it does not look like the SPDX header was added mechanically? I will do it, just curious what the reasoning is. > >> +#define USE_RXB_FOR_CAPTURE > > What's this all about? There’s something we can configure one way or the other way in the hardware (choosing RXA or RXB unit in a cluster for capture). Since this driver developed along reverse-engineering the hardware, this switch got built in. I want to keep it for future experimentation. Also, as the driver’s side gig is documenting the hardware, this way it documents more. >> +static int mca_fe_enable_clocks(struct mca_cluster *cl) >> +{ >> + struct mca_data *mca = cl->host; >> + int ret; >> + >> + ret = clk_prepare_enable(cl->clk_parent); >> + if (ret) { >> + dev_err(mca->dev, >> + "cluster %d: unable to enable clock parent: %d\n", >> + cl->no, ret); >> + return ret; >> + } >> + >> + /* >> + * We can't power up the device earlier than this because >> + * the power state driver would error out on seeing the device >> + * as clock-gated. >> + */ >> + cl->pd_link = device_link_add(mca->dev, cl->pd_dev, >> + DL_FLAG_STATELESS | DL_FLAG_PM_RUNTIME | >> + DL_FLAG_RPM_ACTIVE); > > I'm not clear on this dynamically adding and removing device links stuff > - it looks like the main (only?) purpose is to take a runtime PM > reference to the target device which is fine but it's not clear why > device links are involved given that the links are created and destroyed > every time the DAI is used, AFAICT always in the same fixed > relationship. It's not a problem, it's just unclear. Indeed the only purpose is powering up the cluster’s power domain (there’s one domain for each cluster). Adding the links is the only way I know to do it. They need to be added dynamically (as opposed to statically linking, say, the DAI’s ->dev to the cluster’s ->pd_dev, which I guess may do something similar), because we need to sequence the power-up/power-down with the enablement of the clocks. Martin
On Tue, Aug 23, 2022 at 09:33:36AM +0200, Martin Povišer wrote: > > On 22. 8. 2022, at 19:39, Mark Brown <broonie@kernel.org> wrote: > > On Fri, Aug 19, 2022 at 02:54:29PM +0200, Martin Povišer wrote: > >> +// SPDX-License-Identifier: GPL-2.0-only > >> +/* > >> + * Apple SoCs MCA driver > >> + * > >> + * Copyright (C) The Asahi Linux Contributors > >> + * > >> + * The MCA peripheral is made up of a number of identical units called clusters. > > Please make the entire comment block a C++ one so things look more > > intentional. > Is this so that it does not look like the SPDX header was added > mechanically? I will do it, just curious what the reasoning is. Yes, broadly. > >> + /* > >> + * We can't power up the device earlier than this because > >> + * the power state driver would error out on seeing the device > >> + * as clock-gated. > >> + */ > >> + cl->pd_link = device_link_add(mca->dev, cl->pd_dev, > >> + DL_FLAG_STATELESS | DL_FLAG_PM_RUNTIME | > >> + DL_FLAG_RPM_ACTIVE); > > I'm not clear on this dynamically adding and removing device links stuff > > - it looks like the main (only?) purpose is to take a runtime PM > > reference to the target device which is fine but it's not clear why > > device links are involved given that the links are created and destroyed > > every time the DAI is used, AFAICT always in the same fixed > > relationship. It's not a problem, it's just unclear. > Indeed the only purpose is powering up the cluster’s power domain (there’s > one domain for each cluster). Adding the links is the only way I know to > do it. They need to be added dynamically (as opposed to statically linking, > say, the DAI’s ->dev to the cluster’s ->pd_dev, which I guess may do > something similar), because we need to sequence the power-up/power-down > with the enablement of the clocks. You could also just do the underlying runtime power management operations directly couldn't you? It's not clear what the device link stuff is adding.
> On 23. 8. 2022, at 13:31, Mark Brown <broonie@kernel.org> wrote: > > On Tue, Aug 23, 2022 at 09:33:36AM +0200, Martin Povišer wrote: >>> On 22. 8. 2022, at 19:39, Mark Brown <broonie@kernel.org> wrote: >>> On Fri, Aug 19, 2022 at 02:54:29PM +0200, Martin Povišer wrote: >>>> + /* >>>> + * We can't power up the device earlier than this because >>>> + * the power state driver would error out on seeing the device >>>> + * as clock-gated. >>>> + */ >>>> + cl->pd_link = device_link_add(mca->dev, cl->pd_dev, >>>> + DL_FLAG_STATELESS | DL_FLAG_PM_RUNTIME | >>>> + DL_FLAG_RPM_ACTIVE); > >>> I'm not clear on this dynamically adding and removing device links stuff >>> - it looks like the main (only?) purpose is to take a runtime PM >>> reference to the target device which is fine but it's not clear why >>> device links are involved given that the links are created and destroyed >>> every time the DAI is used, AFAICT always in the same fixed >>> relationship. It's not a problem, it's just unclear. > >> Indeed the only purpose is powering up the cluster’s power domain (there’s >> one domain for each cluster). Adding the links is the only way I know to >> do it. They need to be added dynamically (as opposed to statically linking, >> say, the DAI’s ->dev to the cluster’s ->pd_dev, which I guess may do >> something similar), because we need to sequence the power-up/power-down >> with the enablement of the clocks. > > You could also just do the underlying runtime power management > operations directly couldn't you? It's not clear what the device link > stuff is adding. This seems to be the way to do it. Quoting from documentation of dev_pm_domain_attach_by_id, by which we obtain the mca->dev and cl->pd_dev the link is between: * This function should typically be invoked by a driver during the probe phase, * in case its device requires power management through multiple PM domains. The * driver may benefit from using the received device, to configure device-links * towards its original device. Depending on the use-case and if needed, the * links may be dynamically changed by the driver, which allows it to control * the power to the PM domains independently from each other. -- Martin
> On 23. 8. 2022, at 13:51, Martin Povišer <povik+lin@cutebit.org> wrote: > > > >> On 23. 8. 2022, at 13:31, Mark Brown <broonie@kernel.org> wrote: >> >> On Tue, Aug 23, 2022 at 09:33:36AM +0200, Martin Povišer wrote: >>>> On 22. 8. 2022, at 19:39, Mark Brown <broonie@kernel.org> wrote: >>>> On Fri, Aug 19, 2022 at 02:54:29PM +0200, Martin Povišer wrote: > >>>>> + /* >>>>> + * We can't power up the device earlier than this because >>>>> + * the power state driver would error out on seeing the device >>>>> + * as clock-gated. >>>>> + */ >>>>> + cl->pd_link = device_link_add(mca->dev, cl->pd_dev, >>>>> + DL_FLAG_STATELESS | DL_FLAG_PM_RUNTIME | >>>>> + DL_FLAG_RPM_ACTIVE); >> >>>> I'm not clear on this dynamically adding and removing device links stuff >>>> - it looks like the main (only?) purpose is to take a runtime PM >>>> reference to the target device which is fine but it's not clear why >>>> device links are involved given that the links are created and destroyed >>>> every time the DAI is used, AFAICT always in the same fixed >>>> relationship. It's not a problem, it's just unclear. >> >>> Indeed the only purpose is powering up the cluster’s power domain (there’s >>> one domain for each cluster). Adding the links is the only way I know to >>> do it. They need to be added dynamically (as opposed to statically linking, >>> say, the DAI’s ->dev to the cluster’s ->pd_dev, which I guess may do >>> something similar), because we need to sequence the power-up/power-down >>> with the enablement of the clocks. >> >> You could also just do the underlying runtime power management >> operations directly couldn't you? It's not clear what the device link >> stuff is adding. > > This seems to be the way to do it. Quoting from documentation of > dev_pm_domain_attach_by_id, by which we obtain the mca->dev and cl->pd_dev > the link is between: > > * This function should typically be invoked by a driver during the probe phase, > * in case its device requires power management through multiple PM domains. The > * driver may benefit from using the received device, to configure device-links > * towards its original device. Depending on the use-case and if needed, the > * links may be dynamically changed by the driver, which allows it to control > * the power to the PM domains independently from each other. > > -- > Martin Pardon, just the cl->pd_dev is from dev_pm_domain_attach_by_id, mca->dev is the original device. Martin