From patchwork Tue Dec 17 11:29:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Neronin X-Patchwork-Id: 851635 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) (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 C00C41EC4EE for ; Tue, 17 Dec 2024 11:29:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.19 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734434996; cv=none; b=bQIUzXeg7t/KqKUVktseFEAgJTE1j1f/qJHWWQU3GIqTZb0IQ+lul0LsyjBz4Y+dMLpWtnTaw5G3m08jf/xO7z1o2MQCHydcK0AL9aR6S3Fl2uycwdMF8S8EO9/mws31QNrvKHKoM4LgUV7tQY41qdqr7fNLnXmFqyoNrOO4T+w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734434996; c=relaxed/simple; bh=p715tLQkz7+MGl9DNtWrXEZgZa8rp+2hCNV7ofrYtko=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Rk+r8YbL6MQElOrtRL/sJqrIo+hGd8cRTkWJm1pqSsQecg7fHjDegcPTnW9P7zk3Le4qGcloU+q3DvhZRbHFR96jWoD3lXxpp1MvFKHIevnjeWNo4XCKw7DJJpMvSn0ZKiu4i4LNHRUnvY/RRi9JssCtSZdk17mnydgeZbQaUN8= 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=XOwuY3Y+; arc=none smtp.client-ip=192.198.163.19 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="XOwuY3Y+" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1734434995; x=1765970995; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=p715tLQkz7+MGl9DNtWrXEZgZa8rp+2hCNV7ofrYtko=; b=XOwuY3Y+XAk0N1/pfS/IwMn7npTJJpMT66NsBnRuvk54uRVxxjWg3YO+ RD5+3cj3bgYUTz0+LBALgEuOuqgua8EAhTIyjokl+7Jr0x4yzcXCjKD/f rIgrvhAElPrZfdtEHfABoiccg72FPMAR+nqDPVwQL68GXoNh+OtqwVb06 WX/2uRqahAZVvygQOgs/GstHuUBMn02dDejBX/WA2tqIPJI/fZfP9h8iL ri1Ec0eAnHdyCKZ2mbUWyG/BZb+Ghrtg0k8wFKxpAvdZ57drcWZHohglL 541qtKJeIOIY3dahIXHJIzdDxnsLLTozgVWcrB5YVBO21X3pH77XB5LES g==; X-CSE-ConnectionGUID: XqbzpyEIRtGxzgMPJ6EGJw== X-CSE-MsgGUID: QeN5NY4sSq2JSiUGX13apg== X-IronPort-AV: E=McAfee;i="6700,10204,11288"; a="34146748" X-IronPort-AV: E=Sophos;i="6.12,241,1728975600"; d="scan'208";a="34146748" Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Dec 2024 03:29:55 -0800 X-CSE-ConnectionGUID: 8uO8MqBzRLWQ63d0EGCB4Q== X-CSE-MsgGUID: bTYtkxifQ72CsKhZK+Doiw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,224,1728975600"; d="scan'208";a="120766570" Received: from black.fi.intel.com ([10.237.72.28]) by fmviesa002.fm.intel.com with ESMTP; 17 Dec 2024 03:29:53 -0800 Received: by black.fi.intel.com (Postfix, from userid 1058) id 6B91E329; Tue, 17 Dec 2024 13:29:52 +0200 (EET) From: Niklas Neronin To: WeitaoWang-oc@zhaoxin.com, mathias.nyman@linux.intel.com Cc: linux-usb@vger.kernel.org, Niklas Neronin Subject: [PATCH 1/2] usb: xhci: set page size to the xHCI-supported size Date: Tue, 17 Dec 2024 13:29:16 +0200 Message-ID: <20241217112917.623898-2-niklas.neronin@linux.intel.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241217112917.623898-1-niklas.neronin@linux.intel.com> References: <20241217112917.623898-1-niklas.neronin@linux.intel.com> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The current xHCI driver does not validate whether a page size of 4096 bytes is supported. Address the issue by setting the page size to the value supported by the xHCI controller, as read from the Page Size register. Additionally, this commit removes unnecessary debug messages and instead prints the supported and used page size once. The xHCI controller supports page sizes of (2^{(n+12)}) bytes, where 'n' is the Page Size Bit. Only one page size is supported, with a maximum page size of 128 KB. Signed-off-by: Niklas Neronin --- drivers/usb/host/xhci-mem.c | 28 ++++++++++++---------------- drivers/usb/host/xhci.h | 8 ++++---- 2 files changed, 16 insertions(+), 20 deletions(-) diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c index d2900197a49e..471afeba2828 100644 --- a/drivers/usb/host/xhci-mem.c +++ b/drivers/usb/host/xhci-mem.c @@ -1959,7 +1959,6 @@ void xhci_mem_cleanup(struct xhci_hcd *xhci) xhci->interrupters = NULL; xhci->page_size = 0; - xhci->page_shift = 0; xhci->usb2_rhub.bus_state.bus_suspended = 0; xhci->usb3_rhub.bus_state.bus_suspended = 0; } @@ -2378,6 +2377,16 @@ xhci_create_secondary_interrupter(struct usb_hcd *hcd, unsigned int segs, } EXPORT_SYMBOL_GPL(xhci_create_secondary_interrupter); +static void xhci_hcd_page_size(struct xhci_hcd *xhci) +{ + u32 page_shift; + + page_shift = readl(&xhci->op_regs->page_size) & XHCI_PAGE_SIZE_MASK; + xhci->page_size = page_shift << 12; + xhci_dbg_trace(xhci, trace_xhci_dbg_init, "HCD page size set to %iK", + xhci->page_size >> 10); +} + int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags) { struct xhci_interrupter *ir; @@ -2385,7 +2394,7 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags) dma_addr_t dma; unsigned int val, val2; u64 val_64; - u32 page_size, temp; + u32 temp; int i; INIT_LIST_HEAD(&xhci->cmd_list); @@ -2394,20 +2403,7 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags) INIT_DELAYED_WORK(&xhci->cmd_timer, xhci_handle_command_timeout); init_completion(&xhci->cmd_ring_stop_completion); - page_size = readl(&xhci->op_regs->page_size); - xhci_dbg_trace(xhci, trace_xhci_dbg_init, - "Supported page size register = 0x%x", page_size); - i = ffs(page_size); - if (i < 16) - xhci_dbg_trace(xhci, trace_xhci_dbg_init, - "Supported page size of %iK", (1 << (i+12)) / 1024); - else - xhci_warn(xhci, "WARN: no supported page size\n"); - /* Use 4K pages, since that's common and the minimum the HC supports */ - xhci->page_shift = 12; - xhci->page_size = 1 << xhci->page_shift; - xhci_dbg_trace(xhci, trace_xhci_dbg_init, - "HCD page size set to %iK", xhci->page_size / 1024); + xhci_hcd_page_size(xhci); /* * Program the Number of Device Slots Enabled field in the CONFIG diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index f0fb696d5619..03c0f2226571 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h @@ -211,6 +211,9 @@ struct xhci_op_regs { #define CONFIG_CIE (1 << 9) /* bits 10:31 - reserved and should be preserved */ +/* bits 15:0 - HCD page shift bit */ +#define XHCI_PAGE_SIZE_MASK 0xffff + /** * struct xhci_intr_reg - Interrupt Register Set * @irq_pending: IMAN - Interrupt Management Register. Used to enable @@ -1502,10 +1505,7 @@ struct xhci_hcd { u16 max_interrupters; /* imod_interval in ns (I * 250ns) */ u32 imod_interval; - /* 4KB min, 128MB max */ - int page_size; - /* Valid values are 12 to 20, inclusive */ - int page_shift; + u32 page_size; /* MSI-X/MSI vectors */ int nvecs; /* optional clocks */ From patchwork Tue Dec 17 11:29:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Neronin X-Patchwork-Id: 851987 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) (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 1F94250276 for ; Tue, 17 Dec 2024 11:29:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.19 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734435000; cv=none; b=NhIjmQkNdTyivduAHyckLMdQ+y4VpgWIDx6xbCp7hVhJb+QzQJj/vTcCcfH4y+hN1W9jPiWWyuQzOh3If15GY0JFtkAp3TA/+nOPzpsItKkdNXDn2RBFM/qjFqqlGzntIDWpDAdnvRIX8/zxQRMdgGCp5MBOtyI6t06SLc+LKyw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734435000; c=relaxed/simple; bh=EaCMqDtjWKg5GBGxwi9bC6xq2JVR5kXx2gixI+UMdvQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SvyBUcHepa6dkERmobFLsLG63Q8yYbm+8ZGfobd5CcrsuxEnFZYyNUxXZSPlDovt9d+J63GvID5dhyKqaFYJrrd92sJTgLLK8pqJvkour2yOKt6ZVWtnU/1Tv7/wX5GvSyjndexefc/geeNBKm36ioEVhmIbGH8g3yf7M6JboTM= 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=KcQQefc0; arc=none smtp.client-ip=192.198.163.19 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="KcQQefc0" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1734434999; x=1765970999; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=EaCMqDtjWKg5GBGxwi9bC6xq2JVR5kXx2gixI+UMdvQ=; b=KcQQefc0GmVtk+cpEHp4gHhqHgWI2yE/F4xa049AUScG6aYE/VzgwjHX c7/YIca4Yv/yRQNvmWCRFur0SwIXvCQDJkGvIOJDk8DQBmlRSPOT7leLF GzT77jQcsYV+JUPQrPfS/2SVUZcY8S1clhdKXYum471FbxCRjhs7J/Nhp GpQmwUPskrNBeg4OSIKM0vdf4KZ5DNQo9+8SD1XJm5DVi0Bsig06F3Mft vjCnq0Hox060dlFQCyWBUP84wRzLwUeNdAEJsdCZXiSFClYxtzonbe+Mp 1pl+9hiybkzGlSajlXsXX/F0R9MohLl28L7+EO1kZMgSKXRnsVuXJR6JS A==; X-CSE-ConnectionGUID: pxDjwdtHSviJy5qOd7cD8Q== X-CSE-MsgGUID: oEqNqOFSQRO7pc9GfzCD0A== X-IronPort-AV: E=McAfee;i="6700,10204,11288"; a="34146758" X-IronPort-AV: E=Sophos;i="6.12,241,1728975600"; d="scan'208";a="34146758" Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Dec 2024 03:29:56 -0800 X-CSE-ConnectionGUID: p8Sm3blSS5GAVxspwV1jzw== X-CSE-MsgGUID: geZaBBQlQiyVWytCfLsf4w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,224,1728975600"; d="scan'208";a="120766573" Received: from black.fi.intel.com ([10.237.72.28]) by fmviesa002.fm.intel.com with ESMTP; 17 Dec 2024 03:29:54 -0800 Received: by black.fi.intel.com (Postfix, from userid 1058) id 443D8331; Tue, 17 Dec 2024 13:29:53 +0200 (EET) From: Niklas Neronin To: WeitaoWang-oc@zhaoxin.com, mathias.nyman@linux.intel.com Cc: linux-usb@vger.kernel.org, Niklas Neronin Subject: [PATCH 2/2] Revert "xhci: Fix TRB prefetch issue of ZHAOXIN hosts" Date: Tue, 17 Dec 2024 13:29:17 +0200 Message-ID: <20241217112917.623898-3-niklas.neronin@linux.intel.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241217112917.623898-1-niklas.neronin@linux.intel.com> References: <20241217112917.623898-1-niklas.neronin@linux.intel.com> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This reverts commit 2a865a652299f5666f3b785cbe758c5f57453036. Signed-off-by: Niklas Neronin --- drivers/usb/host/xhci-mem.c | 8 ++------ drivers/usb/host/xhci-pci.c | 7 +------ drivers/usb/host/xhci.h | 2 +- 3 files changed, 4 insertions(+), 13 deletions(-) diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c index 471afeba2828..3a0b98a427e9 100644 --- a/drivers/usb/host/xhci-mem.c +++ b/drivers/usb/host/xhci-mem.c @@ -2439,12 +2439,8 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags) * and our use of dma addresses in the trb_address_map radix tree needs * TRB_SEGMENT_SIZE alignment, so we pick the greater alignment need. */ - if (xhci->quirks & XHCI_ZHAOXIN_TRB_FETCH) - xhci->segment_pool = dma_pool_create("xHCI ring segments", dev, - TRB_SEGMENT_SIZE * 2, TRB_SEGMENT_SIZE * 2, xhci->page_size * 2); - else - xhci->segment_pool = dma_pool_create("xHCI ring segments", dev, - TRB_SEGMENT_SIZE, TRB_SEGMENT_SIZE, xhci->page_size); + xhci->segment_pool = dma_pool_create("xHCI ring segments", dev, + TRB_SEGMENT_SIZE, TRB_SEGMENT_SIZE, xhci->page_size); /* See Table 46 and Note on Figure 55 */ xhci->device_pool = dma_pool_create("xHCI input/output contexts", dev, diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c index cb07cee9ed0c..c8322bb828a6 100644 --- a/drivers/usb/host/xhci-pci.c +++ b/drivers/usb/host/xhci-pci.c @@ -473,13 +473,8 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci) xhci->quirks |= XHCI_ZHAOXIN_HOST; xhci->quirks |= XHCI_LPM_SUPPORT; - if (pdev->device == 0x9202) { + if (pdev->device == 0x9202) xhci->quirks |= XHCI_RESET_ON_RESUME; - xhci->quirks |= XHCI_ZHAOXIN_TRB_FETCH; - } - - if (pdev->device == 0x9203) - xhci->quirks |= XHCI_ZHAOXIN_TRB_FETCH; } if (pdev->vendor == PCI_DEVICE_ID_CADENCE && diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index 03c0f2226571..03a1c31228fc 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h @@ -1620,7 +1620,7 @@ struct xhci_hcd { #define XHCI_EP_CTX_BROKEN_DCS BIT_ULL(42) #define XHCI_SUSPEND_RESUME_CLKS BIT_ULL(43) #define XHCI_RESET_TO_DEFAULT BIT_ULL(44) -#define XHCI_ZHAOXIN_TRB_FETCH BIT_ULL(45) +#define XHCI_ZHAOXIN_TRB_FETCH BIT_ULL(45) /* Deprecated */ #define XHCI_ZHAOXIN_HOST BIT_ULL(46) #define XHCI_WRITE_64_HI_LO BIT_ULL(47) #define XHCI_CDNS_SCTX_QUIRK BIT_ULL(48)