linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Vinod Koul <vinod.koul@intel.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
	ALSA <alsa-devel@alsa-project.org>, Mark <broonie@kernel.org>,
	Takashi <tiwai@suse.de>,
	Pierre <pierre-louis.bossart@linux.intel.com>,
	patches.audio@intel.com, alan@linux.intel.com,
	Charles Keepax <ckeepax@opensource.cirrus.com>,
	Sagar Dharia <sdharia@codeaurora.org>,
	srinivas.kandagatla@linaro.org, plai@codeaurora.org,
	Sudheer Papothi <spapothi@codeaurora.org>
Subject: Re: [PATCH v5 10/15] soundwire: Add sysfs for SoundWire DisCo properties
Date: Wed, 13 Dec 2017 10:15:37 +0100	[thread overview]
Message-ID: <20171213091537.GA6269@kroah.com> (raw)
In-Reply-To: <1512575231-4154-11-git-send-email-vinod.koul@intel.com>

On Wed, Dec 06, 2017 at 09:17:06PM +0530, Vinod Koul wrote:
> It helps to read the properties for understanding and debugging
> systems, so add sysfs files for SoundWire DisCo properties.
> 
> TODO: Add ABI files for sysfs

Is this TODO done?

> +/*
> + * The sysfs for properties reflects the MIPI description as given
> + * in the MIPI DisCo spec
> + *
> + * Base file is:
> + *		properties
> + *		|---- interface-revision
> + *		|---- master-count
> + *		|---- link-N
> + *		      |---- clock-stop-modes
> + *		      |---- max-clock-frequency
> + *		      |---- clock-frequencies
> + *		      |---- default-frame-rows
> + *		      |---- default-frame-cols
> + *		      |---- dynamic-frame-shape
> + *		      |---- command-error-threshold
> + */

Why nest them so deep?  Anyway, that's not really an issue I guess, it's
your ABI, not mine :)

> +
> +struct sdw_master_sysfs {
> +	struct kobject kobj;
> +	struct sdw_bus *bus;

Huh?  Why do you need to use kobjects?

When you switch from using a 'struct device' and hang a kobject off of
it, that's a huge signal that something is wrong here.  That kobject
will now no longer be part of the device "chain" in the system, uevents
will get odd, and other strange things can happen.

Why can't you just use "normal" attributes attached to the device?  You
shouldn't need a kobject here.  What am I missing?

> +/*
> + * Slave sysfs
> + */
> +
> +/*
> + * The sysfs for Slave reflects the MIPI description as given
> + * in the MIPI DisCo spec
> + *
> + * Base file is device
> + *	|---- mipi_revision
> + *	|---- wake_capable
> + *	|---- test_mode_capable
> + *	|---- simple_clk_stop_capable
> + *	|---- clk_stop_timeout
> + *	|---- ch_prep_timeout
> + *	|---- reset_behave
> + *	|---- high_PHY_capable
> + *	|---- paging_support
> + *	|---- bank_delay_support
> + *	|---- p15_behave
> + *	|---- master_count
> + *	|---- source_ports
> + *	|---- sink_ports
> + *	|---- dp0
> + *		|---- max_word
> + *		|---- min_word
> + *		|---- words
> + *		|---- flow_controlled
> + *		|---- simple_ch_prep_sm
> + *		|---- device_interrupts
> + *	|---- dpN
> + *		|---- max_word
> + *		|---- min_word
> + *		|---- words
> + *		|---- type
> + *		|---- max_grouping
> + *		|---- simple_ch_prep_sm
> + *		|---- ch_prep_timeout
> + *		|---- device_interrupts
> + *		|---- max_ch
> + *		|---- min_ch
> + *		|---- ch
> + *		|---- ch_combinations
> + *		|---- modes
> + *		|---- max_async_buffer
> + *		|---- block_pack_mode
> + *		|---- port_encoding
> + *		|---- bus_min_freq
> + *		|---- bus_max_freq
> + *		|---- bus_freq
> + *		|---- max_freq
> + *		|---- min_freq
> + *		|---- freq
> + *		|---- prep_ch_behave
> + *		|---- glitchless
> + *
> + */
> +struct sdw_slave_sysfs {
> +	struct sdw_slave *slave;
> +};

Same here, why are you using kobjects for this "device"?  Shouldn't you
use a real struct device for dpX?


> +
> +#define SLAVE_ATTR(type)					\
> +static ssize_t type##_show(struct device *dev,			\
> +		struct device_attribute *attr, char *buf)	\
> +{								\
> +	struct sdw_slave *slave = dev_to_sdw_dev(dev);		\
> +	return sprintf(buf, "0x%x\n", slave->prop.type);	\
> +}								\
> +static DEVICE_ATTR_RO(type)

Oh wait, you are?  I'm confused, is this a real device or not?

> +
> +SLAVE_ATTR(mipi_revision);
> +SLAVE_ATTR(wake_capable);
> +SLAVE_ATTR(test_mode_capable);
> +SLAVE_ATTR(clk_stop_mode1);
> +SLAVE_ATTR(simple_clk_stop_capable);
> +SLAVE_ATTR(clk_stop_timeout);
> +SLAVE_ATTR(ch_prep_timeout);
> +SLAVE_ATTR(reset_behave);
> +SLAVE_ATTR(high_PHY_capable);
> +SLAVE_ATTR(paging_support);
> +SLAVE_ATTR(bank_delay_support);
> +SLAVE_ATTR(p15_behave);
> +SLAVE_ATTR(master_count);
> +SLAVE_ATTR(source_ports);
> +
> +static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
> +			     char *buf)
> +{
> +	struct sdw_slave *slave = dev_to_sdw_dev(dev);
> +
> +	return sdw_slave_modalias(slave, buf, 256);
> +}
> +static DEVICE_ATTR_RO(modalias);
> +
> +static struct attribute *slave_dev_attrs[] = {
> +	&dev_attr_mipi_revision.attr,
> +	&dev_attr_wake_capable.attr,
> +	&dev_attr_test_mode_capable.attr,
> +	&dev_attr_clk_stop_mode1.attr,
> +	&dev_attr_simple_clk_stop_capable.attr,
> +	&dev_attr_clk_stop_timeout.attr,
> +	&dev_attr_ch_prep_timeout.attr,
> +	&dev_attr_reset_behave.attr,
> +	&dev_attr_high_PHY_capable.attr,
> +	&dev_attr_paging_support.attr,
> +	&dev_attr_bank_delay_support.attr,
> +	&dev_attr_p15_behave.attr,
> +	&dev_attr_master_count.attr,
> +	&dev_attr_source_ports.attr,
> +	&dev_attr_modalias.attr,
> +	NULL,
> +};
> +
> +static struct attribute_group sdw_slave_dev_attr_group = {
> +	.attrs	= slave_dev_attrs,
> +};
> +
> +const struct attribute_group *sdw_slave_dev_attr_groups[] = {
> +	&sdw_slave_dev_attr_group,
> +	NULL
> +};
> diff --git a/include/linux/soundwire/sdw.h b/include/linux/soundwire/sdw.h
> index e752db72a045..fce502d08fef 100644
> --- a/include/linux/soundwire/sdw.h
> +++ b/include/linux/soundwire/sdw.h
> @@ -308,6 +308,15 @@ int sdw_master_read_prop(struct sdw_bus *bus);
>  int sdw_slave_read_prop(struct sdw_slave *slave);
>  
>  /*
> + * SDW sysfs APIs
> + */
> +struct sdw_slave_sysfs;
> +struct sdw_master_sysfs;
> +
> +int sdw_sysfs_bus_init(struct sdw_bus *bus);

How are you handling the sysfs files showing up "after" the device is
registered and userspace not seeing them?  Have you tried using libudev
to get the attributes?  Does this all work properly?  I think with the
use of a kobject that breaks, and that's not good.


> +void sdw_sysfs_bus_exit(struct sdw_bus *bus);
> +
> +/*
>   * SDW Slave Structures and APIs
>   */
>  
> @@ -363,6 +372,7 @@ struct sdw_slave_ops {
>   * @bus: Bus handle
>   * @ops: Slave callback ops
>   * @prop: Slave properties
> + * @sysfs: Sysfs interface
>   * @node: node for bus list
>   * @port_ready: Port ready completion flag for each Slave port
>   * @dev_num: Device Number assigned by Bus
> @@ -374,6 +384,7 @@ struct sdw_slave {
>  	struct sdw_bus *bus;
>  	const struct sdw_slave_ops *ops;
>  	struct sdw_slave_prop prop;
> +	struct sdw_slave_sysfs *sysfs;

So a differently reference counted device is hanging off of this?
That's the big objection to using a kobject here and should have been a
clue that this isn't ok.

>  	struct list_head node;
>  	struct completion *port_ready;
>  	u16 dev_num;
> @@ -453,6 +464,7 @@ struct sdw_master_ops {
>   * @msg_lock: message lock
>   * @ops: Master callback ops
>   * @prop: Master properties
> + * @sysfs: Bus sysfs
>   * @defer_msg: Defer message
>   * @clk_stop_timeout: Clock stop timeout computed
>   */
> @@ -465,6 +477,7 @@ struct sdw_bus {
>  	struct mutex msg_lock;
>  	const struct sdw_master_ops *ops;
>  	struct sdw_master_prop prop;
> +	struct sdw_master_sysfs *sysfs;

Same here.

thanks,

greg k-h

  reply	other threads:[~2017-12-13  9:15 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-06 15:46 [PATCH v5 00/15] soundwire: Add a new SoundWire subsystem Vinod Koul
2017-12-06 15:46 ` [PATCH v5 01/15] Documentation: Add SoundWire summary Vinod Koul
2017-12-06 15:46 ` [PATCH v5 02/15] soundwire: Add SoundWire bus type Vinod Koul
2017-12-13  9:16   ` Greg Kroah-Hartman
2017-12-06 15:46 ` [PATCH v5 03/15] soundwire: Add Master registration Vinod Koul
2017-12-11 16:02   ` Takashi Iwai
2017-12-11 16:44     ` [alsa-devel] " Vinod Koul
2017-12-13  9:16   ` Greg Kroah-Hartman
2017-12-06 15:47 ` [PATCH v5 04/15] soundwire: Add MIPI DisCo property helpers Vinod Koul
2017-12-11 16:10   ` Takashi Iwai
2017-12-11 17:00     ` Vinod Koul
2017-12-11 17:06       ` Takashi Iwai
2017-12-11 17:18         ` Vinod Koul
2017-12-06 15:47 ` [PATCH v5 05/15] soundwire: Add SoundWire MIPI defined registers Vinod Koul
2017-12-06 15:47 ` [PATCH v5 06/15] soundwire: Add IO transfer Vinod Koul
2017-12-06 15:47 ` [PATCH v5 07/15] regmap: Add SoundWire bus support Vinod Koul
2017-12-06 15:47 ` [PATCH v5 08/15] soundwire: Add Slave status handling helpers Vinod Koul
2017-12-06 15:47 ` [PATCH v5 09/15] soundwire: Add slave status handling Vinod Koul
2017-12-06 15:47 ` [PATCH v5 10/15] soundwire: Add sysfs for SoundWire DisCo properties Vinod Koul
2017-12-13  9:15   ` Greg Kroah-Hartman [this message]
2017-12-13  9:54     ` Vinod Koul
2017-12-13 14:31       ` Pierre-Louis Bossart
2017-12-13 16:28       ` Greg Kroah-Hartman
2017-12-13 16:52         ` [alsa-devel] " Vinod Koul
2017-12-13 16:59           ` Greg Kroah-Hartman
2017-12-22  8:26             ` Vinod Koul
2017-12-22  8:33               ` Greg Kroah-Hartman
2017-12-22 11:43                 ` Vinod Koul
2017-12-22 15:20                   ` Greg Kroah-Hartman
2017-12-06 15:47 ` [PATCH v5 11/15] soundwire: cdns: Add cadence library Vinod Koul
2017-12-06 15:47 ` [PATCH v5 12/15] soundwire: cdns: Add sdw_master_ops and IO transfer support Vinod Koul
2017-12-06 15:47 ` [PATCH v5 13/15] soundwire: intel: Add Intel Master driver Vinod Koul
2017-12-06 15:47 ` [PATCH v5 14/15] soundwire: intel: Add Intel init module Vinod Koul
2017-12-06 15:47 ` [PATCH v5 15/15] MAINTAINERS: Add SoundWire entry Vinod Koul
2017-12-06 20:44 ` [PATCH v5 00/15] soundwire: Add a new SoundWire subsystem Philippe Ombredanne
2017-12-07  0:38 ` Pierre-Louis Bossart
2017-12-11 16:30 ` Takashi Iwai
2017-12-13  9:18 ` Greg Kroah-Hartman
2017-12-13  9:57   ` 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=20171213091537.GA6269@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=alan@linux.intel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=ckeepax@opensource.cirrus.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=patches.audio@intel.com \
    --cc=pierre-louis.bossart@linux.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).