Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp468586rwe; Thu, 1 Sep 2022 02:38:40 -0700 (PDT) X-Google-Smtp-Source: AA6agR4nN73XhCtH9KFFcdTuil1KuXerzsc4Yorq2mEwXZ5jSmzIOHLeS1PTbRfDzu2uy6+2sjk1 X-Received: by 2002:a63:eb0e:0:b0:429:aefa:9fa9 with SMTP id t14-20020a63eb0e000000b00429aefa9fa9mr24738447pgh.122.1662025120393; Thu, 01 Sep 2022 02:38:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662025120; cv=none; d=google.com; s=arc-20160816; b=i8UJyNmJa4p99ctUfzzkmc2xG1L1ZfX5PrzzOV44V7SqK+JOwNbNY0y8t0CA57hG0H TQJ6L83Tgjmk6UrrMKIef1so3jhOBaK/RRYnHcUfZh9zRCu5Bz5IEU1WzBphiBM6Cr0g WQh/n03/tLk1sYljrlzCjMk7XY1jSQk6LpsAPXIrswcojPKyxrSuLcMg1uk4S2ZxZ9jK mYrYblmSQv+KN6S8MzfXuV74/fDL5PxamPW2pdMgRPd8ZDLwi6NSbnly3NAKHRpGNMIX DPXflf0Py659EsRGxYI0HaAvq2M7/UzAgx/WDyhtFdnUkoKGPxGMGWGJNABdVqf90Wmg 38Rg== 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 :message-id:date:subject:cc:to:from; bh=S+nmXl7B/ixWoveoA1+iI8W2Rjmt0XdJysFIvfh7Rkk=; b=qt5sQu979f0OGBpAyoAJ6u2zR+SKI0cfuf/Hv4C8H/5jC2M1oApQLNJz9tY7cdJEeF yo0CGffBdI8uKQjsQf4RiQa/ZbQDUPPDu3bhzYICRt4AE0m6ZxDtIBRrKnGJkiy7hz6L iOwRhv+MIww1u5t/frokNoCKLvVqnoQ3u0k4N5/Xqmy7i4pza38oVPk9hMlha57TsD3n FFK+gFgJ+qBhL65/kqN0au2CVXsy/MioqrzwUfrOjhJe6i6WhDahe1AzfwgdF3yPWsFr 7SCazBZI6bI2wlGOladTVd68JRtWEWqpESb/j1RkdUTO39no1cbU2QbfOacLyBWPBzyv 80Ow== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=rock-chips.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n15-20020a63ee4f000000b0042291471f0esi7790289pgk.434.2022.09.01.02.38.29; Thu, 01 Sep 2022 02:38:40 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=rock-chips.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233358AbiIAIl3 (ORCPT + 99 others); Thu, 1 Sep 2022 04:41:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40614 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232804AbiIAIlT (ORCPT ); Thu, 1 Sep 2022 04:41:19 -0400 Received: from mail-m11878.qiye.163.com (mail-m11878.qiye.163.com [115.236.118.78]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 36DC9110882 for ; Thu, 1 Sep 2022 01:41:18 -0700 (PDT) Received: from rockchip.. (unknown [58.22.7.114]) by mail-m11878.qiye.163.com (Hmail) with ESMTPA id 0ECB87407D8; Thu, 1 Sep 2022 16:34:48 +0800 (CST) From: William Wu To: balbi@kernel.org, gregkh@linuxfoundation.org Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, william.wu@rock-chips.com, fabioaiuto83@gmail.com, sven@svenpeter.dev, frank.wang@rock-chips.com, jianwei.zheng@rock-chips.com Subject: [PATCH] usb: dwc3: core: leave default DMA if the controller does not support 64-bit DMA Date: Thu, 1 Sep 2022 16:34:46 +0800 Message-Id: <20220901083446.3799754-1-william.wu@rock-chips.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFJSktLSjdXWS1ZQUlXWQ8JGhUIEh9ZQVkZGEJJVhlCHUJJTEMYS0hLQ1UTARMWGhIXJB QOD1lXWRgSC1lBWU5DVUlJVUxVSkpPWVdZFhoPEhUdFFlBWU9LSFVKSktITkhVSktLWQY+ X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6Nhw6HDo4Gj01AUwyTjIMMkxO MDAKCyxVSlVKTU1JS0lKSUNDTE9PVTMWGhIXVQwSFxcSGhZVDA47CRQYEFYYExILCFUYFBZFWVdZ EgtZQVlOQ1VJSVVMVUpKT1lXWQgBWUFJTE9INwY+ X-HM-Tid: 0a82f83041912eb4kusn0ecb87407d8 X-Spam-Status: No, score=-0.4 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_WEB,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no 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 DWC3 controllers (e.g. Rockchip SoCs), the DWC3 core doesn't support 64-bit DMA address width. In this case, this driver should use the default 32-bit mask. Otherwise, the DWC3 controller will break if it runs on above 4GB physical memory environment. This patch reads the DWC_USB3_AWIDTH bits of GHWPARAMS0 which used for the DMA address width, and only configure 64-bit DMA mask if the DWC_USB3_AWIDTH is 64. Fixes: 45d39448b4d0 ("usb: dwc3: support 64 bit DMA in platform driver") Signed-off-by: William Wu --- drivers/usb/dwc3/core.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index c5c238ab3083..2fcbd05b2af1 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -1751,12 +1751,6 @@ static int dwc3_probe(struct platform_device *pdev) dwc3_get_properties(dwc); - if (!dwc->sysdev_is_parent) { - ret = dma_set_mask_and_coherent(dwc->sysdev, DMA_BIT_MASK(64)); - if (ret) - return ret; - } - dwc->reset = devm_reset_control_array_get_optional_shared(dev); if (IS_ERR(dwc->reset)) return PTR_ERR(dwc->reset); @@ -1823,6 +1817,13 @@ static int dwc3_probe(struct platform_device *pdev) dwc3_cache_hwparams(dwc); device_init_wakeup(&pdev->dev, of_property_read_bool(dev->of_node, "wakeup-source")); + if (!dwc->sysdev_is_parent && + DWC3_GHWPARAMS0_AWIDTH(dwc->hwparams.hwparams0) == 64) { + ret = dma_set_mask_and_coherent(dwc->sysdev, DMA_BIT_MASK(64)); + if (ret) + goto disable_clks; + } + spin_lock_init(&dwc->lock); mutex_init(&dwc->mutex); -- 2.34.1