Received: by 2002:a05:6359:6284:b0:131:369:b2a3 with SMTP id se4csp2435585rwb; Sun, 6 Aug 2023 18:45:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG3Hdn9OobLtGBSGMTe6eeDS7GwoUitGIsMuZHanr0LUojgQzh05u47/cajg9/YegQEBXYm X-Received: by 2002:a05:6a00:1353:b0:687:41cb:e274 with SMTP id k19-20020a056a00135300b0068741cbe274mr8373331pfu.9.1691372732846; Sun, 06 Aug 2023 18:45:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691372732; cv=none; d=google.com; s=arc-20160816; b=Jd+Znw1CDsUW2eLReIwuQAm5UoyBBuc3Eiogomg/imeRZQHty8kjlSPt6kZJ0IVeTr MEpWdiGZL/Bdhwr4AywwCZqx/QrNbY2BOGChmd87/iNj82itdSKhg3RDx6rYj5AZmlN/ K3XtZyDpJU/Mox9CQb+oo2fYKTpbBMO+AoO8dHsRWQS2IuBM/tUt6o9qz4GOvLLmCUSe clHh9G283WIM8bYNu7l58PlTUZpjhZG5IZC2/GN9Vy0BqTqdBAXJp/V4Iz5sPMZytxqL nsUaMMC5bKpVchnUn9GXFYixWS1xs3ctqrP20o0zt739Q1t24SByyeTkxyhherwp8R0A doog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:cc:to:from:authenticated-by; bh=7WYYT9bNZqghBgNFfxotZ1bjHlaRza8w8W3+K3azZsM=; fh=EF8LLZbsWN1B956J92P0HBPTCMR6rkiHjGlJQaYidaU=; b=T9+THt9zib82Boky0/6PECTBx52L1F+dsDTYm6KbhSDx9teoRPdpbGH/YkzuBNcNjq wMMRUGO3Tcfb8NdR1lQ3KWOc387cFZJzq2wNN10La+f6izc/zyRVpoRpDNOt0tur3caK qZbWTLIPFinRl73PSag7FHdIms4yX13rEoO6wA/zMApRyAn3n7A7swaSQkMf8kgynD2M MBU/ZjBg9PDQTSGFYtZZbRlMl9+6TePCb5FrAFOBNHW1EqeG4KHl5Huwaj8wtXfLQL68 vuFbdDNsIjxDOxswxl8qCLDR+7lx5dMN63UlrVezRDhvlaFhAKl+7anGwptbZz3Ci98t pAgg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-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 f13-20020a056a00228d00b00686a189d7d2si5048982pfe.113.2023.08.06.18.45.20; Sun, 06 Aug 2023 18:45:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-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-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230107AbjHGAlt convert rfc822-to-8bit (ORCPT + 56 others); Sun, 6 Aug 2023 20:41:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46682 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229436AbjHGAls (ORCPT ); Sun, 6 Aug 2023 20:41:48 -0400 Received: from rtits2.realtek.com.tw (rtits2.realtek.com [211.75.126.72]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C9942170E; Sun, 6 Aug 2023 17:41:44 -0700 (PDT) Authenticated-By: X-SpamFilter-By: ArmorX SpamTrap 5.77 with qID 3770f2MC1027837, This message is accepted by code: ctloc85258 Received: from mail.realtek.com (rtexh36505.realtek.com.tw[172.21.6.25]) by rtits2.realtek.com.tw (8.15.2/2.81/5.90) with ESMTPS id 3770f2MC1027837 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=FAIL); Mon, 7 Aug 2023 08:41:02 +0800 Received: from RTEXMBS06.realtek.com.tw (172.21.6.99) by RTEXH36505.realtek.com.tw (172.21.6.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.32; Mon, 7 Aug 2023 08:41:02 +0800 Received: from RTEXMBS04.realtek.com.tw (172.21.6.97) by RTEXMBS06.realtek.com.tw (172.21.6.99) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Mon, 7 Aug 2023 08:41:01 +0800 Received: from RTEXMBS04.realtek.com.tw ([fe80::e138:e7f1:4709:ff4d]) by RTEXMBS04.realtek.com.tw ([fe80::e138:e7f1:4709:ff4d%5]) with mapi id 15.01.2375.007; Mon, 7 Aug 2023 08:41:01 +0800 From: Ping-Ke Shih To: Martin Blumenstingl , "linux-wireless@vger.kernel.org" CC: "linux-kernel@vger.kernel.org" , "jernej.skrabec@gmail.com" , "ulf.hansson@linaro.org" , "kvalo@kernel.org" , "tony0620emma@gmail.com" , "Lukas F . Hartmann" Subject: RE: [PATCH v2] wifi: rtw88: sdio: Honor the host max_req_size in the RX path Thread-Topic: [PATCH v2] wifi: rtw88: sdio: Honor the host max_req_size in the RX path Thread-Index: AQHZyJJBxKp6wAKI9k2D+NDrSHNiaq/d+wnA Date: Mon, 7 Aug 2023 00:41:01 +0000 Message-ID: <42e6d455aaa34c68ba8d50ec22a17b79@realtek.com> References: <20230806181656.2072792-1-martin.blumenstingl@googlemail.com> In-Reply-To: <20230806181656.2072792-1-martin.blumenstingl@googlemail.com> Accept-Language: en-US, zh-TW Content-Language: zh-TW X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [172.21.69.188] x-kse-serverinfo: RTEXMBS06.realtek.com.tw, 9 x-kse-antispam-interceptor-info: fallback x-kse-antivirus-interceptor-info: fallback Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-KSE-AntiSpam-Interceptor-Info: fallback X-KSE-ServerInfo: RTEXH36505.realtek.com.tw, 9 X-KSE-AntiSpam-Interceptor-Info: fallback X-KSE-Antivirus-Interceptor-Info: fallback X-KSE-AntiSpam-Interceptor-Info: fallback X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS 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-wireless@vger.kernel.org > -----Original Message----- > From: Martin Blumenstingl > Sent: Monday, August 7, 2023 2:17 AM > To: linux-wireless@vger.kernel.org > Cc: linux-kernel@vger.kernel.org; jernej.skrabec@gmail.com; Ping-Ke Shih ; > ulf.hansson@linaro.org; kvalo@kernel.org; tony0620emma@gmail.com; Martin Blumenstingl > ; Lukas F . Hartmann > Subject: [PATCH v2] wifi: rtw88: sdio: Honor the host max_req_size in the RX path > [...] > > > drivers/net/wireless/realtek/rtw88/sdio.c | 30 +++++++++++++++++------ > 1 file changed, 23 insertions(+), 7 deletions(-) > > diff --git a/drivers/net/wireless/realtek/rtw88/sdio.c b/drivers/net/wireless/realtek/rtw88/sdio.c > index 2c1fb2dabd40..553b7e68ca3b 100644 > --- a/drivers/net/wireless/realtek/rtw88/sdio.c > +++ b/drivers/net/wireless/realtek/rtw88/sdio.c > @@ -500,19 +500,35 @@ static u32 rtw_sdio_get_tx_addr(struct rtw_dev *rtwdev, size_t size, > static int rtw_sdio_read_port(struct rtw_dev *rtwdev, u8 *buf, size_t count) > { > struct rtw_sdio *rtwsdio = (struct rtw_sdio *)rtwdev->priv; > + struct mmc_host *host = rtwsdio->sdio_func->card->host; > bool bus_claim = rtw_sdio_bus_claim_needed(rtwsdio); > u32 rxaddr = rtwsdio->rx_addr++; > - int ret; > + int ret = 0, err = 0; nit: no need initializer of 'err' > + size_t bytes; > > if (bus_claim) > sdio_claim_host(rtwsdio->sdio_func); > > - ret = sdio_memcpy_fromio(rtwsdio->sdio_func, buf, > - RTW_SDIO_ADDR_RX_RX0FF_GEN(rxaddr), count); > - if (ret) > - rtw_warn(rtwdev, > - "Failed to read %zu byte(s) from SDIO port 0x%08x", > - count, rxaddr); > + while (count > 0) { > + bytes = min_t(size_t, host->max_req_size, count); > + > + err = sdio_memcpy_fromio(rtwsdio->sdio_func, buf, > + RTW_SDIO_ADDR_RX_RX0FF_GEN(rxaddr), > + bytes); > + if (err) { > + rtw_warn(rtwdev, > + "Failed to read %zu byte(s) from SDIO port 0x%08x: %d", > + bytes, rxaddr, err); > + ret = err; I think this intends to return an error to callers if one error presents among N times read. Would you like to point out this in comment as well? Because I want to say we don't need 'err' at first glance, but this is indeed needed. > + /* Don't stop here - instead drain the remaining data > + * from the card's buffer, else the card will return > + * corrupt data for the next rtw_sdio_read_port() call. > + */ > + } > + > + count -= bytes; > + buf += bytes; > + } > > if (bus_claim) > sdio_release_host(rtwsdio->sdio_func); > -- > 2.41.0