From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Baojun Xu <baojun.xu@ti.com>
Cc: broonie@kernel.org, tiwai@suse.de, 13916275206@139.com,
alsa-devel@alsa-project.org, shenghao-ding@ti.com,
linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org,
k-yi@ti.com, henry.lo@ti.com, robinchen@ti.com,
niranjan.hy@ti.com, pin-hao.huang@hp.com,
Syed.SabaKareem@amd.com
Subject: Re: [PATCH v1] ASoC: tas2783-sdw: Add basic BPT support
Date: Tue, 3 Nov 2026 19:39:36 +0200 [thread overview]
Message-ID: <auocWKMYhLlqGF8S@ashevche-desk.local> (raw)
In-Reply-To: <20261103133853.1612-1-baojun.xu@ti.com>
On Tue, Nov 03, 2026 at 09:38:53PM +0800, Baojun Xu wrote:
> Add for BPT supported.
...
> +enum {
> + SDW_MSG_FLAG_READ = 0,
> + SDW_MSG_FLAG_WRITE,
Is it going to HW? If not, drop duplicate assignment. Otherwise assign *all* of
the enum to make code robust against modifications.
> +};
...
> +static int tas2783_fw_download_bpt(struct tas2783_prv *tas_dev,
> + const struct firmware *fmw)
> +{
> + struct sdw_slave *slave = tas_dev->sdw_peripheral;
> + struct sdw_bpt_section *sections = NULL;
> + struct sdw_bus *bus = slave->bus;
> + struct sdw_bpt_msg msg = {0};
'0' is not required.
> + struct tas_fw_file file;
> + struct tas_fw_hdr hdr;
> + size_t offset = FW_DL_OFFSET;
> + size_t img_sz = fmw->size;
> + const u8 *buf = fmw->data;
> + int num_sections = 0;
> + int i, ret;
> +
> + if (img_sz < FW_DL_OFFSET)
> + return -EINVAL;
> +
> + tas_fw_read_hdr(buf, &hdr);
> + if (hdr.size != img_sz)
> + return -EINVAL;
> +
> + while (offset < (img_sz - FW_FL_HDR)) {
> + size_t adv = (size_t)tas_fw_get_next_file(&buf[offset], &file);
> +
> + /*
> + * Reject a section whose payload runs past the image. Compare
> + * file.length (not adv) against the space left after this
> + * section's header, so the check is immune to the size_t wrap
> + * in tas_fw_get_next_file() on 32-bit kernels.
> + */
> + if (file.length > img_sz - offset - FW_FL_HDR) {
> + dev_err(tas_dev->dev,
> + "Firmware section at offset %zu exceeded.\n",
> + offset);
> + return -EINVAL;
> + }
> + if (num_sections >= TAS2783_MAX_FW_SECTIONS) {
> + dev_err(tas_dev->dev,
> + "BPT fw has too many sections (max %d)\n",
> + TAS2783_MAX_FW_SECTIONS);
> + return -EINVAL;
> + }
> + offset += adv;
> + num_sections++;
> + }
> +
> + if (num_sections == 0)
> + return -EINVAL;
> +
> + sections = kcalloc(num_sections, sizeof(*sections), GFP_KERNEL);
__free() ?
> + if (!sections)
> + return -ENOMEM;
> +
> + offset = FW_DL_OFFSET;
> + for (i = 0; i < num_sections && offset < (img_sz - FW_FL_HDR); i++) {
for (int i = 0; i < num_sections && offset < (img_sz - FW_FL_HDR); i++) {
> + size_t adv = (size_t)tas_fw_get_next_file(&buf[offset], &file);
> +
> + sections[i].addr = file.dest_addr;
> + sections[i].len = file.length;
> + sections[i].buf = file.fw_data;
> + offset += adv;
> +
> + dev_dbg(tas_dev->dev, "BPT section %d: addr=0x%x len=%d",
> + i, file.dest_addr, file.length);
> + }
> +
> + msg.sec = sections;
> + msg.sections = num_sections;
> + msg.dev_num = slave->dev_num;
> + msg.flags = SDW_MSG_FLAG_WRITE;
> +
> + dev_dbg(tas_dev->dev, "BPT starting: %d sections, dev_num=%d",
> + num_sections, slave->dev_num);
> +
> + ret = sdw_bpt_send_sync(bus, slave, &msg);
> +
Drop blank line.
> + if (ret < 0)
> + dev_err(tas_dev->dev, "BPT firmware download failed: %d", ret);
> + else
> + dev_dbg(tas_dev->dev,
> + "BPT firmware download complete: %d sections",
> + num_sections);
> +
> + kfree(sections);
> + return ret;
> +}
...
> static s32 tas_io_init(struct device *dev, struct sdw_slave *slave)
> {
> struct tas2783_prv *tas_dev = dev_get_drvdata(dev);
> + uint val;
What is this? Use unsigned int or u32 or other better fit.
> s32 ret;
>
> if (tas_dev->hw_init)
> return 0;
--
With Best Regards,
Andy Shevchenko
prev parent reply other threads:[~2026-11-03 17:46 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-03 13:38 Baojun Xu
2026-11-03 17:07 ` Pierre-Louis Bossart
2026-11-03 17:39 ` Andy Shevchenko [this message]
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=auocWKMYhLlqGF8S@ashevche-desk.local \
--to=andriy.shevchenko@linux.intel.com \
--cc=13916275206@139.com \
--cc=Syed.SabaKareem@amd.com \
--cc=alsa-devel@alsa-project.org \
--cc=baojun.xu@ti.com \
--cc=broonie@kernel.org \
--cc=henry.lo@ti.com \
--cc=k-yi@ti.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=niranjan.hy@ti.com \
--cc=pin-hao.huang@hp.com \
--cc=robinchen@ti.com \
--cc=shenghao-ding@ti.com \
--cc=tiwai@suse.de \
/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
all inboxes | Powered by JetHome®