From patchwork Sun Apr 19 18:14:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 221012 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 55AEFC38A30 for ; Sun, 19 Apr 2020 18:16:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 30AB320771 for ; Sun, 19 Apr 2020 18:16:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="jzi+WVUj" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726745AbgDSSQi (ORCPT ); Sun, 19 Apr 2020 14:16:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60350 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725970AbgDSSQi (ORCPT ); Sun, 19 Apr 2020 14:16:38 -0400 Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AFD44C061A0C for ; Sun, 19 Apr 2020 11:16:37 -0700 (PDT) Received: by mail-wr1-x443.google.com with SMTP id x18so9331070wrq.2 for ; Sun, 19 Apr 2020 11:16:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:from:to:cc:references:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=hOJKu6+hXN4oWwRYPk4f7modmHIuix1R+fKs55WqgOk=; b=jzi+WVUjjHzq7OMyz773c+P0Z8GblSi69AZlNhXmVFIm/tIl63lE/sJBn363L6+YHm Jlkqe7TMwVE/LxQm+XlQi02IkfEfU7WFZxxrbzMpa+ySJ1dIppWMuQXKUo3XQp264wbY XKoNEHW6DoQA+/U4Q2rUeP9wCDVHn9SQwJrWc7zNzQOlnMBxhUoYOR3//CPxy+eihc1E i82dhYR4e/t5fe0ZglGQbHnUwONkSDTYWKydeCAUmGh2V/fa9A79H4ZbS1EyYdJ7C1hP qufpkf2bfpGQs1UqiFTBxuRONZgFaWeLcysVY2dTm6L9zgzvEWt2zQ3wEFzLVu7A4rZ/ ncbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=hOJKu6+hXN4oWwRYPk4f7modmHIuix1R+fKs55WqgOk=; b=Ve6w1zepZwm0CWd34xVM4yWVPo2t8GCuY06bJAdryOVzHq6pjR7W08oKvZz+zD+O5l 25pHrSUjhQImCB0qVjNzfNy3+hd2rnBUaOyi/3+CC7IeMHvv7nhqbEff1baIvYeQFtHx TaPy5W212ehdD2p+NUuPACgU3Q5T5vxTRv26c/HoUxV4VQDr/tDuIUwYcTt6ta+qCbMk 281w92q7uq38tZaBcp0/KLKPKKLOuLi3IJwBhiKopSHekG0lfpsAF2Dzs5YShhj0WqxW 5gBQJ4kh6hLyE7ixpBTyOuPv4jtbmPWdHHaKu253ftXKHy0DjtGq9DuqH8s+By2kNo6R 1lcg== X-Gm-Message-State: AGi0Pua7NuppzWPiv4JEEsyl6CRWj7ubFVE49gShsjznzsf+wP/vZHXG AJtpd93yJwDoZFUFIsVQiEIe8HBJ X-Google-Smtp-Source: APiQypIz1p+oOrXTH6J9JZeTH1kpAv8qPoUB/YsyuGd1+VBTKb7hI53Q0NmcJRv17uFVddPsPjRoqg== X-Received: by 2002:adf:e681:: with SMTP id r1mr15952532wrm.213.1587320196003; Sun, 19 Apr 2020 11:16:36 -0700 (PDT) Received: from ?IPv6:2003:ea:8f29:6000:39dc:7003:657c:dd6e? (p200300EA8F29600039DC7003657CDD6E.dip0.t-ipconnect.de. [2003:ea:8f29:6000:39dc:7003:657c:dd6e]) by smtp.googlemail.com with ESMTPSA id z16sm43438810wrl.0.2020.04.19.11.16.35 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 19 Apr 2020 11:16:35 -0700 (PDT) Subject: [PATCH net-next v2 1/3] r8169: use smp_store_mb in rtl_tx From: Heiner Kallweit To: Realtek linux nic maintainers , David Miller Cc: "netdev@vger.kernel.org" References: Message-ID: <788ff95b-9d2c-65c4-4271-025ed0339554@gmail.com> Date: Sun, 19 Apr 2020 20:14:25 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Use helper smp_store_mb() instead of open-coding the functionality. Signed-off-by: Heiner Kallweit --- drivers/net/ethernet/realtek/r8169_main.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c index 1bc415d00..dd6113fd7 100644 --- a/drivers/net/ethernet/realtek/r8169_main.c +++ b/drivers/net/ethernet/realtek/r8169_main.c @@ -4438,7 +4438,6 @@ static void rtl_tx(struct net_device *dev, struct rtl8169_private *tp, tp->tx_stats.bytes += bytes_compl; u64_stats_update_end(&tp->tx_stats.syncp); - tp->dirty_tx = dirty_tx; /* Sync with rtl8169_start_xmit: * - publish dirty_tx ring index (write barrier) * - refresh cur_tx ring index and queue status (read barrier) @@ -4446,7 +4445,7 @@ static void rtl_tx(struct net_device *dev, struct rtl8169_private *tp, * a racing xmit thread can only have a right view of the * ring status. */ - smp_mb(); + smp_store_mb(tp->dirty_tx, dirty_tx); if (netif_queue_stopped(dev) && rtl_tx_slots_avail(tp, MAX_SKB_FRAGS)) { netif_wake_queue(dev); From patchwork Sun Apr 19 18:15:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 221011 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E5076C5321D for ; Sun, 19 Apr 2020 18:16:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C319A20771 for ; Sun, 19 Apr 2020 18:16:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="T9ratNl3" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726756AbgDSSQk (ORCPT ); Sun, 19 Apr 2020 14:16:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60352 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725970AbgDSSQj (ORCPT ); Sun, 19 Apr 2020 14:16:39 -0400 Received: from mail-wm1-x343.google.com (mail-wm1-x343.google.com [IPv6:2a00:1450:4864:20::343]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A0603C061A0C for ; Sun, 19 Apr 2020 11:16:38 -0700 (PDT) Received: by mail-wm1-x343.google.com with SMTP id h2so8402084wmb.4 for ; Sun, 19 Apr 2020 11:16:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:from:to:cc:references:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=agQxSnV3uf+VTUq+2pXVGSO4KIcp8OMEWHxBYus81bM=; b=T9ratNl3NT9r1L7rmv/O6+CkO6BucVRv+uRQ3qs+JVVKeycy+nRum4x56L+bTA5Z9J O9jta65NlxakxOKi7RdKI0a2KSRx9i88vPL0tkIFTrY1AR+ep1ySA1UYeSARw+Dw5QuU Rb9IbC817UD2vggVdvNtB4062dwWaWhZwwDs8jXvgvPICR2dHEgzjYCJCm64a3/QJ5xV YslnL+eDvSX3Hn8NXcoLNinLWgJranmZeasKrSI8HSgKAgWh4sVQX9lxMAbeFix8xzci pb7BdMSvCeuzhteTu7RswuiBKoFCu7UVIZIyb6iZaI/tbGMaAR3S+8Uq92seU0J+pr12 hLmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=agQxSnV3uf+VTUq+2pXVGSO4KIcp8OMEWHxBYus81bM=; b=K2cZaJ/BHdnVQnhbYVtzolUnIrqAmnRmHqp8g6m4n2FvTUc4LTtwaPYZ++90gt21vR F8jt4o7ClHge8GKDZdn67W5+Me1cE0nkcWUl/B2fPhZS15N1v/Fs4/wmBFy/593Nw3OD wZDgIXgmjVu83WCDxKIp12IV/h59nXP2nY7fyefVY0Nk+j9MxdOSAfLKktkW/jxeswFa zu8ZdLNQiKFRn170yxjzIjnQR66FVnPTp+aNBpcMXTfDDAvrMjhGaK4Y3EpEWYkwB/Yj P5vnQM0hqbW04EmuUQYmwWlDH73NBzussd9k2VgjU40UeGK43cDLBSYunKcZHMaAYMmb gKqQ== X-Gm-Message-State: AGi0PuZf5Q9dlbj1uraSKVPTUJAP8Y1d2gKqEwlQD4GcMDQdVHjH80eJ cwf5wzgG4U4EpT08hhTMqfUQBZzS X-Google-Smtp-Source: APiQypLc9cevN8MgpO3YHzOln3jVyVBmjzXJHq/s/Hq8NWEZeKUQbi1K/+v7+dYM6zExklWD0fLCVw== X-Received: by 2002:a1c:4144:: with SMTP id o65mr14362674wma.78.1587320197060; Sun, 19 Apr 2020 11:16:37 -0700 (PDT) Received: from ?IPv6:2003:ea:8f29:6000:39dc:7003:657c:dd6e? (p200300EA8F29600039DC7003657CDD6E.dip0.t-ipconnect.de. [2003:ea:8f29:6000:39dc:7003:657c:dd6e]) by smtp.googlemail.com with ESMTPSA id w11sm16204004wmi.32.2020.04.19.11.16.36 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 19 Apr 2020 11:16:36 -0700 (PDT) Subject: [PATCH net-next v2 2/3] r8169: replace dma_rmb with READ_ONCE in rtl_rx From: Heiner Kallweit To: Realtek linux nic maintainers , David Miller Cc: "netdev@vger.kernel.org" References: Message-ID: <70576d8a-1bb3-c692-6dbd-2304c233e592@gmail.com> Date: Sun, 19 Apr 2020 20:15:29 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org We want to ensure that desc->opts1 is read before desc->opts2. This doesn't require a full compiler barrier. READ_ONCE provides the ordering guarantee we need. Signed-off-by: Heiner Kallweit --- drivers/net/ethernet/realtek/r8169_main.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c index dd6113fd7..2fc65aca3 100644 --- a/drivers/net/ethernet/realtek/r8169_main.c +++ b/drivers/net/ethernet/realtek/r8169_main.c @@ -1548,7 +1548,7 @@ static inline u32 rtl8169_tx_vlan_tag(struct sk_buff *skb) static void rtl8169_rx_vlan_tag(struct RxDesc *desc, struct sk_buff *skb) { - u32 opts2 = le32_to_cpu(desc->opts2); + u32 opts2 = le32_to_cpu(READ_ONCE(desc->opts2)); if (opts2 & RxVlanTag) __vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), swab16(opts2 & 0xffff)); @@ -4490,16 +4490,11 @@ static int rtl_rx(struct net_device *dev, struct rtl8169_private *tp, u32 budget struct RxDesc *desc = tp->RxDescArray + entry; u32 status; - status = le32_to_cpu(desc->opts1); + /* Use READ_ONCE to order descriptor field reads */ + status = le32_to_cpu(READ_ONCE(desc->opts1)); if (status & DescOwn) break; - /* This barrier is needed to keep us from reading - * any other fields out of the Rx descriptor until - * we know the status of DescOwn - */ - dma_rmb(); - if (unlikely(status & RxRES)) { netif_info(tp, rx_err, dev, "Rx ERROR. status = %08x\n", status);