Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2976674imu; Thu, 29 Nov 2018 13:21:20 -0800 (PST) X-Google-Smtp-Source: AFSGD/VKMyaEzOr0V4LW4O9KCtDVLDAaaLnKng9cABdwtI0RrliaYskYTbew72KzBqG39YM2DyAE X-Received: by 2002:a65:5286:: with SMTP id y6mr2592931pgp.439.1543526480599; Thu, 29 Nov 2018 13:21:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543526480; cv=none; d=google.com; s=arc-20160816; b=Svlc5mNru+eg5t/ulFaMb6bJHxQJyxUrGQeG/IguIACYgzLRdJmcJyrpdpeKJG4Cp/ DgyvY3pTOrtmK3tiIb4kqCcfTJu9tOPqQ3nFqicom7QqMKNvtpp/nWbGKV6CyRE4mGZV tvCln42MAWEk1MI7D/QCyldrwbsFD7FJGOL5o7qQh4WQTojXAu7b/A4+gIeUF/s9N/mO /eSnE66AlfhmwK/dJed26gWVkIxO8ucTBwNWRwYONDWQoBTPRPfCfNlMpZTkK+1qlM56 Yu75SQFklULTFucMMVZE64BivzMJDJO2H5iANKCNByw3Cgh5Gtm8P7djhfRZm+ce4z8v l16w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=n9Rfb+lVN7i/hvB6AzWSnntwOaRyBCSxdJ7uGmruUMo=; b=ToUnczNtQXWdJzxNSR8aEsyHMltBaFYNBdaO8sP1FsqqISH3L+pbICz4qhdeIJlQp+ D4VG1DJbdSZd+mzL/Bg6HrYQt0hQGyC7cjXoILxxkNRN2uhqwW4Fh1lx8a42E/2KlvF9 P+aKs/U6ZkHkChnlslZHlQSuzRFEz7YSfFiLPycfoTiSkwwQwm/NeCpzkEW94BkWnoY0 H6HGSIv0N1Ewo2M070Y0CvxxBTecVUy73ObrPKC9NQPNXb0+6Jr5uz1HEUUsd+BzVV6f rVZF5+MMgHsQ0u7CMdbIBpUXwEyMi0UBKdrR+jB9T2kF+dsWPJ3UUUMKcOUCBXSgQsqx dJzg== ARC-Authentication-Results: i=1; mx.google.com; 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 cc16si3476481plb.377.2018.11.29.13.21.06; Thu, 29 Nov 2018 13:21:20 -0800 (PST) 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; 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 S1726779AbeK3I1R (ORCPT + 99 others); Fri, 30 Nov 2018 03:27:17 -0500 Received: from mail-qk1-f195.google.com ([209.85.222.195]:34937 "EHLO mail-qk1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726192AbeK3I1Q (ORCPT ); Fri, 30 Nov 2018 03:27:16 -0500 Received: by mail-qk1-f195.google.com with SMTP id w204so1981047qka.2 for ; Thu, 29 Nov 2018 13:20:30 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=n9Rfb+lVN7i/hvB6AzWSnntwOaRyBCSxdJ7uGmruUMo=; b=n0QlC2EGnWIXIN+MVw+evz+6ZNpKePnrvgQbv3h/ihlrAoHx+hukE+v8LY6dGiqG9U 8JS4Ggos3wDjE65QqjMvNQYmRyMPSBQAGpZbFm986+UBqVDdiwMDBLqmVr0tBwQmYCeW NNJPrrfKVIkFomb7EPhHWPGulZn1WRtbUcWrs0Xl2O0yIWtVoGM6pnxi9p7Gs6sQux6+ SryS7EdYEKC0AwZzrpxTyxJIFYyzzJmXx7WI9H05a8nPuixmHityzFbt8USQ/hj+fkXL euA0DcNpXdezPzoy1ncwxz5ZKs/P9h2EbqBf9XViqqP8q1fyERtvaHdBpktMNGEMPIEM zaCQ== X-Gm-Message-State: AA+aEWarQgkeJp/35ZJMibxPchKL4jc9A7IIAANpmkumUUaPd7BIInAe nXsQX57Uu0kFyr1BdU37dcw/RyLYd5WtcAActtA= X-Received: by 2002:a37:a3c6:: with SMTP id m189mr2931663qke.173.1543526429418; Thu, 29 Nov 2018 13:20:29 -0800 (PST) MIME-Version: 1.0 References: <19fb2e394afcb073bbc109e432417fbbc03323f6.1543499759.git.joabreu@synopsys.com> <89122bd8-bca2-2ae1-0dd0-160abbebcace@synopsys.com> In-Reply-To: From: Arnd Bergmann Date: Thu, 29 Nov 2018 22:20:11 +0100 Message-ID: Subject: Re: [PATCH v2] ARC: io.h: Implement reads{x}()/writes{x}() To: jose.abreu@synopsys.com Cc: David Laight , "open list:SYNOPSYS ARC ARCHITECTURE" , Linux Kernel Mailing List , Vineet Gupta , alexey.brodkin@synopsys.com, Joao Pinto , Vitor Soares Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Nov 29, 2018 at 5:14 PM Jose Abreu wrote: > --->8-- > static noinline void test_readsl(char *buf, int len) > { > readsl(0xdeadbeef, buf, len); > } > --->8--- > > And the disassembly: > --->8--- > 00000e88 : > e88: breq.dr1,0,eac <0xeac> /* if (count) */ > e8c: and r2,r0,3 > > e90: mov_s lp_count,r1 /* r1 = count */ > e92: brne r2,0,eb0 <0xeb0> /* if (bptr % ((t) / 8)) */ > > e96: sub r0,r0,4 > e9a: nop_s > > e9c: lp eac <0xeac> /* first loop */ > ea0: ld r2,[0xdeadbeef] > ea8: st.a r2,[r0,4] > eac: j_s [blink] > eae: nop_s > > eb0: lp ed6 <0xed6> /* second loop */ > eb4: ld r2,[0xdeadbeef] > ebc: lsr r5,r2,8 > ec0: lsr r4,r2,16 > ec4: lsr r3,r2,24 > ec8: stb_s r2,[r0,0] > eca: stb r5,[r0,1] > ece: stb r4,[r0,2] > ed2: stb_s r3,[r0,3] > ed4: add_s r0,r0,4 > ed6: j_s [blink] > > --->8--- > > See how the if condition added in this version is checked in > and then it takes two different loops. This looks good to me. I wonder what the result is for CPUs that /do/ support unaligned accesses. Normally put_unaligned() should fall back to a simple store in that case, but I'm not sure it can fold the two stores back into one and skip the alignment check. Probably not worth overoptimizing for that case (the MMIO access latency should be much higher than anything you could gain here), but I'm still curious about how well our get/put_unaligned macros work. Arnd