Message ID | 20230403025230.25035-1-chunfeng.yun@mediatek.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2028452vqo; Sun, 2 Apr 2023 19:57:45 -0700 (PDT) X-Google-Smtp-Source: AK7set+5E5BZ08h0e1jxPVh5LhNFxez5MScM+aDBUCZ/qIi/i18CFTxtcABKt9xYtN3b43D92eOG X-Received: by 2002:a05:6a20:49a4:b0:da:834d:edd with SMTP id fs36-20020a056a2049a400b000da834d0eddmr31898580pzb.34.1680490664909; Sun, 02 Apr 2023 19:57:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680490664; cv=none; d=google.com; s=arc-20160816; b=zj/AZFrAShU39DdW8f5DjSM22H/dKPDwie0ruoeHa3zKZJCPUtvCI/pUqlBCc85p4A AxwFtuFsvuZm5Zr/xZa7G6gEkYiHX02IbpejDYyWSaYuQNnx5/I05ZtftY040+yNv5ii qJ5K+YEb3BT5NwMqFVMvMmjMV4fC2PJw/9JopSD5FsxIXYRNt6tt0qKs/eUtNpJafqIG a9xFr8HRaj91LBrpVmb06diSiYQqr3Up/27k1HxzXzT19zOGTq/Bt5mS7uBPMi6k8fHa gb7LU8EKrif0Av7WqOEU6+0XgNARSPYWAqEwtj+2iM0x8UbR9O1eHztU4wHu53MBWvPn HhkQ== 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:dkim-signature; bh=ALgZrn1BexLA8a2KpVf+yoJ+e6iJZj9wJZnsbHFyjZg=; b=KcaVwdi0eKUd5qpxr/1NbSkhDao+k9f9XKbIRGGAhvvbS1kswfsGMCthEcb4mDJEHU KFId6JsbOwZPFLmSdvPXl8QN5rZqoK6ClfQK60Pvy1Id0NfIqrB9dVVEXNjqHX4GPGLA FhzBRt2HuMOrSw2khfZfLXhLxghvVJUW+ULoz0SXzgNNmpekpBAQlbV+QWpc1AW61zdj o+Jb50H6Dp49SIwKY6GAI+EWR9l6rNHCkeY3Ardduz6cG4EU9blI4B2jFap0ZLb1tcq4 vkGY1zP4XsZNY2MuJ0SFPOg5EvWMRyrj4vS9tFsb7Eae6QHx8r/xkOxBm2HMcpIMrBlH 8vGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=lwgNW+v9; 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=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f7-20020a635547000000b004fbd58ce355si7203042pgm.511.2023.04.02.19.57.33; Sun, 02 Apr 2023 19:57:44 -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; dkim=pass header.i=@mediatek.com header.s=dk header.b=lwgNW+v9; 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=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231368AbjDCCxK (ORCPT <rfc822;dexuan.linux@gmail.com> + 99 others); Sun, 2 Apr 2023 22:53:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59290 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230490AbjDCCwx (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sun, 2 Apr 2023 22:52:53 -0400 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8284DAF1C; Sun, 2 Apr 2023 19:52:43 -0700 (PDT) X-UUID: 950e5760d1ca11edb6b9f13eb10bd0fe-20230403 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=ALgZrn1BexLA8a2KpVf+yoJ+e6iJZj9wJZnsbHFyjZg=; b=lwgNW+v9gxULRQ6Wgc+twwdm0GwEG/KpQ9vM9CAkCiOj3iAzq8hMA/L8voQi2Nhj64EXSBjh7Y5ejMIUBfpL+FmvEa5GgfDpO/pVAQ9WPbG/E+yqvk1WMLGu4KinXWtAK2Fxs0atUwiA1DDRXZ7OZN3h1Q7++430cewzwShQopg=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.22,REQID:2716070e-a859-48f0-9823-52fa798ab73f,IP:0,U RL:0,TC:0,Content:-25,EDM:0,RT:0,SF:95,FILE:0,BULK:0,RULE:Release_Ham,ACTI ON:release,TS:70 X-CID-INFO: VERSION:1.1.22,REQID:2716070e-a859-48f0-9823-52fa798ab73f,IP:0,URL :0,TC:0,Content:-25,EDM:0,RT:0,SF:95,FILE:0,BULK:0,RULE:Spam_GS981B3D,ACTI ON:quarantine,TS:70 X-CID-META: VersionHash:120426c,CLOUDID:c56f3c2a-564d-42d9-9875-7c868ee415ec,B ulkID:2304031052353JSTK24L,BulkQuantity:0,Recheck:0,SF:38|29|28|17|19|48,T C:nil,Content:0,EDM:-3,IP:nil,URL:11|1,File:nil,Bulk:nil,QS:nil,BEC:nil,CO L:0,OSI:0,OSA:0,AV:0 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-UUID: 950e5760d1ca11edb6b9f13eb10bd0fe-20230403 Received: from mtkmbs10n1.mediatek.inc [(172.21.101.34)] by mailgw02.mediatek.com (envelope-from <chunfeng.yun@mediatek.com>) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1714683017; Mon, 03 Apr 2023 10:52:33 +0800 Received: from mtkmbs11n1.mediatek.inc (172.21.101.185) by mtkmbs10n2.mediatek.inc (172.21.101.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.25; Mon, 3 Apr 2023 10:52:32 +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, 3 Apr 2023 10:52:31 +0800 From: Chunfeng Yun <chunfeng.yun@mediatek.com> To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Rob Herring <robh+dt@kernel.org> CC: Chunfeng Yun <chunfeng.yun@mediatek.com>, Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>, Matthias Brugger <matthias.bgg@gmail.com>, AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>, <linux-usb@vger.kernel.org>, <linux-arm-kernel@lists.infradead.org>, <linux-mediatek@lists.infradead.org>, <devicetree@vger.kernel.org>, <linux-kernel@vger.kernel.org>, Eddie Hung <eddie.hung@mediatek.com>, Tianping Fang <tianping.fang@mediatek.com> Subject: [PATCH 1/7] usb: mtu3: give back request when rx error happens Date: Mon, 3 Apr 2023 10:52:24 +0800 Message-ID: <20230403025230.25035-1-chunfeng.yun@mediatek.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-MTK: N X-Spam-Status: No, score=1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,RDNS_NONE,SPF_HELO_PASS, T_SPF_TEMPERROR,UNPARSEABLE_RELAY autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: * X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1762122179204593205?= X-GMAIL-MSGID: =?utf-8?q?1762122179204593205?= |
Series |
[1/7] usb: mtu3: give back request when rx error happens
|
|
Commit Message
Chunfeng Yun (云春峰)
April 3, 2023, 2:52 a.m. UTC
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 <chunfeng.yun@mediatek.com>
---
drivers/usb/mtu3/mtu3_qmu.c | 39 ++++++++++++++++++++++++++++++++++++-
1 file changed, 38 insertions(+), 1 deletion(-)
Comments
Il 03/04/23 04:52, Chunfeng Yun ha scritto: > 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 <chunfeng.yun@mediatek.com> From what I understand, this is not a new feature, but a fix for a unwanted QMU halt. This means that this commit needs a Fixes tag. > --- > drivers/usb/mtu3/mtu3_qmu.c | 39 ++++++++++++++++++++++++++++++++++++- > 1 file changed, 38 insertions(+), 1 deletion(-) > > diff --git a/drivers/usb/mtu3/mtu3_qmu.c b/drivers/usb/mtu3/mtu3_qmu.c > index a2fdab8b63b2..7be4e4be1a6a 100644 > --- a/drivers/usb/mtu3/mtu3_qmu.c > +++ b/drivers/usb/mtu3/mtu3_qmu.c > @@ -466,6 +466,39 @@ 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 usb_request *req = 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; > + } > + > + req = &mreq->request; > + req->status = -EAGAIN; You don't need a *req pointer for just one simple assignment. mreq->request.status = -EAGAIN; that'll do. > + > + /* 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 +604,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); Please mention in the commit description the reason why you're moving this register write here. Regards, Angelo
On Mon, 2023-04-03 at 14:31 +0200, AngeloGioacchino Del Regno wrote: > External email : Please do not click links or open attachments until > you have verified the sender or the content. > > > Il 03/04/23 04:52, Chunfeng Yun ha scritto: > > 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 <chunfeng.yun@mediatek.com> > > From what I understand, this is not a new feature, but a fix for a > unwanted QMU > halt. > This means that this commit needs a Fixes tag. I did not take into account this cases when write this driver, it caused the issue by the bug of host driver. > > > --- > > drivers/usb/mtu3/mtu3_qmu.c | 39 > > ++++++++++++++++++++++++++++++++++++- > > 1 file changed, 38 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/usb/mtu3/mtu3_qmu.c > > b/drivers/usb/mtu3/mtu3_qmu.c > > index a2fdab8b63b2..7be4e4be1a6a 100644 > > --- a/drivers/usb/mtu3/mtu3_qmu.c > > +++ b/drivers/usb/mtu3/mtu3_qmu.c > > @@ -466,6 +466,39 @@ 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 usb_request *req = 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; > > + } > > + > > + req = &mreq->request; > > + req->status = -EAGAIN; > > You don't need a *req pointer for just one simple assignment. > > mreq->request.status = -EAGAIN; > > that'll do. That's good, I'll modify it, thanks > > > + > > + /* 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 +604,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); > > Please mention in the commit description the reason why you're moving > this register > write here. It clears irq status before handling the error; > > Regards, > Angelo
On Mon, 2023-04-03 at 14:31 +0200, AngeloGioacchino Del Regno wrote: > External email : Please do not click links or open attachments until > you have verified the sender or the content. > > > Il 03/04/23 04:52, Chunfeng Yun ha scritto: > > 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 <chunfeng.yun@mediatek.com> > > From what I understand, this is not a new feature, but a fix for a > unwanted QMU > halt. > This means that this commit needs a Fixes tag. I did not take into account this cases when write this driver, it caused the issue by the bug of host driver. > > > --- > > drivers/usb/mtu3/mtu3_qmu.c | 39 > > ++++++++++++++++++++++++++++++++++++- > > 1 file changed, 38 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/usb/mtu3/mtu3_qmu.c > > b/drivers/usb/mtu3/mtu3_qmu.c > > index a2fdab8b63b2..7be4e4be1a6a 100644 > > --- a/drivers/usb/mtu3/mtu3_qmu.c > > +++ b/drivers/usb/mtu3/mtu3_qmu.c > > @@ -466,6 +466,39 @@ 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 usb_request *req = 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; > > + } > > + > > + req = &mreq->request; > > + req->status = -EAGAIN; > > You don't need a *req pointer for just one simple assignment. > > mreq->request.status = -EAGAIN; > > that'll do. That's good, I'll modify it, thanks > > > + > > + /* 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 +604,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); > > Please mention in the commit description the reason why you're moving > this register > write here. It clears irq status before handling the error; > > Regards, > Angelo
diff --git a/drivers/usb/mtu3/mtu3_qmu.c b/drivers/usb/mtu3/mtu3_qmu.c index a2fdab8b63b2..7be4e4be1a6a 100644 --- a/drivers/usb/mtu3/mtu3_qmu.c +++ b/drivers/usb/mtu3/mtu3_qmu.c @@ -466,6 +466,39 @@ 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 usb_request *req = 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; + } + + req = &mreq->request; + req->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 +604,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) {