From patchwork Fri Dec 27 12:01:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mathias Nyman X-Patchwork-Id: 13921774 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.14]) (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 4FB7579CD for ; Fri, 27 Dec 2024 12:00:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.14 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735300853; cv=none; b=UE3uo7QdepaAJH/4+x/bUE5hR70o0y6KlcwLjIDT/aIee6MxrMqX7Vh7phbir7HzCDBNPpmabp/6b8Z9mdOPzxsprZzH8K0YemWY/BYdq9S2p7SPxVN2z0DCOZalbxjVEX2nL/Lg1vlvOXiMBv6YFMcPwQNvKgSxkXuCnguIquE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735300853; c=relaxed/simple; bh=p/r9M775DijYgWVNHs9Bp2oFksL/LIo1ralk2l27zro=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=GH8h3I+JVP2Ru+i44wou1WUNMQKydP7nysv+bmJetxEx34ILDhnr6LY2HkdAsmjY0WQENtUx7W0992X/6Rqk7HFa4AaC4dpbgnqGKiX/UxWO6ZgQ3IDpVHodZLR/FrADoVYrN/bQNDMIdaORl55MVNfV76iq25hpHFR7cP7MJxY= 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=ApZY/Q7D; arc=none smtp.client-ip=192.198.163.14 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="ApZY/Q7D" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1735300851; x=1766836851; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=p/r9M775DijYgWVNHs9Bp2oFksL/LIo1ralk2l27zro=; b=ApZY/Q7DGlo2L7nN4g5zpbnMKHSNWu9hYfvFQA6SpOuulkXQIoEGJrWk s+J08bQM2x9vJQaCVPa48BRstFCQ/lq1IxJEsJXgQ0YkIeK/ZrGwjH2au 0oSrzMraHddQ3ycOA7Q7uLkAdl8D9Tl88iQzR1b+Q8YG8qeiFf/PzglLz bRZZ5KVyr7r21q13VIdup8jyselBinoHkE0D8MPDAPHMPER2hZFLGY/Rs 3oL16QHjQuwLaYo2+TpYbKZPk0R59ECU28+e938OLn6QfufyHLQWatX0n X5lL0GBfKc3GHrvdDRkBQmCqbYN/dEtFR3P05sW+1vwbTeefQh4QwAhUH w==; X-CSE-ConnectionGUID: BwkKhVkWSSa5WT+oBfWn8w== X-CSE-MsgGUID: dqiI7qqVT9uHOKKPPL6lvg== X-IronPort-AV: E=McAfee;i="6700,10204,11298"; a="35932517" X-IronPort-AV: E=Sophos;i="6.12,269,1728975600"; d="scan'208";a="35932517" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by fmvoesa108.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Dec 2024 04:00:51 -0800 X-CSE-ConnectionGUID: Tgyd5c0iRDus1SWEGbGRcg== X-CSE-MsgGUID: EOD52C0SQC+PKH5H3QKMaQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,224,1728975600"; d="scan'208";a="104772437" Received: from mattu-haswell.fi.intel.com ([10.237.72.199]) by fmviesa005.fm.intel.com with ESMTP; 27 Dec 2024 04:00:49 -0800 From: Mathias Nyman To: Cc: , Mathias Nyman , =?utf-8?q?=C5=81ukasz_Bartos?= =?utf-8?q?ik?= Subject: [PATCH 1/5] xhci: dbc: Improve performance by removing delay in transfer event polling. Date: Fri, 27 Dec 2024 14:01:38 +0200 Message-Id: <20241227120142.1035206-2-mathias.nyman@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241227120142.1035206-1-mathias.nyman@linux.intel.com> References: <20241227120142.1035206-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 Queue event polling work with 0 delay in case there are pending transfers queued up. This is part 2 of a 3 part series that roughly triples dbc performace when using adb push and pull over dbc. Max/min push rate after patches is 210/118 MB/s, pull rate 171/133 MB/s, tested with large files (300MB-9GB) by Łukasz Bartosik First performance improvement patch was commit 31128e7492dc ("xhci: dbc: add dbgtty request to end of list once it completes") Cc: Łukasz Bartosik Signed-off-by: Mathias Nyman --- drivers/usb/host/xhci-dbgcap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/host/xhci-dbgcap.c b/drivers/usb/host/xhci-dbgcap.c index 227e513867dd..fd7895b24367 100644 --- a/drivers/usb/host/xhci-dbgcap.c +++ b/drivers/usb/host/xhci-dbgcap.c @@ -957,7 +957,7 @@ static void xhci_dbc_handle_events(struct work_struct *work) /* set fast poll rate if there are pending data transfers */ if (!list_empty(&dbc->eps[BULK_OUT].list_pending) || !list_empty(&dbc->eps[BULK_IN].list_pending)) - poll_interval = 1; + poll_interval = 0; break; default: dev_info(dbc->dev, "stop handling dbc events\n"); From patchwork Fri Dec 27 12:01:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mathias Nyman X-Patchwork-Id: 13921775 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.14]) (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 8095B156F30 for ; Fri, 27 Dec 2024 12:00:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.14 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735300854; cv=none; b=WeSvt7+wc02dUHUSg4F2GEAduo3WrQGu7aapQKCi42TDNbIWZ9xlsByOEsyDTvbH0/F+rpCxeSPH3lwikqe6q2x+MDC18ENrOHDk4yFNXB/3coMcAlWraZ+2qbESSdFRxskSXfFzxcvPK2iUW+C3XF3C/VGlxWtXOrPBo5rHvNE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735300854; c=relaxed/simple; bh=vfrezEXgg5FfHcY5XjWZybh4amu/zpUhGq8PHVUsPOc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=H17Nv5QdiR5NE+DMnDz40zMwUAFnkA5pyVKjiKNamKsj9z5bm18t2DbVMqM0MbSJaHhXFiicwCwqNspGdkS0X8UER1+EgWAahPUUYsKgJo3kbdYmO7Yie/nQ/TXYRkKL6+AOjCmknSvz2BkVpd0Els9U4efR5vuZA4iWuZO5kl4= 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=HAzZBcxN; arc=none smtp.client-ip=192.198.163.14 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="HAzZBcxN" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1735300853; x=1766836853; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=vfrezEXgg5FfHcY5XjWZybh4amu/zpUhGq8PHVUsPOc=; b=HAzZBcxNxI78zbMkba788VHw7fzqxEGDQxBe6DahGBYZXJnn8A3ksbEN Fj6ZUolNAeQBwp68upyplTsman9P9vXDbdndStOIkSGcDTkJ1r/QWh2Dv mSxDY6eLe+K7h8j8Z52lDax2logCfc+5+G9Q6ulOcFDrDMHHC1Q6Cp0TG 9hV9XRGesUe0SXojBYwveTXzFC7f/bOfrOqmrxJZ/6G5aXayx2mqVnR1U c6kr/mGurqjcdJLG9Jlvd1JUQ3WOSdRnTMVNtHAY4WQYx/bWjhgIjJE0g NDEMO1bf8bKS2CZC7qemCZkCID568iYA8Pl4Yr8lmieUp2s75qYI9ZCg1 w==; X-CSE-ConnectionGUID: wlWdcrYJTIC4KaYeV5ev1Q== X-CSE-MsgGUID: tQ3AYcKkTD2QpORttOvfGQ== X-IronPort-AV: E=McAfee;i="6700,10204,11298"; a="35932522" X-IronPort-AV: E=Sophos;i="6.12,269,1728975600"; d="scan'208";a="35932522" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by fmvoesa108.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Dec 2024 04:00:52 -0800 X-CSE-ConnectionGUID: AP7zFGK8QUyCLTf3GtV6zg== X-CSE-MsgGUID: fDcDkELWSM2vU5dtn4N7pg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,224,1728975600"; d="scan'208";a="104772441" Received: from mattu-haswell.fi.intel.com ([10.237.72.199]) by fmviesa005.fm.intel.com with ESMTP; 27 Dec 2024 04:00:51 -0800 From: Mathias Nyman To: Cc: , Mathias Nyman , =?utf-8?q?=C5=81ukasz_Bartos?= =?utf-8?q?ik?= Subject: [PATCH 2/5] xhci: dbgtty: Improve performance by handling received data immediately. Date: Fri, 27 Dec 2024 14:01:39 +0200 Message-Id: <20241227120142.1035206-3-mathias.nyman@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241227120142.1035206-1-mathias.nyman@linux.intel.com> References: <20241227120142.1035206-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 Improve dbc transfer rate performance by copying the received data to the tty buffer directly in the request complete callback function if possible. Only defer it in case there is already pending deferred work, tty is throttled, or we fail copy the data to the tty buffer The request complete callback is already called by a workqueue. This is part 3/3 of a dbc performance improvement series that roughly triples dbc performace when using adb push and pull over dbc. Max/min push rate after patches is 210/118 MB/s, pull rate 171/133 MB/s, tested with large files (300MB-9GB) by Łukasz Bartosik Cc: Łukasz Bartosik Signed-off-by: Mathias Nyman --- drivers/usb/host/xhci-dbgtty.c | 98 ++++++++++++++++++++++------------ 1 file changed, 65 insertions(+), 33 deletions(-) diff --git a/drivers/usb/host/xhci-dbgtty.c b/drivers/usb/host/xhci-dbgtty.c index d719c16ea30b..60ed753c85bb 100644 --- a/drivers/usb/host/xhci-dbgtty.c +++ b/drivers/usb/host/xhci-dbgtty.c @@ -110,15 +110,74 @@ static void dbc_start_rx(struct dbc_port *port) } } +/* + * Queue received data to tty buffer and push it. + * + * Returns nr of remaining bytes that didn't fit tty buffer, i.e. 0 if all + * bytes sucessfullt moved. In case of error returns negative errno. + * Call with lock held + */ +static int dbc_rx_push_buffer(struct dbc_port *port, struct dbc_request *req) +{ + char *packet = req->buf; + unsigned int n, size = req->actual; + int count; + + if (!req->actual) + return 0; + + /* if n_read is set then request was partially moved to tty buffer */ + n = port->n_read; + if (n) { + packet += n; + size -= n; + } + + count = tty_insert_flip_string(&port->port, packet, size); + if (count) + tty_flip_buffer_push(&port->port); + if (count != size) { + port->n_read += count; + return size - count; + } + + port->n_read = 0; + return 0; +} + static void dbc_read_complete(struct xhci_dbc *dbc, struct dbc_request *req) { unsigned long flags; struct dbc_port *port = dbc_to_port(dbc); + struct tty_struct *tty; + int untransferred; + + tty = port->port.tty; spin_lock_irqsave(&port->port_lock, flags); + + /* + * Only defer copyig data to tty buffer in case: + * - !list_empty(&port->read_queue), there are older pending data + * - tty is throttled + * - failed to copy all data to buffer, defer remaining part + */ + + if (list_empty(&port->read_queue) && tty && !tty_throttled(tty)) { + untransferred = dbc_rx_push_buffer(port, req); + if (untransferred == 0) { + list_add_tail(&req->list_pool, &port->read_pool); + if (req->status != -ESHUTDOWN) + dbc_start_rx(port); + goto out; + } + } + + /* defer moving data from req to tty buffer to a tasklet */ list_add_tail(&req->list_pool, &port->read_queue); tasklet_schedule(&port->push); +out: spin_unlock_irqrestore(&port->port_lock, flags); } @@ -331,10 +390,10 @@ static void dbc_rx_push(struct tasklet_struct *t) struct dbc_request *req; struct tty_struct *tty; unsigned long flags; - bool do_push = false; bool disconnect = false; struct dbc_port *port = from_tasklet(port, t, push); struct list_head *queue = &port->read_queue; + int untransferred; spin_lock_irqsave(&port->port_lock, flags); tty = port->port.tty; @@ -356,42 +415,15 @@ static void dbc_rx_push(struct tasklet_struct *t) break; } - if (req->actual) { - char *packet = req->buf; - unsigned int n, size = req->actual; - int count; - - n = port->n_read; - if (n) { - packet += n; - size -= n; - } - - count = tty_insert_flip_string(&port->port, packet, - size); - if (count) - do_push = true; - if (count != size) { - port->n_read += count; - break; - } - port->n_read = 0; - } + untransferred = dbc_rx_push_buffer(port, req); + if (untransferred > 0) + break; list_move_tail(&req->list_pool, &port->read_pool); } - if (do_push) - tty_flip_buffer_push(&port->port); - - if (!list_empty(queue) && tty) { - if (!tty_throttled(tty)) { - if (do_push) - tasklet_schedule(&port->push); - else - pr_warn("ttyDBC0: RX not scheduled?\n"); - } - } + if (!list_empty(queue)) + tasklet_schedule(&port->push); if (!disconnect) dbc_start_rx(port); From patchwork Fri Dec 27 12:01:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathias Nyman X-Patchwork-Id: 13921776 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.14]) (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 5C5771F190D; Fri, 27 Dec 2024 12:00:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.14 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735300856; cv=none; b=MpA5rTzU1WUj4nzOip62XlA4twaMNTkt7oNWV1q0fgEhH/vQgdywveUEfOowiB9fsQC6yjZoIrb0WaQvw4pe08ek77gQIWgja+u+DljYGxg9pQxYyXTm9fwuvMMiUPa4Q9BS49SOOoZ1mkaDtutOq65oORzFZk1duuZQqOi0t1M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735300856; c=relaxed/simple; bh=4qQzC02wqrdGnNxqHzqMTu/5RUVAiwcDlAflh1KJkWg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=LIvHR0jTWQXuk2z922We/tU1zjY20unqnQxXL/mBXCfMQR64+MoyainSV/5sg4vlWfe20MHCPLI8AfRzp+JCTbpQuGuvbyJAupi0cd2g3vGuPLgu/zhJewaqgYq+8evgrGaaAK8JAxE3HC3uNkCcdhyl6owrT/jCNR51caTBU8U= 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=Hx0TmUyq; arc=none smtp.client-ip=192.198.163.14 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="Hx0TmUyq" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1735300854; x=1766836854; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=4qQzC02wqrdGnNxqHzqMTu/5RUVAiwcDlAflh1KJkWg=; b=Hx0TmUyqNw3edZf/dXDI8MFX7zSE4wwdv9XMO3Owq+SLxdeYagOrweiG 1f8b3moz1VBfoKb7pAJNLUF8HN6SpYbPZneGSEvIFM5kEqOX8Uko4Vs5Y 77595r3Z43oDuU3/tOsedCvDgkx7RbLm7H/3OSQE9tlG6nf2+hInH6Hah w93l2QS70NwfrOWJjtt92Kc3t8kUs2uwRBvtpIWhMR6DK38kiIRgzXQ9L oK8VvySwYhnw8urDtvAGtZKlcp8l+DHKylTWV6SmhvPVwjy/65UnSiX9T O+dy9bkXVnMCSghWaWuWWVrbV1gHFg45pNjGRy6feC9V7jNsPXmw+TI4K Q==; X-CSE-ConnectionGUID: zC8+wOqXTMqEtiDk/6Eg6Q== X-CSE-MsgGUID: FT5zzKMSRbiVe/Ye1rgY6w== X-IronPort-AV: E=McAfee;i="6700,10204,11298"; a="35932527" X-IronPort-AV: E=Sophos;i="6.12,269,1728975600"; d="scan'208";a="35932527" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by fmvoesa108.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Dec 2024 04:00:54 -0800 X-CSE-ConnectionGUID: icueMuu2QbOMTyPg9svYuA== X-CSE-MsgGUID: SCiyC6HtSsSK97X1ZKNWSw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,224,1728975600"; d="scan'208";a="104772445" Received: from mattu-haswell.fi.intel.com ([10.237.72.199]) by fmviesa005.fm.intel.com with ESMTP; 27 Dec 2024 04:00:52 -0800 From: Mathias Nyman To: Cc: , Michal Pecio , stable@vger.kernel.org, Mathias Nyman Subject: [PATCH 3/5] usb: xhci: Fix NULL pointer dereference on certain command aborts Date: Fri, 27 Dec 2024 14:01:40 +0200 Message-Id: <20241227120142.1035206-4-mathias.nyman@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241227120142.1035206-1-mathias.nyman@linux.intel.com> References: <20241227120142.1035206-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: Michal Pecio If a command is queued to the final usable TRB of a ring segment, the enqueue pointer is advanced to the subsequent link TRB and no further. If the command is later aborted, when the abort completion is handled the dequeue pointer is advanced to the first TRB of the next segment. If no further commands are queued, xhci_handle_stopped_cmd_ring() sees the ring pointers unequal and assumes that there is a pending command, so it calls xhci_mod_cmd_timer() which crashes if cur_cmd was NULL. Don't attempt timer setup if cur_cmd is NULL. The subsequent doorbell ring likely is unnecessary too, but it's harmless. Leave it alone. This is probably Bug 219532, but no confirmation has been received. The issue has been independently reproduced and confirmed fixed using a USB MCU programmed to NAK the Status stage of SET_ADDRESS forever. Everything continued working normally after several prevented crashes. Link: https://bugzilla.kernel.org/show_bug.cgi?id=219532 Fixes: c311e391a7ef ("xhci: rework command timeout and cancellation,") CC: stable@vger.kernel.org Signed-off-by: Michal Pecio Signed-off-by: Mathias Nyman --- drivers/usb/host/xhci-ring.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index 4cf5363875c7..da26e317ab0c 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -422,7 +422,8 @@ static void xhci_handle_stopped_cmd_ring(struct xhci_hcd *xhci, if ((xhci->cmd_ring->dequeue != xhci->cmd_ring->enqueue) && !(xhci->xhc_state & XHCI_STATE_DYING)) { xhci->current_cmd = cur_cmd; - xhci_mod_cmd_timer(xhci); + if (cur_cmd) + xhci_mod_cmd_timer(xhci); xhci_ring_cmd_db(xhci); } } From patchwork Fri Dec 27 12:01:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathias Nyman X-Patchwork-Id: 13921777 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.14]) (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 B0610156F30 for ; Fri, 27 Dec 2024 12:00:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.14 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735300857; cv=none; b=hZ5KyAfPk5XoV2dsN1InHWcT5zfVgvNS8tUi4xbodldKfetRmK4j2AVnVSh62CGpa71RzV8AItRt5+VEz/R5H2dNunF7aOpQ0/4ScWXbiZx3eLk/wbTeaqtMaxgFP+R81AF/PyPFIK2ptxfYUfs6o8XwFlf7YG6HPnecVQmqjBg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735300857; c=relaxed/simple; bh=pRMwYk48x3YwKnRHv35RHEganziIbN+DGCJx+N4kNAs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=lPZ//o3sx57HXbW84Fy0dKjLK4UWlo9CYHpHZTo4Et9qVfKqCHUIDqme0AOjqzLARF9aOH/jCiPCtAln1oohCgqP0G8ou90a/vB++HacknP5/5DxwIEBxTWuG77lovBGqcFKair3DzhDqxF/vOEz24Q73+9H3Y+43vfPt+7juDE= 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=WTnj/AKY; arc=none smtp.client-ip=192.198.163.14 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="WTnj/AKY" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1735300856; x=1766836856; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=pRMwYk48x3YwKnRHv35RHEganziIbN+DGCJx+N4kNAs=; b=WTnj/AKYBa8wgScumf8nTStymddwVWMm6DmWohRFDTu4p+GybiNEpD+V /0utrI26PxGo5rIPrAiJqZ/qWDllbutuDWCml2ctwQwUVRquFqmmUCa7G gcCSA/eoi3oRb1LX8v3jJ/ldAJSmJBICCokTeUQ++p5fiLtH8JedNMTR/ uc88WHmrQC+JX++6WNXk4tVeZ33nrQ3NCc/SFOfNEN9uHOj87IlYbtfKT FIo7Ryq5U3pWSmY1bTF1T+jc3pEIKuAO7j+LKKrID5lRie84GbXEl4Tq9 T/SpOYQTT4+Y0qWLBBXl+LAJMYaWwSaJjAuFNaArTSlmRVn0vwUz5P2sT A==; X-CSE-ConnectionGUID: jDwYNsBeQc606TVwx9zL/w== X-CSE-MsgGUID: 7kqhvfTIRSCoCmH5LD0VRw== X-IronPort-AV: E=McAfee;i="6700,10204,11298"; a="35932530" X-IronPort-AV: E=Sophos;i="6.12,269,1728975600"; d="scan'208";a="35932530" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by fmvoesa108.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Dec 2024 04:00:56 -0800 X-CSE-ConnectionGUID: POcWN7t4SReOU1fsN8Utig== X-CSE-MsgGUID: oKu4w0rRSy2Vn+Qmg6XxkA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,224,1728975600"; d="scan'208";a="104772453" Received: from mattu-haswell.fi.intel.com ([10.237.72.199]) by fmviesa005.fm.intel.com with ESMTP; 27 Dec 2024 04:00:54 -0800 From: Mathias Nyman To: Cc: , Mathias Nyman Subject: [PATCH 4/5] xhci: Add command completion parameter support Date: Fri, 27 Dec 2024 14:01:41 +0200 Message-Id: <20241227120142.1035206-5-mathias.nyman@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241227120142.1035206-1-mathias.nyman@linux.intel.com> References: <20241227120142.1035206-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 xHC hosts can pass 24 bits of data with a command completion event TRB as the completion code only uses 8 bits of the 32 bit status field. Only Configure Endpoint, and Get Extended Property commands utilize this "command completion parameter" 24 bit field. For other command completion events the xHC should keep it RsvdZ. Signed-off-by: Mathias Nyman --- drivers/usb/host/xhci-ring.c | 10 ++++++---- drivers/usb/host/xhci.h | 4 ++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index da26e317ab0c..18ad33a01d32 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -1652,12 +1652,13 @@ static void xhci_handle_cmd_nec_get_fw(struct xhci_hcd *xhci, NEC_FW_MINOR(le32_to_cpu(event->status))); } -static void xhci_complete_del_and_free_cmd(struct xhci_command *cmd, u32 status) +static void xhci_complete_del_and_free_cmd(struct xhci_command *cmd, u32 comp_code, u32 comp_param) { list_del(&cmd->cmd_list); if (cmd->completion) { - cmd->status = status; + cmd->status = comp_code; + cmd->comp_param = comp_param; complete(cmd->completion); } else { kfree(cmd); @@ -1669,7 +1670,7 @@ void xhci_cleanup_command_queue(struct xhci_hcd *xhci) struct xhci_command *cur_cmd, *tmp_cmd; xhci->current_cmd = NULL; list_for_each_entry_safe(cur_cmd, tmp_cmd, &xhci->cmd_list, cmd_list) - xhci_complete_del_and_free_cmd(cur_cmd, COMP_COMMAND_ABORTED); + xhci_complete_del_and_free_cmd(cur_cmd, COMP_COMMAND_ABORTED, 0); } void xhci_handle_command_timeout(struct work_struct *work) @@ -1754,6 +1755,7 @@ static void handle_cmd_completion(struct xhci_hcd *xhci, struct xhci_event_cmd *event) { unsigned int slot_id = TRB_TO_SLOT_ID(le32_to_cpu(event->flags)); + u32 status = le32_to_cpu(event->status); u64 cmd_dma; dma_addr_t cmd_dequeue_dma; u32 cmd_comp_code; @@ -1882,7 +1884,7 @@ static void handle_cmd_completion(struct xhci_hcd *xhci, } event_handled: - xhci_complete_del_and_free_cmd(cmd, cmd_comp_code); + xhci_complete_del_and_free_cmd(cmd, cmd_comp_code, COMP_PARAM(status)); inc_deq(xhci, xhci->cmd_ring); } diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index 4914f0a10cff..8c164340a2c3 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h @@ -529,6 +529,7 @@ struct xhci_command { /* Input context for changing device state */ struct xhci_container_ctx *in_ctx; u32 status; + u32 comp_param; int slot_id; /* If completion is null, no one is waiting on this command * and the structure can be freed after the command completes. @@ -959,6 +960,9 @@ struct xhci_event_cmd { __le32 flags; }; +/* status bitmasks */ +#define COMP_PARAM(p) ((p) & 0xffffff) /* Command Completion Parameter */ + /* Address device - disable SetAddress */ #define TRB_BSR (1<<9) From patchwork Fri Dec 27 12:01:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathias Nyman X-Patchwork-Id: 13921778 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.14]) (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 1B42A155336 for ; Fri, 27 Dec 2024 12:00:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.14 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735300858; cv=none; b=jMF5mYZDj07m3AXnHHj2J+BvdYSKff/wmmi+B57a74vBQR0QRjacVFg9DQe07+5dBvHh3wZZOzbjKZNHeIpN1KUyEM0J1raOSqkOeF/I6k/KGSDRz8lMVGZsbgta0HvgjeKx5lX4Sj1R10ZTJdG1VOGEmCORenXTponF1TEWQbQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735300858; c=relaxed/simple; bh=2CnCMP7jM8dDaNlbV30y5UmDchB35bFdXfWnsk8VkfE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=mJwfciDuzW9h95Y5O4JDL8N9LVwqVULxMtFxz2RQMvt5I13LvBs/dBiXJTFGbahh1yA+bx8K7oioCiBeYxqlW4rUW3RBuJTgtT07sLlbBvWDoSAsp4DDzkZg8XwD0MFoU/RyYDYq9Z4PTAs9+985NIppOIyMtC2La3kM8R9iYTw= 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=Wfan24ab; arc=none smtp.client-ip=192.198.163.14 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="Wfan24ab" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1735300857; x=1766836857; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=2CnCMP7jM8dDaNlbV30y5UmDchB35bFdXfWnsk8VkfE=; b=Wfan24abCPVCEOb3IvVvU7WDciqSOCmKKhziz3lSE/2MavSvSC8u5TUg AsDP6wvOydB1UVduvFsGzlAPHV9NbiFEaprgZgZEupVM0G+1xqunfwRAv cl7KPMviVSOI6jDMRuNj7/QynoDucnV5ne83M4jpq4DVy37RhSVV1bv7O 1i/bLYgwiI3LSpI/m5ShihlFSLo4n/Dtr5U5iG7qxa4CRDpOENQ9+f8Dj WHZWLXZbOwj+TF+Zsn2h5JRlSTseqTrmMpOJkQ9ApTiSQ4mr6fCQjpqzl XajZMUp13RWETCJzbyBU3sP0t2bFlNRb3oOnc0d3OTW7kKu5/j9QVSDT1 A==; X-CSE-ConnectionGUID: P/9oRTcGQIOMrxtQhbiVyQ== X-CSE-MsgGUID: o84X4Bq0Qk6H+PTiydLO4Q== X-IronPort-AV: E=McAfee;i="6700,10204,11298"; a="35932533" X-IronPort-AV: E=Sophos;i="6.12,269,1728975600"; d="scan'208";a="35932533" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by fmvoesa108.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Dec 2024 04:00:57 -0800 X-CSE-ConnectionGUID: wRExDhSBTMygO3zvLJ8X7Q== X-CSE-MsgGUID: ZuszN51BREm6nqtAU9GE6A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,224,1728975600"; d="scan'208";a="104772459" Received: from mattu-haswell.fi.intel.com ([10.237.72.199]) by fmviesa005.fm.intel.com with ESMTP; 27 Dec 2024 04:00:56 -0800 From: Mathias Nyman To: Cc: , Mathias Nyman Subject: [PATCH 5/5] xhci: Add missing capability definition bits Date: Fri, 27 Dec 2024 14:01:42 +0200 Message-Id: <20241227120142.1035206-6-mathias.nyman@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241227120142.1035206-1-mathias.nyman@linux.intel.com> References: <20241227120142.1035206-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 Add capability bits for the xHC Capability Parameters 2 (HCCPARAMS2) register described in xHCI specification section 5.3.9 bit 7 Extended TBC TRB Status Capability (ETC_TSC) bit 8 Get/Set Extended Property Capability (GSC) bit 9 Virtualization Based Trusted I/O Capability (VTC) Signed-off-by: Mathias Nyman --- drivers/usb/host/xhci-caps.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/usb/host/xhci-caps.h b/drivers/usb/host/xhci-caps.h index 9e94cebf4a56..f6b9a00a0ab9 100644 --- a/drivers/usb/host/xhci-caps.h +++ b/drivers/usb/host/xhci-caps.h @@ -83,3 +83,9 @@ #define HCC2_CIC(p) ((p) & (1 << 5)) /* true: HC support Extended TBC Capability, Isoc burst count > 65535 */ #define HCC2_ETC(p) ((p) & (1 << 6)) +/* true: HC support Extended TBC TRB Status Capability */ +#define HCC2_ETC_TSC(p) ((p) & (1 << 7)) +/* true: HC support Get/Set Extended Property Capability */ +#define HCC2_GSC(p) ((p) & (1 << 8)) +/* true: HC support Virtualization Based Trusted I/O Capability */ +#define HCC2_VTC(p) ((p) & (1 << 9))