Received: by 10.213.65.68 with SMTP id h4csp1267345imn; Sat, 24 Mar 2018 07:58:56 -0700 (PDT) X-Google-Smtp-Source: AG47ELsaBWT/XYx+yRB3iEXyKk842psb/VXt9KytRHzWPxCUuu/pdY60QKmfBEhfrf0iHR/S/mqK X-Received: by 2002:a17:902:362:: with SMTP id 89-v6mr3868104pld.270.1521903536166; Sat, 24 Mar 2018 07:58:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521903536; cv=none; d=google.com; s=arc-20160816; b=Me/IK7xxYaNDUQiLjWrlgnHSMnWEAh6CSaSGs6v8+RrnCwh3DWmHK4d9eRE+zsYRUB 3aumYIBI7/Ac4f0/yydHocMB5qQKCRYwB8RL+5aq1pCs/JpUmKvMBNnJ3KlUcYFU/W9F JHzvqASu4eimFEtwK3Yp5+PpggrZSSvzPXUkd6XYAshihogtAxDV3OBSe3DnB/ifvBhP BDm4d0kaYcxxHeZAODWsgPD2SRZ3uBBS9kK+Fk7WoxGdtJf8YI3+BiRXJQJWGXyHT4O9 kBrq0hMYKwJ6I64sZWZoY43w9gZl4sUV5pygXru3Rlt2Hew0khAlJixp90WsexPNmIfH ozZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dmarc-filter :dkim-signature:dkim-signature:arc-authentication-results; bh=tAeekawFwqRzM964uOrzg9ggar8UCWxKHO0jTpHas2M=; b=fQMC9xVmcVkLp7TeRlgwEAKer3qcQFjycnF/oUfDKbwwEe863cwZEgpwpx3fa/bktl yQxFbyF5x65JirOI8gcqInltIrD7O6zFUeNA/kI/jqaXV8aRPhIAoPvZMYQSyVpHFfOQ HoDkBKo0aObSfPM36S4vEUJzlRuxp2zR/ilCfvLvZxXeJbfUZY5QI0CC7ts6zABOfjtE zu4oqvjH+R8NeWKC1TCez5EMtqfBQ1eMjHoFJb5hUpUY8bsbfU+9u2xaMYF6GQMre1b4 Teuir6InQocPn6rl4qPikfvXSQ6cqdUEdbpiVnK4/9lZ5RoCX/gVXeBAwCv7lQVnST1s 9MVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=UJTUuPrs; dkim=pass header.i=@codeaurora.org header.s=default header.b=agoUQN/g; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h18si8394525pfi.31.2018.03.24.07.58.40; Sat, 24 Mar 2018 07:58:56 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=UJTUuPrs; dkim=pass header.i=@codeaurora.org header.s=default header.b=agoUQN/g; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752310AbeCXO5o (ORCPT + 99 others); Sat, 24 Mar 2018 10:57:44 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:52852 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751894AbeCXO5m (ORCPT ); Sat, 24 Mar 2018 10:57:42 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id F3F3260271; Sat, 24 Mar 2018 14:57:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1521903462; bh=Qkr1qdRKfU0PT+u5aNCx5gzWKSh02r44K4t3WJEkFac=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=UJTUuPrsRZqsDCzkIa1daqEkyL8u1O3kU9EeLZ6Im2kUmRv9o/8lMYn7xEwmtgGMo 0C0qxuc9C9ILir+/audPsB2oirLDXA+sbXqRdTuI/sQUvwr3yFRSuJmtlV03tAjsZ1 gUYG2hgb7wueEUVcArZ7j761wbqjZgS7Tz3GJ8KY= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 Received: from [192.168.0.105] (cpe-174-109-247-98.nc.res.rr.com [174.109.247.98]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: okaya@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 9547560271; Sat, 24 Mar 2018 14:57:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1521903460; bh=Qkr1qdRKfU0PT+u5aNCx5gzWKSh02r44K4t3WJEkFac=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=agoUQN/gY3xyRKuXdu5w+rkjmVvEt8TvWkTlCNnCLtR/Uf6xVzuaPP3h6m3NPNt4n K0KAf1o2kZgopBLYbo2zNslWVU47cVnsFuR1UwIPHwEu44RKvBHxzbxOoGps9gQ5/z qmHq7U0iWXj1m0H0poei280dStRVqtx4/1HFAkco= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 9547560271 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=okaya@codeaurora.org Subject: Re: [PATCH v5 3/5] bnx2x: Eliminate duplicate barriers on weakly-ordered archs To: "Chopra, Manish" , David Miller Cc: "netdev@vger.kernel.org" , "timur@codeaurora.org" , "sulrich@codeaurora.org" , "linux-arm-msm@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , "Elior, Ariel" , Dept-Eng Everest Linux L2 , "linux-kernel@vger.kernel.org" References: <20180323.124326.2170503491903886041.davem@davemloft.net> <4bd9ccd2-df8f-acad-2513-eefe065dc852@codeaurora.org> <20180323.130418.2223623186761161723.davem@davemloft.net> From: Sinan Kaya Message-ID: <02335376-ca3c-e026-8649-8cb855f96216@codeaurora.org> Date: Sat, 24 Mar 2018 10:57:38 -0400 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 3/24/2018 10:30 AM, Chopra, Manish wrote: >> -----Original Message----- >> From: Sinan Kaya [mailto:okaya@codeaurora.org] >> Sent: Friday, March 23, 2018 10:44 PM >> To: David Miller >> Cc: netdev@vger.kernel.org; timur@codeaurora.org; sulrich@codeaurora.org; >> linux-arm-msm@vger.kernel.org; linux-arm-kernel@lists.infradead.org; Elior, >> Ariel ; Dept-Eng Everest Linux L2 > EngEverestLinuxL2@cavium.com>; linux-kernel@vger.kernel.org >> Subject: Re: [PATCH v5 3/5] bnx2x: Eliminate duplicate barriers on weakly- >> ordered archs >> >> On 3/23/2018 1:04 PM, David Miller wrote: >>> From: Sinan Kaya >>> Date: Fri, 23 Mar 2018 12:51:47 -0400 >>> >>>> It could if txdata->tx_db was not a union. There is a data dependency >>>> between txdata->tx_db.data.prod and txdata->tx_db.raw. >>>> >>>> So, no reordering. >>> >>> I don't see it that way, the code requires that: >>> >>> txdata->tx_db.data.prod += nbd; >>> >>> is visible before the doorbell update.> >>> barrier() doesn't provide that. >>> >>> Neither does writel_relaxed(). However plain writel() does. >> >> Correct for some architectures including ARM but not correct universally. >> >> writel() just guarantees register read/writes before and after to be ordered >> when HW observes it. >> >> writel() doesn't guarantee that the memory update is visible to the HW on all >> architectures. >> >> If you need memory update visibility, that barrier() should have been a >> wmb() >> >> A correct multi-arch pattern is >> >> wmb() >> writel_relaxed() >> mmiowb() >> > > Sinan, Since you have mentioned the use of mmiowb() here after writel_relaxed(). > I believe this is not always correct for all types of IO mapped memory [Specially if IO memory is mapped using write combined (for ex. Ioremap_wc())]. > We have a current issue on our NIC (qede) driver on x86 for which the patch is already been sent more than a week ago [Still awaiting to hear from David on that]. > where mmiowb() seems to be useless since we use write combined mapped doorbell and mmiowb() just seems to be a compiler barrier() there. > So in order to flush write combined buffer we really need writel_relaxed() followed by a wmb() to synchronize writes among CPU cores. > I think the correct pattern in such cases (for write combined IO) would have been like below - > > wmb(); > writel_relaxed(); > wmb(); -> To flush the writes actually. You actually have good points. It is the same problem with barrier() description above. The answer really depends on what you are doing/expecting after mmiowb(). If you expect that some memory content to be observed by HW, you definitely need a wmb() like you mentioned. If you just want writes to be flushed but you don't expect any memory content to be updated, you need a mmiowb(). https://lwn.net/Articles/198988/ "There is mmiowb(), but its real purpose is to enforce ordering between MMIO operations only." > > Thanks. > > > > > -- Sinan Kaya Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm Technologies, Inc. Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.