From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4EFC4ECAAD8 for ; Fri, 23 Sep 2022 09:17:48 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 85137838DB; Fri, 23 Sep 2022 11:17:46 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=quarantine dis=none) header.from=codasip.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=codasip.com header.i=@codasip.com header.b="d+3csffx"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 47A1E838DB; Fri, 23 Sep 2022 11:17:45 +0200 (CEST) Received: from mail-ot1-x32a.google.com (mail-ot1-x32a.google.com [IPv6:2607:f8b0:4864:20::32a]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 408738383F for ; Fri, 23 Sep 2022 11:17:42 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=codasip.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=samuel.obuch@codasip.com Received: by mail-ot1-x32a.google.com with SMTP id l7-20020a056830154700b0065563d564dfso7955185otp.0 for ; Fri, 23 Sep 2022 02:17:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=codasip.com; s=google; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date; bh=QEtfjQiW53xYX886eHi1uxhSg4UoZru+ADEZ2sR1Sfc=; b=d+3csffxkGwYQ4iLoOfhKE2utYTeUG+fPOOrz0MRqlxKHy+Mj8+CTubMk5HABsG9QC 3VvdcYOmru/fv8pwRozA2a/Py04XvPAq9KjnrUeJKLK/qlJnxngoLOiNiOUHfLOJgoGy BP2rWJjscVUIdesJy+GnjsrOir1Q8J6glpQC9sqoZvMdHTxs3SmCfyNRjWZSZK94YUIe CjyRS651n+0ow+3QZDiHmadIMCT0vkVCvLd72QQJdF6cpghYGeY2f4Dz+obDPAX0ncUj RCiUre944KR30LWVfa4p8jhSVCFSTWRMno9R9VjchMQlB4E2VZRHkV4wLLPEBUp9qTcI FoAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date; bh=QEtfjQiW53xYX886eHi1uxhSg4UoZru+ADEZ2sR1Sfc=; b=kocSBQG61LnPllruNBwZHny0p569b+pEcd0Mi0gkOsqlZdLp/j7D8FDAQ2KSWokB73 HsYMGSXRTSyMFflIqq3W4oj8nBz/FxppZBYbXEcuGamvFniG/ikscLLGHCkMrzphiXEb feQruCV60veRXh0mgaPijiD1E6FB6r1JHxaSj1G6gOcolTUDwSsjNkm5PZwkuI6LCRQG 2ZHQNvq6nxQNJyGRFT2fqxlIE5v5dyTfN5y02LKih2CA7CG3c7ddJgqzOrZtJBBj551e Bz/UJKD+PyaZxpiKfiRDXFj65Mh7ykDrKg7xP/gQJLsaPBjn7dR07AbWEjRzf9y7/tNj Mesg== X-Gm-Message-State: ACrzQf3PlbjvQ6a785xqdFtmnA+NSFsgjn10OiwCK8H8ltlHg0qmfDWu qX+r17l5L2GOEHPiX5uUBfyrkHGcnMQ6MlKEAlKMeA== X-Google-Smtp-Source: AMsMyM57pudRnyw8zImVJdA9url/5y44g99XW4ub66rYgbvC29zYLvyq1yFIPJLEBvX7vz52bwWCUAmnpSL409tVZV8= X-Received: by 2002:a05:6830:1f3a:b0:658:bcc:99e with SMTP id e26-20020a0568301f3a00b006580bcc099emr3615594oth.215.1663924660927; Fri, 23 Sep 2022 02:17:40 -0700 (PDT) MIME-Version: 1.0 References: <20220713135204.233268-1-samuel.obuch@codasip.com> <20220713135204.233268-3-samuel.obuch@codasip.com> <44ac0918-fc12-88a9-f25e-9fab1510c73f@amd.com> In-Reply-To: <44ac0918-fc12-88a9-f25e-9fab1510c73f@amd.com> From: Samuel Obuch Date: Fri, 23 Sep 2022 11:17:30 +0200 Message-ID: Subject: Re: [PATCH 2/3] net: emaclite: fix xemaclite_alignedread/write functions To: Michal Simek Cc: Jan Remes , Ramon Fried , U-Boot Mailing List Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.39 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean Hi, I tested both versions to be sure, but the results are as can be expected: 1. both __raw_readl/__raw_writel and readl/writel functions work ok on riscv - only the original nonvolatile accesses were problematic 2. the additional barrier in readl/writel functions can introduce noticeable slowdown - e.g. with our setup, download speed over tftp for the same image decreased from 460 KiB/s to 118 KiB/s Can we conclude to keep the raw versions in the patch? Thanks, Samuel On Tue, Sep 20, 2022 at 4:23 PM Michal Simek wrote: > > > On 9/19/22 19:03, Jan Remes wrote: > > On Mon, Aug 8, 2022 at 10:05 AM Michal Simek > wrote: > >> > >> > >> > >> On 8/6/22 19:33, Ramon Fried wrote: > >>> On Wed, Jul 13, 2022 at 5:02 PM Samuel Obuch > wrote: > >>>> > >>>> Use __raw_read* and __raw_write* functions to ensure read/write > >>>> is passed to the memory-mapped regions, as non-volatile accesses > >>>> may get optimised out. > >>>> > >>>> Signed-off-by: Samuel Obuch > >>>> --- > >>>> drivers/net/xilinx_emaclite.c | 9 ++++----- > >>>> 1 file changed, 4 insertions(+), 5 deletions(-) > >>>> > >>>> diff --git a/drivers/net/xilinx_emaclite.c > b/drivers/net/xilinx_emaclite.c > >>>> index 5cd88e04fe..de7a2dee0b 100644 > >>>> --- a/drivers/net/xilinx_emaclite.c > >>>> +++ b/drivers/net/xilinx_emaclite.c > >>>> @@ -113,12 +113,12 @@ static void xemaclite_alignedread(u32 *srcptr, > void *destptr, u32 bytecount) > >>>> /* Word aligned buffer, no correction needed. */ > >>>> to32ptr = (u32 *) destptr; > >>>> while (bytecount > 3) { > >>>> - *to32ptr++ = *from32ptr++; > >>>> + *to32ptr++ = __raw_readl(from32ptr++); > >>>> bytecount -= 4; > >>>> } > >>>> to8ptr = (u8 *) to32ptr; > >>>> > >>>> - alignbuffer = *from32ptr++; > >>>> + alignbuffer = __raw_readl(from32ptr++); > >>>> from8ptr = (u8 *) &alignbuffer; > >>>> > >>>> for (i = 0; i < bytecount; i++) > >>>> @@ -136,8 +136,7 @@ static void xemaclite_alignedwrite(void *srcptr, > u32 *destptr, u32 bytecount) > >>>> > >>>> from32ptr = (u32 *) srcptr; > >>>> while (bytecount > 3) { > >>>> - > >>>> - *to32ptr++ = *from32ptr++; > >>>> + __raw_writel(*from32ptr++, to32ptr++); > >>>> bytecount -= 4; > >>>> } > >>>> > >>>> @@ -148,7 +147,7 @@ static void xemaclite_alignedwrite(void *srcptr, > u32 *destptr, u32 bytecount) > >>>> for (i = 0; i < bytecount; i++) > >>>> *to8ptr++ = *from8ptr++; > >>>> > >>>> - *to32ptr++ = alignbuffer; > >>>> + __raw_writel(alignbuffer, to32ptr++); > >>>> } > >>>> > >>>> static int wait_for_bit(const char *func, u32 *reg, const u32 mask, > >>>> -- > >>>> 2.31.1 > >>>> > >>> I think that using readl/writel is fine, no need for raw_... > >> > >> For microblaze that should be fine but let me ask my team to rest it on > ARM. > >> I think that __raw version are safer because this IP can also run on > big endian > >> systems and I think that was the reason why readl/writel wasn't used in > past. > >> > >> Thanks, > >> Michal > > > > Hi Michal, > > > > Do you have any new information on this? For the v2, it would be good > > to have this resolved. > > we are not testing emaclite on any ARM design. But in Linux you can find > in this > driver. > > #ifdef __BIG_ENDIAN > #define xemaclite_readl ioread32be > #define xemaclite_writel iowrite32be > #else > #define xemaclite_readl ioread32 > #define xemaclite_writel iowrite32 > #endif > > If you keep __raw variants it will ensure that native endian access is > doing to > be used. > On ARM IIRC readl/writel also have barriers. Origin patch is also using > raw > variant that's why I expect it is working on your system. > > Thanks, > Michal > > >