From: Charles Keepax <ckeepax@opensource.cirrus.com>
To: Pierre-Louis Bossart <pierre-louis.bossart@linux.dev>
Cc: broonie@kernel.org, rafael@kernel.org,
yung-chuan.liao@linux.intel.com, peter.ujfalusi@linux.intel.com,
shumingf@realtek.com, lgirdwood@gmail.com,
linux-sound@vger.kernel.org, patches@opensource.cirrus.com
Subject: Re: [PATCH v2 16/19] ASoC: SDCA: Add completion for FDL start and stop
Date: Thu, 18 Sep 2025 11:57:45 +0100 [thread overview]
Message-ID: <aMvlqUXDVL7VatJB@opensource.cirrus.com> (raw)
In-Reply-To: <e88ae1e0-7fc4-4915-bf20-564232640c6c@linux.dev>
On Wed, Sep 17, 2025 at 10:13:27PM +0200, Pierre-Louis Bossart wrote:
> On 9/12/25 12:35, Charles Keepax wrote:
> > Add some completions and a helper function to allow other parts of the
> > system to wait for FDL to complete. The sdca_fdl_sync() function will
> > wait until it completes a full time out without a new FDL request
> > happening, this ensures that even parts requiring multiple rounds of FDL
> > should be fully downloaded before the driver boot continues.
>
> I couldn't figure out what the last sentence means. In
> theory we have a status that can be checked to know if all
> the firmware sets have been processed by the device. so why
> do we need a 'timeout without a new FDL request'. The status
> tells you exactly when the FDL iterations are over.
This is the other timeout I was asking about after you so
usefully pointed out the DisCo property I was missing for the
UMPs.
Presuming you are referring to the FDL status. That will keep
track of the progress of a single FDL set. But I can't see
anything that prevents a device requesting a second set (and in
fact our device does). So after the first FDL has been complete
one has to wait to see if the device initiates any further FDL.
All the spec says in step 9, 13.1, v1.1 is "Wait until there are
no new requests for File Download". But if I am missing some
additional status field that indicates the device is happy and
ready to rock that would be awesome?
> > /**
> > * struct fdl_state - FDL state structure to keep data between interrupts
> > + * @begin: Completion indicating the start of an FDL download cycle.
> > + * @done: Completion indicating the end of an FDL download cycle.
> > * @set: Pointer to the FDL set currently being downloaded.
> > * @file_index: Index of the current file being processed.
> > */
> > struct fdl_state {
> > + struct completion begin;
> > + struct completion done;
> > +
>
> maybe explain why you need to track the 'begin' phase? This
> isn't a concept I can map to the FDL state machine.
These are not so much concepts from the state machine as just the
naive interpretation of their names. Begin means an FDL has
begun, and done means that FDL has completed. We track the begin
because as far as I can see the only signal the device is fully
ready is that it doesn't initiate an FDL for a while.
> IIRC the device tells you if it needs firmware or not. It
> could very well be that it kept all the context and doesn't
> need to be re-initialized always. Adding a timeout in all
> cases doesn't seem quite right - or it should be something done
> for specific hardware that always needs to be re-initialized
> with firmware.
I think what I am missing here is what is the mechanism for that
telling you it no longer needs firmware? As far as I can see the
only mechanism is an IRQ on the FDL UMP buffer, so we wait for
that.
> > +int sdca_fdl_sync(struct device *dev, struct sdca_function_data *function,
> > + struct sdca_interrupt_info *info)
> > +{
> > + static const int max_fdls = 10;
>
> I think you can have 8 sets with 3 bits for the status. where does the 10 come from?
This is just an arbitrary number of retries before we give up.
Basically for the UMP timeout case you wanted added, we now reset
the function, so hopefully it will succeed on the next go.
Sorry what do you mean by 8 sets with 3 bits for the status? I
am a little concerned I am missing something here. As far as
I can see Set_Index is a 1 byte control, so 256 possible set
numbers, and the FDL status is also 1 byte, so 8 bits for
the status.
> > + int nfdl;
> > + int i, j;
> > +
> > + for (i = 0; i < max_fdls; i++) {
> > + nfdl = 0;
> > +
> > + for (j = 0; j < SDCA_MAX_INTERRUPTS; j++) {
> > + struct sdca_interrupt *interrupt = &info->irqs[j];
>
> I don't fully understand why you have the interrupt in the
> inner loop. For a given XU, one might think that there's a single
> interrupt for the XU UMP used for FDL, and that each set is sent
> with the same mechanism?
There probably is a single interrupt, but you need to find it
first. This is called from the function boot, so it doesn't
automatically have access to what that XU is, it is faster to
search the IRQs than to search all the entities, as there is a
lot less of them typically.
Also I don't think it is a spec requirement that there is only a
single XU FDLing, so the code supports more.
> > + struct fdl_state *fdl_state;
> > + unsigned long time;
> > +
> > + if (interrupt->function != function ||
> > + !interrupt->entity || !interrupt->control ||
> > + interrupt->entity->type != SDCA_ENTITY_TYPE_XU ||
> > + interrupt->control->sel != SDCA_CTL_XU_FDL_CURRENTOWNER)
> > + continue;
> > +
> > + fdl_state = interrupt->priv;
> > + nfdl++;
> > +
> > + /*
> > + * Looking for timeout without any new FDL requests
> > + * to imply the device has completed initial
> > + * firmware setup. Alas the specification doesn't
> > + * have any mechanism to detect this.
> > + */
> > + time = wait_for_completion_timeout(&fdl_state->begin,
> > + begin_timeout);
> > + if (!time) {
> > + dev_dbg(dev, "no new FDL starts\n");
> > + nfdl--;
> > + continue;
> > + }
> > +
> > + time = wait_for_completion_timeout(&fdl_state->done,
> > + done_timeout);
> > + if (!time) {
> > + dev_err(dev, "timed out waiting for FDL to complete\n");
> > + return -ETIMEDOUT;
> > + }
> > + }
> > +
> > + if (!nfdl)
> > + return 0;
> > + }
>
> Why don't you use the mask provided in the NEEDS_SET message?
Perhaps I am misunderstanding here, but NEEDS_SET contains no
data, it just tells you to read the FDL_Set_Index control. Which
then gives you a single set index to download. The device may
then go on to request a second set?
> > +
> > + dev_err(dev, "too many FDL quests\n");
>
> requests?
lol oops, as accidentally hilarious as this is I will fix.
Thanks,
Charles
next prev parent reply other threads:[~2025-09-18 10:58 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-12 10:34 [PATCH v2 00/20] Add SDCA UMP/FDL support Charles Keepax
2025-09-12 10:34 ` [PATCH v2 01/19] ASoC: SDCA: Rename SoundWire struct device variables Charles Keepax
2025-09-12 10:34 ` [PATCH v2 02/19] regmap: sdw-mbq: Don't assume the regmap device is the SoundWire slave Charles Keepax
2025-09-12 10:34 ` [PATCH v2 03/19] ASoC: SDCA: Add manual PM runtime gets to IRQ handlers Charles Keepax
2025-09-12 10:34 ` [PATCH v2 04/19] ASoC: SDCA: Pass SoundWire slave to HID Charles Keepax
2025-09-12 10:34 ` [PATCH v2 05/19] ASoC: SDCA: Pass device register map from IRQ alloc to handlers Charles Keepax
2025-09-12 10:34 ` [PATCH v2 06/19] ASoC: SDCA: Update externally_requested flag to cover all requests Charles Keepax
2025-09-12 10:34 ` [PATCH v2 07/19] ASoC: SDCA: Factor out a helper to find SDCA IRQ data Charles Keepax
2025-09-17 18:49 ` Pierre-Louis Bossart
2025-09-19 10:41 ` Charles Keepax
2025-09-12 10:34 ` [PATCH v2 08/19] ASoC: SDCA: Rely less on the ASoC component in IRQ handling Charles Keepax
2025-09-12 10:34 ` [PATCH v2 09/19] ASoC: SDCA: Force some SDCA Controls to be volatile Charles Keepax
2025-09-17 18:53 ` Pierre-Louis Bossart
2025-09-18 10:18 ` Charles Keepax
2025-09-12 10:34 ` [PATCH v2 10/19] ASoC: SDCA: Parse XU Entity properties Charles Keepax
2025-09-17 18:58 ` Pierre-Louis Bossart
2025-09-18 10:24 ` Charles Keepax
2025-09-12 10:34 ` [PATCH v2 11/19] ASoC: SDCA: Parse Function Reset max delay Charles Keepax
2025-09-12 10:34 ` [PATCH v2 12/19] ASoC: SDCA: Add UMP buffer helper functions Charles Keepax
2025-09-17 19:49 ` Pierre-Louis Bossart
2025-09-18 12:22 ` Charles Keepax
2025-09-12 10:34 ` [PATCH v2 13/19] ASoC: SDCA: Add SDCA FDL data parsing Charles Keepax
2025-09-16 13:38 ` Mark Brown
2025-09-16 13:45 ` Mark Brown
2025-09-16 13:51 ` Charles Keepax
2025-09-17 12:14 ` Mark Brown
2025-09-17 14:31 ` Charles Keepax
2025-09-18 20:25 ` Mark Brown
2025-09-19 8:06 ` Charles Keepax
2025-09-12 10:34 ` [PATCH v2 14/19] ASoC: SDCA: Add FDL library for XU entities Charles Keepax
2025-09-12 10:35 ` [PATCH v2 15/19] ASoC: SDCA: Add FDL-specific IRQ processing Charles Keepax
2025-09-12 10:35 ` [PATCH v2 16/19] ASoC: SDCA: Add completion for FDL start and stop Charles Keepax
2025-09-17 20:13 ` Pierre-Louis Bossart
2025-09-18 10:57 ` Charles Keepax [this message]
2025-09-12 10:35 ` [PATCH v2 17/19] ASoC: SDCA: Add UMP timeout handling for FDL Charles Keepax
2025-09-12 10:35 ` [PATCH v2 18/19] ASoC: SDCA: Add early IRQ handling Charles Keepax
2025-09-12 10:35 ` [PATCH v2 19/19] ASoC: SDCA: Add HID button IRQ Charles Keepax
2025-09-16 2:12 ` [PATCH v2 00/20] Add SDCA UMP/FDL support Liao, Bard
2025-09-17 20:20 ` Pierre-Louis Bossart
2025-10-29 22:02 ` 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=aMvlqUXDVL7VatJB@opensource.cirrus.com \
--to=ckeepax@opensource.cirrus.com \
--cc=broonie@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-sound@vger.kernel.org \
--cc=patches@opensource.cirrus.com \
--cc=peter.ujfalusi@linux.intel.com \
--cc=pierre-louis.bossart@linux.dev \
--cc=rafael@kernel.org \
--cc=shumingf@realtek.com \
--cc=yung-chuan.liao@linux.intel.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