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:   Wed, 16 Oct 2019 12:24:55 +0300
From:   Roger Quadros <rogerq@...com>
To:     John Stultz <john.stultz@...aro.org>,
        Felipe Balbi <balbi@...nel.org>
CC:     lkml <linux-kernel@...r.kernel.org>, Yu Chen <chenyu56@...wei.com>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Rob Herring <robh+dt@...nel.org>,
        Mark Rutland <mark.rutland@....com>,
        Heikki Krogerus <heikki.krogerus@...ux.intel.com>,
        Suzuki K Poulose <suzuki.poulose@....com>,
        Chunfeng Yun <chunfeng.yun@...iatek.com>,
        Hans de Goede <hdegoede@...hat.com>,
        Andy Shevchenko <andy.shevchenko@...il.com>,
        Jun Li <lijun.kernel@...il.com>,
        Valentin Schneider <valentin.schneider@....com>,
        Linux USB List <linux-usb@...r.kernel.org>,
        "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" 
        <devicetree@...r.kernel.org>
Subject: Re: [RFC][PATCH 3/3] usb: dwc3: Registering a role switch in the DRD
 code.

On 15/10/2019 22:10, John Stultz wrote:
> On Tue, Oct 15, 2019 at 1:25 AM Roger Quadros <rogerq@...com> wrote:
>> On 03/10/2019 02:16, John Stultz wrote:
>>> @@ -487,7 +539,28 @@ int dwc3_drd_init(struct dwc3 *dwc)
>>>        if (IS_ERR(dwc->edev))
>>>                return PTR_ERR(dwc->edev);
>>>
>>> -     if (dwc->edev) {
>>> +     if (device_property_read_bool(dwc->dev, "usb-role-switch")) {
>>
>> I think we should use role switch unconditionally and get rid of the
>> debugfs role status/change mechanism.
>>
>>> +             struct usb_role_switch_desc dwc3_role_switch = {0};
>>> +             u32 mode;
>>> +
>>> +             if (device_property_read_bool(dwc->dev,
>>> +                                           "role-switch-default-host")) {
>>> +                     dwc->role_switch_default_mode = USB_DR_MODE_HOST;
>>> +                     mode = DWC3_GCTL_PRTCAP_HOST;
>>> +             } else {
>>> +                     dwc->role_switch_default_mode = USB_DR_MODE_PERIPHERAL;
>>> +                     mode = DWC3_GCTL_PRTCAP_DEVICE;
>>> +             }
>>> +             dwc3_role_switch.fwnode = dev_fwnode(dwc->dev);
>>> +             dwc3_role_switch.set = dwc3_usb_role_switch_set;
>>> +             dwc3_role_switch.get = dwc3_usb_role_switch_get;
>>> +             dwc->role_sw = usb_role_switch_register(dwc->dev,
>>> +                                                     &dwc3_role_switch);
>>> +             if (IS_ERR(dwc->role_sw))
>>> +                     return PTR_ERR(dwc->role_sw);
>>> +
>>> +             dwc3_set_mode(dwc, mode);
>>> +     } else if (dwc->edev) {
>>
>> Role switch should exist regardless if dwc->edev is present or not.
> 
> Does that risk duplicative mode sets when things change (via the
> dwc3_drd_notifier and dwc3_usb_role_switch_set calls?).

Yes, we need to deal with it in the driver. e.g. in current case
when debugfs overrides a role from "otg" to "host" or "device",
we ignore the notifier.

Something similar could be done with role switch I think.

Felipe, what do you think?

-- 
cheers,
-roger
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ