From: Richard Fitzgerald <rf@opensource.cirrus.com> To: <vkoul@kernel.org>, <yung-chuan.liao@linux.intel.com>, <pierre-louis.bossart@linux.intel.com>, <lgirdwood@gmail.com>, <peter.ujfalusi@linux.intel.com>, <ranjani.sridharan@linux.intel.com>, <kai.vehmanen@linux.intel.com>, <daniel.baluta@nxp.com>, <sanyog.r.kale@intel.com>, <broonie@kernel.org> Cc: <alsa-devel@alsa-project.org>, <sound-open-firmware@alsa-project.org>, <linux-kernel@vger.kernel.org>, <patches@opensource.cirrus.com>, Richard Fitzgerald <rf@opensource.cirrus.com> Subject: [PATCH 4/7] soundwire: bus: Add remove callback to struct sdw_master_ops Date: Wed, 7 Sep 2022 11:13:59 +0100 [thread overview] Message-ID: <20220907101402.4685-5-rf@opensource.cirrus.com> (raw) In-Reply-To: <20220907101402.4685-1-rf@opensource.cirrus.com> During removal of a bus driver the bus must stay operational while child drivers are being removed, since (a) they might have been busy when the bus driver removal started and (b) the might need to access the bus to run their shutdown procedures. Only after that can the bus driver disable the bus. Add a new remove callback to struct sdw_master_ops that the bus driver can implement to disable the bus after children are removed. This is modeled on the ASoC component_remove, which indicates that the driver is no longer required. Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com> --- drivers/soundwire/bus.c | 5 +++++ include/linux/soundwire/sdw.h | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/soundwire/bus.c b/drivers/soundwire/bus.c index 99429892221b..1327a312be86 100644 --- a/drivers/soundwire/bus.c +++ b/drivers/soundwire/bus.c @@ -176,6 +176,11 @@ static int sdw_delete_slave(struct device *dev, void *data) void sdw_bus_master_delete(struct sdw_bus *bus) { device_for_each_child(bus->dev, NULL, sdw_delete_slave); + + /* Children have been removed so it is now safe for the bus to stop */ + if (bus->ops->remove) + bus->ops->remove(bus); + sdw_master_device_del(bus); sdw_bus_debugfs_exit(bus); diff --git a/include/linux/soundwire/sdw.h b/include/linux/soundwire/sdw.h index a2b31d25ea27..aa492173d5eb 100644 --- a/include/linux/soundwire/sdw.h +++ b/include/linux/soundwire/sdw.h @@ -839,6 +839,7 @@ struct sdw_defer { * @set_bus_conf: Set the bus configuration * @pre_bank_switch: Callback for pre bank switch * @post_bank_switch: Callback for post bank switch + * @remove: Called when it is safe to stop the bus controller. */ struct sdw_master_ops { int (*read_prop)(struct sdw_bus *bus); @@ -855,7 +856,7 @@ struct sdw_master_ops { struct sdw_bus_params *params); int (*pre_bank_switch)(struct sdw_bus *bus); int (*post_bank_switch)(struct sdw_bus *bus); - + void (*remove)(struct sdw_bus *bus); }; /** -- 2.30.2
WARNING: multiple messages have this Message-ID (diff)
From: Richard Fitzgerald <rf@opensource.cirrus.com> To: <vkoul@kernel.org>, <yung-chuan.liao@linux.intel.com>, <pierre-louis.bossart@linux.intel.com>, <lgirdwood@gmail.com>, <peter.ujfalusi@linux.intel.com>, <ranjani.sridharan@linux.intel.com>, <kai.vehmanen@linux.intel.com>, <daniel.baluta@nxp.com>, <sanyog.r.kale@intel.com>, <broonie@kernel.org> Cc: patches@opensource.cirrus.com, alsa-devel@alsa-project.org, Richard Fitzgerald <rf@opensource.cirrus.com>, linux-kernel@vger.kernel.org, sound-open-firmware@alsa-project.org Subject: [PATCH 4/7] soundwire: bus: Add remove callback to struct sdw_master_ops Date: Wed, 7 Sep 2022 11:13:59 +0100 [thread overview] Message-ID: <20220907101402.4685-5-rf@opensource.cirrus.com> (raw) In-Reply-To: <20220907101402.4685-1-rf@opensource.cirrus.com> During removal of a bus driver the bus must stay operational while child drivers are being removed, since (a) they might have been busy when the bus driver removal started and (b) the might need to access the bus to run their shutdown procedures. Only after that can the bus driver disable the bus. Add a new remove callback to struct sdw_master_ops that the bus driver can implement to disable the bus after children are removed. This is modeled on the ASoC component_remove, which indicates that the driver is no longer required. Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com> --- drivers/soundwire/bus.c | 5 +++++ include/linux/soundwire/sdw.h | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/soundwire/bus.c b/drivers/soundwire/bus.c index 99429892221b..1327a312be86 100644 --- a/drivers/soundwire/bus.c +++ b/drivers/soundwire/bus.c @@ -176,6 +176,11 @@ static int sdw_delete_slave(struct device *dev, void *data) void sdw_bus_master_delete(struct sdw_bus *bus) { device_for_each_child(bus->dev, NULL, sdw_delete_slave); + + /* Children have been removed so it is now safe for the bus to stop */ + if (bus->ops->remove) + bus->ops->remove(bus); + sdw_master_device_del(bus); sdw_bus_debugfs_exit(bus); diff --git a/include/linux/soundwire/sdw.h b/include/linux/soundwire/sdw.h index a2b31d25ea27..aa492173d5eb 100644 --- a/include/linux/soundwire/sdw.h +++ b/include/linux/soundwire/sdw.h @@ -839,6 +839,7 @@ struct sdw_defer { * @set_bus_conf: Set the bus configuration * @pre_bank_switch: Callback for pre bank switch * @post_bank_switch: Callback for post bank switch + * @remove: Called when it is safe to stop the bus controller. */ struct sdw_master_ops { int (*read_prop)(struct sdw_bus *bus); @@ -855,7 +856,7 @@ struct sdw_master_ops { struct sdw_bus_params *params); int (*pre_bank_switch)(struct sdw_bus *bus); int (*post_bank_switch)(struct sdw_bus *bus); - + void (*remove)(struct sdw_bus *bus); }; /** -- 2.30.2
next prev parent reply other threads:[~2022-09-07 10:15 UTC|newest] Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-09-07 10:13 [PATCH 0/7] soundwire: Fix driver removal Richard Fitzgerald 2022-09-07 10:13 ` Richard Fitzgerald 2022-09-07 10:13 ` [PATCH 1/7] soundwire: bus: Do not forcibly disable child pm_runtime Richard Fitzgerald 2022-09-07 10:13 ` Richard Fitzgerald 2022-09-12 10:43 ` Pierre-Louis Bossart 2022-09-12 10:43 ` Pierre-Louis Bossart 2022-09-07 10:13 ` [PATCH 2/7] soundwire: intel_init: Separate shutdown and cleanup Richard Fitzgerald 2022-09-07 10:13 ` Richard Fitzgerald 2022-09-07 10:13 ` [PATCH 3/7] ASoC: SOF: Intel: Don't disable Soundwire interrupt before the bus has shut down Richard Fitzgerald 2022-09-07 10:13 ` Richard Fitzgerald 2022-09-07 11:26 ` Mark Brown 2022-09-07 11:26 ` Mark Brown 2022-09-07 10:13 ` Richard Fitzgerald [this message] 2022-09-07 10:13 ` [PATCH 4/7] soundwire: bus: Add remove callback to struct sdw_master_ops Richard Fitzgerald 2022-09-07 10:14 ` [PATCH 5/7] soundwire: intel: Don't disable interrupt until children are removed Richard Fitzgerald 2022-09-07 10:14 ` Richard Fitzgerald 2022-09-12 10:53 ` Pierre-Louis Bossart 2022-09-12 15:36 ` Richard Fitzgerald 2022-09-12 15:36 ` Richard Fitzgerald 2022-09-12 17:12 ` Pierre-Louis Bossart 2022-09-13 9:29 ` Richard Fitzgerald 2022-09-13 9:29 ` Richard Fitzgerald 2022-09-07 10:14 ` [PATCH 6/7] soundwire: intel: Don't disable pm_runtime " Richard Fitzgerald 2022-09-07 10:14 ` Richard Fitzgerald 2022-09-07 10:14 ` [PATCH 7/7] soundwire: bus: Fix premature removal of sdw_slave objects Richard Fitzgerald 2022-09-07 10:14 ` Richard Fitzgerald 2022-09-12 10:57 ` 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=20220907101402.4685-5-rf@opensource.cirrus.com \ --to=rf@opensource.cirrus.com \ --cc=alsa-devel@alsa-project.org \ --cc=broonie@kernel.org \ --cc=daniel.baluta@nxp.com \ --cc=kai.vehmanen@linux.intel.com \ --cc=lgirdwood@gmail.com \ --cc=linux-kernel@vger.kernel.org \ --cc=patches@opensource.cirrus.com \ --cc=peter.ujfalusi@linux.intel.com \ --cc=pierre-louis.bossart@linux.intel.com \ --cc=ranjani.sridharan@linux.intel.com \ --cc=sanyog.r.kale@intel.com \ --cc=sound-open-firmware@alsa-project.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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.