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 Dec 2022 09:36:28 -0800
From:   Badhri Jagan Sridharan <badhri@...gle.com>
To:     Guenter Roeck <linux@...ck-us.net>
Cc:     Heikki Krogerus <heikki.krogerus@...ux.intel.com>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        linux-usb@...r.kernel.org, linux-kernel@...r.kernel.org,
        Kyle Tso <kyletso@...gle.com>
Subject: Re: [PATCH v9 2/3] usb: typec: tcpci: Add callback for evaluating
 contaminant presence

On Sat, Dec 10, 2022 at 8:08 AM Guenter Roeck <linux@...ck-us.net> wrote:
>
> On 12/9/22 22:16, Badhri Jagan Sridharan wrote:
> > This change adds callback to evaluate presence of contaminant in
> > the TCPCI layer.
> >
> > Signed-off-by: Badhri Jagan Sridharan <badhri@...gle.com>
> > ---
> > Changes since v7:
> > * None. Skipped versions by mistake.
> > Changes since v6:
> > * Removed is_potential_contaminant callback
> > Changes since v5:
> > * None
> > Changes since v4:
> > * None
> > Changes since v3:
> > * None
> > Changes since v2:
> > * Added tcpci_is_potential_contaminant to offload
> > * disconnect_while_debounce logic
> > ---
> >   drivers/usb/typec/tcpm/tcpci.c | 9 +++++++++
> >   include/linux/usb/tcpci.h      | 7 +++++++
> >   2 files changed, 16 insertions(+)
> >
> > diff --git a/drivers/usb/typec/tcpm/tcpci.c b/drivers/usb/typec/tcpm/tcpci.c
> > index fe781a38dc82..c8e78c13c9c4 100644
> > --- a/drivers/usb/typec/tcpm/tcpci.c
> > +++ b/drivers/usb/typec/tcpm/tcpci.c
> > @@ -403,6 +403,14 @@ static void tcpci_frs_sourcing_vbus(struct tcpc_dev *dev)
> >               tcpci->data->frs_sourcing_vbus(tcpci, tcpci->data);
> >   }
> >
> > +static void tcpci_check_contaminant(struct tcpc_dev *dev)
> > +{
> > +     struct tcpci *tcpci = tcpc_to_tcpci(dev);
> > +
> > +     if (tcpci->data->check_contaminant)
> > +             tcpci->data->check_contaminant(tcpci, tcpci->data);
> > +}
> > +
>
> With this callback to tcpm in place, how does tcpm ever leave the
> CHECK_CONTAMINANT state if the low level driver does not support
> the callback ?

Ah ! Good point.. I will fix it by installing the callback only when
the lower level driver implements check_contaminant.
Let me know if you think it wouldn't work.

--- a/drivers/usb/typec/tcpm/tcpci.c
+++ b/drivers/usb/typec/tcpm/tcpci.c
@@ -785,7 +785,9 @@ struct tcpci *tcpci_register_port(struct device
*dev, struct tcpci_data *data)
        tcpci->tcpc.enable_frs = tcpci_enable_frs;
        tcpci->tcpc.frs_sourcing_vbus = tcpci_frs_sourcing_vbus;
        tcpci->tcpc.set_partner_usb_comm_capable =
tcpci_set_partner_usb_comm_capable;
-       tcpci->tcpc.check_contaminant = tcpci_check_contaminant;
+
+       if (tcpci->data->check_contaminant)
+               tcpci->tcpc.check_contaminant = tcpci_check_contaminant;

Thanks,
Badhri

>
> Thanks,
> Guenter
>
>
> >   static int tcpci_set_bist_data(struct tcpc_dev *tcpc, bool enable)
> >   {
> >       struct tcpci *tcpci = tcpc_to_tcpci(tcpc);
> > @@ -777,6 +785,7 @@ struct tcpci *tcpci_register_port(struct device *dev, struct tcpci_data *data)
> >       tcpci->tcpc.enable_frs = tcpci_enable_frs;
> >       tcpci->tcpc.frs_sourcing_vbus = tcpci_frs_sourcing_vbus;
> >       tcpci->tcpc.set_partner_usb_comm_capable = tcpci_set_partner_usb_comm_capable;
> > +     tcpci->tcpc.check_contaminant = tcpci_check_contaminant;
> >
> >       if (tcpci->data->auto_discharge_disconnect) {
> >               tcpci->tcpc.enable_auto_vbus_discharge = tcpci_enable_auto_vbus_discharge;
> > diff --git a/include/linux/usb/tcpci.h b/include/linux/usb/tcpci.h
> > index 17657451c762..85e95a3251d3 100644
> > --- a/include/linux/usb/tcpci.h
> > +++ b/include/linux/usb/tcpci.h
> > @@ -188,6 +188,12 @@ struct tcpci;
> >    *          Optional; The USB Communications Capable bit indicates if port
> >    *          partner is capable of communication over the USB data lines
> >    *          (e.g. D+/- or SS Tx/Rx). Called to notify the status of the bit.
> > + * @check_contaminant:
> > + *           Optional; The callback is invoked when chiplevel drivers indicated
> > + *           that the USB port needs to be checked for contaminant presence.
> > + *           Chip level drivers are expected to check for contaminant and call
> > + *           tcpm_clean_port when the port is clean to put the port back into
> > + *           toggling state.
> >    */
> >   struct tcpci_data {
> >       struct regmap *regmap;
> > @@ -204,6 +210,7 @@ struct tcpci_data {
> >       void (*frs_sourcing_vbus)(struct tcpci *tcpci, struct tcpci_data *data);
> >       void (*set_partner_usb_comm_capable)(struct tcpci *tcpci, struct tcpci_data *data,
> >                                            bool capable);
> > +     void (*check_contaminant)(struct tcpci *tcpci, struct tcpci_data *data);
> >   };
> >
> >   struct tcpci *tcpci_register_port(struct device *dev, struct tcpci_data *data);
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ