AMD-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Li, Sun peng (Leo)" <Sunpeng.Li@amd.com>
To: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
Cc: "dri-devel@lists.freedesktop.org"
	<dri-devel@lists.freedesktop.org>,
	"amd-gfx@lists.freedesktop.org" <amd-gfx@lists.freedesktop.org>
Subject: Re: [PATCH 03/10] drm/sysfs: Add mstpath attribute to connector devices
Date: Fri, 5 Jul 2019 14:03:52 +0000	[thread overview]
Message-ID: <cfb3d588-e961-1d3b-be6b-d41069f5df03@amd.com> (raw)
In-Reply-To: <20190704193304.GJ5942@intel.com>




On 2019-07-04 3:33 p.m., Ville Syrjälä wrote:
> On Thu, Jul 04, 2019 at 03:05:12PM -0400, sunpeng.li@amd.com wrote:
>> From: Leo Li <sunpeng.li@amd.com>
>>
>> This can be used to create more descriptive symlinks for MST aux
>> devices. Consider the following udev rule:
>>
>> SUBSYSTEM=="drm_dp_aux_dev", SUBSYSTEMS=="drm", ATTRS{mstpath}=="?*",
>> 	SYMLINK+="drm_dp_aux/by-path/$attr{mstpath}"
>>
>> The following symlinks will be created (depending on your MST topology):
>>
>> $ ls /dev/drm_dp_aux/by-path/
>> card0-mst:0-1  card0-mst:0-1-1  card0-mst:0-1-8  card0-mst:0-8
>>
>> Signed-off-by: Leo Li <sunpeng.li@amd.com>
>> ---
>>  drivers/gpu/drm/drm_sysfs.c | 23 +++++++++++++++++++++++
>>  1 file changed, 23 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c
>> index ad10810bc972..53fd1f71e900 100644
>> --- a/drivers/gpu/drm/drm_sysfs.c
>> +++ b/drivers/gpu/drm/drm_sysfs.c
>> @@ -236,16 +236,39 @@ static ssize_t modes_show(struct device *device,
>>  	return written;
>>  }
>>  
>> +static ssize_t mstpath_show(struct device *device,
>> +			    struct device_attribute *attr,
>> +			    char *buf)
>> +{
>> +	struct drm_connector *connector = to_drm_connector(device);
>> +	ssize_t ret = 0;
>> +	char *path;
>> +
>> +	mutex_lock(&connector->dev->mode_config.mutex);
> 
> The blob is populated when the connector is created so I don't think
> this lock is actually doing anything for us.

Right, will drop this.

> 
> One would also hope that device_unregister() protects us from racing
> with the removal of the attribute. Eg. if you hold a file descriptor
> open to the sysfs file does device_unregister() block until the fd is
> closed?

For dpcd transactions, as long as the aux device is unregistered through
drm_dp_aux_unregister_devnode(), we should be good. There's an atomic_t
use_count that syncs against reads and writes.

Although I'm not sure what would happen if the device was ripped out
from underneath us, say, if the parent connector device is removed
before calling aux_unregister_devnode(). If this does happen, I think
it's more of an order-of-operations issue from the driver. V2 of patch 2
(and 7-10) actually addresses a specific occurence of this during driver
unload.

Regarding sysfs attrs, the kernfs underneath does seem to guarantee that
any r/w is completed before removal. See kernfs_drain(), called as part
of kernfs_remove().

Leo

> 
>> +	if (!connector->path_blob_ptr)
>> +		goto unlock;
>> +
>> +	path = connector->path_blob_ptr->data;
>> +	ret = snprintf(buf, PAGE_SIZE, "card%d-%s\n",
>> +		       connector->dev->primary->index, path);
>> +
>> +unlock:
>> +	mutex_unlock(&connector->dev->mode_config.mutex);
>> +	return ret;
>> +}
>> +
>>  static DEVICE_ATTR_RW(status);
>>  static DEVICE_ATTR_RO(enabled);
>>  static DEVICE_ATTR_RO(dpms);
>>  static DEVICE_ATTR_RO(modes);
>> +static DEVICE_ATTR_RO(mstpath);
>>  
>>  static struct attribute *connector_dev_attrs[] = {
>>  	&dev_attr_status.attr,
>>  	&dev_attr_enabled.attr,
>>  	&dev_attr_dpms.attr,
>>  	&dev_attr_modes.attr,
>> +	&dev_attr_mstpath.attr,
>>  	NULL
>>  };
>>  
>> -- 
>> 2.22.0
> 
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2019-07-05 14:03 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-04 19:05 [PATCH 00/10] Enable MST Aux devices (v2) sunpeng.li-5C7GfCeVMHo
     [not found] ` <20190704190519.29525-1-sunpeng.li-5C7GfCeVMHo@public.gmane.org>
2019-07-04 19:05   ` [PATCH 01/10] drm/dp: Use non-cyclic idr sunpeng.li-5C7GfCeVMHo
2019-07-04 19:05   ` [PATCH 02/10] drm/dp_mst: Enable registration of AUX devices for MST ports (v2) sunpeng.li-5C7GfCeVMHo
     [not found]     ` <20190704190519.29525-3-sunpeng.li-5C7GfCeVMHo@public.gmane.org>
2019-07-10 19:51       ` Lyude Paul
2019-07-10 23:25     ` Lyude Paul
2019-07-04 19:05   ` [PATCH 04/10] drm/nouveau: Use connector kdev as aux device parent sunpeng.li-5C7GfCeVMHo
2019-07-12 19:55     ` Lyude Paul
2019-07-04 19:05   ` [PATCH 05/10] drm/bridge/analogix-anx78xx: " sunpeng.li-5C7GfCeVMHo
2019-07-04 19:05   ` [PATCH 06/10] drm/amd/display: " sunpeng.li-5C7GfCeVMHo
2019-07-04 19:05   ` [PATCH 07/10] drm/i915: Implement MST Aux device registration sunpeng.li-5C7GfCeVMHo
2019-07-10 10:06     ` Ville Syrjälä
2019-07-12 19:48     ` Lyude Paul
2019-07-12 20:05       ` Ville Syrjälä
     [not found]         ` <20190712200559.GN5942-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2019-07-12 20:15           ` Ville Syrjälä
2019-07-23 14:01             ` Li, Sun peng (Leo)
2019-07-04 19:05   ` [PATCH 08/10] drm/nouveau/kms/nv50: " sunpeng.li-5C7GfCeVMHo
2019-07-12 19:54     ` Lyude Paul
2019-07-04 19:05   ` [PATCH 09/10] drm/radeon: " sunpeng.li-5C7GfCeVMHo
2019-07-04 19:05   ` [PATCH 10/10] drm/amd/display: " sunpeng.li-5C7GfCeVMHo
2019-07-09 19:10   ` [PATCH 00/10] Enable MST Aux devices (v2) Li, Sun peng (Leo)
2019-07-04 19:05 ` [PATCH 03/10] drm/sysfs: Add mstpath attribute to connector devices sunpeng.li
     [not found]   ` <20190704190519.29525-4-sunpeng.li-5C7GfCeVMHo@public.gmane.org>
2019-07-04 19:33     ` Ville Syrjälä
2019-07-05 14:03       ` Li, Sun peng (Leo) [this message]
2019-07-05 14:32     ` [PATCH v2] " sunpeng.li-5C7GfCeVMHo
     [not found]       ` <20190705143220.11109-1-sunpeng.li-5C7GfCeVMHo@public.gmane.org>
2019-07-10 10:07         ` Ville Syrjälä
2019-07-10 22:50         ` Lyude Paul
     [not found]           ` <346980b73f3b1fbbc70cbf3771788cec0777d4c0.camel-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2019-07-16 18:28             ` Li, Sun peng (Leo)
2019-07-16 20:28               ` Lyude Paul

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=cfb3d588-e961-1d3b-be6b-d41069f5df03@amd.com \
    --to=sunpeng.li@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=ville.syrjala@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