mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Wesley Cheng <quic_wcheng@quicinc.com>
To: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>,
	<srinivas.kandagatla@linaro.org>, <mathias.nyman@intel.com>,
	<perex@perex.cz>, <conor+dt@kernel.org>,
	<dmitry.torokhov@gmail.com>, <corbet@lwn.net>,
	<broonie@kernel.org>, <lgirdwood@gmail.com>, <tiwai@suse.com>,
	<krzk+dt@kernel.org>, <Thinh.Nguyen@synopsys.com>,
	<bgoswami@quicinc.com>, <robh@kernel.org>,
	<gregkh@linuxfoundation.org>
Cc: <linux-kernel@vger.kernel.org>, <devicetree@vger.kernel.org>,
	<linux-sound@vger.kernel.org>, <linux-usb@vger.kernel.org>,
	<linux-input@vger.kernel.org>, <linux-arm-msm@vger.kernel.org>,
	<linux-doc@vger.kernel.org>, <alsa-devel@alsa-project.org>,
	Mathias Nyman <mathias.nyman@linux.intel.com>
Subject: Re: [PATCH v25 01/33] xhci: add helper to stop endpoint and wait for completion
Date: Mon, 26 Aug 2024 08:11:43 -0700	[thread overview]
Message-ID: <5459c1bc-33eb-41ad-b290-3d40bb5b81fe@quicinc.com> (raw)
In-Reply-To: <9f25b900-ae1c-41af-a380-ac5e00860283@linux.intel.com>

Hi Pierre,

On 8/26/2024 1:48 AM, Pierre-Louis Bossart wrote:
>
> On 8/23/24 22:00, Wesley Cheng wrote:
>> From: Mathias Nyman <mathias.nyman@linux.intel.com>
>>
>> Expose xhci_stop_endpoint_sync() which is a synchronous variant of
>> xhci_queue_stop_endpoint().  This is useful for client drivers that are
>> using the secondary interrupters, and need to stop/clean up the current
>> session.  The stop endpoint command handler will also take care of cleaning
>> up the ring.
>>
>> Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
>> Signed-off-by: Wesley Cheng <quic_wcheng@quicinc.com>
>> ---
>>  drivers/usb/host/xhci.c | 39 +++++++++++++++++++++++++++++++++++++++
>>  drivers/usb/host/xhci.h |  2 ++
>>  2 files changed, 41 insertions(+)
>>
>> diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
>> index 37eb37b0affa..3a051ed32907 100644
>> --- a/drivers/usb/host/xhci.c
>> +++ b/drivers/usb/host/xhci.c
>> @@ -2784,6 +2784,45 @@ static int xhci_reserve_bandwidth(struct xhci_hcd *xhci,
>>  	return -ENOMEM;
>>  }
>>  
>> +/*
>> + * Synchronous XHCI stop endpoint helper.  Issues the stop endpoint command and
>> + * waits for the command completion before returning.
>> + */
>> +int xhci_stop_endpoint_sync(struct xhci_hcd *xhci, struct xhci_virt_ep *ep, int suspend,
>> +			    gfp_t gfp_flags)
>> +{
>> +	struct xhci_command *command;
>> +	unsigned long flags;
>> +	int ret;
>> +
>> +	command = xhci_alloc_command(xhci, true, gfp_flags);
>> +	if (!command)
>> +		return -ENOMEM;
>> +
>> +	spin_lock_irqsave(&xhci->lock, flags);
>> +	ret = xhci_queue_stop_endpoint(xhci, command, ep->vdev->slot_id,
>> +				       ep->ep_index, suspend);
>> +	if (ret < 0) {
>> +		spin_unlock_irqrestore(&xhci->lock, flags);
>> +		goto out;
>> +	}
>> +
>> +	xhci_ring_cmd_db(xhci);
>> +	spin_unlock_irqrestore(&xhci->lock, flags);
>> +
>> +	wait_for_completion(command->completion);
>> +
>> +	if (command->status == COMP_COMMAND_ABORTED ||
>> +	    command->status == COMP_COMMAND_RING_STOPPED) {
>> +		xhci_warn(xhci, "Timeout while waiting for stop endpoint command\n");
> nit-pick: is this really a timeout? In that case you would have used
> wait_for_completion_timeout(), no?

With respects to the xHCI command implementation, every time a command is queued to the host controller, it arms timer (xhci->cmd_timer) that is used to handle the timeout conditions.  This is the reason for not using the _timeout() variant, as we can let the xHCI command timeout handler do the cleanup and stopping of the HCD. (marking as dead)  It will also ensure that any completion events are completed as part of the timeout handler as well (xhci_handle_command_timeout() --> xhci_abort_cmd_ring())

Thanks

Wesley Cheng

>> +		ret = -ETIME;
>> +	}
>> +out:
>> +	xhci_free_command(xhci, command);
>> +
>> +	return ret;
>> +}
>> +EXPORT_SYMBOL_GPL(xhci_stop_endpoint_sync);
>>  
>>  /* Issue a configure endpoint command or evaluate context command
>>   * and wait for it to finish.
>> diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
>> index 30415158ed3c..1c6126ed55b0 100644
>> --- a/drivers/usb/host/xhci.h
>> +++ b/drivers/usb/host/xhci.h
>> @@ -1914,6 +1914,8 @@ void xhci_ring_doorbell_for_active_rings(struct xhci_hcd *xhci,
>>  void xhci_cleanup_command_queue(struct xhci_hcd *xhci);
>>  void inc_deq(struct xhci_hcd *xhci, struct xhci_ring *ring);
>>  unsigned int count_trbs(u64 addr, u64 len);
>> +int xhci_stop_endpoint_sync(struct xhci_hcd *xhci, struct xhci_virt_ep *ep,
>> +			    int suspend, gfp_t gfp_flags);
>>  
>>  /* xHCI roothub code */
>>  void xhci_set_link_state(struct xhci_hcd *xhci, struct xhci_port *port,

  reply	other threads:[~2024-08-26 15:12 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-23 20:00 [PATCH v25 00/33] Introduce QC USB SND audio offloading support Wesley Cheng
2024-08-23 20:00 ` [PATCH v25 01/33] xhci: add helper to stop endpoint and wait for completion Wesley Cheng
2024-08-26  8:48   ` Pierre-Louis Bossart
2024-08-26 15:11     ` Wesley Cheng [this message]
2024-08-23 20:00 ` [PATCH v25 02/33] usb: host: xhci: Repurpose event handler for skipping interrupter events Wesley Cheng
2024-08-23 20:00 ` [PATCH v25 03/33] xhci: sideband: add initial api to register a sideband entity Wesley Cheng
2024-08-23 20:00 ` [PATCH v25 04/33] usb: xhci: Allow for secondary interrupter to set IMOD Wesley Cheng
2024-08-23 20:00 ` [PATCH v25 05/33] usb: host: xhci-mem: Cleanup pending secondary event ring events Wesley Cheng
2024-08-23 20:00 ` [PATCH v25 06/33] usb: host: xhci-mem: Allow for interrupter clients to choose specific index Wesley Cheng
2024-08-23 20:00 ` [PATCH v25 07/33] usb: host: xhci-plat: Set XHCI max interrupters if property is present Wesley Cheng
2024-08-23 20:00 ` [PATCH v25 08/33] usb: dwc3: Specify maximum number of XHCI interrupters Wesley Cheng
2024-08-23 20:00 ` [PATCH v25 09/33] ALSA: Add USB audio device jack type Wesley Cheng
2024-08-23 20:00 ` [PATCH v25 10/33] ALSA: usb-audio: Export USB SND APIs for modules Wesley Cheng
2024-08-23 20:00 ` [PATCH v25 11/33] ALSA: usb-audio: Check for support for requested audio format Wesley Cheng
2024-08-23 20:00 ` [PATCH v25 12/33] ASoC: Add SOC USB APIs for adding an USB backend Wesley Cheng
2024-08-23 20:00 ` [PATCH v25 13/33] ASoC: usb: Add PCM format check API for " Wesley Cheng
2024-08-23 20:00 ` [PATCH v25 14/33] ASoC: usb: Create SOC USB SND jack kcontrol Wesley Cheng
2024-08-23 20:00 ` [PATCH v25 15/33] ASoC: usb: Fetch ASoC card and pcm device information Wesley Cheng
2024-08-23 20:00 ` [PATCH v25 16/33] ASoC: doc: Add documentation for SOC USB Wesley Cheng
2024-08-23 20:00 ` [PATCH v25 17/33] ASoC: dt-bindings: qcom,q6dsp-lpass-ports: Add USB_RX port Wesley Cheng
2024-08-23 20:00 ` [PATCH v25 18/33] ASoC: dt-bindings: Update example for enabling USB offload on SM8250 Wesley Cheng
2024-08-23 20:00 ` [PATCH v25 19/33] ASoC: qcom: qdsp6: Introduce USB AFE port to q6dsp Wesley Cheng
2024-08-23 20:00 ` [PATCH v25 20/33] ASoC: qcom: qdsp6: q6afe: Increase APR timeout Wesley Cheng
2024-08-23 20:00 ` [PATCH v25 21/33] ASoC: qcom: qdsp6: Add USB backend ASoC driver for Q6 Wesley Cheng
2024-08-23 20:00 ` [PATCH v25 22/33] ASoC: qcom: qdsp6: Add headphone jack for offload connection status Wesley Cheng
2024-08-23 20:00 ` [PATCH v25 23/33] ASoC: qcom: qdsp6: Fetch USB offload mapped card and PCM device Wesley Cheng
2024-08-23 20:00 ` [PATCH v25 24/33] ALSA: usb-audio: Introduce USB SND platform op callbacks Wesley Cheng
2024-08-23 20:00 ` [PATCH v25 25/33] ALSA: usb-audio: Save UAC sample size information Wesley Cheng
2024-08-23 20:00 ` [PATCH v25 26/33] ALSA: usb-audio: Prevent starting of audio stream if in use Wesley Cheng
2024-08-23 20:00 ` [PATCH v25 27/33] ALSA: usb-audio: qcom: Add USB QMI definitions Wesley Cheng
2024-08-23 20:00 ` [PATCH v25 28/33] ALSA: usb-audio: qcom: Introduce QC USB SND offloading support Wesley Cheng
2024-08-23 20:00 ` [PATCH v25 29/33] ALSA: usb-audio: qcom: Don't allow USB offload path if PCM device is in use Wesley Cheng
2024-08-23 20:00 ` [PATCH v25 30/33] ALSA: usb-audio: qcom: Use card and PCM index from QMI request Wesley Cheng
2024-08-23 20:00 ` [PATCH v25 31/33] ALSA: usb-audio: Add USB offload route kcontrol Wesley Cheng
2024-08-26  9:09   ` Pierre-Louis Bossart
2024-08-28 18:59     ` Wesley Cheng
2024-08-23 20:01 ` [PATCH v25 32/33] ALSA: usb-audio: Allow for rediscovery of connected USB SND devices Wesley Cheng
2024-08-23 20:01 ` [PATCH v25 33/33] ASoC: usb: Rediscover USB SND devices on USB port add Wesley Cheng
2024-08-26  9:28 ` [PATCH v25 00/33] Introduce QC USB SND audio offloading support Pierre-Louis Bossart
2024-08-28 19:00   ` Wesley Cheng

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=5459c1bc-33eb-41ad-b290-3d40bb5b81fe@quicinc.com \
    --to=quic_wcheng@quicinc.com \
    --cc=Thinh.Nguyen@synopsys.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=bgoswami@quicinc.com \
    --cc=broonie@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=corbet@lwn.net \
    --cc=devicetree@vger.kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=krzk+dt@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mathias.nyman@intel.com \
    --cc=mathias.nyman@linux.intel.com \
    --cc=perex@perex.cz \
    --cc=pierre-louis.bossart@linux.intel.com \
    --cc=robh@kernel.org \
    --cc=srinivas.kandagatla@linaro.org \
    --cc=tiwai@suse.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®