All of lore.kernel.org
 help / color / mirror / Atom feed
From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: Greg KH <gregkh@linuxfoundation.org>
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
	Mathias Nyman <mathias.nyman@linux.intel.com>,
	Felipe Balbi <balbi@kernel.org>
Subject: Re: [PATCH 1/3] usb: USB Type-C Connector Class
Date: Thu, 11 Feb 2016 16:07:20 +0200	[thread overview]
Message-ID: <20160211140720.GB32213@kuha.fi.intel.com> (raw)
In-Reply-To: <20160210172619.GB28335@kroah.com>

On Wed, Feb 10, 2016 at 09:26:19AM -0800, Greg KH wrote:
> On Wed, Feb 10, 2016 at 12:38:40PM +0200, Heikki Krogerus wrote:
> > > And what is userspace going to do with these files?  Why does it care?
> > 
> > The OS policy regarding USB Type-C ports needs to come from user
> > space.
> 
> What drives this "need"?
> 
> > The user must be allowed to select the USB data role, and when
> > USB PD is supported, also the power role, and at the same time we need
> > to export all the relevant information about the USB Type-C ports to
> > the user space, like connection status, the type of partner etc. And
> > all that from a single interface.
> 
> Again, what drives this "need" to be in a "single interface"?

Because the alternative is that every platform will have a custom way
of doing these things.. With the single interface I mean the class.
If we don't present USB Type-C ports to the userspace from a unified
interface, how can anybody create userspace software to support
control of USB Type-C ports? Or can we accept that we will always need
platform specific user space software if we want to control the USB
Type-C ports?

In case you are still skeptical about why userspace would need any
interaction with the USB Type-C ports, think about the following use
case: You plug what you think is something that will charge your
phone, nothing is printed on the screen - we don't now get any details
about the parter - but we must be charging, right? After a while you
realize that you are not charging, instead the thing you plugged in is
actually draining you phone of power? This will happen if the partner
happens to be for example..
1) Accessory
2) Alternate Mode that we enter successfully, so no Billboard Device.
3) Both our device and the partner are DRP and we end up being the
   host initially.

Nothing bad has happened in this example, but it's horrible user
experience.

> > I'm pretty sure that this is exactly what distributions like Ubuntu,
> > RedHat etc. want, an I know for fact that Chrome OS and Android will
> > expect the user to be in control over the roles and get that
> > information about the ports one way or the other.
> 
> Given that ChromeOS and Android already do this type of thing today, why
> not work with those developers to ensure that this really is the
> interface they want / expect?

I'm in contact with some Android developers, but Android is a bit
frustrating. I know the absolute minimum about the world of Android,
but the way it looks to me is that everybody is doing their own thing.
The expectations about things also vary from company to company.
Maybe there is a forum somewhere that I'm not aware of?

I'm pretty sure ChromeOS is going to be different. I'll try to make
some contacts there.

> > > > The data_role, power_role and alternate_mode are also
> > > > writable and can be used for executing role swapping and
> > > > entering modes. When USB PD is not supported by the
> > > > connector or partner, power_role will reflect the value of
> > > > the data_role, and is not swappable independently.
> > > 
> > > How does this implementation differ from those in other drivers that we
> > > have seen, but not submitted for merging?  I'm referring to the code
> > > from Fairchild for their USB Type C driver:
> > > 	https://github.com/gregkh/fusb30x
> > > and the driver that is in the latest Nexus 6 Android release (don't have
> > > the link to the android kernel tree at the moment sorry, but it's public
> > > and I think Linaro is working on cleaning it up...)
> > 
> > That would be USB PD stack and driver for fusb30x USB Type-C/PD PHYs.
> > It's the second USB PD stack I've seen (and sadly also second driver
> > for fusb30x), but I just know there are more.
> 
> Oh, there's more than just 2 drivers for that fusb30x chip floating
> around.  My repo is not the latest version and it's a truly horrid piece
> of code, never to be run on any hardware you actually care about power
> as it doesn't care.
> 
> > My class is just about exporting control of USB Type-C ports to the
> > user space, and note, USB Type-C *not* USB PD. I don't thing that my
> > little class and the USB PD stack, where ever it ends up coming from,
> > conflict with each other.
> 
> But we need to ensure that it doesn't conflict, and given that you are
> already using the same directory those stacks are using, perhaps you can
> look at them to see that you aren't duplicating any work?

Well, in case of that fusb30x driver, there definitely is no conflict
if there really is no interaction with the userspace. They would just
never register with this class.

But there really should never be any conflict between USB Type-C and
USB PD. For USB Type-C connectors USB PD is just an optional "library"
that can have the following functions and nothing else:

1) DR_Swap - Data Role swap
2) PR_Swap - Power Role swap
2) VCONN_Swap - VCONN Source swap
3) Discover SVIDs - Alternate Modes
3) Discover Modes - The actual modes under SVID
4) Enter Mode
4) Exit Mode

So those functions will always be the same. From Type-C point of view
it really makes no difference how they have actually been implemented
(in software, PD controller, firmware, etc).

> > The only difference is that I'm clearly separating USB Type-C from USB
> > PD (and actually everything else), which is the correct thing to do.
> > USB Type-C is not the same thing as USB PD. USB Type-C does not always
> > come with USB PD.
> 
> I agree, keeping them separate seems good, but I worry when you have to
> do both how that is going to look.

I'm fairly certain that we can make the Type-C part good. It's so
straight forward. I'm more worried about USB PD.

I'm a bit skeptical about whether it will even be possible to create a
stack that works for every type of USB PD thingy out there. For cases
where there is just the PHY like fusb30x, the PD stack will be made
completely in software. That we can (maybe) handle. Also cases where
we have a complex USB PD controller that handles all layers starting
from protocol, we will be able to handle, as with them the stack is not
needed at all. Even the simple USB PD controllers that take care of
protocol layer (completely) but leave the policy layers to the
software, we will be able to handle. The problem comes from the USB PD
controller and PHYs that fall somewhere in-between. The ones that
implement "partial" protocol layer and "partial" policy engine, or
consist of several components, or..

..I have to stop there. I just vomited in my mouth a little. I fear
USB PD can end up being a little bit like USB Charging (Felipe can
tell more about that) except many times worse! Maybe we need to start
thinking about the ground rules when somebody adds the PD stack, like
you can use only complete parts of stack and never try to mix your
oddities into it, otherwise you have to implement everything from
scratch for your particular platform, etc.

Perhaps things are not as bad as I fear, but let's just make sure
Type-C is always separate from USB PD!

> > I did not go through that code, but I'm guessing the guys have for
> > example exported similar role swapping controls to user space from
> > some part of their stack. So those guys would just need to register
> > their fusb30x with this class, let the class take care of exporting
> > those controls and probable continue using their USB PD stack exactly
> > like they have done before.
> 
> the fusb30x code does it all within kernel space, no userspace
> interactions needed due to timing requirements (so they say).  I'm not
> saying that this is a good idea / design, just that I'm getting
> conflicting requirements from different camps at the moment and it's
> really hard to sort it all out :(

I think there must have been some misunderstanding. We really have to
interact with the userspace with USB Type-C ports.


Thanks,

-- 
heikki

  reply	other threads:[~2016-02-11 14:08 UTC|newest]

Thread overview: 90+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-09 17:01 [PATCH 0/3] usb: USB Type-C Class and driver for UCSI Heikki Krogerus
2016-02-09 17:01 ` [PATCH 1/3] usb: USB Type-C Connector Class Heikki Krogerus
2016-02-09 18:20   ` Greg KH
2016-02-10 10:38     ` Heikki Krogerus
2016-02-10 17:26       ` Greg KH
2016-02-11 14:07         ` Heikki Krogerus [this message]
2016-02-10 10:49   ` Oliver Neukum
2016-02-10 11:05     ` Andy Shevchenko
2016-02-10 11:11       ` Heikki Krogerus
2016-02-10 11:14         ` Andy Shevchenko
2016-02-10 11:23     ` Heikki Krogerus
2016-02-15 15:16       ` Oliver Neukum
2016-02-11  8:55     ` Felipe Balbi
2016-02-11  9:08       ` Oliver Neukum
2016-02-11 14:51         ` Heikki Krogerus
2016-02-11 14:36       ` Heikki Krogerus
2016-02-11 14:56         ` Oliver Neukum
2016-02-17 14:07   ` Oliver Neukum
2016-02-18  8:47     ` Heikki Krogerus
2016-02-18  9:21       ` Oliver Neukum
2016-02-18 13:09         ` Heikki Krogerus
2016-02-18  9:35       ` Oliver Neukum
2016-02-18 13:25         ` Heikki Krogerus
2016-02-18 13:44           ` Oliver Neukum
2016-02-18 15:13             ` Heikki Krogerus
2016-02-26 13:09             ` Heikki Krogerus
2016-02-09 17:01 ` [PATCH 2/3] usb: type-c: USB Type-C Connector System Software Interface Heikki Krogerus
2016-02-09 18:21   ` Greg KH
2016-02-10 10:30     ` Heikki Krogerus
2016-02-10 17:20       ` Greg KH
2016-02-11 13:50         ` Heikki Krogerus
2016-02-15 15:30           ` Oliver Neukum
2016-02-16  9:22             ` Heikki Krogerus
2016-02-16 13:39               ` Oliver Neukum
2016-02-17  7:58                 ` Heikki Krogerus
2016-02-17  9:03                   ` Oliver Neukum
2016-02-17 10:29                     ` Felipe Balbi
2016-02-17 10:36                       ` Oliver Neukum
2016-02-17 11:11                         ` Heikki Krogerus
2016-02-17 13:36                           ` Felipe Balbi
2016-02-17 14:28                             ` Heikki Krogerus
2016-02-18  9:07                               ` Peter Chen
2016-02-18 10:44                                 ` Heikki Krogerus
2016-02-18 10:37                               ` Rajaram R
2016-02-18 10:47                                 ` Heikki Krogerus
2016-02-18 11:06                                   ` Rajaram R
2016-02-17 13:34                         ` Felipe Balbi
2016-02-17 13:51                           ` Oliver Neukum
2016-02-18  7:08                             ` Felipe Balbi
2016-02-18 10:18                               ` Oliver Neukum
2016-02-18 10:30                                 ` Felipe Balbi
2016-02-18 10:40                                   ` Oliver Neukum
2016-02-18  9:29       ` Peter Chen
2016-02-18  9:44         ` Oliver Neukum
2016-02-10 11:19   ` Oliver Neukum
2016-02-10 12:04     ` Heikki Krogerus
2016-02-10 11:56   ` Andy Shevchenko
2016-02-10 13:21     ` Oliver Neukum
2016-02-10 14:02       ` Andy Shevchenko
2016-02-10 15:11         ` Bjørn Mork
2016-02-11  8:26           ` Andy Shevchenko
2016-02-11  8:59             ` Bjørn Mork
2016-02-10 14:15     ` Oliver Neukum
2016-02-10 14:24       ` Andy Shevchenko
2016-02-10 15:08         ` Oliver Neukum
     [not found]           ` <CAHp75VfmGsskf7Cmni3b4=tCbkPsR8d3jPYiv93Lm6DM9gq1-g@mail.gmail.com>
2016-02-11  8:13             ` Fwd: " Andy Shevchenko
2016-02-11 14:10               ` Heikki Krogerus
2016-02-10 13:04   ` Oliver Neukum
2016-02-11 14:08     ` Heikki Krogerus
2016-02-09 17:01 ` [PATCH 3/3] usb: type-c: UCSI ACPI driver Heikki Krogerus
2016-02-09 18:22   ` Greg KH
2016-02-10 10:23     ` Heikki Krogerus
2016-02-17 18:53 ` [PATCH 0/3] usb: USB Type-C Class and driver for UCSI Oliver Neukum
2016-02-18  9:21   ` Heikki Krogerus
2016-02-17 19:34 ` Rajaram R
2016-02-18 11:05   ` Heikki Krogerus
2016-02-18 11:15     ` Oliver Neukum
2016-05-05  3:05 ` Guenter Roeck
2016-05-06  6:50   ` Felipe Balbi
2016-05-06  8:05     ` Guenter Roeck
2016-05-06  8:29       ` Heikki Krogerus
2016-05-06 14:10         ` Guenter Roeck
2016-05-06  8:23     ` Heikki Krogerus
2016-05-06  8:08   ` Heikki Krogerus
2016-05-06 14:08     ` Guenter Roeck
2016-05-11  3:14     ` Guenter Roeck
2016-05-11  9:40       ` Heikki Krogerus
2016-05-11 14:47         ` Guenter Roeck
2016-05-13 14:23           ` Heikki Krogerus
2016-05-13 17:48             ` Guenter Roeck

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=20160211140720.GB32213@kuha.fi.intel.com \
    --to=heikki.krogerus@linux.intel.com \
    --cc=balbi@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mathias.nyman@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 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.