From: Pierre-Louis Bossart <pierre-louis.bossart@linux.dev>
To: Charles Keepax <ckeepax@opensource.cirrus.com>, broonie@kernel.org
Cc: 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 v3 RESEND 14/19] ASoC: SDCA: Add FDL library for XU entities
Date: Mon, 27 Oct 2025 15:39:40 +0100 [thread overview]
Message-ID: <39108baa-b379-4171-8426-c3b00a94e5f9@linux.dev> (raw)
In-Reply-To: <20251020155512.353774-15-ckeepax@opensource.cirrus.com>
> +config SND_SOC_SDCA_FDL
> + bool "SDCA FDL (File DownLoad) support"
> + depends on SND_SOC_SDCA
> + default y
> + help
> + This option enables support for the File Download using UMP,
> + typically used for downloading firmware to devices.
nit-pick: shouldn't this option be selected by device drivers who need this library? There should be guardrails to prevent the fallback helpers from being used silently.
> +int sdca_reset_function(struct device *dev, struct sdca_function_data *function,
> + struct regmap *regmap)
> +{
> + unsigned int reg = SDW_SDCA_CTL(function->desc->adr,
> + SDCA_ENTITY_TYPE_ENTITY_0,
> + SDCA_CTL_ENTITY_0_FUNCTION_ACTION, 0);
> + unsigned int val, poll_us;
> + int ret;
> +
> + ret = regmap_write(regmap, reg, SDCA_CTL_ENTITY_0_RESET_FUNCTION_NOW);
> + if (ret) // Allowed for function reset to not be implemented
> + return 0;
nit-pick: maybe document why this is allowed. This doesn't seem very good in terms of design.
> +
> + if (!function->reset_max_delay) {
> + dev_err(dev, "No reset delay specified in DisCo\n");
> + return -EINVAL;
> + }
nit-pick: or maybe fallback to a reasonable default? Making the entire download dependent on Disco correctness isn't going to work long-term.
> +
> + poll_us = umin(function->reset_max_delay >> 4, 1000);
add comment on what this >> 4 means.
> +
> + ret = regmap_read_poll_timeout(regmap, reg, val, !val, poll_us,
> + function->reset_max_delay);
> + if (ret) {
> + dev_err(dev, "Failed waiting for function reset: %d\n", ret);
> + return ret;
> + }
> +
> + return 0;
> +}
> +EXPORT_SYMBOL_NS(sdca_reset_function, "SND_SOC_SDCA");
> +/**
> + * sdca_fdl_process - Process the FDL state machine
> + * @interrupt: SDCA interrupt structure
> + *
> + * Based on section 13.2.5 Flow Diagram for File Download, Host side.
> + *
> + * Return: Zero on success or a negative error code.
> + */
> +int sdca_fdl_process(struct sdca_interrupt *interrupt)
> +{
> + struct device *dev = interrupt->dev;
> + struct sdca_entity_xu *xu = &interrupt->entity->xu;
> + unsigned int reg, status;
> + int response, ret;
> +
> + ret = sdca_ump_get_owner_host(dev, interrupt->function_regmap,
> + interrupt->function, interrupt->entity,
> + interrupt->control);
> + if (ret)
> + goto reset_function;
> +
> + reg = SDW_SDCA_CTL(interrupt->function->desc->adr, interrupt->entity->id,
> + SDCA_CTL_XU_FDL_STATUS, 0);
> + ret = regmap_read(interrupt->function_regmap, reg, &status);
> + if (ret < 0) {
> + dev_err(dev, "failed to read FDL status: %d\n", ret);
> + return ret;
> + }
> +
> + dev_dbg(dev, "FDL status: %#x\n", status);
> +
> + ret = fdl_status_process(interrupt, status);
> + if (ret < 0)
> + goto reset_function;
> +
> + response = ret;
> +
> + dev_dbg(dev, "FDL response: %#x\n", response);
> +
> + ret = regmap_write(interrupt->function_regmap, reg,
> + response | (status & ~SDCA_CTL_XU_FDLH_MASK));
> + if (ret < 0) {
> + dev_err(dev, "failed to set FDL status signal: %d\n", ret);
> + return ret;
> + }
> +
> + ret = sdca_ump_set_owner_device(dev, interrupt->function_regmap,
> + interrupt->function, interrupt->entity,
> + interrupt->control);
> + if (ret)
> + return ret;
> +
> + switch (response) {
> + case SDCA_CTL_XU_FDLH_RESET_ACK:
> + dev_dbg(dev, "FDL request reset\n");
> +
> + switch (xu->reset_mechanism) {
> + default:
> + dev_warn(dev, "Requested reset mechanism not implemented\n");
> + fallthrough;
this fallthrough looks odd since it forces a check on the reset a second time ...
> + case SDCA_XU_RESET_FUNCTION:
> + goto reset_function;
> + }
> + default:
> + return 0;
> + }
> +
> +reset_function:
... inside this function call
> + sdca_reset_function(dev, interrupt->function, interrupt->function_regmap);
> +
> + return ret;
> +}
> +EXPORT_SYMBOL_NS_GPL(sdca_fdl_process, "SND_SOC_SDCA");
next prev parent reply other threads:[~2025-10-27 15:25 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-20 15:54 [PATCH v3 RESEND 00/19] Add SDCA UMP/FDL support Charles Keepax
2025-10-20 15:54 ` [PATCH v3 RESEND 01/19] ASoC: SDCA: Rename SoundWire struct device variables Charles Keepax
2025-10-20 15:54 ` [PATCH v3 RESEND 02/19] regmap: sdw-mbq: Don't assume the regmap device is the SoundWire slave Charles Keepax
2025-10-20 15:54 ` [PATCH v3 RESEND 03/19] ASoC: SDCA: Add manual PM runtime gets to IRQ handlers Charles Keepax
2025-10-20 15:54 ` [PATCH v3 RESEND 04/19] ASoC: SDCA: Pass SoundWire slave to HID Charles Keepax
2025-10-20 15:54 ` [PATCH v3 RESEND 05/19] ASoC: SDCA: Pass device register map from IRQ alloc to handlers Charles Keepax
2025-10-20 15:54 ` [PATCH v3 RESEND 06/19] ASoC: SDCA: Update externally_requested flag to cover all requests Charles Keepax
2025-10-20 15:55 ` [PATCH v3 RESEND 07/19] ASoC: SDCA: Factor out a helper to find SDCA IRQ data Charles Keepax
2025-10-20 15:55 ` [PATCH v3 RESEND 08/19] ASoC: SDCA: Rely less on the ASoC component in IRQ handling Charles Keepax
2025-10-20 15:55 ` [PATCH v3 RESEND 09/19] ASoC: SDCA: Force some SDCA Controls to be volatile Charles Keepax
2025-10-20 15:55 ` [PATCH v3 RESEND 10/19] ASoC: SDCA: Parse XU Entity properties Charles Keepax
2025-10-20 15:55 ` [PATCH v3 RESEND 11/19] ASoC: SDCA: Parse Function Reset max delay Charles Keepax
2025-10-20 15:55 ` [PATCH v3 RESEND 12/19] ASoC: SDCA: Add UMP buffer helper functions Charles Keepax
2025-10-20 15:55 ` [PATCH v3 RESEND 13/19] ASoC: SDCA: Add SDCA FDL data parsing Charles Keepax
2025-10-20 15:55 ` [PATCH v3 RESEND 14/19] ASoC: SDCA: Add FDL library for XU entities Charles Keepax
2025-10-27 14:39 ` Pierre-Louis Bossart [this message]
2025-10-30 11:01 ` Charles Keepax
2025-10-20 15:55 ` [PATCH v3 RESEND 15/19] ASoC: SDCA: Add FDL-specific IRQ processing Charles Keepax
2025-10-20 15:55 ` [PATCH v3 RESEND 16/19] ASoC: SDCA: Add completion for FDL start and stop Charles Keepax
2025-10-20 15:55 ` [PATCH v3 RESEND 17/19] ASoC: SDCA: Add UMP timeout handling for FDL Charles Keepax
2025-10-20 15:55 ` [PATCH v3 RESEND 18/19] ASoC: SDCA: Add early IRQ handling Charles Keepax
2025-10-20 15:55 ` [PATCH v3 RESEND 19/19] ASoC: SDCA: Add HID button IRQ Charles Keepax
2025-10-27 14:43 ` [PATCH v3 RESEND 00/19] Add SDCA UMP/FDL support 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=39108baa-b379-4171-8426-c3b00a94e5f9@linux.dev \
--to=pierre-louis.bossart@linux.dev \
--cc=broonie@kernel.org \
--cc=ckeepax@opensource.cirrus.com \
--cc=lgirdwood@gmail.com \
--cc=linux-sound@vger.kernel.org \
--cc=patches@opensource.cirrus.com \
--cc=peter.ujfalusi@linux.intel.com \
--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;
as well as URLs for NNTP newsgroup(s).