From patchwork Fri Feb 10 09:26:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sascha Hauer X-Patchwork-Id: 55348 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp854270wrn; Fri, 10 Feb 2023 01:37:27 -0800 (PST) X-Google-Smtp-Source: AK7set9WqpOZ36wGEEbidhZoqpwtMNfQfTZMhF+yw377GovN2aPR0mXH9JXoF8NmmZFWlxgwfI2g X-Received: by 2002:a50:9b55:0:b0:4aa:b3f2:726c with SMTP id a21-20020a509b55000000b004aab3f2726cmr14818593edj.30.1676021847309; Fri, 10 Feb 2023 01:37:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676021847; cv=none; d=google.com; s=arc-20160816; b=PdAst9/K35ech8iqMHAnMI43Su6+SzsAamwdXtFPgsVhJQiZacRrxUeLOueXuCzwXe 2LLtJl/d1nibAdQ85uqbVo6LY5ShgO59xg9GsIGJcsScjyetpT8KC0EBq0nWiZTsUMs1 6pzjk4EWTjIwcCe8x1qE4W+PWzYsyCwvFcAuEL4HD+YCLyJt6DFTlHUtzBIQqb9hcTMC Fxxvw7zLQaZhUnQVvZcCTu/rpTDzywAeCVwaGMK2m2BWj9rtHpjEngRih1/dzQpFDOxe THkY4MMPU0z+6pCrSQQhs9a7LU4SC19ErCpZ+nJv3W1jUXGyfmKQLIrxR6wS/yQ857d0 hsIQ== 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=/kDyxuWJ8BtaSKvklq8K73SuP/Are+PZ+SdY5gSrgds=; b=CnATP1TLg9QEOvFPxGpWOCY7VSTDBJruF1Z0YBvlKItvHUUvx9WdcD8hq9vK5LSeHj 39nl6cyAxCOZ8SlglMIVq8u4MjJLZciPysNkIAqMTOG6FXWAYk1JfBnIrF8JASW2zt1l +3pN/6/cYZcdD3Pk1vFL7byMMFw+IrAvEFbgfibO9nECOwVyBHJbu6y5F3LuH3sTHJYn 6PLeLhJVepuOddmt6gYaIC36s6gu/d/DatszW0m8eOPqfGAkQ/xSz5Hk6+chKgoGJ/HD NI01zv3ECa22DHaKgu/RITPFDCiOl9R1eUvnHOowTabcTDz8o23lNkA0JHk19cOZI7Zj 0moQ== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e2-20020a056402148200b004aa99250f07si4342580edv.398.2023.02.10.01.37.04; Fri, 10 Feb 2023 01:37:27 -0800 (PST) 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 S231727AbjBJJ1S (ORCPT + 99 others); Fri, 10 Feb 2023 04:27:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58528 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231843AbjBJJ1M (ORCPT ); Fri, 10 Feb 2023 04:27:12 -0500 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3D588518F4 for ; Fri, 10 Feb 2023 01:27:11 -0800 (PST) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pQPgI-0003Uq-2o; Fri, 10 Feb 2023 10:26:58 +0100 Received: from [2a0a:edc0:0:1101:1d::28] (helo=dude02.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1pQPg9-003w64-Pf; Fri, 10 Feb 2023 10:26:50 +0100 Received: from sha by dude02.red.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1pQPg9-002tIF-VJ; Fri, 10 Feb 2023 10:26:49 +0100 From: Sascha Hauer To: linux-wireless@vger.kernel.org Cc: Neo Jou , Hans Ulli Kroll , Ping-Ke Shih , Yan-Hsuan Chuang , Kalle Valo , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Martin Blumenstingl , kernel@pengutronix.de, Alexander Hochbaum , Da Xue , Po-Hao Huang , Andreas Henriksson , Viktor Petrenko , Sascha Hauer Subject: [PATCH 2/2] wifi: rtw88: usb: Fix urbs with size multiple of bulkout_size Date: Fri, 10 Feb 2023 10:26:42 +0100 Message-Id: <20230210092642.685905-3-s.hauer@pengutronix.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230210092642.685905-1-s.hauer@pengutronix.de> References: <20230210092642.685905-1-s.hauer@pengutronix.de> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: sha@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757436284356476207?= X-GMAIL-MSGID: =?utf-8?q?1757436284356476207?= The hardware can't handle urbs with a data size of multiple of bulkout_size. With such a packet the endpoint gets stuck and only replugging the hardware helps. Fix this by moving the header eight bytes down, thus making the packet eight bytes bigger. The same is done in rtw_usb_write_data_rsvd_page() already, but not yet for the tx data. Fixes: a82dfd33d1237 ("wifi: rtw88: Add common USB chip support") Signed-off-by: Sascha Hauer --- drivers/net/wireless/realtek/rtw88/tx.h | 2 ++ drivers/net/wireless/realtek/rtw88/usb.c | 34 +++++++++++++++--------- 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/drivers/net/wireless/realtek/rtw88/tx.h b/drivers/net/wireless/realtek/rtw88/tx.h index a2f3ac326041b..38ce9c7ae62ed 100644 --- a/drivers/net/wireless/realtek/rtw88/tx.h +++ b/drivers/net/wireless/realtek/rtw88/tx.h @@ -75,6 +75,8 @@ le32p_replace_bits((__le32 *)(txdesc) + 0x07, value, GENMASK(15, 0)) #define SET_TX_DESC_DMA_TXAGG_NUM(txdesc, value) \ le32p_replace_bits((__le32 *)(txdesc) + 0x07, value, GENMASK(31, 24)) +#define GET_TX_DESC_OFFSET(txdesc) \ + le32_get_bits(*((__le32 *)(txdesc) + 0x00), GENMASK(23, 16)) #define GET_TX_DESC_PKT_OFFSET(txdesc) \ le32_get_bits(*((__le32 *)(txdesc) + 0x01), GENMASK(28, 24)) #define GET_TX_DESC_QSEL(txdesc) \ diff --git a/drivers/net/wireless/realtek/rtw88/usb.c b/drivers/net/wireless/realtek/rtw88/usb.c index d9e995544e405..08cd480958b6b 100644 --- a/drivers/net/wireless/realtek/rtw88/usb.c +++ b/drivers/net/wireless/realtek/rtw88/usb.c @@ -281,6 +281,7 @@ static int rtw_usb_write_port(struct rtw_dev *rtwdev, u8 qsel, struct sk_buff *s static bool rtw_usb_tx_agg_skb(struct rtw_usb *rtwusb, struct sk_buff_head *list) { struct rtw_dev *rtwdev = rtwusb->rtwdev; + const struct rtw_chip_info *chip = rtwdev->chip; struct rtw_usb_txcb *txcb; struct sk_buff *skb_head; struct sk_buff *skb_iter; @@ -299,16 +300,11 @@ static bool rtw_usb_tx_agg_skb(struct rtw_usb *rtwusb, struct sk_buff_head *list skb_iter = skb_dequeue(list); - if (skb_queue_empty(list)) { - skb_head = skb_iter; - goto queue; - } - skb_head = dev_alloc_skb(RTW_USB_MAX_XMITBUF_SZ); - if (!skb_head) { - skb_head = skb_iter; - goto queue; - } + if (!skb_head) + return false; + + skb_reserve(skb_head, RTW_USB_PACKET_OFFSET_SZ); while (skb_iter) { unsigned long flags; @@ -326,17 +322,31 @@ static bool rtw_usb_tx_agg_skb(struct rtw_usb *rtwusb, struct sk_buff_head *list skb_iter = skb_peek(list); - if (skb_iter && skb_iter->len + skb_head->len <= RTW_USB_MAX_XMITBUF_SZ) + if (skb_iter && skb_iter->len + skb_head->len <= + RTW_USB_MAX_XMITBUF_SZ - RTW_USB_PACKET_OFFSET_SZ) __skb_unlink(skb_iter, list); else skb_iter = NULL; spin_unlock_irqrestore(&list->lock, flags); } - if (agg_num > 1) + if (skb_head->len % rtwusb->bulkout_size == 0) { + unsigned int offset; + + skb_push(skb_head, RTW_USB_PACKET_OFFSET_SZ); + + memmove(skb_head->data, skb_head->data + 8, chip->tx_pkt_desc_sz); + + offset = GET_TX_DESC_OFFSET(skb_head->data); + offset += RTW_USB_PACKET_OFFSET_SZ; + SET_TX_DESC_OFFSET(skb_head->data, offset); + + SET_TX_DESC_PKT_OFFSET(skb_head->data, 1); + rtw_usb_fill_tx_checksum(rtwusb, skb_head, agg_num); + } else if (agg_num > 1) { rtw_usb_fill_tx_checksum(rtwusb, skb_head, agg_num); + } -queue: skb_queue_tail(&txcb->tx_ack_queue, skb_head); rtw_usb_write_port(rtwdev, GET_TX_DESC_QSEL(skb_head->data), skb_head,