From patchwork Mon Apr 17 02:51:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?Q2h1bmZlbmcgWXVuICjkupHmmKXls7Ap?= X-Patchwork-Id: 674831 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 22666C77B7A for ; Mon, 17 Apr 2023 02:52:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229930AbjDQCwS (ORCPT ); Sun, 16 Apr 2023 22:52:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54154 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229674AbjDQCwR (ORCPT ); Sun, 16 Apr 2023 22:52:17 -0400 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9C3681726; Sun, 16 Apr 2023 19:52:14 -0700 (PDT) X-UUID: d74b9ed4dcca11edb6b9f13eb10bd0fe-20230417 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:Content-Transfer-Encoding:MIME-Version:Message-ID:Date:Subject:CC:To:From; bh=ejR+XuzhyQVgZP+TJeLCfwXAB17U9qlUN9dfvgvCkck=; b=CiWs7+3iWV4KsaTwoGgxYf+BSUTOO6lryBUFYloulVcG5QbkmggCTPA0Wzzos+nivP2Bl0twgbn3A1NZWUbzQvF8WraIrZI6KxrtrMjYGNNv1WVz3sq52E0pYORXDAXvdn4orBNLMq2Rgf7XUduG4fEKw5tubKCUx81J5pFONgk=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.22, REQID:1ee975f6-1929-4c2c-9898-dbf6b65dc5c8, IP:0, U RL:0,TC:0,Content:-25,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTIO N:release,TS:-25 X-CID-META: VersionHash:120426c, CLOUDID:191628eb-db6f-41fe-8b83-13fe7ed1ef52, B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL:11|1,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV:0 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-UUID: d74b9ed4dcca11edb6b9f13eb10bd0fe-20230417 Received: from mtkmbs11n2.mediatek.inc [(172.21.101.187)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1739159041; Mon, 17 Apr 2023 10:52:07 +0800 Received: from mtkmbs11n1.mediatek.inc (172.21.101.185) by mtkmbs10n1.mediatek.inc (172.21.101.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.25; Mon, 17 Apr 2023 10:52:05 +0800 Received: from mhfsdcap04.gcn.mediatek.inc (10.17.3.154) by mtkmbs11n1.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.25 via Frontend Transport; Mon, 17 Apr 2023 10:52:05 +0800 From: Chunfeng Yun To: Greg Kroah-Hartman , Rob Herring CC: Chunfeng Yun , Krzysztof Kozlowski , Matthias Brugger , AngeloGioacchino Del Regno , , , , , , Tianping Fang Subject: [PATCH v3 1/7] usb: mtu3: give back request when rx error happens Date: Mon, 17 Apr 2023 10:51:57 +0800 Message-ID: <20230417025203.18097-1-chunfeng.yun@mediatek.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-MTK: N Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org When the Rx enconnter errors, currently, only print error logs, that may cause class driver's RX halt, shall give back the request with error status meanwhile. Signed-off-by: Chunfeng Yun --- v3: no changes v2: remove @req suggested by AngeloGioacchino --- drivers/usb/mtu3/mtu3_qmu.c | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/drivers/usb/mtu3/mtu3_qmu.c b/drivers/usb/mtu3/mtu3_qmu.c index a2fdab8b63b2..a4da1af0b2c0 100644 --- a/drivers/usb/mtu3/mtu3_qmu.c +++ b/drivers/usb/mtu3/mtu3_qmu.c @@ -466,6 +466,37 @@ static void qmu_tx_zlp_error_handler(struct mtu3 *mtu, u8 epnum) mtu3_qmu_resume(mep); } +/* + * when rx error happens (except zlperr), QMU will stop, and RQCPR saves + * the GPD encountered error, Done irq will arise after resuming QMU again. + */ +static void qmu_error_rx(struct mtu3 *mtu, u8 epnum) +{ + struct mtu3_ep *mep = mtu->out_eps + epnum; + struct mtu3_gpd_ring *ring = &mep->gpd_ring; + struct qmu_gpd *gpd_current = NULL; + struct mtu3_request *mreq; + dma_addr_t cur_gpd_dma; + + cur_gpd_dma = read_rxq_cur_addr(mtu->mac_base, epnum); + gpd_current = gpd_dma_to_virt(ring, cur_gpd_dma); + + mreq = next_request(mep); + if (!mreq || mreq->gpd != gpd_current) { + dev_err(mtu->dev, "no correct RX req is found\n"); + return; + } + + mreq->request.status = -EAGAIN; + + /* by pass the current GDP */ + gpd_current->dw0_info |= cpu_to_le32(GPD_FLAGS_BPS | GPD_FLAGS_HWO); + mtu3_qmu_resume(mep); + + dev_dbg(mtu->dev, "%s EP%d, current=%p, req=%p\n", + __func__, epnum, gpd_current, mreq); +} + /* * NOTE: request list maybe is already empty as following case: * queue_tx --> qmu_interrupt(clear interrupt pending, schedule tasklet)--> @@ -571,14 +602,18 @@ static void qmu_exception_isr(struct mtu3 *mtu, u32 qmu_status) if ((qmu_status & RXQ_CSERR_INT) || (qmu_status & RXQ_LENERR_INT)) { errval = mtu3_readl(mbase, U3D_RQERRIR0); + mtu3_writel(mbase, U3D_RQERRIR0, errval); + for (i = 1; i < mtu->num_eps; i++) { if (errval & QMU_RX_CS_ERR(i)) dev_err(mtu->dev, "Rx %d CS error!\n", i); if (errval & QMU_RX_LEN_ERR(i)) dev_err(mtu->dev, "RX %d Length error\n", i); + + if (errval & (QMU_RX_CS_ERR(i) | QMU_RX_LEN_ERR(i))) + qmu_error_rx(mtu, i); } - mtu3_writel(mbase, U3D_RQERRIR0, errval); } if (qmu_status & RXQ_ZLPERR_INT) { From patchwork Mon Apr 17 02:51:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?Q2h1bmZlbmcgWXVuICjkupHmmKXls7Ap?= X-Patchwork-Id: 674830 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9DB23C77B7E for ; Mon, 17 Apr 2023 02:52:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229953AbjDQCwT (ORCPT ); Sun, 16 Apr 2023 22:52:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229849AbjDQCwR (ORCPT ); Sun, 16 Apr 2023 22:52:17 -0400 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 853391FFC; Sun, 16 Apr 2023 19:52:15 -0700 (PDT) X-UUID: d74d9bbcdcca11edb6b9f13eb10bd0fe-20230417 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=J0FGTmUrLx+j+AGEiyeNq3HtAlIDUKglYm4c41XRe4g=; b=q1sI64MJYy+5vRMgq9Ddwr0SVDHFUMnFOEbrBiMVYgAUQshlBrWTfhcQrvSJHLLSl1X4FVCAjBKCrO2YQYuaY8+y1N2q14XSrp+lUYJQQq9CbT2EXeRoyf3emKYq0na+nN6ZGAnSlqY4fk07ACAN3rVxhnQAOEWwj0U4EdYUg28=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.22, REQID:c8eafc9d-040d-49eb-89f9-e99c14ebf179, IP:0, U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION: release,TS:0 X-CID-META: VersionHash:120426c, CLOUDID:171628eb-db6f-41fe-8b83-13fe7ed1ef52, B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL:11|1,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV:0 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-UUID: d74d9bbcdcca11edb6b9f13eb10bd0fe-20230417 Received: from mtkmbs11n2.mediatek.inc [(172.21.101.187)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 639314019; Mon, 17 Apr 2023 10:52:07 +0800 Received: from mtkmbs11n1.mediatek.inc (172.21.101.185) by mtkmbs10n1.mediatek.inc (172.21.101.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.25; Mon, 17 Apr 2023 10:52:06 +0800 Received: from mhfsdcap04.gcn.mediatek.inc (10.17.3.154) by mtkmbs11n1.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.25 via Frontend Transport; Mon, 17 Apr 2023 10:52:06 +0800 From: Chunfeng Yun To: Greg Kroah-Hartman , Rob Herring CC: Chunfeng Yun , Krzysztof Kozlowski , Matthias Brugger , AngeloGioacchino Del Regno , , , , , , Tianping Fang Subject: [PATCH v3 2/7] usb: mtu3: use boolean return value Date: Mon, 17 Apr 2023 10:51:58 +0800 Message-ID: <20230417025203.18097-2-chunfeng.yun@mediatek.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230417025203.18097-1-chunfeng.yun@mediatek.com> References: <20230417025203.18097-1-chunfeng.yun@mediatek.com> MIME-Version: 1.0 X-MTK: N Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Prefer to use boolean value due to gpd_ring_empty() return true or false. See "16) Function return values and names" in coding-style.rst Reviewed-by: AngeloGioacchino Del Regno Signed-off-by: Chunfeng Yun --- v3: no changes v2: add Reviewed-by AngeloGioacchino --- drivers/usb/mtu3/mtu3_qmu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/mtu3/mtu3_qmu.c b/drivers/usb/mtu3/mtu3_qmu.c index a4da1af0b2c0..6be4977a5db5 100644 --- a/drivers/usb/mtu3/mtu3_qmu.c +++ b/drivers/usb/mtu3/mtu3_qmu.c @@ -221,7 +221,7 @@ static struct qmu_gpd *advance_deq_gpd(struct mtu3_gpd_ring *ring) } /* check if a ring is emtpy */ -static int gpd_ring_empty(struct mtu3_gpd_ring *ring) +static bool gpd_ring_empty(struct mtu3_gpd_ring *ring) { struct qmu_gpd *enq = ring->enqueue; struct qmu_gpd *next; From patchwork Mon Apr 17 02:51:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?Q2h1bmZlbmcgWXVuICjkupHmmKXls7Ap?= X-Patchwork-Id: 674032 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7B500C77B73 for ; Mon, 17 Apr 2023 02:52:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229924AbjDQCwR (ORCPT ); Sun, 16 Apr 2023 22:52:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54146 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229458AbjDQCwQ (ORCPT ); Sun, 16 Apr 2023 22:52:16 -0400 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F0DB51BEC; Sun, 16 Apr 2023 19:52:14 -0700 (PDT) X-UUID: d82498c4dcca11eda9a90f0bb45854f4-20230417 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=Qh6zarOh98fchldCyV0UeHoUwNPvYTXdIyeS2Lngrzk=; b=UtcNocLj7P0nX2j9hdE/DYEPWNQ8/8tEV1SFpz4jjL/eIdOrJBEPsFgthi8es8jgzJqhNawSXnRtuK4AJOcTR4r7fb2liQfwO/lunHCbHEStlrgB6I0yFg6NFGmE3rVeCn+7oUaNSzzboBKD2SX/5+cMdXHpa1cVlB8Aatqs5UM=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.22, REQID:bec4139b-2146-4690-957f-ccf43ba04f37, IP:0, U RL:0,TC:0,Content:0,EDM:0,RT:1,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION: release,TS:1 X-CID-META: VersionHash:120426c, CLOUDID:d76386a1-8fcb-430b-954a-ba3f00fa94a5, B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL:11|1,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV:0 X-CID-BVR: 0,NGT X-CID-BAS: 0,NGT,0,_ X-UUID: d82498c4dcca11eda9a90f0bb45854f4-20230417 Received: from mtkmbs10n2.mediatek.inc [(172.21.101.183)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 418582238; Mon, 17 Apr 2023 10:52:08 +0800 Received: from mtkmbs11n1.mediatek.inc (172.21.101.185) by mtkmbs10n1.mediatek.inc (172.21.101.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.25; Mon, 17 Apr 2023 10:52:07 +0800 Received: from mhfsdcap04.gcn.mediatek.inc (10.17.3.154) by mtkmbs11n1.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.25 via Frontend Transport; Mon, 17 Apr 2023 10:52:06 +0800 From: Chunfeng Yun To: Greg Kroah-Hartman , Rob Herring CC: Chunfeng Yun , Krzysztof Kozlowski , Matthias Brugger , AngeloGioacchino Del Regno , , , , , , Tianping Fang Subject: [PATCH v3 3/7] usb: mtu3: fix kernel panic at qmu transfer done irq handler Date: Mon, 17 Apr 2023 10:51:59 +0800 Message-ID: <20230417025203.18097-3-chunfeng.yun@mediatek.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230417025203.18097-1-chunfeng.yun@mediatek.com> References: <20230417025203.18097-1-chunfeng.yun@mediatek.com> MIME-Version: 1.0 X-MTK: N Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org When handle qmu transfer irq, it will unlock @mtu->lock before give back request, if another thread handle disconnect event at the same time, and try to disable ep, it may lock @mtu->lock and free qmu ring, then qmu irq hanlder may get a NULL gpd, avoid the KE by checking gpd's value before handling it. e.g. qmu done irq on cpu0 thread running on cpu1 qmu_done_tx() handle gpd [0] mtu3_requ_complete() mtu3_gadget_ep_disable() unlock @mtu->lock give back request lock @mtu->lock mtu3_ep_disable() mtu3_gpd_ring_free() unlock @mtu->lock lock @mtu->lock get next gpd [1] [1]: goto [0] to handle next gpd, and next gpd may be NULL. Fixes: 48e0d3735aa5 ("usb: mtu3: supports new QMU format") Signed-off-by: Chunfeng Yun --- v3: add Fixes tag suggested by AngeloGioacchino v2: fix typo suggested by AngeloGioacchino --- drivers/usb/mtu3/mtu3_qmu.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/usb/mtu3/mtu3_qmu.c b/drivers/usb/mtu3/mtu3_qmu.c index 6be4977a5db5..3d77408e3133 100644 --- a/drivers/usb/mtu3/mtu3_qmu.c +++ b/drivers/usb/mtu3/mtu3_qmu.c @@ -210,6 +210,7 @@ static struct qmu_gpd *advance_enq_gpd(struct mtu3_gpd_ring *ring) return ring->enqueue; } +/* @dequeue may be NULL if ring is unallocated or freed */ static struct qmu_gpd *advance_deq_gpd(struct mtu3_gpd_ring *ring) { if (ring->dequeue < ring->end) @@ -522,7 +523,7 @@ static void qmu_done_tx(struct mtu3 *mtu, u8 epnum) dev_dbg(mtu->dev, "%s EP%d, last=%p, current=%p, enq=%p\n", __func__, epnum, gpd, gpd_current, ring->enqueue); - while (gpd != gpd_current && !GET_GPD_HWO(gpd)) { + while (gpd && gpd != gpd_current && !GET_GPD_HWO(gpd)) { mreq = next_request(mep); @@ -561,7 +562,7 @@ static void qmu_done_rx(struct mtu3 *mtu, u8 epnum) dev_dbg(mtu->dev, "%s EP%d, last=%p, current=%p, enq=%p\n", __func__, epnum, gpd, gpd_current, ring->enqueue); - while (gpd != gpd_current && !GET_GPD_HWO(gpd)) { + while (gpd && gpd != gpd_current && !GET_GPD_HWO(gpd)) { mreq = next_request(mep); From patchwork Mon Apr 17 02:52:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?Q2h1bmZlbmcgWXVuICjkupHmmKXls7Ap?= X-Patchwork-Id: 674031 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E2871C77B7D for ; Mon, 17 Apr 2023 02:52:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229484AbjDQCwT (ORCPT ); Sun, 16 Apr 2023 22:52:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54158 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229853AbjDQCwR (ORCPT ); Sun, 16 Apr 2023 22:52:17 -0400 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0771626A8; Sun, 16 Apr 2023 19:52:15 -0700 (PDT) X-UUID: d8264020dcca11eda9a90f0bb45854f4-20230417 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=xB2a4j+9oSlVHdO9s2m66FnR/js/Kho03AMOZGc+G6E=; b=Ypodj9yMvkfQyuVFhdc3Nv8jaUXCfXN97lSx817SUqrOLkRPPLVR7ELGtCBD+dADzs3y7sYjCbCTWaNyinAYoxOyd6A23h7qi43NubXhvPGcNpa6KT+d21UknLXHiLb/6/7+qxd8KtQsvkINm4jhv6lYrdwPHOeN08TNyGRHnPg=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.22, REQID:ef2cd2ce-41cc-4183-adac-fe3b7738aaba, IP:0, U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION: release,TS:0 X-CID-META: VersionHash:120426c, CLOUDID:5f704184-cd9c-45f5-8134-710979e3df0e, B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL:11|1,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV:0 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-UUID: d8264020dcca11eda9a90f0bb45854f4-20230417 Received: from mtkmbs10n2.mediatek.inc [(172.21.101.183)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 675118410; Mon, 17 Apr 2023 10:52:08 +0800 Received: from mtkmbs11n1.mediatek.inc (172.21.101.185) by mtkmbs10n1.mediatek.inc (172.21.101.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.25; Mon, 17 Apr 2023 10:52:08 +0800 Received: from mhfsdcap04.gcn.mediatek.inc (10.17.3.154) by mtkmbs11n1.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.25 via Frontend Transport; Mon, 17 Apr 2023 10:52:07 +0800 From: Chunfeng Yun To: Greg Kroah-Hartman , Rob Herring CC: Chunfeng Yun , Krzysztof Kozlowski , Matthias Brugger , AngeloGioacchino Del Regno , , , , , , Tianping Fang Subject: [PATCH v3 4/7] usb: mtu3: unlock @mtu->lock just before giving back request Date: Mon, 17 Apr 2023 10:52:00 +0800 Message-ID: <20230417025203.18097-4-chunfeng.yun@mediatek.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230417025203.18097-1-chunfeng.yun@mediatek.com> References: <20230417025203.18097-1-chunfeng.yun@mediatek.com> MIME-Version: 1.0 X-MTK: N Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org No need unlock @mtu->lock when unmap request, unlock it just before giving back request, due to we do not lock this spinlock when map the request. Reviewed-by: AngeloGioacchino Del Regno Signed-off-by: Chunfeng Yun --- v3: no changes v2: add Reviewed-by AngeloGioacchino --- drivers/usb/mtu3/mtu3_gadget.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/mtu3/mtu3_gadget.c b/drivers/usb/mtu3/mtu3_gadget.c index c0264d5426bf..ad0eeac4332d 100644 --- a/drivers/usb/mtu3/mtu3_gadget.c +++ b/drivers/usb/mtu3/mtu3_gadget.c @@ -23,7 +23,6 @@ __acquires(mep->mtu->lock) req->status = status; trace_mtu3_req_complete(mreq); - spin_unlock(&mtu->lock); /* ep0 makes use of PIO, needn't unmap it */ if (mep->epnum) @@ -32,6 +31,7 @@ __acquires(mep->mtu->lock) dev_dbg(mtu->dev, "%s complete req: %p, sts %d, %d/%d\n", mep->name, req, req->status, req->actual, req->length); + spin_unlock(&mtu->lock); usb_gadget_giveback_request(&mep->ep, req); spin_lock(&mtu->lock); } From patchwork Mon Apr 17 02:52:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?Q2h1bmZlbmcgWXVuICjkupHmmKXls7Ap?= X-Patchwork-Id: 674832 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 014C8C77B61 for ; Mon, 17 Apr 2023 02:52:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229822AbjDQCwR (ORCPT ); Sun, 16 Apr 2023 22:52:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54144 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229484AbjDQCwQ (ORCPT ); Sun, 16 Apr 2023 22:52:16 -0400 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F205B1716; Sun, 16 Apr 2023 19:52:13 -0700 (PDT) X-UUID: d8fca9eedcca11eda9a90f0bb45854f4-20230417 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=R8FF6lMcTE2Du4EqFA1FCtjHRKeby9msjh9agEcXgfE=; b=DqFAJJh+NapZkgNFFF5JnWkLA5gA/csY23EVOfEKq0E7JbDOxd7n41uTcmR12jG35BE3G68OkjhMfe8Pw2+loIZF8xCJMgcBA0TgEpkRXiRJDPxXt4UdmYZYeUKQuhECqDSIst63ZrCPNb/olIiHUefMmb5L1z97NrMcyw0LoBA=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.22, REQID:496955e4-349b-471d-a74f-a610fec81d62, IP:0, U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION: release,TS:0 X-CID-META: VersionHash:120426c, CLOUDID:641628eb-db6f-41fe-8b83-13fe7ed1ef52, B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL:11|1,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV:0 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-UUID: d8fca9eedcca11eda9a90f0bb45854f4-20230417 Received: from mtkmbs10n2.mediatek.inc [(172.21.101.183)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1722364561; Mon, 17 Apr 2023 10:52:10 +0800 Received: from mtkmbs11n1.mediatek.inc (172.21.101.185) by mtkmbs11n1.mediatek.inc (172.21.101.185) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.25; Mon, 17 Apr 2023 10:52:08 +0800 Received: from mhfsdcap04.gcn.mediatek.inc (10.17.3.154) by mtkmbs11n1.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.25 via Frontend Transport; Mon, 17 Apr 2023 10:52:08 +0800 From: Chunfeng Yun To: Greg Kroah-Hartman , Rob Herring CC: Chunfeng Yun , Krzysztof Kozlowski , Matthias Brugger , AngeloGioacchino Del Regno , , , , , , Tianping Fang Subject: [PATCH v3 5/7] usb: mtu3: expose role-switch control to userspace Date: Mon, 17 Apr 2023 10:52:01 +0800 Message-ID: <20230417025203.18097-5-chunfeng.yun@mediatek.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230417025203.18097-1-chunfeng.yun@mediatek.com> References: <20230417025203.18097-1-chunfeng.yun@mediatek.com> MIME-Version: 1.0 X-MTK: N Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org The allow_userspace_control flag enables manual role switch from userspace, turn this feature on like several other USB DRD controller drivers. Reviewed-by: AngeloGioacchino Del Regno Signed-off-by: Chunfeng Yun --- v3: no changes v2: add Reviewed-by AngeloGioacchino --- drivers/usb/mtu3/mtu3_dr.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/usb/mtu3/mtu3_dr.c b/drivers/usb/mtu3/mtu3_dr.c index 9b8aded3d95e..8191b7ed3852 100644 --- a/drivers/usb/mtu3/mtu3_dr.c +++ b/drivers/usb/mtu3/mtu3_dr.c @@ -294,6 +294,7 @@ static int ssusb_role_sw_register(struct otg_switch_mtk *otg_sx) role_sx_desc.get = ssusb_role_sw_get; role_sx_desc.fwnode = dev_fwnode(dev); role_sx_desc.driver_data = ssusb; + role_sx_desc.allow_userspace_control = true; otg_sx->role_sw = usb_role_switch_register(dev, &role_sx_desc); if (IS_ERR(otg_sx->role_sw)) return PTR_ERR(otg_sx->role_sw); From patchwork Mon Apr 17 02:52:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?Q2h1bmZlbmcgWXVuICjkupHmmKXls7Ap?= X-Patchwork-Id: 674030 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6BFE0C7EE21 for ; Mon, 17 Apr 2023 02:52:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229680AbjDQCwU (ORCPT ); Sun, 16 Apr 2023 22:52:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54204 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229948AbjDQCwT (ORCPT ); Sun, 16 Apr 2023 22:52:19 -0400 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8C9E41716; Sun, 16 Apr 2023 19:52:17 -0700 (PDT) X-UUID: d8fac48adcca11edb6b9f13eb10bd0fe-20230417 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=phBD2vwO8iWkQPmc/hArOU7MCQMYMDUaIR/NpBQEQxI=; b=bgMGBa2xJimhb3a4aECTh4uTVzkEAQG0PiXd9j+Qc0g4weo/ERCAKZfw47EXZBtXOFXvUtFLFHsc/s1mUwJ5XshVbFI432V8MGosNdrp9zvs6Ijqoe3TnY22Vjaug5s+GoYzMPnUsCJ462KEZ4hFmkWBRmt25kS8LzH+sR010is=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.22, REQID:5476b978-1572-43f1-8a59-2ed28f0a8191, IP:0, U RL:0,TC:0,Content:-5,EDM:0,RT:0,SF:95,FILE:0,BULK:0,RULE:Release_Ham,ACTIO N:release,TS:90 X-CID-INFO: VERSION:1.1.22, REQID:5476b978-1572-43f1-8a59-2ed28f0a8191, IP:0, URL :0,TC:0,Content:-5,EDM:0,RT:0,SF:95,FILE:0,BULK:0,RULE:Spam_GS981B3D,ACTIO N:quarantine,TS:90 X-CID-META: VersionHash:120426c, CLOUDID:a6704184-cd9c-45f5-8134-710979e3df0e, B ulkID:230417105211YF4HE74T,BulkQuantity:1,Recheck:0,SF:19|48|38|29|28|17,T C:nil,Content:0,EDM:-3,IP:nil,URL:11|1,File:nil,Bulk:40,QS:nil,BEC:nil,COL :0,OSI:0,OSA:0,AV:0 X-CID-BVR: 0,NGT X-CID-BAS: 0,NGT,0,_ X-UUID: d8fac48adcca11edb6b9f13eb10bd0fe-20230417 Received: from mtkmbs10n1.mediatek.inc [(172.21.101.34)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 337964305; Mon, 17 Apr 2023 10:52:10 +0800 Received: from mtkmbs11n1.mediatek.inc (172.21.101.185) by mtkmbs10n1.mediatek.inc (172.21.101.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.25; Mon, 17 Apr 2023 10:52:09 +0800 Received: from mhfsdcap04.gcn.mediatek.inc (10.17.3.154) by mtkmbs11n1.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.25 via Frontend Transport; Mon, 17 Apr 2023 10:52:09 +0800 From: Chunfeng Yun To: Greg Kroah-Hartman , Rob Herring CC: Chunfeng Yun , Krzysztof Kozlowski , Matthias Brugger , AngeloGioacchino Del Regno , , , , , , Tianping Fang , Rob Herring Subject: [PATCH v3 6/7] dt-bindings: usb: mtu3: add two optional clocks Date: Mon, 17 Apr 2023 10:52:02 +0800 Message-ID: <20230417025203.18097-6-chunfeng.yun@mediatek.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230417025203.18097-1-chunfeng.yun@mediatek.com> References: <20230417025203.18097-1-chunfeng.yun@mediatek.com> MIME-Version: 1.0 X-MTK: N Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Add optional clock 'xhci_ck' and 'frmcnt_ck'; Reviewed-by: Rob Herring Signed-off-by: Chunfeng Yun --- v3: add reviewed-by Rob v2: remove assigned-clocks* properties suggested by Rob --- Documentation/devicetree/bindings/usb/mediatek,mtu3.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Documentation/devicetree/bindings/usb/mediatek,mtu3.yaml b/Documentation/devicetree/bindings/usb/mediatek,mtu3.yaml index d2655173e108..3d403d944453 100644 --- a/Documentation/devicetree/bindings/usb/mediatek,mtu3.yaml +++ b/Documentation/devicetree/bindings/usb/mediatek,mtu3.yaml @@ -66,6 +66,8 @@ properties: - description: Reference clock used by low power mode etc - description: Mcu bus clock for register access - description: DMA bus clock for data transfer + - description: DRD controller clock + - description: Frame count clock clock-names: minItems: 1 @@ -74,6 +76,8 @@ properties: - const: ref_ck - const: mcu_ck - const: dma_ck + - const: xhci_ck + - const: frmcnt_ck phys: description: From patchwork Mon Apr 17 02:52:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?Q2h1bmZlbmcgWXVuICjkupHmmKXls7Ap?= X-Patchwork-Id: 674829 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4696CC77B7D for ; Mon, 17 Apr 2023 02:52:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229969AbjDQCwW (ORCPT ); Sun, 16 Apr 2023 22:52:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54252 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229958AbjDQCwU (ORCPT ); Sun, 16 Apr 2023 22:52:20 -0400 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 93C282718; Sun, 16 Apr 2023 19:52:18 -0700 (PDT) X-UUID: d9eba7ecdcca11edb6b9f13eb10bd0fe-20230417 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=HFOJULAIHGPq12XJm5Jmua93Eyz9XsckyqBFWPq6Mto=; b=gfCiOOD+B9+kvoHzDrcYT4GH/TGTJ+8BqL6WjGsl3XivL0yrInRqb7rIVnlaGrCT66WUZm/b/HZPFNDCRM4m0N1XqVObh9r6uJ0NUd8TwOXqPUBVYbrvNaXb6EFVKGMdvKWjfUNarlQW7UdDtV2+dfIFfXDcPwE7mdtekV9LIQ0=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.22, REQID:c1048cdd-4b14-4cd6-b560-eecc7f31c219, IP:0, U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION: release,TS:0 X-CID-META: VersionHash:120426c, CLOUDID:216486a1-8fcb-430b-954a-ba3f00fa94a5, B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL:11|1,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV:0 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-UUID: d9eba7ecdcca11edb6b9f13eb10bd0fe-20230417 Received: from mtkmbs11n1.mediatek.inc [(172.21.101.185)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1512352980; Mon, 17 Apr 2023 10:52:11 +0800 Received: from mtkmbs11n1.mediatek.inc (172.21.101.185) by mtkmbs11n1.mediatek.inc (172.21.101.185) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.25; Mon, 17 Apr 2023 10:52:10 +0800 Received: from mhfsdcap04.gcn.mediatek.inc (10.17.3.154) by mtkmbs11n1.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.25 via Frontend Transport; Mon, 17 Apr 2023 10:52:09 +0800 From: Chunfeng Yun To: Greg Kroah-Hartman , Rob Herring CC: Chunfeng Yun , Krzysztof Kozlowski , Matthias Brugger , AngeloGioacchino Del Regno , , , , , , Tianping Fang Subject: [PATCH v3 7/7] usb: mtu3: add optional clock xhci_ck and frmcnt_ck Date: Mon, 17 Apr 2023 10:52:03 +0800 Message-ID: <20230417025203.18097-7-chunfeng.yun@mediatek.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230417025203.18097-1-chunfeng.yun@mediatek.com> References: <20230417025203.18097-1-chunfeng.yun@mediatek.com> MIME-Version: 1.0 X-MTK: N Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Add optional clock 'xhci_ck' which is usually the same as sys_ck, but some SoC use two separated clocks when the controller supports dual role mode; Add optional clock 'frmcnt_ck' used on 4nm or advanced process SoC. Signed-off-by: Chunfeng Yun --- v2~v3: no changes --- drivers/usb/mtu3/mtu3.h | 2 +- drivers/usb/mtu3/mtu3_plat.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/usb/mtu3/mtu3.h b/drivers/usb/mtu3/mtu3.h index 2d7b57e07eee..b4a7662dded5 100644 --- a/drivers/usb/mtu3/mtu3.h +++ b/drivers/usb/mtu3/mtu3.h @@ -90,7 +90,7 @@ struct mtu3_request; */ #define EP0_RESPONSE_BUF 6 -#define BULK_CLKS_CNT 4 +#define BULK_CLKS_CNT 6 /* device operated link and speed got from DEVICE_CONF register */ enum mtu3_speed { diff --git a/drivers/usb/mtu3/mtu3_plat.c b/drivers/usb/mtu3/mtu3_plat.c index d78ae52b4e26..6f264b129243 100644 --- a/drivers/usb/mtu3/mtu3_plat.c +++ b/drivers/usb/mtu3/mtu3_plat.c @@ -234,6 +234,8 @@ static int get_ssusb_rscs(struct platform_device *pdev, struct ssusb_mtk *ssusb) clks[1].id = "ref_ck"; clks[2].id = "mcu_ck"; clks[3].id = "dma_ck"; + clks[4].id = "xhci_ck"; + clks[5].id = "frmcnt_ck"; ret = devm_clk_bulk_get_optional(dev, BULK_CLKS_CNT, clks); if (ret) return ret;