Message ID | 20221031142516.266704-4-drake@draketalley.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2350892wru; Mon, 31 Oct 2022 07:37:50 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4EvRUPUsGfKtgqmVC/0s9frAiLyLzkZQs/JLYJ/d1FgzupIxb9qXmFNuy+StlOQyDznMZs X-Received: by 2002:a17:906:6a17:b0:794:f0e8:1918 with SMTP id qw23-20020a1709066a1700b00794f0e81918mr13561026ejc.474.1667227070215; Mon, 31 Oct 2022 07:37:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667227070; cv=none; d=google.com; s=arc-20160816; b=WTLy1fODlzf+EMdpjAMSrcs6AkMhyb1UDRU/YxCdCkBV8GIGZIjkFNW801qet7ivL9 PrZv4Stm31qGJEdXNqMooAvbFPjPCZrEVSGWTyqhdd5J7glm8YPDWA7LV+O1KmKKURHT GFtQ5zlP6g33OC5J4zjm3JmaKPrrniumd2ARj9QPHCQLDRaJecDM8VCLiC9DNn4ke2Lc tt8gzAhwiQo0HIkL5bcMPaddN8quUb+S8c3ICxaOLm6lryAY61FO5yxNtE80hsb2F6Li EADDjOfynCcz/egBdOUZ/3MOXaH+kIc7aNeOgPBy4pGFcDCCRqxI8LbT4xUmTMGcSDBO dvHA== 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=ZKnMIIi3dkx/Tr+herIgANb8VHE+1Sal7TQh/7d7m+8=; b=vIrdvbZW/J66icNb6t0qyoGI7gLJ4Yh2cepl2R1X75bwbZGHw5DtH3Ws55QJgNLCmS RQTQvpPsQi8SM4Yihiq7hwkdtwJ0rguaw5bh3NOxOYWRGl+7eD2Yos7Raz1ACGmZ1p6m L7kjfMA3O4lYfHsxmTvcRDbIL1+ekrr/J3GnwDxfcMXFS8UKl7d1tjp5tijrL6kZCCmw sKacLjb0Y1a2ix/XcaVIxc5FhH44EAbQ005w01HWo0Jwp2IyPac8qC3Mw5CFIbPQC2q9 OZBHQhJGFgnW8yAvyC/K26APaAh/pkCvQJOKceJWJkDui3LPnr+rgDoNsZU3K1BcQpDQ 7HCw== 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 c17-20020a05640227d100b00462846fc76fsi9223297ede.108.2022.10.31.07.37.23; Mon, 31 Oct 2022 07:37:50 -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 S231634AbiJaOdH (ORCPT <rfc822;kartikey406@gmail.com> + 99 others); Mon, 31 Oct 2022 10:33:07 -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 <rfc822;linux-kernel@vger.kernel.org>); 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 <manishc@marvell.com>, GR-Linux-NIC-Dev@marvell.com, Coiby Xu <coiby.xu@gmail.com>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, netdev@vger.kernel.org, linux-staging@lists.linux.dev Cc: linux-kernel@vger.kernel.org, Drake Talley <drake@draketalley.com> 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 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_00,SPF_HELO_SOFTFAIL, T_SPF_PERMERROR autolearn=no 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: <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?1748214292607454360?= X-GMAIL-MSGID: =?utf-8?q?1748214292607454360?= |
Series |
cleanup style for staging qlge driver
|
|
Commit Message
drake@draketalley.com
Oct. 31, 2022, 2:25 p.m. UTC
From: Drake Talley <drake@draketalley.com> 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 <drake@draketalley.com> --- drivers/staging/qlge/qlge_main.c | 6 ++++++ 1 file changed, 6 insertions(+)
Comments
On Mon, Oct 31, 2022 at 10:25:16AM -0400, drake@draketalley.com wrote: > From: Drake Talley <drake@draketalley.com> > > 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 <drake@draketalley.com> > --- > 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. > + */ Which "next item"? > rmb(); > switch (net_rsp->opcode) { So the opcode read is what you want to prevent from reordering? Where is the other users of this that could have changed it? Changes like this are hard to determine if your comments are correct. We know what a rmb() does, the question that needs to be answered here is _why_ it is used here. So try to step back and see if it really is needed at all. If it is needed, why? And go from there on how to document this properly. thanks, greg k-h
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: