Received: by 10.192.165.156 with SMTP id m28csp368803imm; Tue, 17 Apr 2018 11:30:16 -0700 (PDT) X-Google-Smtp-Source: AIpwx49iTs7/2b4UghFzTxM/5rCnRWzPIQhDdKLvLCYFPP143r3rFB0Fy8NyBV5gzV9IyzLGY/IN X-Received: by 10.98.236.4 with SMTP id k4mr2977302pfh.240.1523989816534; Tue, 17 Apr 2018 11:30:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523989816; cv=none; d=google.com; s=arc-20160816; b=OMKFRzwtA2F/cThWn9iL/xj+ZcvEssuMktAGVF2TIwszhDRRDZWxwBrl9Ju9+s8EED JSe0zeFp8ILMR+/wdSf3QAoP5IR42eEHnRO7xV+2F8RV8IezxZoVqBqtWZHJsETwl2Qr 9qpBuKUags6HggqSvwUyATXsi7QfT5cPzRIfB6ObGoEJkTxMBJ5AvJkMVDIAcY21QOT4 s530cUr8aCz9DflsJynrsh3c/ajZ6DI9U5RPFQBJ9rbqA/jqsQAXemXdezq95dyl6NHd fChM08WkOAaLXQFhvAr+gzam/vN4fhMzEKgAnnkrUbpflSYvH36jt/QIfBsl/msw69HG 3RfQ== 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=4yrhsH9n9aPSf8kYZrxnWABxzWdGYAEVknAFgq6AQ70=; b=SCes+Qz2+cax4wFj1EE2E2P3LRNXVyuwdum/T+o/uUYGmMO4fuU1DA/+jzF0B185R5 qIOPBAK+frW04bpZtRLUdK9io7TQfSp+UP83o/eb0JFObBpAZNRBZAsG9zecovUuUIII Yu0C/QTh6DfWO2iOBYVKyRELbg4YnY3oNVIaas/hwP1HwIExoNOlWOOAtxlkL7fb4szW sA9YP2pSWedCEtz+YPZK8BTK+te9vW76hffMcXDH8M0URq0gibETYa1ARBOrGXoGq7W3 k18DNv8UlaaO0I6NIivFOLYPrdr4FF3ltrwqdiKA63IVWWjoty38o6upsarzdtkitV9b ypwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=Wfu4GDsb; dkim=pass header.i=@codeaurora.org header.s=default header.b=cBykc+j4; 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 l19-v6si13245851pli.600.2018.04.17.11.30.00; Tue, 17 Apr 2018 11:30:16 -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=Wfu4GDsb; dkim=pass header.i=@codeaurora.org header.s=default header.b=cBykc+j4; 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 S1752199AbeDQS2q (ORCPT + 99 others); Tue, 17 Apr 2018 14:28:46 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:45254 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751157AbeDQS2o (ORCPT ); Tue, 17 Apr 2018 14:28:44 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 3BC0060246; Tue, 17 Apr 2018 18:28:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1523989724; bh=G8+A+d23w+LybU8bKN+Vm5/Gvb/J0XLaG360EJfo8uk=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=Wfu4GDsbIhfH5ecVVs1zJ7nPkRlgEIJPIoXekWi/gBh/2Ti4fS8Jf6SJZARcO1nBi vtDhhMhVIcTUxU96/WEz1h7zyxTDzwEg1r4YruZIw+5sJD/jCKtYEYDmHWmCnSlfaU 5TFcOKZes/9HxbG00JpUhpYxbTzhdTJb8KM5iWkM= 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 00A9560246; Tue, 17 Apr 2018 18:28:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1523989723; bh=G8+A+d23w+LybU8bKN+Vm5/Gvb/J0XLaG360EJfo8uk=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=cBykc+j4WRFxzHdETCIM11E1bo7YCcYtgyyPNjccoUygIQSCVFZ2L+gRl1a4AGOCF regcHm4zxJ39Z4T7HNbbUcPAf2aA3697KgbLJBmMzao0J5wPBpiFs9Dq3wLyqeDDpz t+oreLTQUbweK5hkhVmxh6jSPAduwMOYODNNSQ7o= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 00A9560246 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 v2 2/2] parisc: define stronger ordering for the default readX() To: James Bottomley , linux-parisc@vger.kernel.org, arnd@arndb.de, timur@codeaurora.org, sulrich@codeaurora.org Cc: linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Helge Deller , Philippe Ombredanne , Kate Stewart , Thomas Gleixner , Greg Kroah-Hartman , linux-kernel@vger.kernel.org References: <1523938133-3224-1-git-send-email-okaya@codeaurora.org> <1523938133-3224-2-git-send-email-okaya@codeaurora.org> <1523957852.3250.9.camel@HansenPartnership.com> <38a1d4e3-cabe-6c39-4355-8d8111637382@codeaurora.org> <1523980508.3310.9.camel@HansenPartnership.com> From: Sinan Kaya Message-ID: <86252a65-265d-e081-b71f-42a0be6b1693@codeaurora.org> Date: Tue, 17 Apr 2018 14:28:40 -0400 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <1523980508.3310.9.camel@HansenPartnership.com> 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 4/17/2018 11:55 AM, James Bottomley wrote: > On Tue, 2018-04-17 at 10:13 -0400, Sinan Kaya wrote: >> Hi James, >> >>> >>> Perhaps if you gave an example of the actual problem you're trying >>> to fix we could assess if it affects parisc. >> >> Let me clarify myself here. Maybe, there is a better solution. >> >> /* assign ownership */ >> desc->status = DEVICE_OWN; >> >> /* notify device of new descriptors */ >> writel(DESC_NOTIFY, doorbell); >> >> The difference between writel() and writel_relax() is writel() >> guarantees memory transactions to be flushed to the device before the >> register write. > > Um, no it doesn't, at least not in PCI. It guarantees the write will > be issued by the memory system, but it may still be cached (called > posting) in the PCI bridge. So it doesn't guarantee the write reaches > the device by the time it returns. The correct terminology here would be to use observability. Yes, it can be cached in whatever part of the system for some amount of time as long as PCI device sees it in the correct order. Let's do this exercise. 1. OS writes to memory for some descriptor update 2. OS writes to the device via writel to hit a doorbell 3. Device comes and fetches the memory contents for the descriptor writel() of PA-RISC needs to ensure that 3. cannot bypass 1. This is typically done by a write barrier embedded into the writel() on relaxed architectures. > >> writel_relaxed() does not provide any guarantees about the memory >> and IO operations. >> >> Similarly, readl() provides following code to observe the DMA result >> while readl_relaxed() does not provide this guarantee. > > Right, the relaxed operator provides no guarantee of ordering between > the memory and IO domains. However, it's only really a problem on > multiple memory controller systems (i.e. NUMA). Parisc (except > superdome, which we don't support) doesn't have this problem. We also > turn of CPU stream reordering, so compile order is retire order on our > CPUs (which makes life a lot simpler). Good to know. > >> Ideally, you want to embed rmb() and wmb() into the writel() and >> readl() to provide this guarantee. >> >> PA-RISC doesn't seem to support neither one of the barrier types. If >> you are familiar with the architecture, maybe you could guide us >> here. >> >> Is __raw_writeX() enough to provide this guarantee for this >> architecture? > > Well, with the volatile address it is. > > The current implementations provide the expected semantics: namely the > position in the instruction stream is compile (retire) ordered and > issued from memory once retired. We still do have the write posting > problem, but you'll find additional reads in the drivers to flush the > posted writes, so I don't actually believe we need anything changing. > OK. I'll withdraw my patch. I'm just trying to ensure that all architectures support writel() semantics. There is an attempt to remove unnecessary write barriers from the drivers directory between the descriptor update and writel. Just checking that PA-RISC won't break after this. > James > > -- 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.