From patchwork Mon Oct 31 14:25:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: drake@draketalley.com X-Patchwork-Id: 13025970 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 558D1FA3746 for ; Mon, 31 Oct 2022 14:33:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231524AbiJaOdB (ORCPT ); Mon, 31 Oct 2022 10:33:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231237AbiJaOc5 (ORCPT ); Mon, 31 Oct 2022 10:32:57 -0400 Received: from mail.draketalley.com (mail.draketalley.com [3.213.214.50]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D6671F58F; Mon, 31 Oct 2022 07:32:55 -0700 (PDT) Received: from pop-os.lan (cpe-74-72-139-32.nyc.res.rr.com [74.72.139.32]) by mail.draketalley.com (Postfix) with ESMTPSA id 9613655DD1; Mon, 31 Oct 2022 14:25:30 +0000 (UTC) From: drake@draketalley.com To: Manish Chopra , GR-Linux-NIC-Dev@marvell.com, Coiby Xu , Greg Kroah-Hartman , netdev@vger.kernel.org, linux-staging@lists.linux.dev Cc: linux-kernel@vger.kernel.org, Drake Talley Subject: [PATCH 1/3] staging: qlge: Separate multiple assignments Date: Mon, 31 Oct 2022 10:25:14 -0400 Message-Id: <20221031142516.266704-2-drake@draketalley.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221031142516.266704-1-drake@draketalley.com> References: <20221031142516.266704-1-drake@draketalley.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Drake Talley Adhere to coding style. Reported by checkpatch: > CHECK: multiple assignments should be avoided > #4088: FILE: drivers/staging/qlge/qlge_main.c:4088 > CHECK: multiple assignments should be avoided > #4108: FILE: drivers/staging/qlge/qlge_main.c:4108: Signed-off-by: Drake Talley --- drivers/staging/qlge/qlge_main.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/staging/qlge/qlge_main.c b/drivers/staging/qlge/qlge_main.c index 1ead7793062a..8c1fdd8ebba0 100644 --- a/drivers/staging/qlge/qlge_main.c +++ b/drivers/staging/qlge/qlge_main.c @@ -4085,7 +4085,12 @@ static struct net_device_stats *qlge_get_stats(struct net_device int i; /* Get RX stats. */ - pkts = mcast = dropped = errors = bytes = 0; + pkts = 0; + mcast = 0; + dropped = 0; + errors = 0; + bytes = 0; + for (i = 0; i < qdev->rss_ring_count; i++, rx_ring++) { pkts += rx_ring->rx_packets; bytes += rx_ring->rx_bytes; @@ -4100,7 +4105,10 @@ static struct net_device_stats *qlge_get_stats(struct net_device ndev->stats.multicast = mcast; /* Get TX stats. */ - pkts = errors = bytes = 0; + pkts = 0; + errors = 0; + bytes = 0; + for (i = 0; i < qdev->tx_ring_count; i++, tx_ring++) { pkts += tx_ring->tx_packets; bytes += tx_ring->tx_bytes; From patchwork Mon Oct 31 14:25:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: drake@draketalley.com X-Patchwork-Id: 13025968 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 001AEECAAA1 for ; Mon, 31 Oct 2022 14:32:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231381AbiJaOc6 (ORCPT ); Mon, 31 Oct 2022 10:32:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49794 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231194AbiJaOc5 (ORCPT ); Mon, 31 Oct 2022 10:32:57 -0400 Received: from mail.draketalley.com (mail.draketalley.com [3.213.214.50]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D680EFADC; Mon, 31 Oct 2022 07:32:55 -0700 (PDT) Received: from pop-os.lan (cpe-74-72-139-32.nyc.res.rr.com [74.72.139.32]) by mail.draketalley.com (Postfix) with ESMTPSA id 0A33055DD3; Mon, 31 Oct 2022 14:25:31 +0000 (UTC) From: drake@draketalley.com To: Manish Chopra , GR-Linux-NIC-Dev@marvell.com, Coiby Xu , Greg Kroah-Hartman , netdev@vger.kernel.org, linux-staging@lists.linux.dev Cc: linux-kernel@vger.kernel.org, Drake Talley Subject: [PATCH 2/3] staging: qlge: replace msleep with usleep_range Date: Mon, 31 Oct 2022 10:25:15 -0400 Message-Id: <20221031142516.266704-3-drake@draketalley.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221031142516.266704-1-drake@draketalley.com> References: <20221031142516.266704-1-drake@draketalley.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Drake Talley Since msleep may delay for up to 20ms, usleep_range is recommended for short durations in the docs linked in the below warning. I set the range to 1000-2000 based on looking at other usages of usleep_range. Reported by checkpatch: WARNING: msleep < 20ms can sleep for up to 20ms; see Documentation/timers/timers-howto.rst Signed-off-by: Drake Talley --- drivers/staging/qlge/qlge_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/qlge/qlge_main.c b/drivers/staging/qlge/qlge_main.c index 8c1fdd8ebba0..c8403dbb5bad 100644 --- a/drivers/staging/qlge/qlge_main.c +++ b/drivers/staging/qlge/qlge_main.c @@ -3890,7 +3890,7 @@ static int qlge_close(struct net_device *ndev) * (Rarely happens, but possible.) */ while (!test_bit(QL_ADAPTER_UP, &qdev->flags)) - msleep(1); + usleep_range(1000, 2000); /* Make sure refill_work doesn't re-enable napi */ for (i = 0; i < qdev->rss_ring_count; i++) From patchwork Mon Oct 31 14:25:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: drake@draketalley.com X-Patchwork-Id: 13025971 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 5AB01FA3741 for ; Mon, 31 Oct 2022 14:33:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231601AbiJaOdC (ORCPT ); Mon, 31 Oct 2022 10:33:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49790 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231304AbiJaOc5 (ORCPT ); Mon, 31 Oct 2022 10:32:57 -0400 X-Greylist: delayed 444 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Mon, 31 Oct 2022 07:32:55 PDT Received: from mail.draketalley.com (mail.draketalley.com [3.213.214.50]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BA153EE2B; Mon, 31 Oct 2022 07:32:55 -0700 (PDT) Received: from pop-os.lan (cpe-74-72-139-32.nyc.res.rr.com [74.72.139.32]) by mail.draketalley.com (Postfix) with ESMTPSA id 5EC0D55DD6; Mon, 31 Oct 2022 14:25:31 +0000 (UTC) From: drake@draketalley.com To: Manish Chopra , GR-Linux-NIC-Dev@marvell.com, Coiby Xu , Greg Kroah-Hartman , netdev@vger.kernel.org, linux-staging@lists.linux.dev Cc: linux-kernel@vger.kernel.org, Drake Talley Subject: [PATCH 3/3] staging: qlge: add comment explaining memory barrier Date: Mon, 31 Oct 2022 10:25:16 -0400 Message-Id: <20221031142516.266704-4-drake@draketalley.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221031142516.266704-1-drake@draketalley.com> References: <20221031142516.266704-1-drake@draketalley.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Drake Talley codestyle change that fixes the following report from checkpatch: > WARNING: memory barrier without comment > #2101: FILE: drivers/staging/qlge/qlge_main.c:2101: The added comment identifies the next item from the circular buffer (rx_ring->curr_entry) and its handling/unmapping as the two operations that must not be reordered. Based on the kernel documentation for memory barriers in circular buffers (https://www.kernel.org/doc/Documentation/circular-buffers.txt) and the presence of atomic operations in the current context I'm assuming this usage of the memory barrier is akin to what is explained in the linked doc. There are a couple of other uncommented usages of memory barriers in the current file. If this comment is adequate I can add similar comments to the others. Signed-off-by: Drake Talley --- drivers/staging/qlge/qlge_main.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/staging/qlge/qlge_main.c b/drivers/staging/qlge/qlge_main.c index c8403dbb5bad..f70390bce6d8 100644 --- a/drivers/staging/qlge/qlge_main.c +++ b/drivers/staging/qlge/qlge_main.c @@ -2098,6 +2098,12 @@ static int qlge_clean_outbound_rx_ring(struct rx_ring *rx_ring) rx_ring->cq_id, prod, rx_ring->cnsmr_idx); net_rsp = (struct qlge_ob_mac_iocb_rsp *)rx_ring->curr_entry; + /* + * Ensure that the next item from the ring buffer is loaded + * before being processed. + * Adding rmb() prevents the compiler from reordering the read + * and subsequent handling of the outbound completion pointer. + */ rmb(); switch (net_rsp->opcode) { case OPCODE_OB_MAC_TSO_IOCB: