Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp2180828rwr; Fri, 21 Apr 2023 05:40:16 -0700 (PDT) X-Google-Smtp-Source: AKy350ZrNRZJOs9pTkQAt5JrJnyw6vetmN6aFhVpAeg0hlCNXhcy13/epTwEnAEoHTS0LdhIcumz X-Received: by 2002:a05:6a00:14cf:b0:63b:5257:6837 with SMTP id w15-20020a056a0014cf00b0063b52576837mr5618333pfu.1.1682080815781; Fri, 21 Apr 2023 05:40:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682080815; cv=none; d=google.com; s=arc-20160816; b=vRj945lGH5stsgC4Q45jQu5K5heU69/j/a2UClAPXVH3J47gjZf/9hlUVKgnQpSQST aeoS3XyMpmMbXmUnjxLQ2suK/1jAd5rVPwya11dp2vLQwbPp/Xa/fct5pn6HVAtx8T26 UsmB3RxEYw9zsh6DPpC5zCg0H3htE0ay/peFKnfhhm8efI+Or9YYFK6FOywRy/Jk+Lpb Kjw5wVJXtD4Tg6LlRm7Wv/fdA6unb3HikrkVLH6EQ9KgTExjY673AdLc3JA4hZ7rY9Zn PJMn10guAOjX/4fvETB5Tn8zjWi4XCaCuO5UB9bddf3P00t8YYrhRPFKK59BNt/YaQ8P fQJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=YHRj5L/fLF3iNxolLfIS/dvyys47E00n6wRHH+tu1Rw=; b=H5yspe7m24v4uYRTol0BoSH8vgfpxsPyoGwX5AkMvvwV0eN9WaPyPB78aNHLGgRfoU 1HjXK6TNQuL1E1ZPPpYcWzc+uwMSRxXn6D930ANu/RwHNkqMYXj8GKXm+BClSJJbCF04 MKLfSPEYVNMVoGEXdgLVXfZztfHyu6lrj3ztb84DFS09S6ioCXrKH8q3bIyr57/pjVgm C8zgFgkJ3oAJ2hS0BVWRoH3A+97yzEd8BT4MNsIwNVyOyQA3QQezh76cBm5UujjNj5LK 1GUdBhS+S9BZpFUNJKDAulMumQus8Tyd6HaLRZJ3hS7aYi6CtDjuRiDhQfpKquKEq7Uc DnwQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k190-20020a6284c7000000b0063f24efaf7bsi272497pfd.390.2023.04.21.05.40.01; Fri, 21 Apr 2023 05:40:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232083AbjDUMjU (ORCPT + 99 others); Fri, 21 Apr 2023 08:39:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232075AbjDUMjE (ORCPT ); Fri, 21 Apr 2023 08:39:04 -0400 Received: from mx2.zhaoxin.com (mx2.zhaoxin.com [203.110.167.99]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 36D4AC645 for ; Fri, 21 Apr 2023 05:39:01 -0700 (PDT) X-ASG-Debug-ID: 1682080734-1eb14e6388386f0003-xx1T2L Received: from ZXSHMBX1.zhaoxin.com (ZXSHMBX1.zhaoxin.com [10.28.252.163]) by mx2.zhaoxin.com with ESMTP id E01wIE25l8yGQyfi (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NO); Fri, 21 Apr 2023 20:38:55 +0800 (CST) X-Barracuda-Envelope-From: WeitaoWang-oc@zhaoxin.com X-Barracuda-RBL-Trusted-Forwarder: 10.28.252.163 Received: from zxbjmbx1.zhaoxin.com (10.29.252.163) by ZXSHMBX1.zhaoxin.com (10.28.252.163) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Fri, 21 Apr 2023 20:38:54 +0800 Received: from L440.zhaoxin.com (10.29.8.21) by zxbjmbx1.zhaoxin.com (10.29.252.163) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Fri, 21 Apr 2023 20:38:54 +0800 X-Barracuda-RBL-Trusted-Forwarder: 10.28.252.163 From: Weitao Wang X-Barracuda-RBL-Trusted-Forwarder: 10.29.252.163 To: , , , CC: , , Subject: [PATCH v2 2/4] xhci: fix issue of cross page boundary in TRB prefetch Date: Sat, 22 Apr 2023 04:38:51 +0800 X-ASG-Orig-Subj: [PATCH v2 2/4] xhci: fix issue of cross page boundary in TRB prefetch Message-ID: <20230421203853.387210-3-WeitaoWang-oc@zhaoxin.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20230421203853.387210-1-WeitaoWang-oc@zhaoxin.com> References: <20230421203853.387210-1-WeitaoWang-oc@zhaoxin.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.29.8.21] X-ClientProxiedBy: zxbjmbx1.zhaoxin.com (10.29.252.163) To zxbjmbx1.zhaoxin.com (10.29.252.163) X-Barracuda-Connect: ZXSHMBX1.zhaoxin.com[10.28.252.163] X-Barracuda-Start-Time: 1682080735 X-Barracuda-Encrypted: ECDHE-RSA-AES128-GCM-SHA256 X-Barracuda-URL: https://10.28.252.36:4443/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at zhaoxin.com X-Barracuda-Scan-Msg-Size: 1483 X-Barracuda-BRTS-Status: 1 X-Barracuda-Bayes: INNOCENT GLOBAL 0.0495 1.0000 -1.7031 X-Barracuda-Spam-Score: 1.41 X-Barracuda-Spam-Status: No, SCORE=1.41 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=9.0 tests=DATE_IN_FUTURE_06_12, DATE_IN_FUTURE_06_12_2 X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.107724 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- 0.01 DATE_IN_FUTURE_06_12 Date: is 6 to 12 hours after Received: date 3.10 DATE_IN_FUTURE_06_12_2 DATE_IN_FUTURE_06_12_2 X-Spam-Status: No, score=0.0 required=5.0 tests=BAYES_00,DATE_IN_FUTURE_06_12, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On some Zhaoxin platforms, xHCI will prefetch TRB for performance improvement. However this TRB prefetch mechanism may cross page boundary, which may access memory not allocated by xHCI driver. In order to fix this issue, two pages was allocated for TRB and only the first page will be used. Cc: stable@vger.kernel.org Signed-off-by: Weitao Wang --- drivers/usb/host/xhci-mem.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c index d0a9467aa5fc..d5517400d874 100644 --- a/drivers/usb/host/xhci-mem.c +++ b/drivers/usb/host/xhci-mem.c @@ -2369,8 +2369,12 @@ 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. */ - xhci->segment_pool = dma_pool_create("xHCI ring segments", dev, - TRB_SEGMENT_SIZE, TRB_SEGMENT_SIZE, xhci->page_size); + 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); /* See Table 46 and Note on Figure 55 */ xhci->device_pool = dma_pool_create("xHCI input/output contexts", dev, -- 2.32.0