public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Vinod Koul <vkoul@kernel.org>
To: Bard Liao <yung-chuan.liao@linux.intel.com>
Cc: linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org,
	pierre-louis.bossart@linux.intel.com, bard.liao@intel.com
Subject: Re: [PATCH 7/7] soundwire: bus: add stream refcount
Date: Fri, 5 Apr 2024 17:17:28 +0530	[thread overview]
Message-ID: <Zg_k0IsnvjXlr1Jp@matsya> (raw)
In-Reply-To: <20240326090122.1051806-8-yung-chuan.liao@linux.intel.com>

On 26-03-24, 09:01, Bard Liao wrote:
> From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
> 
> The notion of stream is by construction based on a multi-bus
> capability, to allow for aggregation of Peripheral devices or
> functions located on different segments. We currently count how many
> master_rt contexts are used by a stream, but we don't have the dual
> refcount of how many streams are allocated on a given bus. This
> refcount will be useful to check if BTP/BRA streams can be allocated.
> 
> Note that the stream_refcount is modified in sdw_master_rt_alloc() and
> sdw_master_rt_free() which are both called with the bus_lock mutex
> held, so there's no need for refcount_ primitives for additional
> protection.

This lgtm, I would like to see this patch with its user when you
allocate BTP/BRA streams

> 
> Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
> Reviewed-by: Rander Wang <rander.wang@intel.com>
> Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
> ---
>  drivers/soundwire/stream.c    | 5 +++++
>  include/linux/soundwire/sdw.h | 2 ++
>  2 files changed, 7 insertions(+)
> 
> diff --git a/drivers/soundwire/stream.c b/drivers/soundwire/stream.c
> index 4e9e7d2a942d..7aa4900dcf31 100644
> --- a/drivers/soundwire/stream.c
> +++ b/drivers/soundwire/stream.c
> @@ -1181,6 +1181,8 @@ static struct sdw_master_runtime
>  	m_rt->bus = bus;
>  	m_rt->stream = stream;
>  
> +	bus->stream_refcount++;
> +
>  	return m_rt;
>  }
>  
> @@ -1217,6 +1219,7 @@ static void sdw_master_rt_free(struct sdw_master_runtime *m_rt,
>  			       struct sdw_stream_runtime *stream)
>  {
>  	struct sdw_slave_runtime *s_rt, *_s_rt;
> +	struct sdw_bus *bus = m_rt->bus;
>  
>  	list_for_each_entry_safe(s_rt, _s_rt, &m_rt->slave_rt_list, m_rt_node) {
>  		sdw_slave_port_free(s_rt->slave, stream);
> @@ -1226,6 +1229,8 @@ static void sdw_master_rt_free(struct sdw_master_runtime *m_rt,
>  	list_del(&m_rt->stream_node);
>  	list_del(&m_rt->bus_node);
>  	kfree(m_rt);
> +
> +	bus->stream_refcount--;
>  }
>  
>  /**
> diff --git a/include/linux/soundwire/sdw.h b/include/linux/soundwire/sdw.h
> index e3a4bccc2a7e..71a7031f7b3a 100644
> --- a/include/linux/soundwire/sdw.h
> +++ b/include/linux/soundwire/sdw.h
> @@ -902,6 +902,7 @@ struct sdw_master_ops {
>   * meaningful if multi_link is set. If set to 1, hardware-based
>   * synchronization will be used even if a stream only uses a single
>   * SoundWire segment.
> + * @stream_refcount: number of streams currently using this bus
>   */
>  struct sdw_bus {
>  	struct device *dev;
> @@ -931,6 +932,7 @@ struct sdw_bus {
>  	u32 bank_switch_timeout;
>  	bool multi_link;
>  	int hw_sync_min_links;
> +	int stream_refcount;
>  };
>  
>  int sdw_bus_master_add(struct sdw_bus *bus, struct device *parent,
> -- 
> 2.34.1

-- 
~Vinod

  reply	other threads:[~2024-04-05 11:47 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-26  9:01 [PATCH 0/7] soundwire: add BTP/BRA prerequisites Bard Liao
2024-03-26  9:01 ` [PATCH 1/7] soundwire: cadence: fix invalid PDI offset Bard Liao
2024-03-26  9:01 ` [PATCH 2/7] soundwire: cadence: remove PDI offset completely Bard Liao
2024-03-26  9:01 ` [PATCH 3/7] soundwire: remove unused sdw_bus_conf structure Bard Liao
2024-03-26  9:01 ` [PATCH 4/7] soundwire: reconcile dp0_prop and dpn_prop Bard Liao
2024-04-05 11:33   ` Vinod Koul
2024-04-08  6:39     ` Liao, Bard
2024-03-26  9:01 ` [PATCH 5/7] soundwire: clarify maximum allowed address Bard Liao
2024-03-26  9:01 ` [PATCH 6/7] soundwire: debugfs: add interface to read/write commands Bard Liao
2024-04-05 11:45   ` Vinod Koul
2024-04-05 15:12     ` Pierre-Louis Bossart
2024-04-11  9:28       ` Vinod Koul
2024-04-11 14:24         ` Pierre-Louis Bossart
2024-03-26  9:01 ` [PATCH 7/7] soundwire: bus: add stream refcount Bard Liao
2024-04-05 11:47   ` Vinod Koul [this message]
2024-04-05 11:52 ` (subset) [PATCH 0/7] soundwire: add BTP/BRA prerequisites Vinod Koul

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=Zg_k0IsnvjXlr1Jp@matsya \
    --to=vkoul@kernel.org \
    --cc=bard.liao@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=pierre-louis.bossart@linux.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