* [PATCH] soundwire: debugfs: add root-level peripherals table
@ 2026-09-02 8:18 Bard Liao
2026-09-04 7:35 ` Pierre-Louis Bossart
0 siblings, 1 reply; 5+ messages in thread
From: Bard Liao @ 2026-09-02 8:18 UTC (permalink / raw)
To: linux-sound, vkoul
Cc: vinod.koul, linux-kernel, pierre-louis.bossart, peter.ujfalusi,
bard.liao
The table will let user know what peripherals are listed and get the
detected status by the dev_num.
Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
---
drivers/soundwire/debugfs.c | 72 +++++++++++++++++++++++++++++++++++++
1 file changed, 72 insertions(+)
diff --git a/drivers/soundwire/debugfs.c b/drivers/soundwire/debugfs.c
index 2905ec19b838..3cc3428df6a4 100644
--- a/drivers/soundwire/debugfs.c
+++ b/drivers/soundwire/debugfs.c
@@ -9,12 +9,82 @@
#include <linux/pm_runtime.h>
#include <linux/slab.h>
#include <linux/soundwire/sdw.h>
+#include <linux/soundwire/sdw_type.h>
#include <linux/soundwire/sdw_registers.h>
#include <linux/string_choices.h>
#include "bus.h"
static struct dentry *sdw_debugfs_root;
+#define SDW_PERIPH_HEADER_FMT "%-28s %-7s %-16s %-6s %-7s %-8s %-9s %-11s\n"
+#define SDW_PERIPH_ENTRY_FMT "%-28s %-7u %#016llx %-6.4x %-7.4x %-8.2x %-9.2x %-11.1x\n"
+
+static u64 sdw_slave_addr_from_id(struct sdw_bus *bus,
+ const struct sdw_slave_id *id)
+{
+ u64 addr = 0;
+ u8 unique_id = id->unique_id;
+
+ if (unique_id == SDW_IGNORED_UNIQUE_ID)
+ unique_id = 0;
+
+ addr |= FIELD_PREP(SDW_DISCO_LINK_ID_MASK, bus->link_id);
+ addr |= FIELD_PREP(SDW_VERSION_MASK, id->sdw_version);
+ addr |= FIELD_PREP(SDW_UNIQUE_ID_MASK, unique_id);
+ addr |= FIELD_PREP(SDW_MFG_ID_MASK, id->mfg_id);
+ addr |= FIELD_PREP(SDW_PART_ID_MASK, id->part_id);
+ addr |= FIELD_PREP(SDW_CLASS_ID_MASK, id->class_id);
+
+ return addr;
+}
+
+static void sdw_dump_bus_peripherals(struct seq_file *s_file, struct sdw_bus *bus)
+{
+ struct sdw_slave *slave;
+ u64 addr;
+
+ seq_printf(s_file, "master-%d-%d\n",
+ bus->controller_id, bus->link_id);
+ seq_printf(s_file, SDW_PERIPH_HEADER_FMT,
+ "name", "dev_num", "addr", "mfg_id", "part_id",
+ "class_id", "unique_id", "sdw_version");
+
+ mutex_lock(&bus->bus_lock);
+ list_for_each_entry(slave, &bus->slaves, node) {
+ addr = sdw_slave_addr_from_id(bus, &slave->id);
+ seq_printf(s_file, SDW_PERIPH_ENTRY_FMT,
+ dev_name(&slave->dev), slave->dev_num,
+ addr,
+ slave->id.mfg_id, slave->id.part_id,
+ slave->id.class_id, slave->id.unique_id,
+ slave->id.sdw_version);
+ }
+ mutex_unlock(&bus->bus_lock);
+
+ seq_putc(s_file, '\n');
+}
+
+static int sdw_root_peripherals_dump(struct device *dev, void *data)
+{
+ struct sdw_master_device *md;
+ struct seq_file *s_file = data;
+
+ if (dev->type != &sdw_master_type)
+ return 0;
+
+ md = dev_to_sdw_master_device(dev);
+ sdw_dump_bus_peripherals(s_file, md->bus);
+
+ return 0;
+}
+
+static int sdw_root_peripherals_show(struct seq_file *s_file, void *data)
+{
+ return bus_for_each_dev(&sdw_bus_type, NULL, s_file,
+ sdw_root_peripherals_dump);
+}
+DEFINE_SHOW_ATTRIBUTE(sdw_root_peripherals);
+
void sdw_bus_debugfs_init(struct sdw_bus *bus)
{
char name[16];
@@ -375,6 +445,8 @@ void sdw_debugfs_init(void)
firmware_file = kstrdup("", GFP_KERNEL);
sdw_debugfs_root = debugfs_create_dir("soundwire", NULL);
+ debugfs_create_file("peripherals", 0400, sdw_debugfs_root, NULL,
+ &sdw_root_peripherals_fops);
}
void sdw_debugfs_exit(void)
--
2.43.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] soundwire: debugfs: add root-level peripherals table
2026-09-02 8:18 [PATCH] soundwire: debugfs: add root-level peripherals table Bard Liao
@ 2026-09-04 7:35 ` Pierre-Louis Bossart
2026-09-04 11:36 ` Liao, Bard
2026-09-04 12:11 ` Charles Keepax
0 siblings, 2 replies; 5+ messages in thread
From: Pierre-Louis Bossart @ 2026-09-04 7:35 UTC (permalink / raw)
To: Bard Liao, linux-sound, vkoul
Cc: vinod.koul, linux-kernel, peter.ujfalusi, bard.liao
On 9/2/26 10:18, Bard Liao wrote:
> The table will let user know what peripherals are listed and get the
> detected status by the dev_num.
This sounds useful indeed, but does this need to be in debugfs?
We already have a sysfs entry for every peripheral listed in ACPI. Each
peripheral will have a set of properties extracted from DisCo tables,
could we piggy-back on all this and just expose the dev_num?
>
> Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
> ---
> drivers/soundwire/debugfs.c | 72 +++++++++++++++++++++++++++++++++++++
> 1 file changed, 72 insertions(+)
>
> diff --git a/drivers/soundwire/debugfs.c b/drivers/soundwire/debugfs.c
> index 2905ec19b838..3cc3428df6a4 100644
> --- a/drivers/soundwire/debugfs.c
> +++ b/drivers/soundwire/debugfs.c
> @@ -9,12 +9,82 @@
> #include <linux/pm_runtime.h>
> #include <linux/slab.h>
> #include <linux/soundwire/sdw.h>
> +#include <linux/soundwire/sdw_type.h>
> #include <linux/soundwire/sdw_registers.h>
> #include <linux/string_choices.h>
> #include "bus.h"
>
> static struct dentry *sdw_debugfs_root;
>
> +#define SDW_PERIPH_HEADER_FMT "%-28s %-7s %-16s %-6s %-7s %-8s %-9s %-11s\n"
> +#define SDW_PERIPH_ENTRY_FMT "%-28s %-7u %#016llx %-6.4x %-7.4x %-8.2x %-9.2x %-11.1x\n"
> +
> +static u64 sdw_slave_addr_from_id(struct sdw_bus *bus,
> + const struct sdw_slave_id *id)
> +{
> + u64 addr = 0;
> + u8 unique_id = id->unique_id;
> +
> + if (unique_id == SDW_IGNORED_UNIQUE_ID)
> + unique_id = 0;
> +
> + addr |= FIELD_PREP(SDW_DISCO_LINK_ID_MASK, bus->link_id);
> + addr |= FIELD_PREP(SDW_VERSION_MASK, id->sdw_version);
> + addr |= FIELD_PREP(SDW_UNIQUE_ID_MASK, unique_id);
> + addr |= FIELD_PREP(SDW_MFG_ID_MASK, id->mfg_id);
> + addr |= FIELD_PREP(SDW_PART_ID_MASK, id->part_id);
> + addr |= FIELD_PREP(SDW_CLASS_ID_MASK, id->class_id);
> +
> + return addr;
> +}
> +
> +static void sdw_dump_bus_peripherals(struct seq_file *s_file, struct sdw_bus *bus)
> +{
> + struct sdw_slave *slave;
> + u64 addr;
> +
> + seq_printf(s_file, "master-%d-%d\n",
> + bus->controller_id, bus->link_id);
> + seq_printf(s_file, SDW_PERIPH_HEADER_FMT,
> + "name", "dev_num", "addr", "mfg_id", "part_id",
> + "class_id", "unique_id", "sdw_version");
> +
> + mutex_lock(&bus->bus_lock);
> + list_for_each_entry(slave, &bus->slaves, node) {
> + addr = sdw_slave_addr_from_id(bus, &slave->id);
> + seq_printf(s_file, SDW_PERIPH_ENTRY_FMT,
> + dev_name(&slave->dev), slave->dev_num,
> + addr,
> + slave->id.mfg_id, slave->id.part_id,
> + slave->id.class_id, slave->id.unique_id,
> + slave->id.sdw_version);
> + }
> + mutex_unlock(&bus->bus_lock);
> +
> + seq_putc(s_file, '\n');
> +}
> +
> +static int sdw_root_peripherals_dump(struct device *dev, void *data)
> +{
> + struct sdw_master_device *md;
> + struct seq_file *s_file = data;
> +
> + if (dev->type != &sdw_master_type)
> + return 0;
> +
> + md = dev_to_sdw_master_device(dev);
> + sdw_dump_bus_peripherals(s_file, md->bus);
> +
> + return 0;
> +}
> +
> +static int sdw_root_peripherals_show(struct seq_file *s_file, void *data)
> +{
> + return bus_for_each_dev(&sdw_bus_type, NULL, s_file,
> + sdw_root_peripherals_dump);
> +}
> +DEFINE_SHOW_ATTRIBUTE(sdw_root_peripherals);
> +
> void sdw_bus_debugfs_init(struct sdw_bus *bus)
> {
> char name[16];
> @@ -375,6 +445,8 @@ void sdw_debugfs_init(void)
> firmware_file = kstrdup("", GFP_KERNEL);
>
> sdw_debugfs_root = debugfs_create_dir("soundwire", NULL);
> + debugfs_create_file("peripherals", 0400, sdw_debugfs_root, NULL,
> + &sdw_root_peripherals_fops);
> }
>
> void sdw_debugfs_exit(void)
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: [PATCH] soundwire: debugfs: add root-level peripherals table
2026-09-04 7:35 ` Pierre-Louis Bossart
@ 2026-09-04 11:36 ` Liao, Bard
2026-09-04 13:47 ` Pierre-Louis Bossart
2026-09-04 12:11 ` Charles Keepax
1 sibling, 1 reply; 5+ messages in thread
From: Liao, Bard @ 2026-09-04 11:36 UTC (permalink / raw)
To: Pierre-Louis Bossart, Bard Liao, linux-sound, vkoul
Cc: vinod.koul, linux-kernel, peter.ujfalusi
> -----Original Message-----
> From: Pierre-Louis Bossart <pierre-louis.bossart@linux.dev>
> Sent: Friday, September 4, 2026 3:35 PM
> To: Bard Liao <yung-chuan.liao@linux.intel.com>; linux-
> sound@vger.kernel.org; vkoul@kernel.org
> Cc: vinod.koul@linaro.org; linux-kernel@vger.kernel.org;
> peter.ujfalusi@linux.intel.com; Liao, Bard <bard.liao@intel.com>
> Subject: Re: [PATCH] soundwire: debugfs: add root-level peripherals table
>
> On 9/2/26 10:18, Bard Liao wrote:
> > The table will let user know what peripherals are listed and get the
> > detected status by the dev_num.
>
> This sounds useful indeed, but does this need to be in debugfs?
>
> We already have a sysfs entry for every peripheral listed in ACPI. Each
> peripheral will have a set of properties extracted from DisCo tables,
> could we piggy-back on all this and just expose the dev_num?
It is convenient for the user to get all information on top of the
soundwire folder instead of looking for the information one by one
in each peripheral folder.
>
> >
> > Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] soundwire: debugfs: add root-level peripherals table
2026-09-04 7:35 ` Pierre-Louis Bossart
2026-09-04 11:36 ` Liao, Bard
@ 2026-09-04 12:11 ` Charles Keepax
1 sibling, 0 replies; 5+ messages in thread
From: Charles Keepax @ 2026-09-04 12:11 UTC (permalink / raw)
To: Pierre-Louis Bossart
Cc: Bard Liao, linux-sound, vkoul, vinod.koul, linux-kernel,
peter.ujfalusi, bard.liao
On Fri, Sep 04, 2026 at 09:35:15AM +0200, Pierre-Louis Bossart wrote:
> On 9/2/26 10:18, Bard Liao wrote:
> > The table will let user know what peripherals are listed and get the
> > detected status by the dev_num.
>
> This sounds useful indeed, but does this need to be in debugfs?
>
> We already have a sysfs entry for every peripheral listed in ACPI. Each
> peripheral will have a set of properties extracted from DisCo tables,
> could we piggy-back on all this and just expose the dev_num?
>
The dev_num is already exposed through sysfs, so I think this is
more of a see everything in one place kinda deal. Although I
guess one could just make a script that pulled all the sysfs
stuff together?
Thanks,
Charles
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] soundwire: debugfs: add root-level peripherals table
2026-09-04 11:36 ` Liao, Bard
@ 2026-09-04 13:47 ` Pierre-Louis Bossart
0 siblings, 0 replies; 5+ messages in thread
From: Pierre-Louis Bossart @ 2026-09-04 13:47 UTC (permalink / raw)
To: Liao, Bard, Bard Liao, linux-sound, vkoul
Cc: vinod.koul, linux-kernel, peter.ujfalusi
On 9/4/26 13:36, Liao, Bard wrote:
>
>
>> -----Original Message-----
>> From: Pierre-Louis Bossart <pierre-louis.bossart@linux.dev>
>> Sent: Friday, September 4, 2026 3:35 PM
>> To: Bard Liao <yung-chuan.liao@linux.intel.com>; linux-
>> sound@vger.kernel.org; vkoul@kernel.org
>> Cc: vinod.koul@linaro.org; linux-kernel@vger.kernel.org;
>> peter.ujfalusi@linux.intel.com; Liao, Bard <bard.liao@intel.com>
>> Subject: Re: [PATCH] soundwire: debugfs: add root-level peripherals table
>>
>> On 9/2/26 10:18, Bard Liao wrote:
>>> The table will let user know what peripherals are listed and get the
>>> detected status by the dev_num.
>>
>> This sounds useful indeed, but does this need to be in debugfs?
>>
>> We already have a sysfs entry for every peripheral listed in ACPI. Each
>> peripheral will have a set of properties extracted from DisCo tables,
>> could we piggy-back on all this and just expose the dev_num?
>
> It is convenient for the user to get all information on top of the
> soundwire folder instead of looking for the information one by one
> in each peripheral folder.
Right, but as Charles suggested one could use a script to provide the
information in a more self-explanatory format.
That script could even be added to 'alsa-info' and make existing reports
better without needing kernel changes.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-09-04 13:47 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-02 8:18 [PATCH] soundwire: debugfs: add root-level peripherals table Bard Liao
2026-09-04 7:35 ` Pierre-Louis Bossart
2026-09-04 11:36 ` Liao, Bard
2026-09-04 13:47 ` Pierre-Louis Bossart
2026-09-04 12:11 ` Charles Keepax
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®