Message ID | 20210309141514.24744-4-srinivas.kandagatla@linaro.org |
---|---|
State | Superseded |
Headers | show |
Series | soundwire: add static port map support | expand |
> list_for_each_entry(m_rt, &bus->m_rt_list, bus_node) { > @@ -473,8 +475,13 @@ static int qcom_swrm_compute_params(struct sdw_bus *bus) > } > > list_for_each_entry(s_rt, &m_rt->slave_rt_list, m_rt_node) { > + slave = s_rt->slave; > list_for_each_entry(p_rt, &s_rt->port_list, port_node) { > - pcfg = &ctrl->pconfig[i]; > + m_port = slave->m_port_map[_rtp->num - 1]; > + if (m_port) > + pcfg = &ctrl->pconfig[m_port - 1]; > + else > + pcfg = &ctrl->pconfig[i]; Maybe add a short comment on port allocation, I had to think a bit to figure out why the -1 was required on both peripheral and manager but it is not below [1] > p_rt->transport_params.port_num = p_rt->num; > p_rt->transport_params.sample_interval = > pcfg->si + 1; > @@ -535,8 +542,10 @@ static int qcom_swrm_stream_alloc_ports(struct qcom_swrm_ctrl *ctrl, > struct sdw_master_runtime *m_rt; > struct sdw_slave_runtime *s_rt; > struct sdw_port_runtime *p_rt; > + struct sdw_slave *slave; > unsigned long *port_mask; > int i, maxport, pn, nports = 0, ret = 0; > + unsigned int m_port; > > mutex_lock(&ctrl->port_lock); > list_for_each_entry(m_rt, &stream->master_list, stream_node) { > @@ -549,9 +558,15 @@ static int qcom_swrm_stream_alloc_ports(struct qcom_swrm_ctrl *ctrl, > } > > list_for_each_entry(s_rt, &m_rt->slave_rt_list, m_rt_node) { > + slave = s_rt->slave; > list_for_each_entry(p_rt, &s_rt->port_list, port_node) { > + m_port = slave->m_port_map[p_rt->num - 1]; > /* Port numbers start from 1 - 14*/ > - pn = find_first_zero_bit(port_mask, maxport); > + if (m_port) > + pn = m_port; > + else > + pn = find_first_zero_bit(port_mask, maxport); [1] > + > if (pn > (maxport)) { > dev_err(ctrl->dev, "All ports busy\n"); > ret = -EBUSY; >
On 09/03/2021 16:10, Pierre-Louis Bossart wrote: > > > >> list_for_each_entry(m_rt, &bus->m_rt_list, bus_node) { >> @@ -473,8 +475,13 @@ static int qcom_swrm_compute_params(struct >> sdw_bus *bus) >> } >> list_for_each_entry(s_rt, &m_rt->slave_rt_list, m_rt_node) { >> + slave = s_rt->slave; >> list_for_each_entry(p_rt, &s_rt->port_list, port_node) { >> - pcfg = &ctrl->pconfig[i]; >> + m_port = slave->m_port_map[_rtp->num - 1]; >> + if (m_port) >> + pcfg = &ctrl->pconfig[m_port - 1]; >> + else >> + pcfg = &ctrl->pconfig[i]; > > Maybe add a short comment on port allocation, I had to think a bit to > figure out why the -1 was required on both peripheral and manager but it > is not below [1] I agree, will add some comment here to explain the offsets correctly! --srini > >> p_rt->transport_params.port_num = p_rt->num; >> p_rt->transport_params.sample_interval = >> pcfg->si + 1; >> @@ -535,8 +542,10 @@ static int qcom_swrm_stream_alloc_ports(struct >> qcom_swrm_ctrl *ctrl, >> struct sdw_master_runtime *m_rt; >> struct sdw_slave_runtime *s_rt; >> struct sdw_port_runtime *p_rt; >> + struct sdw_slave *slave; >> unsigned long *port_mask; >> int i, maxport, pn, nports = 0, ret = 0; >> + unsigned int m_port; >> mutex_lock(&ctrl->port_lock); >> list_for_each_entry(m_rt, &stream->master_list, stream_node) { >> @@ -549,9 +558,15 @@ static int qcom_swrm_stream_alloc_ports(struct >> qcom_swrm_ctrl *ctrl, >> } >> list_for_each_entry(s_rt, &m_rt->slave_rt_list, m_rt_node) { >> + slave = s_rt->slave; >> list_for_each_entry(p_rt, &s_rt->port_list, port_node) { >> + m_port = slave->m_port_map[p_rt->num - 1]; >> /* Port numbers start from 1 - 14*/ >> - pn = find_first_zero_bit(port_mask, maxport); >> + if (m_port) >> + pn = m_port; >> + else >> + pn = find_first_zero_bit(port_mask, maxport); > > [1] > >> + >> if (pn > (maxport)) { >> dev_err(ctrl->dev, "All ports busy\n"); >> ret = -EBUSY; >>
diff --git a/drivers/soundwire/qcom.c b/drivers/soundwire/qcom.c index f4f1c5f2af0b..b4d1aaf535c5 100644 --- a/drivers/soundwire/qcom.c +++ b/drivers/soundwire/qcom.c @@ -460,6 +460,8 @@ static int qcom_swrm_compute_params(struct sdw_bus *bus) struct sdw_slave_runtime *s_rt; struct sdw_port_runtime *p_rt; struct qcom_swrm_port_config *pcfg; + struct sdw_slave *slave; + unsigned int m_port; int i = 0; list_for_each_entry(m_rt, &bus->m_rt_list, bus_node) { @@ -473,8 +475,13 @@ static int qcom_swrm_compute_params(struct sdw_bus *bus) } list_for_each_entry(s_rt, &m_rt->slave_rt_list, m_rt_node) { + slave = s_rt->slave; list_for_each_entry(p_rt, &s_rt->port_list, port_node) { - pcfg = &ctrl->pconfig[i]; + m_port = slave->m_port_map[p_rt->num - 1]; + if (m_port) + pcfg = &ctrl->pconfig[m_port - 1]; + else + pcfg = &ctrl->pconfig[i]; p_rt->transport_params.port_num = p_rt->num; p_rt->transport_params.sample_interval = pcfg->si + 1; @@ -535,8 +542,10 @@ static int qcom_swrm_stream_alloc_ports(struct qcom_swrm_ctrl *ctrl, struct sdw_master_runtime *m_rt; struct sdw_slave_runtime *s_rt; struct sdw_port_runtime *p_rt; + struct sdw_slave *slave; unsigned long *port_mask; int i, maxport, pn, nports = 0, ret = 0; + unsigned int m_port; mutex_lock(&ctrl->port_lock); list_for_each_entry(m_rt, &stream->master_list, stream_node) { @@ -549,9 +558,15 @@ static int qcom_swrm_stream_alloc_ports(struct qcom_swrm_ctrl *ctrl, } list_for_each_entry(s_rt, &m_rt->slave_rt_list, m_rt_node) { + slave = s_rt->slave; list_for_each_entry(p_rt, &s_rt->port_list, port_node) { + m_port = slave->m_port_map[p_rt->num - 1]; /* Port numbers start from 1 - 14*/ - pn = find_first_zero_bit(port_mask, maxport); + if (m_port) + pn = m_port; + else + pn = find_first_zero_bit(port_mask, maxport); + if (pn > (maxport)) { dev_err(ctrl->dev, "All ports busy\n"); ret = -EBUSY;
SoundWire device ports are statically mapped to Controller ports during design. Add support to read these from SoundWire devices. This controller uses static port map info to setup bandwidth parameters for those ports. A generic port allocation is not possible in this cases! Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> --- drivers/soundwire/qcom.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) -- 2.21.0