All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
From: "Martin Povišer" <povik+lin@cutebit.org>
To: Mark Brown <broonie@kernel.org>
Cc: Liam Girdwood <lgirdwood@gmail.com>,
	Rob Herring <robh+dt@kernel.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
	Hector Martin <marcan@marcan.st>, Sven Peter <sven@svenpeter.dev>,
	Philipp Zabel <p.zabel@pengutronix.de>,
	Alyssa Rosenzweig <alyssa@rosenzweig.io>,
	asahi@lists.linux.dev, alsa-devel@alsa-project.org,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 3/4] ASoC: apple: mca: Start new platform driver
Date: Tue, 23 Aug 2022 09:33:36 +0200	[thread overview]
Message-ID: <24C0ABFA-BF71-4492-8A6A-E9BE1462B403@cutebit.org> (raw)
In-Reply-To: <YwO/aqs7eqZx07kS@sirena.org.uk>


> 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


WARNING: multiple messages have this Message-ID (diff)
From: "Martin Povišer" <povik+lin@cutebit.org>
To: Mark Brown <broonie@kernel.org>
Cc: devicetree@vger.kernel.org, alsa-devel@alsa-project.org,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
	Sven Peter <sven@svenpeter.dev>, Hector Martin <marcan@marcan.st>,
	Liam Girdwood <lgirdwood@gmail.com>,
	linux-kernel@vger.kernel.org, Rob Herring <robh+dt@kernel.org>,
	asahi@lists.linux.dev, Philipp Zabel <p.zabel@pengutronix.de>,
	Alyssa Rosenzweig <alyssa@rosenzweig.io>
Subject: Re: [PATCH v2 3/4] ASoC: apple: mca: Start new platform driver
Date: Tue, 23 Aug 2022 09:33:36 +0200	[thread overview]
Message-ID: <24C0ABFA-BF71-4492-8A6A-E9BE1462B403@cutebit.org> (raw)
In-Reply-To: <YwO/aqs7eqZx07kS@sirena.org.uk>


> 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


  reply	other threads:[~2022-08-23  7:33 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-19 12:54 [PATCH v2 0/4] ASoC platform driver for Apple MCA Martin Povišer
2022-08-19 12:54 ` Martin Povišer
2022-08-19 12:54 ` [PATCH v2 1/4] dt-bindings: sound: Add Apple MCA I2S transceiver Martin Povišer
2022-08-19 12:54   ` Martin Povišer
2022-08-19 12:58   ` Martin Povišer
2022-08-19 12:58     ` Martin Povišer
2022-08-19 13:08     ` Krzysztof Kozlowski
2022-08-19 13:08       ` Krzysztof Kozlowski
2022-08-19 13:09       ` Krzysztof Kozlowski
2022-08-19 13:09         ` Krzysztof Kozlowski
2022-08-19 14:14       ` Martin Povišer
2022-08-19 14:14         ` Martin Povišer
2022-08-19 14:17         ` Krzysztof Kozlowski
2022-08-19 14:17           ` Krzysztof Kozlowski
2022-08-22 18:59           ` Rob Herring
2022-08-22 18:59             ` Rob Herring
2022-08-19 12:54 ` [PATCH v2 2/4] arm64: dts: apple: t8103: Add MCA and its support Martin Povišer
2022-08-19 12:54   ` Martin Povišer
2022-08-19 13:12   ` Krzysztof Kozlowski
2022-08-19 13:12     ` Krzysztof Kozlowski
2022-08-19 14:24     ` Martin Povišer
2022-08-19 14:24       ` Martin Povišer
2022-08-23 11:02       ` Krzysztof Kozlowski
2022-08-23 11:02         ` Krzysztof Kozlowski
2022-08-19 12:54 ` [PATCH v2 3/4] ASoC: apple: mca: Start new platform driver Martin Povišer
2022-08-19 12:54   ` Martin Povišer
2022-08-22 17:39   ` Mark Brown
2022-08-22 17:39     ` Mark Brown
2022-08-23  7:33     ` Martin Povišer [this message]
2022-08-23  7:33       ` Martin Povišer
2022-08-23 11:31       ` Mark Brown
2022-08-23 11:31         ` Mark Brown
2022-08-23 11:51         ` Martin Povišer
2022-08-23 11:51           ` Martin Povišer
2022-08-23 11:53           ` Martin Povišer
2022-08-23 11:53             ` Martin Povišer
2022-08-19 12:54 ` [PATCH v2 4/4] ASoC: apple: mca: Add locks on foreign cluster access Martin Povišer
2022-08-19 12:54   ` Martin Povišer
2022-08-22 17:45   ` Mark Brown
2022-08-22 17:45     ` 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=24C0ABFA-BF71-4492-8A6A-E9BE1462B403@cutebit.org \
    --to=povik+lin@cutebit.org \
    --cc=alsa-devel@alsa-project.org \
    --cc=alyssa@rosenzweig.io \
    --cc=asahi@lists.linux.dev \
    --cc=broonie@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcan@marcan.st \
    --cc=p.zabel@pengutronix.de \
    --cc=robh+dt@kernel.org \
    --cc=sven@svenpeter.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.