From patchwork Wed Jul 26 03:08:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hayes Wang X-Patchwork-Id: 126045 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a985:0:b0:3e4:2afc:c1 with SMTP id t5csp153614vqo; Tue, 25 Jul 2023 20:37:24 -0700 (PDT) X-Google-Smtp-Source: APBJJlFOhVnyTtOGsS7yFKSzz7FxWpicmDpnOTpRHioNO+lUMMvyW922RFbUO12gEZrRBsSd6ig0 X-Received: by 2002:a05:6808:13c3:b0:3a0:3495:c8d4 with SMTP id d3-20020a05680813c300b003a03495c8d4mr1048244oiw.28.1690342643929; Tue, 25 Jul 2023 20:37:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690342643; cv=none; d=google.com; s=arc-20160816; b=fPAhiUNBoG6uio0eq2AKMpLfidQKCLiRb0cFHgLcQNplcseOZUS302yZ6hMvsCfUS9 i6olS5EnS+dKCdHTZUVOZTSJ/zDSSvGexTLyUyGgfcnhOw2UhrH4N/fvFKe3tIw0Fc3N awxxnrKMf71LAzGom5PGWS6be4t9Spg6Nj+9GJ9Xh+G1l4XXPhoUVXm/H/sEVEi9Ml4K uwdzon9pA1gvBEkT0Q1ltZK/rrcG4yNHWhWtA215KAKV2VUffmJmXCNCdk+GlJBTJso6 891dyCXkcMU99EtS7d2cLZdWmZ2eyXdAvHFhpp/g1O4Fo4T/bfcexXoKI3pLkCX0VUGB 8SaQ== 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 :authenticated-by; bh=xoKalkRvf8JZEX9w0Gkc/Dny2yYlVrYkDgd4yzr7vds=; fh=q9cLQonAfV/WNLezu8/aPFdhVajKMg7lBtPBnvx15GA=; b=dzwh88WYCGfXhnOZQxqf+9Bsc5uJbRRPBVjXFINwCDmIc8AURUGAQaWIWW0oJnYWyC 7Bje9IN7EN7HGH1KBUJMTwccnCrbG26HVhTq6HC2x0pp/vRrR0geMlWyIb7X2Xt4DdsP fSFlfcZk5biHU0/LHUyyMwh0nBGgf+Z8lYv+KNQZYEXhoC5tyEoBJA5YIRD62Or+eJuW ZBU36MXsGagpEfN+oAdLe1o+Ru9t42TJmH1EH0gKtX+E2dixD9sG0b6JzXVC4fRAfVHd MIjzLitchp10w+lkHV6+UPLw2jwP6ZCXednZj7a22P9I169qRbLoK75iHLOtXrqo9MBn PHDQ== 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 l24-20020a639858000000b0055b1a2f6d2bsi12656538pgo.76.2023.07.25.20.37.10; Tue, 25 Jul 2023 20:37:23 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230439AbjGZDI4 (ORCPT + 99 others); Tue, 25 Jul 2023 23:08:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229487AbjGZDIy (ORCPT ); Tue, 25 Jul 2023 23:08:54 -0400 Received: from rtits2.realtek.com.tw (rtits2.realtek.com [211.75.126.72]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 14AD92689; Tue, 25 Jul 2023 20:08:50 -0700 (PDT) Authenticated-By: X-SpamFilter-By: ArmorX SpamTrap 5.77 with qID 36Q38NE50011093, This message is accepted by code: ctloc85258 Received: from mail.realtek.com (rtexh36506.realtek.com.tw[172.21.6.27]) by rtits2.realtek.com.tw (8.15.2/2.81/5.90) with ESMTPS id 36Q38NE50011093 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=FAIL); Wed, 26 Jul 2023 11:08:23 +0800 Received: from RTEXMBS04.realtek.com.tw (172.21.6.97) by RTEXH36506.realtek.com.tw (172.21.6.27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.17; Wed, 26 Jul 2023 11:08:35 +0800 Received: from fc38.localdomain (172.22.228.98) by RTEXMBS04.realtek.com.tw (172.21.6.97) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.7; Wed, 26 Jul 2023 11:08:34 +0800 From: Hayes Wang To: , CC: , , , , Hayes Wang Subject: [PATCH net-next v2 1/2] r8152: adjust generic_ocp_write function Date: Wed, 26 Jul 2023 11:08:07 +0800 Message-ID: <20230726030808.9093-418-nic_swsd@realtek.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230726030808.9093-417-nic_swsd@realtek.com> References: <20230726030808.9093-417-nic_swsd@realtek.com> MIME-Version: 1.0 X-Originating-IP: [172.22.228.98] X-ClientProxiedBy: RTEXH36505.realtek.com.tw (172.21.6.25) To RTEXMBS04.realtek.com.tw (172.21.6.97) X-KSE-ServerInfo: RTEXMBS04.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,T_SCC_BODY_TEXT_LINE 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-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772452728391373568 X-GMAIL-MSGID: 1772452728391373568 Reduce the control transfer if all bytes of first or the last DWORD are written. The original method is to split the control transfer into three parts (the first DWORD, middle continuous data, and the last DWORD). However, they could be combined if whole bytes of the first DWORD or last DWORD are written. That is, the first DWORD or the last DWORD could be combined with the middle continuous data, if the byte_en is 0xff. Signed-off-by: Hayes Wang --- drivers/net/usb/r8152.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c index 0738baa5b82e..f6578a99dbac 100644 --- a/drivers/net/usb/r8152.c +++ b/drivers/net/usb/r8152.c @@ -1314,16 +1314,24 @@ static int generic_ocp_write(struct r8152 *tp, u16 index, u16 byteen, byteen_end = byteen & BYTE_EN_END_MASK; byen = byteen_start | (byteen_start << 4); - ret = set_registers(tp, index, type | byen, 4, data); - if (ret < 0) - goto error1; - index += 4; - data += 4; - size -= 4; + /* Split the first DWORD if the byte_en is not 0xff */ + if (byen != BYTE_EN_DWORD) { + ret = set_registers(tp, index, type | byen, 4, data); + if (ret < 0) + goto error1; - if (size) { + index += 4; + data += 4; size -= 4; + } + + if (size) { + byen = byteen_end | (byteen_end >> 4); + + /* Split the last DWORD if the byte_en is not 0xff */ + if (byen != BYTE_EN_DWORD) + size -= 4; while (size) { if (size > limit) { @@ -1350,10 +1358,9 @@ static int generic_ocp_write(struct r8152 *tp, u16 index, u16 byteen, } } - byen = byteen_end | (byteen_end >> 4); - ret = set_registers(tp, index, type | byen, 4, data); - if (ret < 0) - goto error1; + /* Set the last DWORD */ + if (byen != BYTE_EN_DWORD) + ret = set_registers(tp, index, type | byen, 4, data); } error1: