All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Abhishek Pandit-Subedi <abhishekpandit@chromium.org>
Cc: heikki.krogerus@linux.intel.com, tzungbi@kernel.org,
	linux-usb@vger.kernel.org, chrome-platform@lists.linux.dev,
	jthies@google.com, akuchynski@google.com, pmalani@chromium.org,
	dmitry.baryshkov@linaro.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 3/7] usb: typec: Check port is active before enter mode on probe
Date: Fri, 8 Nov 2024 14:17:23 +0100	[thread overview]
Message-ID: <2024110849-bonded-flatten-5f5e@gregkh> (raw)
In-Reply-To: <20241107112955.v3.3.I439cffc7bf76d94f5850eb85980f1197c4f9154c@changeid>

On Thu, Nov 07, 2024 at 11:29:56AM -0800, Abhishek Pandit-Subedi wrote:
> Enforce the same requirement as when we attempt to activate altmode via
> sysfs (do not enter partner mode if port mode is not active). In order
> to set a default value for this field, also introduce the inactive field
> in struct typec_altmode_desc.
> 
> Signed-off-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org>
> ---
> 
> Changes in v3:
> - Use port.active instead of introducing auto-enter field
> - Introduce inactive field to typec_altmode_desc to set default value
>   for active.
> - Always make port 'active' field writable
> 
>  drivers/usb/typec/altmodes/displayport.c | 7 +++++--
>  drivers/usb/typec/altmodes/thunderbolt.c | 6 +++++-
>  drivers/usb/typec/class.c                | 5 +++--
>  include/linux/usb/typec.h                | 2 ++
>  4 files changed, 15 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/usb/typec/altmodes/displayport.c b/drivers/usb/typec/altmodes/displayport.c
> index 3245e03d59e6..f4116e96f6a1 100644
> --- a/drivers/usb/typec/altmodes/displayport.c
> +++ b/drivers/usb/typec/altmodes/displayport.c
> @@ -767,8 +767,11 @@ int dp_altmode_probe(struct typec_altmode *alt)
>  	if (plug)
>  		typec_altmode_set_drvdata(plug, dp);
>  
> -	dp->state = plug ? DP_STATE_ENTER_PRIME : DP_STATE_ENTER;
> -	schedule_work(&dp->work);
> +	/* Only attempt to enter altmode if port is active. */
> +	if (port->active) {
> +		dp->state = plug ? DP_STATE_ENTER_PRIME : DP_STATE_ENTER;
> +		schedule_work(&dp->work);
> +	}

What prevents active from changing right after you checked it?

> @@ -150,6 +151,7 @@ struct typec_altmode_desc {
>  	u32			vdo;
>  	/* Only used with ports */
>  	enum typec_port_data	roles;
> +	bool			inactive : 1;

A boolean bitfield?  That's not needed, please just do this properly.

thanks,

greg k-h

  parent reply	other threads:[~2024-11-08 13:17 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-07 19:29 [PATCH v3 0/7] Thunderbolt and DP altmode support for cros-ec-typec Abhishek Pandit-Subedi
2024-11-07 19:29 ` [PATCH v3 1/7] usb: typec: Only use SVID for matching altmodes Abhishek Pandit-Subedi
2024-11-08 11:41   ` Heikki Krogerus
2024-11-07 19:29 ` [PATCH v3 2/7] usb: typec: Add driver for Thunderbolt 3 Alternate Mode Abhishek Pandit-Subedi
2024-11-09  6:21   ` Dmitry Baryshkov
2024-11-14  3:51     ` Abhishek Pandit-Subedi
2024-11-22 18:50   ` Benson Leung
2024-12-06 22:27     ` Abhishek Pandit-Subedi
2024-11-07 19:29 ` [PATCH v3 3/7] usb: typec: Check port is active before enter mode on probe Abhishek Pandit-Subedi
2024-11-08 12:21   ` Heikki Krogerus
2024-11-08 13:17   ` Greg Kroah-Hartman [this message]
2024-11-08 18:28     ` Abhishek Pandit-Subedi
2024-11-07 19:29 ` [PATCH v3 4/7] platform/chrome: cros_ec_typec: Update partner altmode active Abhishek Pandit-Subedi
2024-11-07 19:29 ` [PATCH v3 5/7] platform/chrome: cros_ec_typec: Displayport support Abhishek Pandit-Subedi
2024-11-09  6:38   ` Dmitry Baryshkov
2024-11-14  4:13     ` Abhishek Pandit-Subedi
2024-11-12  0:16   ` Benson Leung
2024-11-07 19:29 ` [PATCH v3 6/7] platform/chrome: cros_ec_typec: Thunderbolt support Abhishek Pandit-Subedi
2024-11-09  6:41   ` Dmitry Baryshkov
2024-11-14  4:01     ` Abhishek Pandit-Subedi
2024-11-14 10:55       ` Dmitry Baryshkov
2024-12-06 22:23         ` Abhishek Pandit-Subedi
2024-12-06 23:30           ` Dmitry Baryshkov
2024-11-07 19:30 ` [PATCH v3 7/7] platform/chrome: cros_ec_typec: Disable tbt on port Abhishek Pandit-Subedi

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=2024110849-bonded-flatten-5f5e@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=abhishekpandit@chromium.org \
    --cc=akuchynski@google.com \
    --cc=chrome-platform@lists.linux.dev \
    --cc=dmitry.baryshkov@linaro.org \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=jthies@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=pmalani@chromium.org \
    --cc=tzungbi@kernel.org \
    /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.