Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp325118lqt; Thu, 6 Jun 2024 05:03:39 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXaLnnjc7eYNht2MT0/G6MS2F4sLnTQxPuOgl5wb3Sx8ofsE1US9ubxp/rbb386UsjrVj4oSraknjlRS/uk4Y8qLkkWM5nP+M3psQ1cKQ== X-Google-Smtp-Source: AGHT+IEtonG2o1dYNv/nqAQnRWQcnkZ5aaolQFSkiNAII8AtjJ5GhHv7Fi6SoMpNGLjRyoEcxxG4 X-Received: by 2002:a17:906:71cd:b0:a69:2fc:8340 with SMTP id a640c23a62f3a-a69a0253b38mr366645166b.73.1717675418990; Thu, 06 Jun 2024 05:03:38 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717675418; cv=pass; d=google.com; s=arc-20160816; b=B62X08cR6ydyVhGQgoUTGL8sQx8tVZhrFIbkPBg1wEJtPXY1fMAjSmwHcxWfsj4T/+ 7vxGqO5vo77Sb+QMb2TVY7t1chBsXNuSU2tKNrvsKsumuJyBSHvMbmyxjW+tf39x5k4J KYMTaO8olJNwv7Let3L7izpYBOnXeLjDHjGg5qJfeRu8oQtKE7U0agOrQG6XR0k6Is/3 iQQStWWinhS1lt7aweDJrR8WcBcAnLEICuyGRju8XGafY/ur5YhghILPu82L5uBDCNAX ruzVgkvNJE6Wmpxn+PJpiq8y2bdY2jHxxaO7E+PopA0N2WPvLDj0aR7r1DQ5ocUo8paA kZ5A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:date:message-id :dkim-signature; bh=EhzgN21teDTF/ZW3qgf+NvcxVJfop3KgFTk3I1MLoU0=; fh=zyxBNhuNk3MGI6+pI/sqor0y5z4WvNTMo16eGvZRRh4=; b=Gt1AnR45OCLZocmALGOrlEYBxZO1nY+iOVDc588v5izuvjvCgUVowr7Qh88qSvqBDL OR+D2wIc6KpT5RrpIrQG6E0kqT/RvplI/U+Eve4riWRWHEiTv2okSVZ1aEAGLlSOg1Yi ePxQy1CeOPpCG5oggw+pTd9y+mOrwmG9vfLWbnbw2EcI0fNkthj/xDbXk6YIoEo0011z YNQyqOvgzMkaPcil52imyYT9QdbNj1NGba9xbXWsZkUq0vupLQpA2BNQqehHVb9H5hJd plKds92skEjqXhaZks/JIHdNXl/S7UjOU/cZeu/fUQlIf18qZFxZf+UpqztyxeBoLXPg 2YMA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=i3xxWfNA; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-204224-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-204224-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a640c23a62f3a-a6c80709088si61517266b.537.2024.06.06.05.03.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jun 2024 05:03:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-204224-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=i3xxWfNA; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-204224-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-204224-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 866D81F252E2 for ; Thu, 6 Jun 2024 12:03:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AF8E2195967; Thu, 6 Jun 2024 12:03:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="i3xxWfNA" Received: from mail-ej1-f45.google.com (mail-ej1-f45.google.com [209.85.218.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EE67EC153 for ; Thu, 6 Jun 2024 12:03:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717675410; cv=none; b=FxYHmxJrKgDPCBpQ+sT7vTa47LCh73RDsU4YjtUAxuFTKMBCZKt+zQB27zEWg5ipKBJifrHnz+/eVJFBFRFcKzTbJgA7o12Ub6RZt5g4Y7rdd1L9TjFgCqWaGHJtBjUksBfjUbSRqr5/7DJCAQMH5vArnbHt+Ijb0M/fB5x3txs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717675410; c=relaxed/simple; bh=ZC64W4+d+w1mCtWVvbgfFjvEH56VmkQcN4glvoyhyJc=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=QFeipT+YM9ZGAfLn2qL85bOn7nH6q/F0oqLYEp9YRvPOuNyhamJpZbU00dRLzrsGKZx2C+emvuT5rjchpkIff8xRXIWLhl1s8YCO8j/6CBTyUoPzYkPjiPsNISlfLMSBLotUjR553KuOALEecYNN6IzZRulsLHEzHbigmhQo0HE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=i3xxWfNA; arc=none smtp.client-ip=209.85.218.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-ej1-f45.google.com with SMTP id a640c23a62f3a-a68ee841138so104212466b.1 for ; Thu, 06 Jun 2024 05:03:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1717675407; x=1718280207; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to; bh=EhzgN21teDTF/ZW3qgf+NvcxVJfop3KgFTk3I1MLoU0=; b=i3xxWfNAx7aUVvtHaboUeK7VrdjgDsVq2xCS1IM8l78h/wwDe75WFzV8tpQ/V6h072 G6iBP0ngjE9HmJSRtuMVsUp3Jg9YRGmeC+pdfaSLwSsZxSmUDIe9EKs0KEFIS5iPtvw6 0Eqp45QGbMqdOObg/WnWdwhoDha2OSYGdHTM+X8M+r1KfI1DAW8NZP2hCABGu9Uw1Vk5 Tm7dPwG7OVFVsAJowi38/m9kiY0wlQzCmFZiOVWtMWSYpVX5uaOectfb1fiJtp5nTnGg eMOamuoi0y0bdWYEGTvl3++l1DROKvo3MBpwKMXoF/TzeQmAMY+Q2D+ha5qNxKnCpOk8 QKTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717675407; x=1718280207; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=EhzgN21teDTF/ZW3qgf+NvcxVJfop3KgFTk3I1MLoU0=; b=DRJt/gQLJGFaXYuHVvTkn09NqCIQ4cKrkq3CIY0gAMPqL7qx8uIK3d/3HLvGdJyxKM o7t6CqmNo+Tvmm/VgZ2supH+70KvYKWGAQ8WlMdYLMnW/ZYfG5giBY4dZSJBGR/CvdGu dx34vP9PxyT41V58z5bBBsLdD0rQ9z9CYPKroA3N0gd8HL73epkv/MKQ+ZGBmOb2HCrx gYEN/pkqCXrII3mvj+Vqa9/ZM7/ufPXpWQoTC0Dm66HbJVp9TahtQMQA61MvbW5KZNTj MPIhlJxpy+OMW0nj7zCB1N8v/baTG0neI8aDIVsny9WRF0NElGUeOZH6RY9plAPsB7Df /qtQ== X-Forwarded-Encrypted: i=1; AJvYcCXX0wHXPAr6shF3IJQw5IHzaMjSJr037xn84bIQ0KhoH1M+h4rAobTJn0kPBWnHeLm+bX/vyXKzikv4RQW7SSS2QJ/fu3WdHlq5Fure X-Gm-Message-State: AOJu0YzBH2wWjaESUzTUBb9lPzHUpAqPGh0nDd8bXIkPSNNa8SxnAclU qmRJqn4NXUt+933USl+s6dBO6Ow3dX2NwRO3Spc71LSpHcvYoAqlCgYuFCYvljA= X-Received: by 2002:a17:906:c44d:b0:a6b:c993:7ede with SMTP id a640c23a62f3a-a6bc9938015mr258898966b.11.1717675407204; Thu, 06 Jun 2024 05:03:27 -0700 (PDT) Received: from [192.168.128.139] (078088045245.garwolin.vectranet.pl. [78.88.45.245]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a6c806ebd48sm88558666b.108.2024.06.06.05.03.25 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 06 Jun 2024 05:03:26 -0700 (PDT) Message-ID: <444f6a34-6636-44b0-850b-777c44fd62dd@linaro.org> Date: Thu, 6 Jun 2024 14:03:24 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] drm/msm/adreno: De-spaghettify the use of memory barriers To: Will Deacon , Andrew Halaney Cc: Akhil P Oommen , Rob Clark , Sean Paul , Abhinav Kumar , Dmitry Baryshkov , Marijn Suijten , David Airlie , Daniel Vetter , Rob Clark , linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, linux-kernel@vger.kernel.org References: <20240508-topic-adreno-v1-1-1babd05c119d@linaro.org> <20240514183849.6lpyplifero5u35r@hu-akhilpo-hyd.qualcomm.com> <20240516145005.gdksmvxp35m45ifh@hu-akhilpo-hyd.qualcomm.com> <5vyrmxvkurdstqfiatxfqcqljwyiswda2vpkea27ighb2eqbav@n24yzdykbc23> <20240604144055.GE20384@willie-the-truck> Content-Language: en-US From: Konrad Dybcio Autocrypt: addr=konrad.dybcio@linaro.org; keydata= xsFNBF9ALYUBEADWAhxdTBWrwAgDQQzc1O/bJ5O7b6cXYxwbBd9xKP7MICh5YA0DcCjJSOum BB/OmIWU6X+LZW6P88ZmHe+KeyABLMP5s1tJNK1j4ntT7mECcWZDzafPWF4F6m4WJOG27kTJ HGWdmtO+RvadOVi6CoUDqALsmfS3MUG5Pj2Ne9+0jRg4hEnB92AyF9rW2G3qisFcwPgvatt7 TXD5E38mLyOPOUyXNj9XpDbt1hNwKQfiidmPh5e7VNAWRnW1iCMMoKqzM1Anzq7e5Afyeifz zRcQPLaqrPjnKqZGL2BKQSZDh6NkI5ZLRhhHQf61fkWcUpTp1oDC6jWVfT7hwRVIQLrrNj9G MpPzrlN4YuAqKeIer1FMt8cq64ifgTzxHzXsMcUdclzq2LTk2RXaPl6Jg/IXWqUClJHbamSk t1bfif3SnmhA6TiNvEpDKPiT3IDs42THU6ygslrBxyROQPWLI9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EAZdVAQUBAQdAwmUx xrbSCx2ksDxz7rFFGX1KmTkdRtcgC6F3NfuNYkYDAQgHwsF2BBgBCAAgFiEEU24if9oCL2zd AAQVR4cBcg5dfFgFAmQ5bvICGwwACgkQR4cBcg5dfFju1Q//Xta1ShwL0MLSC1KL1lXGXeRM 8arzfyiB5wJ9tb9U/nZvhhdfilEDLe0jKJY0RJErbdRHsalwQCrtq/1ewQpMpsRxXzAjgfRN jc4tgxRWmI+aVTzSRpywNahzZBT695hMz81cVZJoZzaV0KaMTlSnBkrviPz1nIGHYCHJxF9r cIu0GSIyUjZ/7xslxdvjpLth16H27JCWDzDqIQMtg61063gNyEyWgt1qRSaK14JIH/DoYRfn jfFQSC8bffFjat7BQGFz4ZpRavkMUFuDirn5Tf28oc5ebe2cIHp4/kajTx/7JOxWZ80U70mA cBgEeYSrYYnX+UJsSxpzLc/0sT1eRJDEhI4XIQM4ClIzpsCIN5HnVF76UQXh3a9zpwh3dk8i bhN/URmCOTH+LHNJYN/MxY8wuukq877DWB7k86pBs5IDLAXmW8v3gIDWyIcgYqb2v8QO2Mqx YMqL7UZxVLul4/JbllsQB8F/fNI8AfttmAQL9cwo6C8yDTXKdho920W4WUR9k8NT/OBqWSyk bGqMHex48FVZhexNPYOd58EY9/7mL5u0sJmo+jTeb4JBgIbFPJCFyng4HwbniWgQJZ1WqaUC nas9J77uICis2WH7N8Bs9jy0wQYezNzqS+FxoNXmDQg2jetX8en4bO2Di7Pmx0jXA4TOb9TM izWDgYvmBE8= In-Reply-To: <20240604144055.GE20384@willie-the-truck> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 4.06.2024 4:40 PM, Will Deacon wrote: > On Thu, May 16, 2024 at 01:55:26PM -0500, Andrew Halaney wrote: >> On Thu, May 16, 2024 at 08:20:05PM GMT, Akhil P Oommen wrote: >>> On Thu, May 16, 2024 at 08:15:34AM -0500, Andrew Halaney wrote: >>>> If I understand correctly, you don't need any memory barrier. >>>> writel()/readl()'s are ordered to the same endpoint. That goes for all >>>> the reordering/barrier comments mentioned below too. >>>> >>>> device-io.rst: >>>> >>>> The read and write functions are defined to be ordered. That is the >>>> compiler is not permitted to reorder the I/O sequence. When the ordering >>>> can be compiler optimised, you can use __readb() and friends to >>>> indicate the relaxed ordering. Use this with care. >>>> >>>> memory-barriers.txt: >>>> >>>> (*) readX(), writeX(): >>>> >>>> The readX() and writeX() MMIO accessors take a pointer to the >>>> peripheral being accessed as an __iomem * parameter. For pointers >>>> mapped with the default I/O attributes (e.g. those returned by >>>> ioremap()), the ordering guarantees are as follows: >>>> >>>> 1. All readX() and writeX() accesses to the same peripheral are ordered >>>> with respect to each other. This ensures that MMIO register accesses >>>> by the same CPU thread to a particular device will arrive in program >>>> order. >>>> >>> >>> In arm64, a writel followed by readl translates to roughly the following >>> sequence: dmb_wmb(), __raw_writel(), __raw_readl(), dmb_rmb(). I am not >>> sure what is stopping compiler from reordering __raw_writel() and __raw_readl() >>> above? I am assuming iomem cookie is ignored during compilation. >> >> It seems to me that is due to some usage of volatile there in >> __raw_writel() etc, but to be honest after reading about volatile and >> some threads from gcc mailing lists, I don't have a confident answer :) >> >>> >>> Added Will to this thread if he can throw some light on this. >> >> Hopefully Will can school us. > > The ordering in this case is ensured by the memory attributes used for > ioremap(). When an MMIO region is mapped using Device-nGnRE attributes > (as it the case for ioremap()), the "nR" part means "no reordering", so > readX() and writeX() to that region are ordered wrt each other. > > Note that guarantee _doesn't_ apply to other flavours of ioremap(), so > e.g. ioremap_wc() won't give you the ordering. > > Hope that helps, Just to make sure I'm following, would mapping things as nGnRnE effectively get rid of write buffering, perhaps being a way of debugging whether that in particular is causing issues (at the cost of speed)? Konrad