From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
To: Vinod Koul <vinod.koul@intel.com>
Cc: ALSA <alsa-devel@alsa-project.org>,
Charles Keepax <ckeepax@opensource.cirrus.com>,
Sudheer Papothi <spapothi@codeaurora.org>,
Takashi <tiwai@suse.de>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
plai@codeaurora.org, LKML <linux-kernel@vger.kernel.org>,
patches.audio@intel.com, Mark <broonie@kernel.org>,
srinivas.kandagatla@linaro.org,
Sagar Dharia <sdharia@codeaurora.org>,
alan@linux.intel.com
Subject: Re: [PATCH v4 08/15] soundwire: Add Slave status handling helpers
Date: Sun, 3 Dec 2017 21:07:29 -0600 [thread overview]
Message-ID: <b5f75b94-f0c6-d113-67dc-c159f0ca6a79@linux.intel.com> (raw)
In-Reply-To: <20171203170818.GO32417@localhost>
On 12/3/17 11:08 AM, Vinod Koul wrote:
> On Fri, Dec 01, 2017 at 05:36:47PM -0600, Pierre-Louis Bossart wrote:
>
>>> +/* called with bus_lock held */
>>> +static int sdw_get_device_num(struct sdw_slave *slave)
>>> +{
>>> + int bit;
>>> +
>>> + bit = find_first_zero_bit(slave->bus->assigned, SDW_MAX_DEVICES);
>>> + if (bit == SDW_MAX_DEVICES) {
>>> + bit = -ENODEV;
>>> + goto err;
>>
>> My brain is starting to fry but is this correct? Bit11 seems like a valid
>> value. Should it be bit > 15 (assuming bit 12,13,14 are set to avoid using
>> groups and master)?
>
> this is correct. You are confusing SDW concept and API return types!
> That should be hint for you to start weekend if you didn't do so :D
>
> This API returns max value it was provided (last arg) if it doesn't
> find free bit. That's an indication to caller that we ran out of devices
> hence ENODEV error!
Can you just make sure bit11 is included?
>
>>> +static int sdw_program_device_num(struct sdw_bus *bus)
>>> +{
>>> + u8 buf[SDW_NUM_DEV_ID_REGISTERS] = {0};
>>> + struct sdw_slave *slave, *_s;
>>> + struct sdw_slave_id id;
>>> + struct sdw_msg msg;
>>> + bool found = false;
>>> + int count = 0, ret;
>>> + u64 addr;
>>> +
>>> + /* No Slave, so use raw xfer api */
>>> + ret = sdw_fill_msg(&msg, NULL, SDW_SCP_DEVID_0,
>>> + SDW_NUM_DEV_ID_REGISTERS, 0, SDW_MSG_FLAG_READ, buf);
>>> + if (ret < 0)
>>> + return ret;
>>> +
>>> + do {
>>> + ret = sdw_transfer(bus, NULL, &msg);
>>> + if (ret == -ENODATA) { /* end of device id reads */
>>> + ret = 0;
>>> + break;
>>> + }
>>> + if (ret < 0) {
>>> + dev_err(bus->dev, "DEVID read fail:%d\n", ret);
>>> + break;
>>> + }
>>> +
>>> + /*
>>> + * Construct the addr and extract. Cast the higher shift
>>> + * bits to avoid truncation due to size limit.
>>> + */
>>> + addr = buf[5] | (buf[4] << 8) | (buf[3] << 16) |
>>> + (buf[2] << 24) | ((unsigned long long)buf[1] << 32) |
>>> + ((unsigned long long)buf[0] << 40);
>>> +
>>> + sdw_extract_slave_id(bus, addr, &id);
>>> +
>>> + /* Now compare with entries */
>>> + list_for_each_entry_safe(slave, _s, &bus->slaves, node) {
>>> + if (sdw_compare_devid(slave, id) == 0) {
>>> + found = true;
>>> +
>>> + /*
>>> + * Assign a new dev_num to this Slave and
>>> + * not mark it present. It will be marked
>>> + * present after it reports ATTACHED on new
>>> + * dev_num
>>> + */
>>> + ret = sdw_assign_device_num(slave);
>>> + if (ret) {
>>> + dev_err(slave->bus->dev,
>>> + "Assign dev_num failed:%d",
>>> + ret);
>>> + return ret;
>>> + }
>>> +
>>> + break;
>>> + }
>>> + }
>>> +
>>> + if (found == false) {
>>> + /* TODO: Park this device in Group 13 */
>>> + dev_err(bus->dev, "Slave Entry not found");
>>> + }
>>> +
>>> + count++;
>>> +
>>> + } while (ret == 0 && count < (SDW_MAX_DEVICES * 2));
>>
>> explain that the last condition is intentional - this is not a bug -, some
>> devices can drop off during enumeration and rejoin so might be counted
>> twice.
>
> ok will add
>
next prev parent reply other threads:[~2017-12-04 3:07 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-01 9:56 [PATCH v4 00/15] soundwire: Add a new SoundWire subsystem Vinod Koul
2017-12-01 9:56 ` [PATCH v4 01/15] Documentation: Add SoundWire summary Vinod Koul
2017-12-01 9:56 ` [PATCH v4 02/15] soundwire: Add SoundWire bus type Vinod Koul
2017-12-01 9:56 ` [PATCH v4 03/15] soundwire: Add Master registration Vinod Koul
2017-12-01 22:10 ` [alsa-devel] " Pierre-Louis Bossart
2017-12-03 16:41 ` Vinod Koul
2017-12-04 2:44 ` Pierre-Louis Bossart
2017-12-04 2:59 ` Vinod Koul
2017-12-01 9:56 ` [PATCH v4 04/15] soundwire: Add MIPI DisCo property helpers Vinod Koul
2017-12-01 22:49 ` [alsa-devel] " Pierre-Louis Bossart
2017-12-03 16:52 ` Vinod Koul
2017-12-04 2:50 ` Pierre-Louis Bossart
2017-12-01 9:56 ` [PATCH v4 05/15] soundwire: Add SoundWire MIPI defined registers Vinod Koul
2017-12-01 9:56 ` [PATCH v4 06/15] soundwire: Add IO transfer Vinod Koul
2017-12-01 23:27 ` [alsa-devel] " Pierre-Louis Bossart
2017-12-03 17:04 ` Vinod Koul
2017-12-04 3:01 ` [alsa-devel] " Pierre-Louis Bossart
2017-12-05 6:31 ` Vinod Koul
2017-12-05 13:43 ` Pierre-Louis Bossart
2017-12-05 14:48 ` Pierre-Louis Bossart
2017-12-06 5:58 ` [alsa-devel] " Vinod Koul
2017-12-06 13:32 ` Pierre-Louis Bossart
2017-12-06 14:44 ` [alsa-devel] " Vinod Koul
2017-12-01 9:56 ` [PATCH v4 07/15] regmap: Add SoundWire bus support Vinod Koul
2017-12-01 9:56 ` [PATCH v4 08/15] soundwire: Add Slave status handling helpers Vinod Koul
2017-12-01 23:36 ` [alsa-devel] " Pierre-Louis Bossart
2017-12-03 17:08 ` Vinod Koul
2017-12-04 3:07 ` Pierre-Louis Bossart [this message]
2017-12-04 3:13 ` Vinod Koul
2017-12-01 9:56 ` [PATCH v4 09/15] soundwire: Add slave status handling Vinod Koul
2017-12-01 23:52 ` [alsa-devel] " Pierre-Louis Bossart
2017-12-03 17:11 ` Vinod Koul
2017-12-04 3:11 ` [alsa-devel] " Pierre-Louis Bossart
2017-12-04 3:21 ` Vinod Koul
2017-12-04 3:52 ` Pierre-Louis Bossart
2017-12-06 9:44 ` Vinod Koul
2017-12-01 9:56 ` [PATCH v4 10/15] soundwire: Add sysfs for SoundWire DisCo properties Vinod Koul
2017-12-01 9:56 ` [PATCH v4 11/15] soundwire: cdns: Add cadence library Vinod Koul
2017-12-01 9:56 ` [PATCH v4 12/15] soundwire: cdns: Add sdw_master_ops and IO transfer support Vinod Koul
2017-12-02 0:02 ` Pierre-Louis Bossart
2017-12-03 17:10 ` Vinod Koul
2017-12-01 9:56 ` [PATCH v4 13/15] soundwire: intel: Add Intel Master driver Vinod Koul
2017-12-01 9:56 ` [PATCH v4 14/15] soundwire: intel: Add Intel init module Vinod Koul
2017-12-01 9:56 ` [PATCH v4 15/15] MAINTAINERS: Add SoundWire entry Vinod Koul
2017-12-02 0:24 ` [PATCH v4 00/15] soundwire: Add a new SoundWire subsystem Pierre-Louis Bossart
2017-12-03 17:12 ` 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=b5f75b94-f0c6-d113-67dc-c159f0ca6a79@linux.intel.com \
--to=pierre-louis.bossart@linux.intel.com \
--cc=alan@linux.intel.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=ckeepax@opensource.cirrus.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=patches.audio@intel.com \
--cc=plai@codeaurora.org \
--cc=sdharia@codeaurora.org \
--cc=spapothi@codeaurora.org \
--cc=srinivas.kandagatla@linaro.org \
--cc=tiwai@suse.de \
--cc=vinod.koul@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).