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]
Message-ID: <CANFp7mXCChVFaQHiW_RCu_97BnPHc5qHs=E6WcGRGLUEniZieA@mail.gmail.com>
Date: Fri, 13 Dec 2024 10:01:04 -0800
From: Abhishek Pandit-Subedi <abhishekpandit@...omium.org>
To: Stephen Boyd <swboyd@...omium.org>
Cc: chrome-platform@...ts.linux.dev, heikki.krogerus@...ux.intel.com, 
	linux-usb@...r.kernel.org, tzungbi@...nel.org, akuchynski@...gle.com, 
	pmalani@...omium.org, jthies@...gle.com, dmitry.baryshkov@...aro.org, 
	badhri@...gle.com, rdbabiera@...gle.com, Benson Leung <bleung@...omium.org>, 
	Guenter Roeck <groeck@...omium.org>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v4 4/7] platform/chrome: cros_ec_typec: Update partner
 altmode active

On Tue, Dec 10, 2024 at 3:32 PM Stephen Boyd <swboyd@...omium.org> wrote:
>
> Quoting Abhishek Pandit-Subedi (2024-12-06 15:38:15)
> > diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c
> > index c7781aea0b88..e3eabe5e42ac 100644
> > --- a/drivers/platform/chrome/cros_ec_typec.c
> > +++ b/drivers/platform/chrome/cros_ec_typec.c
> > @@ -676,6 +677,16 @@ static int cros_typec_configure_mux(struct cros_typec_data *typec, int port_num,
> >                         port->mux_flags);
> >         }
> >
> > +       /* Iterate all partner alt-modes and set the active alternate mode. */
> > +       list_for_each_entry_safe(node, n, &port->partner_mode_list, list) {
>
> This can just be list_for_each_entry() because the list isn't changing
> during iteration.
Done

>
> > +               if (port->state.alt != NULL &&
> > +                   node->amode->svid == port->state.alt->svid) {
> > +                       typec_altmode_update_active(node->amode, true);
> > +               } else {
> > +                       typec_altmode_update_active(node->amode, false);
> > +               }
>
> It could also be shorter:
>
>         list_for_each_entry(node, &port->partner_mode_list, list) {
>                 typec_altmode_update_active(node->amode,
>                         port->state.alt && node->amode->svid == port->state.alt->svid);
>         }
Done

>
> As far as I can tell, cros_typec_configure_mux() is called when the HPD
> state changes. We'll iterate through here unnecessarily in that case.
> Can that be avoided somehow?
Writing the same value to `typec_altmode_update_active` is a no-op.
I'd prefer to leave this code as-is since it's quite simple (having to
determine HPD vs non-HPD, whether DP is currently active, etc. is
going to be more work than it saves from not calling this loop).

>
> > +
> >  mux_ack:
> >         if (!typec->needs_mux_ack)
> >                 return ret;

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ