lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Sat, 10 Sep 2016 07:19:32 +1000
From:   NeilBrown <neilb@...e.com>
To:     Baolin Wang <baolin.wang@...aro.org>
Cc:     NeilBrown <nfbrown@...ell.com>, Felipe Balbi <balbi@...nel.org>,
        Greg KH <gregkh@...uxfoundation.org>,
        Sebastian Reichel <sre@...nel.org>,
        Dmitry Eremin-Solenikov <dbaryshkov@...il.com>,
        David Woodhouse <dwmw2@...radead.org>, robh@...nel.org,
        Jun Li <jun.li@....com>,
        Marek Szyprowski <m.szyprowski@...sung.com>,
        Ruslan Bilovol <ruslan.bilovol@...il.com>,
        Peter Chen <peter.chen@...escale.com>,
        Alan Stern <stern@...land.harvard.edu>, r.baldyga@...sung.com,
        grygorii.strashko@...com,
        Yoshihiro Shimoda <yoshihiro.shimoda.uh@...esas.com>,
        Lee Jones <lee.jones@...aro.org>,
        Mark Brown <broonie@...nel.org>,
        Charles Keepax <ckeepax@...nsource.wolfsonmicro.com>,
        patches@...nsource.wolfsonmicro.com,
        Linux PM list <linux-pm@...r.kernel.org>,
        USB <linux-usb@...r.kernel.org>,
        device-mainlining@...ts.linuxfoundation.org,
        LKML <linux-kernel@...r.kernel.org>,
        "Bird\, Timothy" <Tim.Bird@...sony.com>
Subject: Re: [PATCH v16 0/4] Introduce usb charger framework to deal with the usb gadget power negotation

On Fri, Sep 09 2016, Baolin Wang wrote:

>>
>> In practice, the USB PHY and the Power manager will often be in the same
>> IC (the PMIC) so the driver for one could look at the registers for the
>> other.
>> But there is no guarantee that the hardware works like that.  It is
>> best to create a generally design.
>
> Yes, we hope to create one generally design, so we need to consider
> this situation: the power supply getting the charger type by accessing
> PMIC registers. The registers which save the charger type are not
> always belong to the USB PHY, may be just some registers on PMIC.

If the power_supply can directly detect the type of charger, then it
doesn't need any usb-charger-infrastructure to tell it.  It can handle
current selection entirely internally.
Surely the only interesting case for a framework to address is the one
where the power_supply cannot directly detect the charger type.

>
> Now in mainline kernel, there are 3 methods can get the charger type
> which need to integrate with USB charger framework:
> 1. power supply
> 2. extcon (need to add as you suggested)
> 3. others (by 'get_charger_type' callback of USB charger)

There is no "get_charger_type" now in the mainline kernel.

>>>
>>> Suppose the USB configuration requests 100mA, then we should set the
>>> USB charger current is 100mA by __usb_charger_set_cur_limit_by_type()
>>> funtion, then notify this to power driver.
>>
>> ahh.... I had missed something there.  It's a while since I looked
>> closely at these patches.
>>
>> Only.... this usage of usb_charger_set_cur_limit_by_type() is really
>> nonsensical.
>>
>> If the cable is detected as being DCP or CDP or ACA (or ACA/DOCK) then
>> the number negotiated with the USB configuration is not relevant and
>> should be ignored.  There is a guaranteed minimum which is at least the
>> maximum that *can* be negotiated.
>
> Yes. If it is not relevant, we will no't set the current from USB
> configuration. Just when your charger type is SDP and the USB
> enumeration is done, we can get the USB configuration from host to set
> current.

But you do!
The mA number from the USB configuration is passed to usb_gadget_vbus_draw.
Your patch passes that to usb_charger_set_cur_limit_by_type()
which calls __usb_charger_set_cur_limit_by_type() which will set the
cur_limit for whichever type uchger->type currently is.

So when it is not relevant, your code *does* set some current limit.

NeilBrown

Download attachment "signature.asc" of type "application/pgp-signature" (801 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ