From patchwork Thu Sep 5 14:32:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mathias Nyman X-Patchwork-Id: 13792453 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B53B638C for ; Thu, 5 Sep 2024 14:31:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.7 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725546677; cv=none; b=huGud3E02cCq1J2udIyeiDYh5D89+T+3rkU8qMO5R7yiGaM3LhEZ5Dp0GCqjROs73+F2AcVQEl1bsIp8/jKhAVE2d2YyFghpNszl7eS95XuTHy5+BGCu+J3TDLlVKghqrOGJeWQX0qrFbwkfTP6b1ScWkbpYfpl28NKUE2cvR1A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725546677; c=relaxed/simple; bh=pDwJdKWkZugJSCbH7fXH5UfPQhEL4bGy+BdU2B/CM4I=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=r6bqvhuVc+dV+jlhCJr560YT5rT1ykcM89QB5OKM98gqmVIH2L1dRRlR/jaNmUD/Rjb4KHM+gPga+SMaYlsM+d4DEgetRtczcP5D0oq2nWkzK82yWSwIIu5htvLqbwwWjQBX+SfJBuO3/52bHXOkEUy4sFs43wBX+mZV5oKkcMQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Ev1sF0Qn; arc=none smtp.client-ip=192.198.163.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Ev1sF0Qn" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1725546676; x=1757082676; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=pDwJdKWkZugJSCbH7fXH5UfPQhEL4bGy+BdU2B/CM4I=; b=Ev1sF0Qn6Hk3tamfvfo+05vIZzXCkpE5idkQspA2lcE7Jg7MCaRJqL3O o1kGzwha8mW8ciMVYacjosRO9eMPSAPNGpzXMLOyNbbOV1eMsAxFHDYez jPTb0Wv4XS9AUh0LEMjKfyZMFs5aXPUCBZlC+Lc1tBIYYqZeOzbHE51d5 FlwawVy2OT8H6KUbzaJN2VYcXZ5MjG0rfzBOTUIWWIcoeUe4GKJ61QNn7 XQjh7fiD/ufKtDeHQ+Ul/vymWV3XvTsbdvnvOxoGBECRQEJVmtieQSE/1 4HLjGWZyOJzWLEv3FdQB8cbcfLL8RwfHeDjlFJ8TdriOOmmBucknx0EOS g==; X-CSE-ConnectionGUID: cqtSDjLbSAy+vmPp2/POXg== X-CSE-MsgGUID: tgacE4KtTf2AUKIUlX/e1g== X-IronPort-AV: E=McAfee;i="6700,10204,11186"; a="49677492" X-IronPort-AV: E=Sophos;i="6.10,205,1719903600"; d="scan'208";a="49677492" Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Sep 2024 07:31:15 -0700 X-CSE-ConnectionGUID: zNs9I29aQXGga4N5vLMlfQ== X-CSE-MsgGUID: WhVD6AAEQUOLc/gXpuMDOA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,205,1719903600"; d="scan'208";a="88883213" Received: from mattu-haswell.fi.intel.com ([10.237.72.199]) by fmviesa002.fm.intel.com with ESMTP; 05 Sep 2024 07:31:13 -0700 From: Mathias Nyman To: Cc: , Mathias Nyman , =?utf-8?q?=C5=81ukasz_Bartos?= =?utf-8?q?ik?= Subject: [PATCH 01/12] xhci: dbc: Fix STALL transfer event handling Date: Thu, 5 Sep 2024 17:32:49 +0300 Message-Id: <20240905143300.1959279-2-mathias.nyman@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240905143300.1959279-1-mathias.nyman@linux.intel.com> References: <20240905143300.1959279-1-mathias.nyman@linux.intel.com> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Don't flush all pending DbC data requests when an endpoint halts. An endpoint may halt and xHC DbC triggers a STALL error event if there's an issue with a bulk data transfer. The transfer should restart once xHC DbC receives a ClearFeature(ENDPOINT_HALT) request from the host. Once xHC DbC restarts it will start from the TRB pointed to by dequeue field in the endpoint context, which might be the same TRB we got the STALL event for. Turn the TRB to a no-op in this case to make sure xHC DbC doesn't reuse and tries to retransmit this same TRB after we already handled it, and gave its corresponding data request back. Other STALL events might be completely bogus. Lukasz Bartosik discovered that xHC DbC might issue spurious STALL events if hosts sends a ClearFeature(ENDPOINT_HALT) request to non-halted endpoints even without any active bulk transfers. Assume STALL event is spurious if it reports 0 bytes transferred, and the endpoint stopped on the STALLED TRB. Don't give back the data request corresponding to the TRB in this case. The halted status is per endpoint. Track it with a per endpoint flag instead of the driver invented DbC wide DS_STALLED state. DbC remains in DbC-Configured state even if endpoints halt. There is no Stalled state in the DbC Port state Machine (xhci section 7.6.6) Reported-by: Łukasz Bartosik Closes: https://lore.kernel.org/linux-usb/20240725074857.623299-1-ukaszb@chromium.org/ Tested-by: Łukasz Bartosik Signed-off-by: Mathias Nyman --- drivers/usb/host/xhci-dbgcap.c | 133 ++++++++++++++++++++------------- drivers/usb/host/xhci-dbgcap.h | 2 +- 2 files changed, 83 insertions(+), 52 deletions(-) diff --git a/drivers/usb/host/xhci-dbgcap.c b/drivers/usb/host/xhci-dbgcap.c index 161c09953c4e..241d7aa1fbc2 100644 --- a/drivers/usb/host/xhci-dbgcap.c +++ b/drivers/usb/host/xhci-dbgcap.c @@ -173,16 +173,18 @@ static void xhci_dbc_giveback(struct dbc_request *req, int status) spin_lock(&dbc->lock); } -static void xhci_dbc_flush_single_request(struct dbc_request *req) +static void trb_to_noop(union xhci_trb *trb) { - union xhci_trb *trb = req->trb; - trb->generic.field[0] = 0; trb->generic.field[1] = 0; trb->generic.field[2] = 0; trb->generic.field[3] &= cpu_to_le32(TRB_CYCLE); trb->generic.field[3] |= cpu_to_le32(TRB_TYPE(TRB_TR_NOOP)); +} +static void xhci_dbc_flush_single_request(struct dbc_request *req) +{ + trb_to_noop(req->trb); xhci_dbc_giveback(req, -ESHUTDOWN); } @@ -649,7 +651,6 @@ static void xhci_dbc_stop(struct xhci_dbc *dbc) case DS_DISABLED: return; case DS_CONFIGURED: - case DS_STALLED: if (dbc->driver->disconnect) dbc->driver->disconnect(dbc); break; @@ -669,6 +670,23 @@ static void xhci_dbc_stop(struct xhci_dbc *dbc) pm_runtime_put_sync(dbc->dev); /* note, was self.controller */ } +static void +handle_ep_halt_changes(struct xhci_dbc *dbc, struct dbc_ep *dep, bool halted) +{ + if (halted) { + dev_info(dbc->dev, "DbC Endpoint halted\n"); + dep->halted = 1; + + } else if (dep->halted) { + dev_info(dbc->dev, "DbC Endpoint halt cleared\n"); + dep->halted = 0; + + if (!list_empty(&dep->list_pending)) + writel(DBC_DOOR_BELL_TARGET(dep->direction), + &dbc->regs->doorbell); + } +} + static void dbc_handle_port_status(struct xhci_dbc *dbc, union xhci_trb *event) { @@ -697,6 +715,7 @@ static void dbc_handle_xfer_event(struct xhci_dbc *dbc, union xhci_trb *event) struct xhci_ring *ring; int ep_id; int status; + struct xhci_ep_ctx *ep_ctx; u32 comp_code; size_t remain_length; struct dbc_request *req = NULL, *r; @@ -706,8 +725,30 @@ static void dbc_handle_xfer_event(struct xhci_dbc *dbc, union xhci_trb *event) ep_id = TRB_TO_EP_ID(le32_to_cpu(event->generic.field[3])); dep = (ep_id == EPID_OUT) ? get_out_ep(dbc) : get_in_ep(dbc); + ep_ctx = (ep_id == EPID_OUT) ? + dbc_bulkout_ctx(dbc) : dbc_bulkin_ctx(dbc); ring = dep->ring; + /* Match the pending request: */ + list_for_each_entry(r, &dep->list_pending, list_pending) { + if (r->trb_dma == event->trans_event.buffer) { + req = r; + break; + } + if (r->status == -COMP_STALL_ERROR) { + dev_warn(dbc->dev, "Give back stale stalled req\n"); + ring->num_trbs_free++; + xhci_dbc_giveback(r, 0); + } + } + + if (!req) { + dev_warn(dbc->dev, "no matched request\n"); + return; + } + + trace_xhci_dbc_handle_transfer(ring, &req->trb->generic); + switch (comp_code) { case COMP_SUCCESS: remain_length = 0; @@ -718,31 +759,49 @@ static void dbc_handle_xfer_event(struct xhci_dbc *dbc, union xhci_trb *event) case COMP_TRB_ERROR: case COMP_BABBLE_DETECTED_ERROR: case COMP_USB_TRANSACTION_ERROR: - case COMP_STALL_ERROR: dev_warn(dbc->dev, "tx error %d detected\n", comp_code); status = -comp_code; break; + case COMP_STALL_ERROR: + dev_warn(dbc->dev, "Stall error at bulk TRB %llx, remaining %zu, ep deq %llx\n", + event->trans_event.buffer, remain_length, ep_ctx->deq); + status = 0; + dep->halted = 1; + + /* + * xHC DbC may trigger a STALL bulk xfer event when host sends a + * ClearFeature(ENDPOINT_HALT) request even if there wasn't an + * active bulk transfer. + * + * Don't give back this transfer request as hardware will later + * start processing TRBs starting from this 'STALLED' TRB, + * causing TRBs and requests to be out of sync. + * + * If STALL event shows some bytes were transferred then assume + * it's an actual transfer issue and give back the request. + * In this case mark the TRB as No-Op to avoid hw from using the + * TRB again. + */ + + if ((ep_ctx->deq & ~TRB_CYCLE) == event->trans_event.buffer) { + dev_dbg(dbc->dev, "Ep stopped on Stalled TRB\n"); + if (remain_length == req->length) { + dev_dbg(dbc->dev, "Spurious stall event, keep req\n"); + req->status = -COMP_STALL_ERROR; + req->actual = 0; + return; + } + dev_dbg(dbc->dev, "Give back stalled req, but turn TRB to No-op\n"); + trb_to_noop(req->trb); + } + break; + default: dev_err(dbc->dev, "unknown tx error %d\n", comp_code); status = -comp_code; break; } - /* Match the pending request: */ - list_for_each_entry(r, &dep->list_pending, list_pending) { - if (r->trb_dma == event->trans_event.buffer) { - req = r; - break; - } - } - - if (!req) { - dev_warn(dbc->dev, "no matched request\n"); - return; - } - - trace_xhci_dbc_handle_transfer(ring, &req->trb->generic); - ring->num_trbs_free++; req->actual = req->length - remain_length; xhci_dbc_giveback(req, status); @@ -762,7 +821,6 @@ static void inc_evt_deq(struct xhci_ring *ring) static enum evtreturn xhci_dbc_do_handle_events(struct xhci_dbc *dbc) { dma_addr_t deq; - struct dbc_ep *dep; union xhci_trb *evt; u32 ctrl, portsc; bool update_erdp = false; @@ -814,43 +872,17 @@ static enum evtreturn xhci_dbc_do_handle_events(struct xhci_dbc *dbc) return EVT_DISC; } - /* Handle endpoint stall event: */ + /* Check and handle changes in endpoint halt status */ ctrl = readl(&dbc->regs->control); - if ((ctrl & DBC_CTRL_HALT_IN_TR) || - (ctrl & DBC_CTRL_HALT_OUT_TR)) { - dev_info(dbc->dev, "DbC Endpoint stall\n"); - dbc->state = DS_STALLED; - - if (ctrl & DBC_CTRL_HALT_IN_TR) { - dep = get_in_ep(dbc); - xhci_dbc_flush_endpoint_requests(dep); - } - - if (ctrl & DBC_CTRL_HALT_OUT_TR) { - dep = get_out_ep(dbc); - xhci_dbc_flush_endpoint_requests(dep); - } - - return EVT_DONE; - } + handle_ep_halt_changes(dbc, get_in_ep(dbc), ctrl & DBC_CTRL_HALT_IN_TR); + handle_ep_halt_changes(dbc, get_out_ep(dbc), ctrl & DBC_CTRL_HALT_OUT_TR); /* Clear DbC run change bit: */ if (ctrl & DBC_CTRL_DBC_RUN_CHANGE) { writel(ctrl, &dbc->regs->control); ctrl = readl(&dbc->regs->control); } - break; - case DS_STALLED: - ctrl = readl(&dbc->regs->control); - if (!(ctrl & DBC_CTRL_HALT_IN_TR) && - !(ctrl & DBC_CTRL_HALT_OUT_TR) && - (ctrl & DBC_CTRL_DBC_RUN)) { - dbc->state = DS_CONFIGURED; - break; - } - - return EVT_DONE; default: dev_err(dbc->dev, "Unknown DbC state %d\n", dbc->state); break; @@ -939,7 +971,6 @@ static const char * const dbc_state_strings[DS_MAX] = { [DS_ENABLED] = "enabled", [DS_CONNECTED] = "connected", [DS_CONFIGURED] = "configured", - [DS_STALLED] = "stalled", }; static ssize_t dbc_show(struct device *dev, diff --git a/drivers/usb/host/xhci-dbgcap.h b/drivers/usb/host/xhci-dbgcap.h index 0118c6288a3c..97c5dc290138 100644 --- a/drivers/usb/host/xhci-dbgcap.h +++ b/drivers/usb/host/xhci-dbgcap.h @@ -81,7 +81,6 @@ enum dbc_state { DS_ENABLED, DS_CONNECTED, DS_CONFIGURED, - DS_STALLED, DS_MAX }; @@ -90,6 +89,7 @@ struct dbc_ep { struct list_head list_pending; struct xhci_ring *ring; unsigned int direction:1; + unsigned int halted:1; }; #define DBC_QUEUE_SIZE 16 From patchwork Thu Sep 5 14:32:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathias Nyman X-Patchwork-Id: 13792454 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 916EB10A1F for ; Thu, 5 Sep 2024 14:31:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.7 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725546678; cv=none; b=aDIV1n3dPncEP0VzkZXV+htdcXHCm9xWT9cdHMBAKLF+VIPGsoGcL5Tj50KyZ/IhYKowhXcAWCYYyRPicv5ovBoGgfeJa7K33Jfbq8i0d+twR4C76vZv6h9CIVdcemUmD4rBBxWs9CVp8exMc0Mg3QPqL7QCRHIJvVYw8yO8luk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725546678; c=relaxed/simple; bh=CLucGv1pavS/wLejQmnD5HY67vRpdNogchfIfuY5Qzc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Ouw0j68g2PL2jhjIhO/EeIUu9FixefQ6rzLdV/M89Of37nQzNB90IadV3uYbsaidormhFflkZR0zNOec+kHpNgoojv1FztB3A6pW92g+Mp2BrwPHbMb/129yxQikXOBqI1LTLVgfRuzyffbPOyEOUEZYnNowR5uegxRo8OtCQ9s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=G4qjorFU; arc=none smtp.client-ip=192.198.163.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="G4qjorFU" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1725546677; x=1757082677; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=CLucGv1pavS/wLejQmnD5HY67vRpdNogchfIfuY5Qzc=; b=G4qjorFUe2ZyP521TjPxLU/ZIrNEeICC6KJGJCx7WHInyDc0YXoGIG3T frQF9zEflkjfgWfAZ3m+CzfSqiUGIXTGDp0M7TOjPz96mIcGpN6KthTTa P2dwY6gJhoaMgTecjqAl8g5E5G5HltiVQYidbjG8bKnKhpvthj8fSPu4j eh+TryPpFsC+xlMSLcLDd4xK1vIk0uNCvJw3wrrlS/rnhGnJL9eHozzv3 mf8T2/KNISXFv5IHylNh+Vg9CjwhC4Yf1/Ob4YtWepMqHQT0vliiMyFie ErvciKRmupKuYVuK/vDzOep5GhV+hjKX/Fp8jJdFVrYmkmEpFY2DVoE9M w==; X-CSE-ConnectionGUID: OOhyL3iuR4il+95GtbSR4g== X-CSE-MsgGUID: GY1aayP6TiiDh8ICuwUxvg== X-IronPort-AV: E=McAfee;i="6700,10204,11186"; a="49677499" X-IronPort-AV: E=Sophos;i="6.10,205,1719903600"; d="scan'208";a="49677499" Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Sep 2024 07:31:16 -0700 X-CSE-ConnectionGUID: MccVbFa5SSOSDUFNx8pl2A== X-CSE-MsgGUID: 8ZAOLlRDTN2HrHWArE3EHA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,205,1719903600"; d="scan'208";a="88883214" Received: from mattu-haswell.fi.intel.com ([10.237.72.199]) by fmviesa002.fm.intel.com with ESMTP; 05 Sep 2024 07:31:15 -0700 From: Mathias Nyman To: Cc: , Mathias Nyman Subject: [PATCH 02/12] xhci: dbc: add dbgtty request to end of list once it completes Date: Thu, 5 Sep 2024 17:32:50 +0300 Message-Id: <20240905143300.1959279-3-mathias.nyman@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240905143300.1959279-1-mathias.nyman@linux.intel.com> References: <20240905143300.1959279-1-mathias.nyman@linux.intel.com> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Make sure we move the requests from the read_queue to the end of the read_pool list, avoiding looping and using the same one request all the time. Signed-off-by: Mathias Nyman --- drivers/usb/host/xhci-dbgtty.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/host/xhci-dbgtty.c b/drivers/usb/host/xhci-dbgtty.c index b74e98e94393..5e567b3eb4d9 100644 --- a/drivers/usb/host/xhci-dbgtty.c +++ b/drivers/usb/host/xhci-dbgtty.c @@ -346,7 +346,7 @@ static void dbc_rx_push(struct tasklet_struct *t) port->n_read = 0; } - list_move(&req->list_pool, &port->read_pool); + list_move_tail(&req->list_pool, &port->read_pool); } if (do_push) From patchwork Thu Sep 5 14:32:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathias Nyman X-Patchwork-Id: 13792455 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0A52A171AF for ; Thu, 5 Sep 2024 14:31:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.7 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725546680; cv=none; b=jFJe+mTsM/B6ZGJwZ7FJ7w5Nq2mnINMlklPr9k3IcIFzbQ/VXOr1XvY2ZesFhhXkFqzpIwjMRviq8kWvWaZu4QHuASRwGbSuxXxDZSBJVhIeXLeAbeslA1u85GX5kzSkIiGlYJqad0HzQX+mtez7QFpsSDTWKwJhCjtZSzDVmKI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725546680; c=relaxed/simple; bh=mOyvzH86quUGn1zroWBj1Drw6Y+UGpsCxFWlBatQ7lM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=GMiwjQQ6YCpKCRubfkA0LI/YJOg2gWye9bZ9pSyOl+jz1wiM/SM97d83a35mBwJmvilZd2tsohczUb20eygIjdsYpJtUzOmPJhgc5Vd5zCwSEhyUmlhvnDhYE/I14ephYphdyLCyWU9Qxjlfm8f+dKpTOZ13gV0x8ED0RhHcxHU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=iF7pbz1s; arc=none smtp.client-ip=192.198.163.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="iF7pbz1s" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1725546679; x=1757082679; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=mOyvzH86quUGn1zroWBj1Drw6Y+UGpsCxFWlBatQ7lM=; b=iF7pbz1sDitwkZ0e+IUqG+mjb1YhVgPuEIBOYAzI/23LGvKDnvcl6siK AifoG3tRZk4Gkkfy9qEf0VRZwgII2ovng0c869b5yaJNfn2yDC1cWDUU+ pOYEqRvC01RHrCmnIgQXdRJcB1lSzxcb1eV2u9kcOWCx5Hv5fD6dxYqyY qsV3jPEDExu0jWytCtvuHlQ+0lwZfg6SumK8zMNk7YHsNT/4AMPlmDl1E nX8c3BQTNEu/7xQnu6MB/5ll4H+EVl/YYEj24qisbZ171lGfmkC3LqZfU JNCEe85Ibaj5VIjH+icENrzTf4Ew7tZnKl4q6wCQWjitBxvnVnvuIxn2/ Q==; X-CSE-ConnectionGUID: QwAwgFqiR+WI1IGNeLr3SA== X-CSE-MsgGUID: +hJpq5ixThGtbnzJNGclPg== X-IronPort-AV: E=McAfee;i="6700,10204,11186"; a="49677502" X-IronPort-AV: E=Sophos;i="6.10,205,1719903600"; d="scan'208";a="49677502" Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Sep 2024 07:31:18 -0700 X-CSE-ConnectionGUID: /CPv48lpQGCXg0RD9e/mNA== X-CSE-MsgGUID: qmcJz1oYQIGa+RIK5q6xew== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,205,1719903600"; d="scan'208";a="88883216" Received: from mattu-haswell.fi.intel.com ([10.237.72.199]) by fmviesa002.fm.intel.com with ESMTP; 05 Sep 2024 07:31:16 -0700 From: Mathias Nyman To: Cc: , Yue Haibing , Mathias Nyman Subject: [PATCH 03/12] xhci: Remove unused function declarations Date: Thu, 5 Sep 2024 17:32:51 +0300 Message-Id: <20240905143300.1959279-4-mathias.nyman@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240905143300.1959279-1-mathias.nyman@linux.intel.com> References: <20240905143300.1959279-1-mathias.nyman@linux.intel.com> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Yue Haibing Commit 674f8438c121 ("xhci: split handling halted endpoints into two steps") removed xhci_cleanup_stalled_ring() but left declaration. Commit 25355e046d29 ("xhci: use generic command timer for stop endpoint commands.") left behind xhci_stop_endpoint_command_watchdog(). Signed-off-by: Yue Haibing Signed-off-by: Mathias Nyman --- drivers/usb/host/xhci.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index 40aebdfb37c9..ae4b50b01284 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h @@ -1904,10 +1904,6 @@ int xhci_queue_reset_ep(struct xhci_hcd *xhci, struct xhci_command *cmd, enum xhci_ep_reset_type reset_type); int xhci_queue_reset_device(struct xhci_hcd *xhci, struct xhci_command *cmd, u32 slot_id); -void xhci_cleanup_stalled_ring(struct xhci_hcd *xhci, unsigned int slot_id, - unsigned int ep_index, unsigned int stream_id, - struct xhci_td *td); -void xhci_stop_endpoint_command_watchdog(struct timer_list *t); void xhci_handle_command_timeout(struct work_struct *work); void xhci_ring_ep_doorbell(struct xhci_hcd *xhci, unsigned int slot_id, From patchwork Thu Sep 5 14:32:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathias Nyman X-Patchwork-Id: 13792456 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6561110A1F for ; Thu, 5 Sep 2024 14:31:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.7 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725546681; cv=none; b=dJeMgv87i1GDW599NwVi6HWADGs10Mhc4eaOxliuKYgvPCmRPeS1Tt45d+BWKsouFTKUB/AH3kU56a06I1tKvSE2wy7v5vsRuSfoh8QKI9NkfmulCyPO2Vme7gTcTQJGegSP4ZVBFvNfQpM40DoOav0K+EIwSRJLv7z8fTJ4dRM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725546681; c=relaxed/simple; bh=BbVf7oWdTnzRs3XA1mUNCBp6/6M5uPjXTuF6D+ZFuPY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=rhrzNwFbuOweTDGFAMW3AkIJXKSYqODm5htDJLdiTz2WOJrhi0qOAAfiWslTuJcvNgqRZMjE4ulKPcLOkdu24TDTkHjUcGbFNywBsPqRAvOrWv1/VD9TWWMQg6A/EwO/VvilcuNxJ9Pd9JZXvuJoW+05JinCL/4dcRxsLNluGmQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=MKh5OYXf; arc=none smtp.client-ip=192.198.163.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="MKh5OYXf" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1725546680; x=1757082680; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=BbVf7oWdTnzRs3XA1mUNCBp6/6M5uPjXTuF6D+ZFuPY=; b=MKh5OYXfinE5OdnnZTnOtaW3pmaHqcPPZ8v2p/QZdy58kviWMV37lbjO YnC/TH1wRqCNTMTY/jUD8olNng8iV7OyezXBHTT/1FCTVF54o76WNfu/a 1Cyyrf2qBYQHmKtXVbvI3nUpfMyJL+IynHhTtdkgJNMV+HgdnQ1DOoz8Z M8ghijmESXUmsFSKXM86INXCPwrqb6g36osdzhQgJAHIEvtE2f58oqSof HAXjcGMa/ZDVTyEPsxBWJR/aIfmWoGJ9v78F4Jma9qtnehka61ZhYpRXJ YxbjV7EzvgpLc7qRyZn3sxSq3FMwYFHxG3WrzKPLex9hNgUL7yewLyvXp Q==; X-CSE-ConnectionGUID: uhrQnCPoQb+t22KNIA9xlA== X-CSE-MsgGUID: Du1vl8KgROu+DxYLO7JOsg== X-IronPort-AV: E=McAfee;i="6700,10204,11186"; a="49677506" X-IronPort-AV: E=Sophos;i="6.10,205,1719903600"; d="scan'208";a="49677506" Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Sep 2024 07:31:20 -0700 X-CSE-ConnectionGUID: xMcfDAZASQmNwGLqmw/9Yg== X-CSE-MsgGUID: XBHv+OOVQIOUXXOxWykn3g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,205,1719903600"; d="scan'208";a="88883218" Received: from mattu-haswell.fi.intel.com ([10.237.72.199]) by fmviesa002.fm.intel.com with ESMTP; 05 Sep 2024 07:31:18 -0700 From: Mathias Nyman To: Cc: , Niklas Neronin , Mathias Nyman Subject: [PATCH 04/12] usb: xhci: remove excessive isoc frame debug message spam Date: Thu, 5 Sep 2024 17:32:52 +0300 Message-Id: <20240905143300.1959279-5-mathias.nyman@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240905143300.1959279-1-mathias.nyman@linux.intel.com> References: <20240905143300.1959279-1-mathias.nyman@linux.intel.com> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Niklas Neronin The removed debug messages trigger each time an isoc frame is handled. In case of an error, a dedicated debug message exists. For example, a 60fps USB camera will trigger the debug message every 0.6s. Signed-off-by: Niklas Neronin Signed-off-by: Mathias Nyman --- drivers/usb/host/xhci-ring.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index 4ea2c3e072a9..e1c9838084bf 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -3941,10 +3941,6 @@ static int xhci_get_isoc_frame_id(struct xhci_hcd *xhci, start_frame_id = (start_frame_id >> 3) & 0x7ff; end_frame_id = (end_frame_id >> 3) & 0x7ff; - xhci_dbg(xhci, "%s: index %d, reg 0x%x start_frame_id 0x%x, end_frame_id 0x%x, start_frame 0x%x\n", - __func__, index, readl(&xhci->run_regs->microframe_index), - start_frame_id, end_frame_id, start_frame); - if (start_frame_id < end_frame_id) { if (start_frame > end_frame_id || start_frame < start_frame_id) From patchwork Thu Sep 5 14:32:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathias Nyman X-Patchwork-Id: 13792457 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5308117736 for ; Thu, 5 Sep 2024 14:31:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.7 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725546683; cv=none; b=agZ0JwZbVSCUuBkBXwcIangoYplE81UdwFp9eDcODK6PHlaxzTNdtWZWt+nW1QmG1AhC53k982GDzlZsXGGFUnWq884/Fnmx7eGOsJeOh3u/b8QRf0pBhj5DL2kIFMd+CwqpQz/azoWdZvbvzlZaCvyE1tp6uHy3DrSNRWlZBVk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725546683; c=relaxed/simple; bh=u9mc28OYRpsO7s/iOl9pmEDJG/WbGYWclELkvMbB4FI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=G+jtvRYbauaQ8JjFH4RHCOK3sUtulb6CnAkfHEABMvOMmgIk5YsN3ZGbhSxXRxT6kyYLVKsVb5VgwLyc0P8ccjM2Fh3TaRVBUgK3W/bytW/0qRjhVYrGMRGUBdY/5b40ykxVNRYcIsE/RLreXX47hUekKaOyM5rIGs+ZYMDW1bw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=bIdoCO/X; arc=none smtp.client-ip=192.198.163.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="bIdoCO/X" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1725546682; x=1757082682; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=u9mc28OYRpsO7s/iOl9pmEDJG/WbGYWclELkvMbB4FI=; b=bIdoCO/XyDk4GrqsZpUSW0ErdOpIt2+vnAkQERnWdSArPDqWeykerKzb lP6t+eEtYCaqtos+KhVnFrsZ+XbCRJI2DcEUJrZXByipWh505Z6s4lpXI ThkAoK9gtJZlyRgKeKH0XvnZz6389+AgKuZljqbiJpS+E0iVXOfqVXu3q 6xl6BKr5fO72OpU/nOIddlm+YutQCsjGsfLmNOnu64shJ9l2jH/ePouDP 5/Fdjq2Fnq3BLIIZEI3OT9gkvYx49Q4xu2gub0zL5Jeyw9uHsqrL+9C80 +H8CCYEsZGLga2SieY0AlBnJrTH8YlIRKqIpm0AL8IJN1+k0KNM4OgvB5 A==; X-CSE-ConnectionGUID: D3XeboFuR6SlhTUYZ/eT/g== X-CSE-MsgGUID: HD1oyrmBTyCOsUBwnVbhBw== X-IronPort-AV: E=McAfee;i="6700,10204,11186"; a="49677511" X-IronPort-AV: E=Sophos;i="6.10,205,1719903600"; d="scan'208";a="49677511" Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Sep 2024 07:31:22 -0700 X-CSE-ConnectionGUID: n3Yb7Tk4QYa6sOCO/vxxXA== X-CSE-MsgGUID: Kmh8kUDKRQKEWj2blBb98g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,205,1719903600"; d="scan'208";a="88883219" Received: from mattu-haswell.fi.intel.com ([10.237.72.199]) by fmviesa002.fm.intel.com with ESMTP; 05 Sep 2024 07:31:20 -0700 From: Mathias Nyman To: Cc: , Niklas Neronin , Mathias Nyman Subject: [PATCH 05/12] usb: xhci: remove excessive Bulk short packet debug message Date: Thu, 5 Sep 2024 17:32:53 +0300 Message-Id: <20240905143300.1959279-6-mathias.nyman@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240905143300.1959279-1-mathias.nyman@linux.intel.com> References: <20240905143300.1959279-1-mathias.nyman@linux.intel.com> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Niklas Neronin Completion codes 'COMP_SUCCESS' and 'COMP_SHORT_PACKET' are the most frequently encountered completion codes. Typically, these codes do not trigger a default debug message but rather a warning that indicates a potential issue. This behavior is consistent across all transfer types with the exception of Bulk transfers. To reduce unnecessary log clutter, remove the Bulk 'COMP_SHORT_PACKET' debug message. Signed-off-by: Niklas Neronin Signed-off-by: Mathias Nyman --- drivers/usb/host/xhci-ring.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index e1c9838084bf..d37eeee74960 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -2521,9 +2521,6 @@ static int process_bulk_intr_td(struct xhci_hcd *xhci, struct xhci_virt_ep *ep, td->status = 0; break; case COMP_SHORT_PACKET: - xhci_dbg(xhci, "ep %#x - asked for %d bytes, %d bytes untransferred\n", - td->urb->ep->desc.bEndpointAddress, - requested, remaining); td->status = 0; break; case COMP_STOPPED_SHORT_PACKET: From patchwork Thu Sep 5 14:32:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathias Nyman X-Patchwork-Id: 13792458 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D38D517736 for ; Thu, 5 Sep 2024 14:31:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.7 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725546686; cv=none; b=f9Y+bYssceChe7PtHlyljdIV5L20s/tRanx2yLnw8Mg3ycxl3LYENyYIiVG5Tb2X10Jd6Di+Ci+/HgM7gGHPK8DECq/tNTa9ApFbSy7bwYX4SpAYqa7Z1vam4SYXCISr5wG8JkcUlYwO0Q3DuZfT/d8h+xMZJY1ZprAbfCey2oQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725546686; c=relaxed/simple; bh=fKmpZxxOtoB7MSVZpavAfmQDOA7o9vprgKXivQNwWFY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=hqRHbYiNZ2LhsKyaSlELrmdTNWbcNOl2RRiFeYnlTxmVT3Ix8fZvbeofPDhu/9hSDy+vO0EijayuhI8G1h1G8CdpR7a/GNpgIlN0loMH8Owa50tyN5Jc9EO9yeZRIpBoB+jyyRZ+Z5XDA1vTJ7v8t/9N0/3FjH2FngngjToE1Qk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=TmVmbfRI; arc=none smtp.client-ip=192.198.163.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="TmVmbfRI" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1725546685; x=1757082685; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=fKmpZxxOtoB7MSVZpavAfmQDOA7o9vprgKXivQNwWFY=; b=TmVmbfRIVF7RMSxsDeITd0e1mpyijxNpJxM1UFiQ0M329C2ymZNYgKDz X90she68B72j+XCUVPfY1tIxOcrhYSYdHXzTpPApYqs7YyKOqIp5lrqCU uJ4q7YtmafW7UqwvhSGD4yJ2pBKnhO1EydwYJoeiRfcEWSou8wB9NnY8E aLZEW2QpmFvVmSjNETimPnOWy+Lldp0KtI7Ed08aDCEtyMZAInbCKJNzg IDr9/mr2fSXbs8AgaPaZbMN2nJtG/il7ajqF9rmuk9yWbPhO7Pq/FJxZK ZFgydxCk44I/RoF09k6A7tK4rcR3bsVBtJf6hIqHtOQtNcwDF/eQ7CFsX w==; X-CSE-ConnectionGUID: hXW6kGWUR/WVXncb3fJ1Yw== X-CSE-MsgGUID: BojbG8KhQt+lRYRXuZMugg== X-IronPort-AV: E=McAfee;i="6700,10204,11186"; a="49677520" X-IronPort-AV: E=Sophos;i="6.10,205,1719903600"; d="scan'208";a="49677520" Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Sep 2024 07:31:23 -0700 X-CSE-ConnectionGUID: SyfdwqBCT+6yn3vDDCRuzw== X-CSE-MsgGUID: tdhttNGRT6OAL33C3i7IkQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,205,1719903600"; d="scan'208";a="88883220" Received: from mattu-haswell.fi.intel.com ([10.237.72.199]) by fmviesa002.fm.intel.com with ESMTP; 05 Sep 2024 07:31:22 -0700 From: Mathias Nyman To: Cc: , Niklas Neronin , Mathias Nyman Subject: [PATCH 06/12] usb: xhci: remove unused variables from struct 'xhci_hcd' Date: Thu, 5 Sep 2024 17:32:54 +0300 Message-Id: <20240905143300.1959279-7-mathias.nyman@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240905143300.1959279-1-mathias.nyman@linux.intel.com> References: <20240905143300.1959279-1-mathias.nyman@linux.intel.com> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Niklas Neronin Variables 'max_slots', 'max_ports', 'isoc_threshold' and 'event_ring_max' are never set or used. Thus, remove them. Signed-off-by: Niklas Neronin Signed-off-by: Mathias Nyman --- drivers/usb/host/xhci.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index ae4b50b01284..6f8cecc789d6 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h @@ -1500,13 +1500,9 @@ struct xhci_hcd { /* packed release number */ u8 sbrn; u16 hci_version; - u8 max_slots; u16 max_interrupters; - u8 max_ports; - u8 isoc_threshold; /* imod_interval in ns (I * 250ns) */ u32 imod_interval; - int event_ring_max; /* 4KB min, 128MB max */ int page_size; /* Valid values are 12 to 20, inclusive */ From patchwork Thu Sep 5 14:32:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathias Nyman X-Patchwork-Id: 13792459 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5034317C96 for ; Thu, 5 Sep 2024 14:31:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.7 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725546686; cv=none; b=uoG8+mE2P67rhbl/4M5XuS5wbXlh9QIVjhszJ1KpCEh9viA9hMHu+5+bRG/Gy6gbFffCbauhGFNSbK76ROcrdfnR1DzftRdNC4TgN40u6mVVhLI1Y0Zv/azl/DVqGf8OIHCi4fPSBtiTLb3kA2kz+pn/mMI/MEHEFlLmWH5/Vak= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725546686; c=relaxed/simple; bh=8zjlQXzjTvi2dUvYk8XGVnSOeV+iRlLs414mkRgasCg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=XaKN5bRTlodDHm2uYOSSNE4RMnoY3N9xneO8I0TdCG97G+3kHFgpSjGYaXcP1+OF/Gxz9HsrMb/pyC5Rao4rkpa//XLLP+eeGqMK0jSMGjuQLkGHICWrTx38d/mcEq9u6Eaft4a77AcnrOlL737VOS1/Nb7Qss0u5cuSeHS4Mms= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=AivwY7Na; arc=none smtp.client-ip=192.198.163.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="AivwY7Na" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1725546685; x=1757082685; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=8zjlQXzjTvi2dUvYk8XGVnSOeV+iRlLs414mkRgasCg=; b=AivwY7NaU62o6Dgo/ltVRJ0ijS8nw5bJFOeV+R8u1orjsUl/HKs7Jkd4 8bLJwby6aEkN7971uCRO/9obgEw3dbAbPgp++TyN+qaHKuFWGSucf2u6j FMpE50Sy6S4av5I83pzy/gC1iI4YpnBgqH4NwbHzAFCJu+Tr946CRPQac rHqzNjKzmFBTmLzbBvthGvyxJtUa9tB2H4mKywQq4v9SOP+y0oWFHalm8 4ncV4NbUqp9cpoO4UTPZ1xmldFNxGAgKCohiEWmYGD91YMQii/z0QaYfJ 3YLiZAw83JD5EX+67bnVrnnluCa2uaSRsTwTo75YTjlBkvTusTlR7PMgL w==; X-CSE-ConnectionGUID: XYktj4HYQDGzfWK8kw2O1g== X-CSE-MsgGUID: OsjsfbO7T2atcJkRidVxyA== X-IronPort-AV: E=McAfee;i="6700,10204,11186"; a="49677524" X-IronPort-AV: E=Sophos;i="6.10,205,1719903600"; d="scan'208";a="49677524" Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Sep 2024 07:31:25 -0700 X-CSE-ConnectionGUID: 9QwAbOn0QxWZxCA48iJoiw== X-CSE-MsgGUID: Guwu0kG2TLGQbmboMc5CHg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,205,1719903600"; d="scan'208";a="88883222" Received: from mattu-haswell.fi.intel.com ([10.237.72.199]) by fmviesa002.fm.intel.com with ESMTP; 05 Sep 2024 07:31:23 -0700 From: Mathias Nyman To: Cc: , Niklas Neronin , Mathias Nyman Subject: [PATCH 07/12] usb: xhci: make 'sbrn' a local variable Date: Thu, 5 Sep 2024 17:32:55 +0300 Message-Id: <20240905143300.1959279-8-mathias.nyman@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240905143300.1959279-1-mathias.nyman@linux.intel.com> References: <20240905143300.1959279-1-mathias.nyman@linux.intel.com> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Niklas Neronin Variable 'sbrn' is used to store the Serial Bus Release Number, which is then only used for a debug message. Thus, 'sbrn' can be a local variable and assigned after the primary HCD check. The SBRN debug message is only printed when a primary HCD is setup. Signed-off-by: Niklas Neronin Signed-off-by: Mathias Nyman --- drivers/usb/host/xhci-pci.c | 6 +++--- drivers/usb/host/xhci.h | 1 - 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c index b5705ed01d83..b405cff2d600 100644 --- a/drivers/usb/host/xhci-pci.c +++ b/drivers/usb/host/xhci-pci.c @@ -525,10 +525,9 @@ static int xhci_pci_setup(struct usb_hcd *hcd) struct xhci_hcd *xhci; struct pci_dev *pdev = to_pci_dev(hcd->self.controller); int retval; + u8 sbrn; xhci = hcd_to_xhci(hcd); - if (!xhci->sbrn) - pci_read_config_byte(pdev, XHCI_SBRN_OFFSET, &xhci->sbrn); /* imod_interval is the interrupt moderation value in nanoseconds. */ xhci->imod_interval = 40000; @@ -543,7 +542,8 @@ static int xhci_pci_setup(struct usb_hcd *hcd) if (xhci->quirks & XHCI_PME_STUCK_QUIRK) xhci_pme_acpi_rtd3_enable(pdev); - xhci_dbg(xhci, "Got SBRN %u\n", (unsigned int) xhci->sbrn); + pci_read_config_byte(pdev, XHCI_SBRN_OFFSET, &sbrn); + xhci_dbg(xhci, "Got SBRN %u\n", (unsigned int)sbrn); /* Find any debug ports */ return xhci_pci_reinit(xhci, pdev); diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index 6f8cecc789d6..d41523c9b15c 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h @@ -1498,7 +1498,6 @@ struct xhci_hcd { spinlock_t lock; /* packed release number */ - u8 sbrn; u16 hci_version; u16 max_interrupters; /* imod_interval in ns (I * 250ns) */ From patchwork Thu Sep 5 14:32:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathias Nyman X-Patchwork-Id: 13792460 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D333A2110E for ; Thu, 5 Sep 2024 14:31:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.7 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725546689; cv=none; b=m6JKelZWSPaRSjVBaoqPwVPCzz0rHENfdAnt0UA1dCivJUXx7W/EJvGLG+SZGL0cr2YziKHrjhn83eiVJbvnGfZptISa8I3kGn8I2sUfk360x6XM9y9CtoaYnxbLEBslLAEyTf2IJMVDVqbUPCunRMIRR/0vorbRJknTJ6a3t5c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725546689; c=relaxed/simple; bh=syxiCHyfpbwv/wA4SM7Uib+ynZqMebMAFHJ7dpZuFn0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=UD0geKLuTatbK+Xi7vyDuy7rQDl+d3C9gdcHLURVBen7xiZZZoRtWUlOC0//zdmZBe4zdE9DB/g9fwBneZSHDo3Gzr0so9URVVuQFDfRsus69fudmIFFRVwtYC7XpXHANjiDWwu+dbRBgHisPQItFC2SOVBAnWSAVSoRCYoD4a4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=ZccL0P3J; arc=none smtp.client-ip=192.198.163.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="ZccL0P3J" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1725546688; x=1757082688; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=syxiCHyfpbwv/wA4SM7Uib+ynZqMebMAFHJ7dpZuFn0=; b=ZccL0P3JRfY57i3vkZf1MXC7JVFOJssSb6fS3bjuRIGy3VGPlTCcVihZ hTHHJvwvjC1Q9ooPtqDJToFwaAJXmYX2YdlGL4GCiuRzVL2A5m8mB//VV kNfWZpF2Tus0Dv1E0fKqMjV1KlZ8nKRGK/iMj4I7GdQVIj3Q3nHZZAPyB rqOxiJnxr650Q2TGQjyjfRGGKDBZfOUjIteYdEQhFYYR2wyi3vlN9buqZ A5F5FX86ccaoAW76EK7WVxrFNAzWDMfmeFL3MIUeBeaRrhLi60rnJoUK9 kUuVesVDrbw3G6gV01XI4VxQrnKVFCKnEYEXwMMf4TokiGxJNZyb9LLs6 A==; X-CSE-ConnectionGUID: eS05se//SHGFu+in7YZyxQ== X-CSE-MsgGUID: 0CIhYwVGR6iEHzEqtl3QdA== X-IronPort-AV: E=McAfee;i="6700,10204,11186"; a="49677531" X-IronPort-AV: E=Sophos;i="6.10,205,1719903600"; d="scan'208";a="49677531" Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Sep 2024 07:31:27 -0700 X-CSE-ConnectionGUID: OSdN/coWTsmMOfDjotdA0Q== X-CSE-MsgGUID: eA3LaZKBT+22hQm9VpsevQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,205,1719903600"; d="scan'208";a="88883225" Received: from mattu-haswell.fi.intel.com ([10.237.72.199]) by fmviesa002.fm.intel.com with ESMTP; 05 Sep 2024 07:31:25 -0700 From: Mathias Nyman To: Cc: , Niklas Neronin , Mathias Nyman Subject: [PATCH 08/12] usb: xhci: add comments explaining specific interrupt behaviour Date: Thu, 5 Sep 2024 17:32:56 +0300 Message-Id: <20240905143300.1959279-9-mathias.nyman@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240905143300.1959279-1-mathias.nyman@linux.intel.com> References: <20240905143300.1959279-1-mathias.nyman@linux.intel.com> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Niklas Neronin HCD does not allocate or request interrupt for the xhci driver, but HCD does free and sync xhci interrupts in some cases. Add comment detailing in which cases HCD will free/sync xhci interrupts. Signed-off-by: Niklas Neronin Signed-off-by: Mathias Nyman --- drivers/usb/host/xhci-pci.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c index b405cff2d600..d6196c08ea87 100644 --- a/drivers/usb/host/xhci-pci.c +++ b/drivers/usb/host/xhci-pci.c @@ -93,6 +93,10 @@ static const struct xhci_driver_overrides xhci_pci_overrides __initconst = { .update_hub_device = xhci_pci_update_hub_device, }; +/* + * Primary Legacy and MSI IRQ are synced in suspend_common(). + * All MSI-X IRQs and secondary MSI IRQs should be synced here. + */ static void xhci_msix_sync_irqs(struct xhci_hcd *xhci) { struct usb_hcd *hcd = xhci_to_hcd(xhci); @@ -105,13 +109,12 @@ static void xhci_msix_sync_irqs(struct xhci_hcd *xhci) } } -/* Free any IRQs and disable MSI-X */ +/* Legacy IRQ is freed by usb_remove_hcd() or usb_hcd_pci_shutdown() */ static void xhci_cleanup_msix(struct xhci_hcd *xhci) { struct usb_hcd *hcd = xhci_to_hcd(xhci); struct pci_dev *pdev = to_pci_dev(hcd->self.controller); - /* return if using legacy interrupt */ if (hcd->irq > 0) return; From patchwork Thu Sep 5 14:32:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathias Nyman X-Patchwork-Id: 13792461 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 600FA14F90 for ; Thu, 5 Sep 2024 14:31:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.7 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725546690; cv=none; b=eE7hEMpedU9YCRZtmHMlIddODKngfill2824SkNtCkA+pXdbr6dKCNMlTEa6IGc8gHdICLiA1haPyubspvYz3UxIJx3QqVGBhY9TEav1zObZTlLxCiUeWoUFo4aoghCnNaeIps6r96UuZt1/UeDXja+20p0Pnp/qoGTmANMGEco= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725546690; c=relaxed/simple; bh=6/iv40Bpaax3JxEkaFBdgWmk350HVupew/Nc0hSbZkA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=gnVXANaWihtcZfWrGIq4MaGq0dl9aoleF0zX1gJCrDM8nEUlmebpkO5boWK3GLQZKmY+4mSIRtoaf5+IupWubhOHj9ltZWkl9MDMpnuh8C9iZ8Sly3KTtBWWTz4xc1gJwjwG2W1sgDioQK+OIZUvWzJBUHaGsz1AurfjyGc3uQ8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=fkZUbeY4; arc=none smtp.client-ip=192.198.163.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="fkZUbeY4" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1725546689; x=1757082689; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=6/iv40Bpaax3JxEkaFBdgWmk350HVupew/Nc0hSbZkA=; b=fkZUbeY4FaeomnVEHrDfioU5kG1o3tHFcDdYQ/JyrZl4ZFSwooM8Rc9L oU4gsTuOh/rWcAm9uDp3rYLMgjf+MqpID8FC6nlIODEbmBVvzVgW/+LjX uiANCjijEHxEjEar2KAWf31w0yYX81uCNgOiRLG4F4kmMH/1+aJLf5fwH Csbnz+v9ptB/v7H/9VR0edav0b8GJ3l4dfB0wiHh1Id/XH3aTmKWg/JRo Ag4wABdzkkdD985tzXLh/STfQqF2CoOF9O3OzL/8lIOxQAezxmetZge2o aF8lUnm85f79wPBdWx2bvL6dCEt+UiJ3P/z5OFV5gLLgtJq1RHBIVTBgf A==; X-CSE-ConnectionGUID: h+JgQalHRSKsIFom9qATYw== X-CSE-MsgGUID: ypCsz+4TSiuS/21tw0e9mg== X-IronPort-AV: E=McAfee;i="6700,10204,11186"; a="49677541" X-IronPort-AV: E=Sophos;i="6.10,205,1719903600"; d="scan'208";a="49677541" Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Sep 2024 07:31:29 -0700 X-CSE-ConnectionGUID: BZli71vUQT6hg1xp5la+ww== X-CSE-MsgGUID: CfqXgxw4TCeqAx9JBgADug== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,205,1719903600"; d="scan'208";a="88883227" Received: from mattu-haswell.fi.intel.com ([10.237.72.199]) by fmviesa002.fm.intel.com with ESMTP; 05 Sep 2024 07:31:27 -0700 From: Mathias Nyman To: Cc: , Niklas Neronin , Mathias Nyman Subject: [PATCH 09/12] usb: xhci: remove 'retval' from xhci_pci_resume() Date: Thu, 5 Sep 2024 17:32:57 +0300 Message-Id: <20240905143300.1959279-10-mathias.nyman@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240905143300.1959279-1-mathias.nyman@linux.intel.com> References: <20240905143300.1959279-1-mathias.nyman@linux.intel.com> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Niklas Neronin Remove unnecessary local 'retval' argument. Signed-off-by: Niklas Neronin Signed-off-by: Mathias Nyman --- drivers/usb/host/xhci-pci.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c index d6196c08ea87..526739af2070 100644 --- a/drivers/usb/host/xhci-pci.c +++ b/drivers/usb/host/xhci-pci.c @@ -786,7 +786,6 @@ static int xhci_pci_resume(struct usb_hcd *hcd, pm_message_t msg) { struct xhci_hcd *xhci = hcd_to_xhci(hcd); struct pci_dev *pdev = to_pci_dev(hcd->self.controller); - int retval = 0; reset_control_reset(xhci->reset); @@ -817,8 +816,7 @@ static int xhci_pci_resume(struct usb_hcd *hcd, pm_message_t msg) if (xhci->quirks & XHCI_PME_STUCK_QUIRK) xhci_pme_quirk(hcd); - retval = xhci_resume(xhci, msg); - return retval; + return xhci_resume(xhci, msg); } static int xhci_pci_poweroff_late(struct usb_hcd *hcd, bool do_wakeup) From patchwork Thu Sep 5 14:32:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathias Nyman X-Patchwork-Id: 13792462 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1E74943149 for ; Thu, 5 Sep 2024 14:31:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.7 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725546692; cv=none; b=ZPn0tV9LiTpFq2k79V4J6kivEz7UwEamuIiLW3V5/jSmbQu2yHB2qYcojgl4WGVHhq3OraCzFiJZsfVphNh5Rb8ikxt8KTsq5WP1+PdNVDCHeKByrnqdCgHcxFn0ZYld32qlyIWVUg5Mbr7KN7Kl6Uj2Gwo8fnlouiyp85xX0TE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725546692; c=relaxed/simple; bh=DddwRJJvllW6A/PVAi5YTTyoVri0dn1rja2b35DG9+8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=haBE6u2ffMATGiRpGi6L79gBKzDZJD0KXpEA7d3y3M0+9uBzODPBzZM0tPyLxU7F1qcJU4pxqlBSgp6o9H315ve4NP7T1vzG2jmMIIdcpZVpQeu5gERiB8dhwhxeuEfK2A4uYS3G587Zvu+YSfP1TBtEPYrpkLORKzgbyNlY3N8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=DK7IbvYp; arc=none smtp.client-ip=192.198.163.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="DK7IbvYp" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1725546691; x=1757082691; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=DddwRJJvllW6A/PVAi5YTTyoVri0dn1rja2b35DG9+8=; b=DK7IbvYppNaqCbNm/Y6vai0faNd0PNn4pqXte3qVZ3I6YufUxLau0TWf tYGHlWOXdlPVjrPwzFEVOPdOQ4gZcjc83PAiZZQYVdLzM2MMm6I78/6Js dW1bFI97dN9hD8/8bS6LzY/DHsRg2efwv7lahP+9TpgbbGi9HmfgBi7lX w/GegyB0Ogry/arXCBucfzkcY7NMaB7Ag++NudAVDxgjvRT7HvUUYNi03 rgpHUFnzjSt+NKfg1g8AgmP/AWSxQMcQ0L5ffxD371Ck6ro1dRz7aD+BJ jzfQY9dtBqAfLkW4SDaU/eW8kjyKYZV3BWwwkOEkCWO8qk8D7DXOU2N1H w==; X-CSE-ConnectionGUID: KILaieCuQMiywwwGz1hqDw== X-CSE-MsgGUID: L+BpsSq8SbyZa2LZ6ObHGA== X-IronPort-AV: E=McAfee;i="6700,10204,11186"; a="49677553" X-IronPort-AV: E=Sophos;i="6.10,205,1719903600"; d="scan'208";a="49677553" Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Sep 2024 07:31:31 -0700 X-CSE-ConnectionGUID: rMlXhEd/St6AknDI1jgpXw== X-CSE-MsgGUID: 53JdOeV2S+y0h2+Zm7j01Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,205,1719903600"; d="scan'208";a="88883231" Received: from mattu-haswell.fi.intel.com ([10.237.72.199]) by fmviesa002.fm.intel.com with ESMTP; 05 Sep 2024 07:31:29 -0700 From: Mathias Nyman To: Cc: , Niklas Neronin , Mathias Nyman Subject: [PATCH 10/12] usb: xhci: adjust empty TD list handling in handle_tx_event() Date: Thu, 5 Sep 2024 17:32:58 +0300 Message-Id: <20240905143300.1959279-11-mathias.nyman@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240905143300.1959279-1-mathias.nyman@linux.intel.com> References: <20240905143300.1959279-1-mathias.nyman@linux.intel.com> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Niklas Neronin Introduce an initial check for an empty list prior to entering the while loop. Which enables, the implementation of distinct warnings to differentiate between scenarios where the list is initially empty and when it has been emptied during processing skipped isoc TDs. These adjustments not only simplifies the large while loop, but also facilitates future enhancements to the handle_tx_event() function. Signed-off-by: Niklas Neronin Signed-off-by: Mathias Nyman --- drivers/usb/host/xhci-ring.c | 51 +++++++++++++++++------------------- 1 file changed, 24 insertions(+), 27 deletions(-) diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index d37eeee74960..a4383735b16c 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -2761,35 +2761,25 @@ static int handle_tx_event(struct xhci_hcd *xhci, return 0; } - do { - /* This TRB should be in the TD at the head of this ring's - * TD list. + if (list_empty(&ep_ring->td_list)) { + /* + * Don't print wanings if ring is empty due to a stopped endpoint generating an + * extra completion event if the device was suspended. Or, a event for the last TRB + * of a short TD we already got a short event for. The short TD is already removed + * from the TD list. */ - if (list_empty(&ep_ring->td_list)) { - /* - * Don't print wanings if it's due to a stopped endpoint - * generating an extra completion event if the device - * was suspended. Or, a event for the last TRB of a - * short TD we already got a short event for. - * The short TD is already removed from the TD list. - */ - - if (!(trb_comp_code == COMP_STOPPED || - trb_comp_code == COMP_STOPPED_LENGTH_INVALID || - ep_ring->last_td_was_short)) { - xhci_warn(xhci, "WARN Event TRB for slot %u ep %d with no TDs queued?\n", - slot_id, ep_index); - } - if (ep->skip) { - ep->skip = false; - xhci_dbg(xhci, "td_list is empty while skip flag set. Clear skip flag for slot %u ep %u.\n", - slot_id, ep_index); - } - - td = NULL; - goto check_endpoint_halted; + if (trb_comp_code != COMP_STOPPED && + trb_comp_code != COMP_STOPPED_LENGTH_INVALID && + !ep_ring->last_td_was_short) { + xhci_warn(xhci, "Event TRB for slot %u ep %u with no TDs queued\n", + slot_id, ep_index); } + ep->skip = false; + goto check_endpoint_halted; + } + + do { td = list_first_entry(&ep_ring->td_list, struct xhci_td, td_list); @@ -2800,7 +2790,14 @@ static int handle_tx_event(struct xhci_hcd *xhci, if (ep->skip && usb_endpoint_xfer_isoc(&td->urb->ep->desc)) { skip_isoc_td(xhci, td, ep, status); - continue; + if (!list_empty(&ep_ring->td_list)) + continue; + + xhci_dbg(xhci, "All TDs skipped for slot %u ep %u. Clear skip flag.\n", + slot_id, ep_index); + ep->skip = false; + td = NULL; + goto check_endpoint_halted; } /* From patchwork Thu Sep 5 14:32:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathias Nyman X-Patchwork-Id: 13792463 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6E14654F87; Thu, 5 Sep 2024 14:31:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.7 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725546694; cv=none; b=hYRV/dxHbGCmGb6BQjO0JjfBOSSpOpRSB19A55omNrfbI44vBQPnrr6W5s2kH3WxD6eCNrb9BkUkiIeaCQxLTU5F6lYBG7GmWQ+WL2MV2Ti/e14Hdgcz0nNG7FT6a9JZXBCjCIIt70kvdnLe9k6aggGydwe/Uo+8MYLQzr55wPE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725546694; c=relaxed/simple; bh=uGI6SGIrD/O2eBQ4Wq4v9jYmgtUXRGyG4r1dvAlrzFM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=L+4XtslcFXMvWPxXHQNIVqSx06rw97XCOYPKwC/HNI2icVWhiwBg+mUrghdoxXE0bKLdnScYnWKIhm8e7d/oUZ94iYz15tDE6A5CrzQJJsAhdOYBCPK+Xnrz9xWXBM/Qn2W9snvfkGT45nLRho2x8uJ/kqC0OTylGS5TRgoFePQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Yj5sV8Rf; arc=none smtp.client-ip=192.198.163.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Yj5sV8Rf" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1725546693; x=1757082693; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=uGI6SGIrD/O2eBQ4Wq4v9jYmgtUXRGyG4r1dvAlrzFM=; b=Yj5sV8RfKMOiwbBbhSyTCMTv980JjQ1ODr5/sKKkZ9JU34FlZHiSV91W U0ttmxbXv73FrVZvekoPKfCtxFI+V2TDICTA0bFbV0zQjN4cmhLP/U2Al YM/jeR6kUHXyU0hgFVhJ/yzHOGGHG2crbgRV3/FFJpuAGhzw2zWo1TrLY ghfo5zy+9WKkzKexLyFNq1ySxvZi58YhFasIsltg/6ENHvnQ25fiUmyIG GGcPTsT/FH5MUna3I3PSFcUPecqOeekDC0H91sIX+i39+Si1BMlKCyudK lPPfjkiqJT7umueLDw4DcMQqxeWQOwm79+CzT4y19byAICqmq+8rkFr7p A==; X-CSE-ConnectionGUID: qqrLFIq6RnueAyUiz5M15Q== X-CSE-MsgGUID: Yf882uCmTACDAD6RGlMCBA== X-IronPort-AV: E=McAfee;i="6700,10204,11186"; a="49677561" X-IronPort-AV: E=Sophos;i="6.10,205,1719903600"; d="scan'208";a="49677561" Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Sep 2024 07:31:33 -0700 X-CSE-ConnectionGUID: qgWnCSLvROWaQC2raElYlw== X-CSE-MsgGUID: Ism/uomFQDWtq9U3m0egiw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,205,1719903600"; d="scan'208";a="88883235" Received: from mattu-haswell.fi.intel.com ([10.237.72.199]) by fmviesa002.fm.intel.com with ESMTP; 05 Sep 2024 07:31:31 -0700 From: Mathias Nyman To: Cc: , Mathias Nyman , stable@vger.kernel.org Subject: [PATCH 11/12] xhci: Set quirky xHC PCI hosts to D3 _after_ stopping and freeing them. Date: Thu, 5 Sep 2024 17:32:59 +0300 Message-Id: <20240905143300.1959279-12-mathias.nyman@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240905143300.1959279-1-mathias.nyman@linux.intel.com> References: <20240905143300.1959279-1-mathias.nyman@linux.intel.com> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 PCI xHC host should be stopped and xhci driver memory freed before putting host to PCI D3 state during PCI remove callback. Hosts with XHCI_SPURIOUS_WAKEUP quirk did this the wrong way around and set the host to D3 before calling usb_hcd_pci_remove(dev), which will access the host to stop it, and then free xhci. Fixes: f1f6d9a8b540 ("xhci: don't dereference a xhci member after removing xhci") Cc: stable@vger.kernel.org Signed-off-by: Mathias Nyman --- drivers/usb/host/xhci-pci.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c index 526739af2070..de50f5ba60df 100644 --- a/drivers/usb/host/xhci-pci.c +++ b/drivers/usb/host/xhci-pci.c @@ -657,8 +657,10 @@ static int xhci_pci_probe(struct pci_dev *dev, const struct pci_device_id *id) void xhci_pci_remove(struct pci_dev *dev) { struct xhci_hcd *xhci; + bool set_power_d3; xhci = hcd_to_xhci(pci_get_drvdata(dev)); + set_power_d3 = xhci->quirks & XHCI_SPURIOUS_WAKEUP; xhci->xhc_state |= XHCI_STATE_REMOVING; @@ -671,11 +673,11 @@ void xhci_pci_remove(struct pci_dev *dev) xhci->shared_hcd = NULL; } + usb_hcd_pci_remove(dev); + /* Workaround for spurious wakeups at shutdown with HSW */ - if (xhci->quirks & XHCI_SPURIOUS_WAKEUP) + if (set_power_d3) pci_set_power_state(dev, PCI_D3hot); - - usb_hcd_pci_remove(dev); } EXPORT_SYMBOL_NS_GPL(xhci_pci_remove, xhci); From patchwork Thu Sep 5 14:33:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathias Nyman X-Patchwork-Id: 13792464 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C354C17557 for ; Thu, 5 Sep 2024 14:31:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.7 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725546696; cv=none; b=P0LkwshnN1IJ4hRXeILHSkcvcAMRRZvxsxjv7V6wqwWpoZRuvPPli2m1OaeVDAG+EKDWt6fNjMAoVtLI/F0eA5PXYaOJjDj43AE6QChbdnsomybzi5xIA0x4xFan2m4JaaUMmC3A5KsYvAJ+5EUyzDzI5LxGKnZmauPt94t2Vws= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725546696; c=relaxed/simple; bh=mWX9bAzpDZP9VWo0vn5ZVc9iJPwQi09Lvho/X43VJ80=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Afvpukto93BGKaBcy107SkbFcpEpUOWpl0i/TGFZ5/v1EwRnUh3URYnME74MEsN8RCMMGqpJH1QbwYcR792OULRCo7bBbk+SJJbtYZGnjoXF3ryG4hldGkmDc3P/OQg1DPvFMpwJBKQU9BTrimebCyvUmbLU5CGG8V/sPo6nkaU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=V5r8kLp0; arc=none smtp.client-ip=192.198.163.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="V5r8kLp0" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1725546695; x=1757082695; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=mWX9bAzpDZP9VWo0vn5ZVc9iJPwQi09Lvho/X43VJ80=; b=V5r8kLp0S7P59zZIi3R6bRjyJCXR/pf4KXyayL+B+XOB7fgvwF4L4rKy HYdioRmKf0ygz/4putF/rq/GwVFmVnur3z7VSGG32hQQR5fmSt6XR+UeS HAbjzqOhAqiQU/UmPT3YVLlszPgzLruVrYnjOpZs9gDoftT1m0sexqaCd hdry1OwgvOpkgbJvksXTnTc09ArZkyt/1kkMDnaWdUJyrfzq5Kvvs6mql rlw1IpJSU9cDmYCWx/EpNbJVA0OtH6ep2dTn2TE3qHNZzoRU+loRtWaDv PmnU5EBMf9VmTnJof4zfxf3kpSIuo00ZYAaZsNmwbChxK54VRWdCfFnOB g==; X-CSE-ConnectionGUID: mHFwIeoTSsCi2kUCMbe6AQ== X-CSE-MsgGUID: 9g95+a+pTZekE81Stg7lVQ== X-IronPort-AV: E=McAfee;i="6700,10204,11186"; a="49677567" X-IronPort-AV: E=Sophos;i="6.10,205,1719903600"; d="scan'208";a="49677567" Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Sep 2024 07:31:34 -0700 X-CSE-ConnectionGUID: zRcD1Ih+QtmhZPnl1T9F/w== X-CSE-MsgGUID: F3/JC7xwROSi9GUKU63Bvg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,205,1719903600"; d="scan'208";a="88883247" Received: from mattu-haswell.fi.intel.com ([10.237.72.199]) by fmviesa002.fm.intel.com with ESMTP; 05 Sep 2024 07:31:33 -0700 From: Mathias Nyman To: Cc: , Mathias Nyman , Wesley Cheng Subject: [PATCH 12/12] xhci: support setting interrupt moderation IMOD for secondary interrupters Date: Thu, 5 Sep 2024 17:33:00 +0300 Message-Id: <20240905143300.1959279-13-mathias.nyman@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240905143300.1959279-1-mathias.nyman@linux.intel.com> References: <20240905143300.1959279-1-mathias.nyman@linux.intel.com> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Allow creators of seconday interrupters to specify the interrupt moderation interval value in nanoseconds when creating the interrupter. If not sure what value to use then use the xhci driver default xhci->imod_interval Suggested-by: Wesley Cheng Signed-off-by: Mathias Nyman --- drivers/usb/host/xhci-mem.c | 8 +++++++- drivers/usb/host/xhci.c | 4 ++-- drivers/usb/host/xhci.h | 5 ++++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c index 937ce5fd5809..d2900197a49e 100644 --- a/drivers/usb/host/xhci-mem.c +++ b/drivers/usb/host/xhci-mem.c @@ -2332,7 +2332,8 @@ xhci_add_interrupter(struct xhci_hcd *xhci, struct xhci_interrupter *ir, } struct xhci_interrupter * -xhci_create_secondary_interrupter(struct usb_hcd *hcd, unsigned int segs) +xhci_create_secondary_interrupter(struct usb_hcd *hcd, unsigned int segs, + u32 imod_interval) { struct xhci_hcd *xhci = hcd_to_xhci(hcd); struct xhci_interrupter *ir; @@ -2365,6 +2366,11 @@ xhci_create_secondary_interrupter(struct usb_hcd *hcd, unsigned int segs) return NULL; } + err = xhci_set_interrupter_moderation(ir, imod_interval); + if (err) + xhci_warn(xhci, "Failed to set interrupter %d moderation to %uns\n", + i, imod_interval); + xhci_dbg(xhci, "Add secondary interrupter %d, max interrupters %d\n", i, xhci->max_interrupters); diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index a69245074395..899c0effb5d3 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -347,8 +347,8 @@ static int xhci_disable_interrupter(struct xhci_interrupter *ir) } /* interrupt moderation interval imod_interval in nanoseconds */ -static int xhci_set_interrupter_moderation(struct xhci_interrupter *ir, - u32 imod_interval) +int xhci_set_interrupter_moderation(struct xhci_interrupter *ir, + u32 imod_interval) { u32 imod; diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index d41523c9b15c..1e50ebbe9514 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h @@ -1826,7 +1826,8 @@ struct xhci_container_ctx *xhci_alloc_container_ctx(struct xhci_hcd *xhci, void xhci_free_container_ctx(struct xhci_hcd *xhci, struct xhci_container_ctx *ctx); struct xhci_interrupter * -xhci_create_secondary_interrupter(struct usb_hcd *hcd, unsigned int segs); +xhci_create_secondary_interrupter(struct usb_hcd *hcd, unsigned int segs, + u32 imod_interval); void xhci_remove_secondary_interrupter(struct usb_hcd *hcd, struct xhci_interrupter *ir); @@ -1866,6 +1867,8 @@ int xhci_alloc_tt_info(struct xhci_hcd *xhci, struct xhci_virt_device *virt_dev, struct usb_device *hdev, struct usb_tt *tt, gfp_t mem_flags); +int xhci_set_interrupter_moderation(struct xhci_interrupter *ir, + u32 imod_interval); /* xHCI ring, segment, TRB, and TD functions */ dma_addr_t xhci_trb_virt_to_dma(struct xhci_segment *seg, union xhci_trb *trb);