mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
To: Vinod Koul <vkoul@kernel.org>,
	Bard Liao <yung-chuan.liao@linux.intel.com>
Cc: alsa-devel@alsa-project.org, gregkh@linuxfoundation.org,
	linux-kernel@vger.kernel.org, hui.wang@canonical.com,
	srinivas.kandagatla@linaro.org, sanyog.r.kale@intel.com,
	rander.wang@linux.intel.com, bard.liao@intel.com
Subject: Re: [PATCH] soundwire: add slave device to linked list after device_register()
Date: Tue, 23 Mar 2021 13:30:38 -0500	[thread overview]
Message-ID: <82d579ca-5021-341c-1fcd-5c85c54c637b@linux.intel.com> (raw)
In-Reply-To: <YFmRcPUxxFxkuMkr@vkoul-mobl.Dlink>

Hi Vinod,

>> We currently add the slave device to a linked list before
>> device_register(), and then remove it if device_register() fails.
>>
>> It's not clear why this sequence was necessary, this patch moves the
>> linked list management to after the device_register().
> 
> Maybe add a comment :-)
> 
> The reason here is that before calling device_register() we need to be
> ready and completely initialized. device_register is absolutely the last
> step in the flow, always.
> 
> The probe of the device can happen and before you get a chance to
> add to list, many number of things can happen.. So adding after is not a
> very good idea :)

Can you describe that 'many number of things' in the SoundWire context?

While you are correct in general on the use of device_register(), in 
this specific case the device registration and the possible Slave driver 
probe if there's a match doesn't seem to use this linked list.

This sdw_slave_add() routine is called while parsing ACPI/DT tables and 
at this point the bus isn't functional. This sequence only deals with 
device registration and driver probe, the actual activation and 
enumeration happen much later. What does matter is that by the time all 
ACPI/DT devices have been scanned all initialization is complete. The 
last part of the flow is not the device_register() at the individual 
peripheral level.

Even for the Qualcomm case, the steps are different:

	ret = sdw_bus_master_add(&ctrl->bus, dev, dev->fwnode);
	if (ret) {
		dev_err(dev, "Failed to register Soundwire controller (%d)\n",
			ret);
		goto err_clk;
	}

	qcom_swrm_init(ctrl); <<< that's where the bus is functional

Note that we are not going to lay on the tracks for this, this sequence 
was tagged by static analysis tools who don't understand that 
put_device() actually frees memory by way of the .release callback, but 
that led us to ask ourselves whether this sequence was actually necessary.

  reply	other threads:[~2021-03-23 18:31 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-23  2:25 Bard Liao
2021-03-23  6:57 ` Vinod Koul
2021-03-23 18:30   ` Pierre-Louis Bossart [this message]
2021-04-19  1:46     ` Liao, Bard

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=82d579ca-5021-341c-1fcd-5c85c54c637b@linux.intel.com \
    --to=pierre-louis.bossart@linux.intel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=bard.liao@intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hui.wang@canonical.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rander.wang@linux.intel.com \
    --cc=sanyog.r.kale@intel.com \
    --cc=srinivas.kandagatla@linaro.org \
    --cc=vkoul@kernel.org \
    --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

all inboxes | Powered by JetHome®