Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp2116595rwr; Sat, 6 May 2023 05:17:59 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5Jp8tvr4tLP5T28yvWAI96hWELS9cZoSS1Z3HobMNEHVt5gWi9Bx224XyFfJLr1h0C517v X-Received: by 2002:a05:6a20:2594:b0:f0:a8e7:bbee with SMTP id k20-20020a056a20259400b000f0a8e7bbeemr5499261pzd.1.1683375479039; Sat, 06 May 2023 05:17:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683375479; cv=none; d=google.com; s=arc-20160816; b=hSo3XxolPNS0DBGjQcZ2ydUiND+++h2ROZthY2mnQc2KsCEHVa3Z1+Vi56uZKyFYQh A72tOZsOsGEOlP7fJFf1SRmsRsrQF4UGlYfnq3SqFcRrmNA0AzELGLrn0N+26XX36qBS NARI5zm/z/8yy5/wAq/loT/K2lY3ffUEuVeIOCiI5Bv8QsZP9wRzvi7is/bs8EC9aU3z I1h2mEkLtX9scluHZD5NjMBqrp+kSIbRkwvvRgd0iIJ4OGSe7YoG/8VorNQ6SpbUXRPZ wA6KPGRETQdWw86Yz9LdRCa22Zjph++qpTSEu9D/d9npTuh9ijmYjdpr8jYzHDIYU/Zs TIeA== 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=SbjRbmzk26b+GWIx9WD9JTBfmKwWX6D1DPZiKo/XKCQ=; b=yP+VTwMqajhRMeIX+BYPInkdIZwoUNj7zzFrP5sCzfaaJgt4gj5hH1ABHfJS0nTPqM kOGP04uuTCaJY+/RltCgFqWcZjQ7RJshlXbdSe8TJf3meJARRbj2iGWrffOBWPIAMA+1 eaDHv8ckOI3Bl1nYDRLG6S3Qiu+jIluk/zdqy3xoSO3IqJnhf5RUXa39Rgh3krGNGMtM ys6pdeRvDPFxMZwVtP0SOCAwi7H9lf7Q+ZmHrG5alT/XWz6ZPh3HlGC68n4JidTrlon6 9N9OAEz0EXTO/SOlO/w1NTKXyx6X/MucQae0t/Zjnjw4URgu9vlRgXip/S+RC0zq3pXg vtSg== 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 16-20020a621810000000b0063b6bc7df13si4088121pfy.209.2023.05.06.05.17.46; Sat, 06 May 2023 05:17:59 -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 S232305AbjEFMQD (ORCPT + 99 others); Sat, 6 May 2023 08:16:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231675AbjEFMPq (ORCPT ); Sat, 6 May 2023 08:15:46 -0400 Received: from mx2.zhaoxin.com (mx2.zhaoxin.com [203.110.167.99]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C78313862 for ; Sat, 6 May 2023 05:15:45 -0700 (PDT) X-ASG-Debug-ID: 1683375338-1eb14e6386684a0003-xx1T2L Received: from ZXSHMBX2.zhaoxin.com (ZXSHMBX2.zhaoxin.com [10.28.252.164]) by mx2.zhaoxin.com with ESMTP id huYN8YpydczO45r7 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NO); Sat, 06 May 2023 20:15:39 +0800 (CST) X-Barracuda-Envelope-From: WeitaoWang-oc@zhaoxin.com X-Barracuda-RBL-Trusted-Forwarder: 10.28.252.164 Received: from zxbjmbx1.zhaoxin.com (10.29.252.163) by ZXSHMBX2.zhaoxin.com (10.28.252.164) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Sat, 6 May 2023 20:15:38 +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; Sat, 6 May 2023 20:15:38 +0800 X-Barracuda-RBL-Trusted-Forwarder: 10.28.252.164 From: Weitao Wang X-Barracuda-RBL-Trusted-Forwarder: 10.29.252.163 To: , , , CC: , , Subject: [PATCH v3 2/4] xhci: fix issue of cross page boundary in TRB prefetch Date: Sun, 7 May 2023 04:15:34 +0800 X-ASG-Orig-Subj: [PATCH v3 2/4] xhci: fix issue of cross page boundary in TRB prefetch Message-ID: <20230506201536.7362-3-WeitaoWang-oc@zhaoxin.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20230506201536.7362-1-WeitaoWang-oc@zhaoxin.com> References: <20230506201536.7362-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: ZXSHMBX2.zhaoxin.com[10.28.252.164] X-Barracuda-Start-Time: 1683375339 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: 1471 X-Barracuda-BRTS-Status: 1 X-Barracuda-Bayes: INNOCENT GLOBAL 0.0136 1.0000 -1.9322 X-Barracuda-Spam-Score: 1.18 X-Barracuda-Spam-Status: No, SCORE=1.18 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.108401 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 7e106bd804ca..6d00980d0070 100644 --- a/drivers/usb/host/xhci-mem.c +++ b/drivers/usb/host/xhci-mem.c @@ -2352,8 +2352,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, TRB_SEGMENT_SIZE, xhci->page_size); + 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