From: Vinod Koul <vkoul@kernel.org>
To: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Cc: linux-sound@vger.kernel.org, alsa-devel@alsa-project.org,
tiwai@suse.de, broonie@kernel.org, vinod.koul@intel.com,
Bard liao <yung-chuan.liao@linux.intel.com>,
Ranjani Sridharan <ranjani.sridharan@linux.intel.com>,
Peter Ujfalusi <peter.ujfalusi@linux.intel.com>,
Kai Vehmanen <kai.vehmanen@linux.intel.com>,
srinivas.kandagatla@linaro.org,
Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>,
vijendar.mukunda@amd.com,
Charles Keepax <ckeepax@opensource.cirrus.com>,
Richard Fitzgerald <rf@opensource.cirrus.com>,
Shuming Fan <shumingf@realtek.com>, Jack Yu <jack.yu@realtek.com>,
Oder Chiou <oder_chiou@realtek.com>
Subject: Re: [RFC PATCH 07/16] soundwire: bus: add API for BPT protocol
Date: Thu, 21 Dec 2023 20:19:58 +0530 [thread overview]
Message-ID: <ZYRQliKCliLcLAG0@matsya> (raw)
In-Reply-To: <4f66f792-79c0-4221-82b5-a0d9ec5a898b@linux.intel.com>
On 18-12-23, 14:12, Pierre-Louis Bossart wrote:
>
> >> +int sdw_bpt_open_stream(struct sdw_bus *bus,
> >> + struct sdw_slave *slave,
> >> + enum sdw_bpt_type mode,
> >> + struct sdw_bpt_msg *msg)
> >> +{
> >> + int ret;
> >> +
> >> + /* only Bulk Register Access (BRA) is supported for now */
> >> + if (mode != SDW_BRA)
> >> + return -EINVAL;
> >> +
> >> + if (msg->len < SDW_BPT_MSG_MIN_BYTES) {
> >> + dev_err(bus->dev, "BPT message length %d, min supported %d\n",
> >> + msg->len, SDW_BPT_MSG_MIN_BYTES);
> >> + return -EINVAL;
> >> + }
> >> +
> >> + if (msg->len % SDW_BPT_MSG_BYTE_ALIGNMENT) {
> >> + dev_err(bus->dev, "BPT message length %d is not a multiple of %d bytes\n",
> >> + msg->len, SDW_BPT_MSG_BYTE_ALIGNMENT);
> >> + return -EINVAL;
> >> + }
> >
> > Is this a protocol requirement?
>
> No, it's an implementation requirement.
>
> We could move this to host-specific parts but then the codec drivers
> will have to know about alignment requirements for each host they are
> use with. IOW, it's more work for codec drivers if we don't have a
> minimum bar for alignment requirement across all platforms.
>
> >
> >> +
> >> + /* check device is enumerated */
> >> + if (slave->dev_num == SDW_ENUM_DEV_NUM ||
> >> + slave->dev_num > SDW_MAX_DEVICES)
> >> + return -ENODEV;
> >> +
> >> + /* make sure all callbacks are defined */
> >> + if (!bus->ops->bpt_open_stream ||
> >> + !bus->ops->bpt_close_stream ||
> >> + !bus->ops->bpt_send_async ||
> >> + !bus->ops->bpt_wait)
> >> + return -ENOTSUPP;
> >
> > should this not be checked at probe time, if device declares the support
>
> sdw_bpt_open_stream() would be called by the peripheral driver (or
> regmap as a proxy). The peripheral driver could also decide to check for
> those callback during its probe, but that's beyond the scope of this
> patchset.
I would think that it is better to have capablities registered by the
driver and those are checked at registration, so we know if bpt is
supported or not for a particular platform.
This make more sense to me as some driver, depending on the SoC may or
maynot support this, so easy way would be to turn off caps, what do you
think?
>
> These checks are just there for paranoia, in case a peripheral driver
> uses BTP/BRA on a host where they are not supported.
>
> It's not science-fiction, we see AMD- and INTEL-based platforms using
> the same SoundWire-based codecs.
Ofcourse, it is entrely reasonable thing to do, event across x86/arm64
>
> >> + ret = bus->ops->bpt_open_stream(bus, slave, mode, msg);
> >> + if (ret < 0)
> >> + dev_err(bus->dev, "BPT stream open, err %d\n", ret);
> >> +
> >> + return ret;
> >> +}
> >> +EXPORT_SYMBOL(sdw_bpt_open_stream);
> >
> > can we open multiple times (i dont see a check preventing that), how do
> > we close..?
>
> there's a refcount preventing multiples BTP streams from being opened.
>
> > Re-iterating my comment on documentation patch, can we do with a async api
> > and wait api, that makes symantics a lot simpler, right..?
>
> see reply in previous email, combining open+send is weird IMHO.
>
> >> +
> >> +int sdw_bpt_send_async(struct sdw_bus *bus,
> >> + struct sdw_slave *slave,
> >> + struct sdw_bpt_msg *msg)
> >> +{
> >> + if (msg->len > SDW_BPT_MSG_MAX_BYTES)
> >> + return -EINVAL;
> >> +
> >> + return bus->ops->bpt_send_async(bus, slave, msg);
> >> +}
> >> +EXPORT_SYMBOL(sdw_bpt_send_async);
> >
> > Can we call this multiple times after open, it is unclear to me. Can you
> > please add kernel-doc comments about the APIs here as well
>
> This can be called multiple times but it's useless: all the buffers are
> prepared in the open() stage. This is the moral equivalent of a trigger
> step, just enable data transfers.
>
> >
> >> struct sdw_master_ops {
> >> int (*read_prop)(struct sdw_bus *bus);
> >> @@ -869,6 +913,20 @@ struct sdw_master_ops {
> >> void (*new_peripheral_assigned)(struct sdw_bus *bus,
> >> struct sdw_slave *slave,
> >> int dev_num);
> >> + int (*bpt_open_stream)(struct sdw_bus *bus,
> >> + struct sdw_slave *slave,
> >> + enum sdw_bpt_type mode,
> >> + struct sdw_bpt_msg *msg);
> >> + int (*bpt_close_stream)(struct sdw_bus *bus,
> >> + struct sdw_slave *slave,
> >> + enum sdw_bpt_type mode,
> >> + struct sdw_bpt_msg *msg);
> >> + int (*bpt_send_async)(struct sdw_bus *bus,
> >> + struct sdw_slave *slave,
> >> + struct sdw_bpt_msg *msg);
> >> + int (*bpt_wait)(struct sdw_bus *bus,
> >> + struct sdw_slave *slave,
> >> + struct sdw_bpt_msg *msg);
> >
> > do we need both bus and slave, that was a mistake in orignal design IMO.
> > We should fix that for bpt_ apis
>
> No disagreement. All the routines follow the same template, if we change
> one we should also change the others.
>
> The main question as discussed with Charles is whether we want to pass
> the 'msg' argument in all routines.
Lets revisit when we have new API
--
~Vinod
next prev parent reply other threads:[~2023-12-21 14:50 UTC|newest]
Thread overview: 61+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-07 22:29 [RFC PATCH 00/16] soundwire/ASoC: speed-up downloads with BTP/BRA protocol Pierre-Louis Bossart
2023-12-07 22:29 ` [RFC PATCH 01/16] Documentation: driver: add SoundWire BRA description Pierre-Louis Bossart
2023-12-07 23:29 ` Mark Brown
2023-12-08 0:56 ` Pierre-Louis Bossart
2023-12-08 21:49 ` Mark Brown
2023-12-19 16:50 ` Pierre-Louis Bossart
2023-12-19 16:53 ` Mark Brown
2023-12-19 17:08 ` Pierre-Louis Bossart
2023-12-20 15:16 ` Charles Keepax
2023-12-20 18:26 ` Pierre-Louis Bossart
2023-12-20 18:28 ` Mark Brown
2023-12-21 9:46 ` Charles Keepax
2024-08-20 7:48 ` Pierre-Louis Bossart
2024-08-20 11:53 ` Mark Brown
2024-08-20 14:58 ` Pierre-Louis Bossart
2024-08-20 15:09 ` Mark Brown
2023-12-08 16:27 ` Charles Keepax
2023-12-08 18:45 ` Pierre-Louis Bossart
2023-12-08 18:55 ` Mark Brown
2023-12-18 11:40 ` Vinod Koul
2023-12-18 12:58 ` Pierre-Louis Bossart
2023-12-18 14:29 ` Charles Keepax
2023-12-18 16:33 ` Pierre-Louis Bossart
2023-12-21 14:45 ` Vinod Koul
2023-12-21 14:44 ` Vinod Koul
2023-12-21 14:44 ` Vinod Koul
2023-12-07 22:29 ` [RFC PATCH 02/16] soundwire: cadence: add BTP support for DP0 Pierre-Louis Bossart
2023-12-07 22:29 ` [RFC PATCH 03/16] soundwire: stream: extend sdw_alloc_stream() to take 'type' parameter Pierre-Louis Bossart
2023-12-07 22:29 ` [RFC PATCH 04/16] soundwire: extend sdw_stream_type to BPT Pierre-Louis Bossart
2023-12-07 22:29 ` [RFC PATCH 05/16] soundwire: stream: special-case the bus compute_params() routine Pierre-Louis Bossart
2023-12-07 22:29 ` [RFC PATCH 06/16] soundwire: stream: reuse existing code for BPT stream Pierre-Louis Bossart
2023-12-12 12:30 ` Charles Keepax
2023-12-18 10:45 ` Pierre-Louis Bossart
2023-12-07 22:29 ` [RFC PATCH 07/16] soundwire: bus: add API for BPT protocol Pierre-Louis Bossart
2023-12-12 12:19 ` Charles Keepax
2023-12-18 10:38 ` Pierre-Louis Bossart
2023-12-18 11:54 ` Vinod Koul
2023-12-18 13:12 ` Pierre-Louis Bossart
2023-12-18 14:57 ` Charles Keepax
2023-12-18 16:44 ` Pierre-Louis Bossart
2023-12-21 14:49 ` Vinod Koul [this message]
2023-12-07 22:29 ` [RFC PATCH 08/16] soundwire: bus: add bpt_stream pointer Pierre-Louis Bossart
2023-12-18 11:55 ` Vinod Koul
2023-12-18 13:20 ` Pierre-Louis Bossart
2023-12-21 14:39 ` Vinod Koul
2023-12-21 17:09 ` Pierre-Louis Bossart
2023-12-07 22:29 ` [RFC PATCH 09/16] soundwire: crc8: add constant table Pierre-Louis Bossart
2023-12-18 12:01 ` Vinod Koul
2023-12-18 13:26 ` Pierre-Louis Bossart
2023-12-21 14:42 ` Vinod Koul
2023-12-21 17:15 ` Pierre-Louis Bossart
2023-12-21 17:21 ` Vinod Koul
2023-12-07 22:29 ` [RFC PATCH 10/16] soundwire: cadence: add BTP/BRA helpers to format data Pierre-Louis Bossart
2023-12-07 22:29 ` [RFC PATCH 11/16] soundwire: intel_auxdevice: add indirection for BPT open/close/send_async/wait Pierre-Louis Bossart
2023-12-07 22:29 ` [RFC PATCH 12/16] ASoC: SOF: Intel: hda-sdw-bpt: add helpers for SoundWire BPT DMA Pierre-Louis Bossart
2023-12-07 22:29 ` [RFC PATCH 13/16] soundwire: intel: add BPT context definition Pierre-Louis Bossart
2023-12-07 22:29 ` [RFC PATCH 14/16] soundwire: intel_ace2x: add BPT open/close/send_async/wait Pierre-Louis Bossart
2023-12-07 22:29 ` [RFC PATCH 15/16] soundwire: debugfs: add interface for BPT/BRA transfers Pierre-Louis Bossart
2023-12-07 22:29 ` [RFC PATCH 16/16] ASoC: rt711-sdca: add DP0 support Pierre-Louis Bossart
2023-12-07 22:56 ` [RFC PATCH 00/16] soundwire/ASoC: speed-up downloads with BTP/BRA protocol Mark Brown
2023-12-07 23:06 ` Pierre-Louis Bossart
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=ZYRQliKCliLcLAG0@matsya \
--to=vkoul@kernel.org \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=ckeepax@opensource.cirrus.com \
--cc=jack.yu@realtek.com \
--cc=kai.vehmanen@linux.intel.com \
--cc=krzysztof.kozlowski@linaro.org \
--cc=linux-sound@vger.kernel.org \
--cc=oder_chiou@realtek.com \
--cc=peter.ujfalusi@linux.intel.com \
--cc=pierre-louis.bossart@linux.intel.com \
--cc=ranjani.sridharan@linux.intel.com \
--cc=rf@opensource.cirrus.com \
--cc=shumingf@realtek.com \
--cc=srinivas.kandagatla@linaro.org \
--cc=tiwai@suse.de \
--cc=vijendar.mukunda@amd.com \
--cc=vinod.koul@intel.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