Linux-USB Archive on lore.kernel.org
 help / color / Atom feed
From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: Guenter Roeck <linux@roeck-us.net>
Cc: Hans de Goede <hdegoede@redhat.com>, linux-usb@vger.kernel.org
Subject: Re: [PATCH 1/7] usb: typec: Copy everything from struct typec_capability during registration
Date: Thu, 3 Oct 2019 16:29:01 +0300
Message-ID: <20191003132901.GB1048@kuha.fi.intel.com> (raw)
In-Reply-To: <58ec0c7e-10b5-2a73-0629-abb2bddba469@roeck-us.net>

On Wed, Oct 02, 2019 at 08:51:32PM -0700, Guenter Roeck wrote:
> On 10/2/19 12:16 PM, Heikki Krogerus wrote:
> > On Wed, Oct 02, 2019 at 07:06:55PM +0300, Heikki Krogerus wrote:
> > > This is a bit off topic, but that attribute file is really horrible.
> > > Right now there is no way to know the actual capability of the
> > > port in user space. If something changes a DRP port into sink or
> > > source, there is no way to know after that that the port is actually
> > > DRP capable.
> > 
> > That statement is not correct. I'm sorry. I don't know why did I put
> > it that way.
> > 
> > I wanted to say that now the userpsace is forced to keep track of a
> > specific sysfs file in order to be sure of the currently supported
> > role, That alone is wrong, but there is no way to guarantee that
> > one day we would not need to support another capability in a similar
> > fashion, and that would mean another sysfs file, and we just forced
> > the userspace to be modified. The capabilities of the port really need
> > to be static.
> > 
> 
> I assume you refer to port_type. If I remember correctly, this is actually
> used by Android userspace code to specifically select if a port can be
> source, sink, or drp. I am not sure if it is a good idea to enforce
> port removal and re-registration in conjunction with this - the port
> can, after all, be connected to some storage device or to a monitor.
> I am not sure how we could "sell" to users the idea that if they change
> the port type, their screen will go dark for a few seconds.
> 
> Am I missing something ?

I'm not sure how can you avoid flickering screen even with the current
port_type sysfs flag? If you change the port type, you will reset the
port, which means you have to also re-enter the altmode again, no? If
so, then does unregistering and registering the ports actually make
that much difference from the users perspective?

But why do you need the supported roles to be changed when there is
already a partner device plugged to the connector? What is the
use-case/requirement here?

One note about my proposal: With my proposal the userspace can be
given the possibility to influence the port capabilities even before
the ports have been registered. I would imagine that should cover at
least some of the requirements.

The major problem here is that we can not guarantee how the ports
behave if the supported roles are changed when a device is already
plugged to the connector (don't forget, we are not always using
tcpm.c). With UCSI at least it really depends on the underlying
firmware implementation. It also creates risks for the user, like
writing "sink" to that port_type and ending up with a black screen,
and I mean permanently black screen. Un-plugging and re-plugging the
monitor back will not help. Only changing the port_type again, or
reboot work.

Ideally we should not allow the capabilities to be changed after the
partner device is already registered at all, but if we really have to
allow it, then I still think we should do it the way I proposed.

thanks,

> Thanks,
> Guenter
> 
> > We can handle the capability changes like I propose below without
> > affecting the userspace.
> > 
> > > So that ABI is "buggy", but even without the problem, I still really
> > > think that allowing the capabilities to be changed like that in
> > > general is completely wrong. I don't have a problem with changing the
> > > capabilities, but IMO it should be handled at one level higher, at the
> > > controller device level. If the capabilities of a port need to be
> > > changed, the old port should be removed, and a new with the new
> > > capabilities registered. That is the only way to handle it without
> > > making things unnecessarily difficult for the user space.
> > > 
> > > I'm pretty sure that that was my counter proposal already at the time
> > > when the attribute file was introduced, but I don't remember why
> > > wasn't it accepted at the time? My protest against adding that
> > > attribute file was in any case ignored :-(. In any case, my plan was
> > > to later propose a new sysfs group that we offer to the parent
> > > controller devices instead assigning it to the port devices, and that
> > > group is meant to allow port capability changes the way I explained
> > > above. Unless of course you are against it?
> > > 
> > > thanks,
> > > 
> > > -- 
> > > heikki
> > 

-- 
heikki

  reply index

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-01  9:48 [PATCH 0/7] usb: typec: Small API improvement Heikki Krogerus
2019-10-01  9:48 ` [PATCH 1/7] usb: typec: Copy everything from struct typec_capability during registration Heikki Krogerus
2019-10-01 13:08   ` Guenter Roeck
2019-10-02 16:06     ` Heikki Krogerus
2019-10-02 16:36       ` Guenter Roeck
2019-10-02 18:29         ` Heikki Krogerus
2019-10-03  3:45           ` Guenter Roeck
2019-10-03  8:03             ` Heikki Krogerus
2019-10-02 19:16       ` Heikki Krogerus
2019-10-03  3:51         ` Guenter Roeck
2019-10-03 13:29           ` Heikki Krogerus [this message]
2019-10-01  9:48 ` [PATCH 2/7] usb: typec: Introduce typec_get_drvdata() Heikki Krogerus
2019-10-01  9:48 ` [PATCH 3/7] usb: typec: Separate the operations vector Heikki Krogerus
2019-10-01 13:22   ` Guenter Roeck
2019-10-04  8:45     ` Heikki Krogerus
2019-10-01  9:48 ` [PATCH 4/7] usb: typec: tcpm: Start using struct typec_operations Heikki Krogerus
2019-10-01 13:30   ` Guenter Roeck
2019-10-04  8:46     ` Heikki Krogerus
2019-10-01  9:48 ` [PATCH 5/7] usb: typec: tps6598x: " Heikki Krogerus
2019-10-01 13:34   ` Guenter Roeck
2019-10-01 13:35   ` Guenter Roeck
2019-10-04  8:49     ` Heikki Krogerus
2019-10-01  9:48 ` [PATCH 6/7] usb: typec: ucsi: " Heikki Krogerus
2019-10-01 13:35   ` Guenter Roeck
2019-10-01  9:48 ` [PATCH 7/7] usb: typec: Remove the callback members from struct typec_capability Heikki Krogerus
2019-10-01 13:37   ` Guenter Roeck

Reply instructions:

You may reply publically 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=20191003132901.GB1048@kuha.fi.intel.com \
    --to=heikki.krogerus@linux.intel.com \
    --cc=hdegoede@redhat.com \
    --cc=linux-usb@vger.kernel.org \
    --cc=linux@roeck-us.net \
    /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

Linux-USB Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-usb/0 linux-usb/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-usb linux-usb/ https://lore.kernel.org/linux-usb \
		linux-usb@vger.kernel.org
	public-inbox-index linux-usb

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-usb


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git