[{"id":1761171,"web_url":"http://patchwork.ozlabs.org/comment/1761171/","msgid":"<7a5267e3-c012-7bfd-ced2-cfaa3f47524a@synopsys.com>","list_archive_url":null,"date":"2017-08-31T16:31:33","subject":"Re: [PATCH] arc: Flush and invalidate caches on start","submitter":{"id":26707,"url":"http://patchwork.ozlabs.org/api/people/26707/","name":"Vineet Gupta","email":"Vineet.Gupta1@synopsys.com"},"content":"On 08/31/2017 07:22 AM, Alexey Brodkin wrote:\n> This is useful to make sure no stale data exists in caches after bootloaders.\n> The worst thing could be some lines of cache were locked in a bootloader\n> for example during DDR recalibration and never unlocked. This may lead\n> to really unpredictable issues later down the line.\n>\n> Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>\n> ---\n>   arch/arc/kernel/head.S | 16 ++++++++++++++++\n>   1 file changed, 16 insertions(+)\n>\n> diff --git a/arch/arc/kernel/head.S b/arch/arc/kernel/head.S\n> index 8b90d25a15cc..04e28b664183 100644\n> --- a/arch/arc/kernel/head.S\n> +++ b/arch/arc/kernel/head.S\n> @@ -34,6 +34,10 @@\n>   #endif\n>   \tsr\tr5, [ARC_REG_IC_CTRL]\n>   \n> +\t; Invalidate entire I$\n> +\tmov\tr5, 1\n> +\tsr\tr5, [ARC_REG_IC_IVIC]\n> +\n>   1:\n>   \tlr\tr5, [ARC_REG_DC_BCR]\n>   \tbreq    r5, 0, 1f\t\t; D$ doesn't exist\n> @@ -46,6 +50,18 @@\n>   #endif\n>   \tsr\tr5, [ARC_REG_DC_CTRL]\n>   \n> +\t; Flush entire D$\n> +\tmov\tr5, 1\n> +\tsr\tr5, [ARC_REG_DC_FLSH]\n> +\t; Wait for flush operation to complete\n> +1:\n> +\tlr\tr5, [ARC_REG_DC_CTRL]\n> +\tbbit1\tr5, DC_CTRL_FLUSH_STATUS, 1b\n> +\n> +\t; Invalidate entire D$\n> +\tmov\tr5, 1\n> +\tsr\tr5, [ARC_REG_DC_IVDC]\n> +\n\nAFAIK uboot already flushes the caches before handing control over to kernel - so \nwhy do we need it here.\nIf uboot is locking lines, it needs to fix that and not penalize the general case \nwith or w/o uboot !\n\n-Vineet","headers":{"Return-Path":"<linux-snps-arc-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org; spf=none (mailfrom)\n\tsmtp.mailfrom=lists.infradead.org (client-ip=65.50.211.133;\n\thelo=bombadil.infradead.org;\n\tenvelope-from=linux-snps-arc-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (2048-bit key;\n\tunprotected) header.d=lists.infradead.org\n\theader.i=@lists.infradead.org header.b=\"JXrknFQJ\"; \n\tdkim-atps=neutral"],"Received":["from bombadil.infradead.org (bombadil.infradead.org\n\t[65.50.211.133])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xjnvq2kjTz9sPm\n\tfor <incoming@patchwork.ozlabs.org>;\n\tFri,  1 Sep 2017 02:32:07 +1000 (AEST)","from localhost ([127.0.0.1] helo=bombadil.infradead.org)\n\tby bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux))\n\tid 1dnSNx-0000vN-Lu; Thu, 31 Aug 2017 16:32:05 +0000","from smtprelay.synopsys.com ([198.182.60.111])\n\tby bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux))\n\tid 1dnSNv-0000qx-86 for linux-snps-arc@lists.infradead.org;\n\tThu, 31 Aug 2017 16:32:04 +0000","from mailhost.synopsys.com (mailhost2.synopsys.com [10.13.184.66])\n\tby smtprelay.synopsys.com (Postfix) with ESMTP id E882F10C05EC;\n\tThu, 31 Aug 2017 09:31:39 -0700 (PDT)","from mailhost.synopsys.com (localhost [127.0.0.1])\n\tby mailhost.synopsys.com (Postfix) with ESMTP id D4E38FDD;\n\tThu, 31 Aug 2017 09:31:39 -0700 (PDT)","from US01WEHTC3.internal.synopsys.com\n\t(us01wehtc3.internal.synopsys.com [10.15.84.232])\n\tby mailhost.synopsys.com (Postfix) with ESMTP id CC3E2FDB;\n\tThu, 31 Aug 2017 09:31:39 -0700 (PDT)","from IN01WEHTCB.internal.synopsys.com (10.144.199.106) by\n\tUS01WEHTC3.internal.synopsys.com (10.15.84.232) with Microsoft SMTP\n\tServer (TLS) id 14.3.266.1; Thu, 31 Aug 2017 09:31:39 -0700","from IN01WEHTCA.internal.synopsys.com (10.144.199.104) by\n\tIN01WEHTCB.internal.synopsys.com (10.144.199.105) with Microsoft SMTP\n\tServer (TLS) id 14.3.266.1; Thu, 31 Aug 2017 22:01:37 +0530","from [10.10.161.108] (10.10.161.108) by\n\tIN01WEHTCA.internal.synopsys.com (10.144.199.243) with Microsoft SMTP\n\tServer (TLS) id 14.3.266.1; Thu, 31 Aug 2017 22:01:36 +0530"],"DKIM-Signature":"v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;\n\td=lists.infradead.org; s=bombadil.20170209; h=Sender:Content-Type:\n\tContent-Transfer-Encoding:Cc:List-Subscribe:List-Help:List-Post:List-Archive:\n\tList-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date:Message-ID:From:\n\tReferences:To:Subject:Reply-To:Content-ID:Content-Description:Resent-Date:\n\tResent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner;\n\tbh=CG4mftUHxg0qbJsKUqM/UMxb9L8Ou3rKSCEN3f1AyGI=;\n\tb=JXrknFQJxFlZQ0NKamA2t1QNq\n\tZVqsAQkGckuCOHR2fNdn35YsTkfr5dnwHGm1J3n2FND1iJHGQKiAi9I8KdL09k7b2zUB34WgbwYYS\n\tlkE+38DOD9VJa1VfZmmn6FDB1RoLhis+YZxc3xWDbh/dJvJB/GwbkBo/mW3Fa98b9XpjXLLFAbDrV\n\tAk5PzC3OtopmxXeskLjddQGxwXnY4INQqY3yOHDFlYJLjNP0uyWBNskm47OEeHuSC6axsHwmz/zhy\n\tJQFTRWCL1WIvov7rLz+oMqPnfiX5ec5AEAWbP4rpZ79VeCXd8y4PWmlcby79JdQhr0UpHiz0nCGcy\n\tRV/1Yx9lg==;","Subject":"Re: [PATCH] arc: Flush and invalidate caches on start","To":"Alexey Brodkin <Alexey.Brodkin@synopsys.com>,\n\t\"linux-snps-arc@lists.infradead.org\" <linux-snps-arc@lists.infradead.org>","References":"<20170831142158.27245-1-abrodkin@synopsys.com>","From":"Vineet Gupta <Vineet.Gupta1@synopsys.com>","Message-ID":"<7a5267e3-c012-7bfd-ced2-cfaa3f47524a@synopsys.com>","Date":"Thu, 31 Aug 2017 09:31:33 -0700","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101\n\tThunderbird/52.2.1","MIME-Version":"1.0","In-Reply-To":"<20170831142158.27245-1-abrodkin@synopsys.com>","Content-Language":"en-US","X-Originating-IP":"[10.10.161.108]","X-CRM114-Version":"20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 ","X-CRM114-CacheID":"sfid-20170831_093203_299155_EEDB546B ","X-CRM114-Status":"GOOD (  10.37  )","X-Spam-Score":"-1.9 (-)","X-Spam-Report":"SpamAssassin version 3.4.1 on bombadil.infradead.org summary:\n\tContent analysis details:   (-1.9 points)\n\tpts rule name              description\n\t---- ----------------------\n\t--------------------------------------------------\n\t-0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/,\n\tno trust [198.182.60.111 listed in list.dnswl.org]\n\t-0.0 RP_MATCHES_RCVD Envelope sender domain matches handover relay\n\tdomain\n\t-1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%\n\t[score: 0.0000]","X-BeenThere":"linux-snps-arc@lists.infradead.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Id":"Linux on Synopsys ARC Processors\n\t<linux-snps-arc.lists.infradead.org>","List-Unsubscribe":"<http://lists.infradead.org/mailman/options/linux-snps-arc>, \n\t<mailto:linux-snps-arc-request@lists.infradead.org?subject=unsubscribe>","List-Archive":"<http://lists.infradead.org/pipermail/linux-snps-arc/>","List-Post":"<mailto:linux-snps-arc@lists.infradead.org>","List-Help":"<mailto:linux-snps-arc-request@lists.infradead.org?subject=help>","List-Subscribe":"<http://lists.infradead.org/mailman/listinfo/linux-snps-arc>, \n\t<mailto:linux-snps-arc-request@lists.infradead.org?subject=subscribe>","Cc":"\"linux-kernel@vger.kernel.org\" <linux-kernel@vger.kernel.org>","Content-Transfer-Encoding":"7bit","Content-Type":"text/plain; charset=\"us-ascii\"; Format=\"flowed\"","Sender":"\"linux-snps-arc\" <linux-snps-arc-bounces@lists.infradead.org>","Errors-To":"linux-snps-arc-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org"}},{"id":1761174,"web_url":"http://patchwork.ozlabs.org/comment/1761174/","msgid":"<1504197268.3799.8.camel@synopsys.com>","list_archive_url":null,"date":"2017-08-31T16:34:29","subject":"Re: [PATCH] arc: Flush and invalidate caches on start","submitter":{"id":23881,"url":"http://patchwork.ozlabs.org/api/people/23881/","name":"Alexey Brodkin","email":"Alexey.Brodkin@synopsys.com"},"content":"Hi Vineet,\r\n\r\nOn Thu, 2017-08-31 at 09:31 -0700, Vineet Gupta wrote:\r\n> On 08/31/2017 07:22 AM, Alexey Brodkin wrote:\r\n> > \r\n> > This is useful to make sure no stale data exists in caches after bootloaders.\r\n> > The worst thing could be some lines of cache were locked in a bootloader\r\n> > for example during DDR recalibration and never unlocked. This may lead\r\n> > to really unpredictable issues later down the line.\r\n> > \r\n> > Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>\r\n> > ---\r\n> >   arch/arc/kernel/head.S | 16 ++++++++++++++++\r\n> >   1 file changed, 16 insertions(+)\r\n> > \r\n> > diff --git a/arch/arc/kernel/head.S b/arch/arc/kernel/head.S\r\n> > index 8b90d25a15cc..04e28b664183 100644\r\n> > --- a/arch/arc/kernel/head.S\r\n> > +++ b/arch/arc/kernel/head.S\r\n> > @@ -34,6 +34,10 @@\r\n> >   #endif\r\n> >   \tsr\tr5, [ARC_REG_IC_CTRL]\r\n> >   \r\n> > +\t; Invalidate entire I$\r\n> > +\tmov\tr5, 1\r\n> > +\tsr\tr5, [ARC_REG_IC_IVIC]\r\n> > +\r\n> >   1:\r\n> >   \tlr\tr5, [ARC_REG_DC_BCR]\r\n> >   \tbreq    r5, 0, 1f\t\t; D$ doesn't exist\r\n> > @@ -46,6 +50,18 @@\r\n> >   #endif\r\n> >   \tsr\tr5, [ARC_REG_DC_CTRL]\r\n> >   \r\n> > +\t; Flush entire D$\r\n> > +\tmov\tr5, 1\r\n> > +\tsr\tr5, [ARC_REG_DC_FLSH]\r\n> > +\t; Wait for flush operation to complete\r\n> > +1:\r\n> > +\tlr\tr5, [ARC_REG_DC_CTRL]\r\n> > +\tbbit1\tr5, DC_CTRL_FLUSH_STATUS, 1b\r\n> > +\r\n> > +\t; Invalidate entire D$\r\n> > +\tmov\tr5, 1\r\n> > +\tsr\tr5, [ARC_REG_DC_IVDC]\r\n> > +\r\n> \r\n> AFAIK uboot already flushes the caches before handing control over to kernel - so \r\n> why do we need it here.\r\n> If uboot is locking lines, it needs to fix that and not penalize the general case \r\n> with or w/o uboot !\r\n\r\nU-Boot indeed flushes caches.. but doesn't invalidate them!\r\nAnd only invalidation unlocks locked lines.\r\n\r\nThat indeed should be added in U-Boot but I'd say above stuff doesn't\r\ninfluence a lot code size or execution time while makes system more fool-proof.\r\n\r\n-Alexey","headers":{"Return-Path":"<linux-snps-arc-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org; spf=none (mailfrom)\n\tsmtp.mailfrom=lists.infradead.org (client-ip=65.50.211.133;\n\thelo=bombadil.infradead.org;\n\tenvelope-from=linux-snps-arc-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (2048-bit key;\n\tunprotected) header.d=lists.infradead.org\n\theader.i=@lists.infradead.org header.b=\"DAemaVuW\"; \n\tdkim-atps=neutral"],"Received":["from bombadil.infradead.org (bombadil.infradead.org\n\t[65.50.211.133])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xjnzR143Fz9s81\n\tfor <incoming@patchwork.ozlabs.org>;\n\tFri,  1 Sep 2017 02:35:15 +1000 (AEST)","from localhost ([127.0.0.1] helo=bombadil.infradead.org)\n\tby bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux))\n\tid 1dnSQz-0002cK-Qa; Thu, 31 Aug 2017 16:35:13 +0000","from smtprelay.synopsys.com ([198.182.60.111])\n\tby bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux))\n\tid 1dnSQu-0001Ou-Vi for linux-snps-arc@lists.infradead.org;\n\tThu, 31 Aug 2017 16:35:11 +0000","from mailhost.synopsys.com (mailhost2.synopsys.com [10.13.184.66])\n\tby smtprelay.synopsys.com (Postfix) with ESMTP id D3DB710C0B4B;\n\tThu, 31 Aug 2017 09:34:48 -0700 (PDT)","from mailhost.synopsys.com (localhost [127.0.0.1])\n\tby mailhost.synopsys.com (Postfix) with ESMTP id C3F5B6B;\n\tThu, 31 Aug 2017 09:34:48 -0700 (PDT)","from US01WEHTC2.internal.synopsys.com\n\t(us01wehtc2.internal.synopsys.com [10.12.239.237])\n\tby mailhost.synopsys.com (Postfix) with ESMTP id B8A4A69;\n\tThu, 31 Aug 2017 09:34:48 -0700 (PDT)","from DE02WEHTCB.internal.synopsys.com (10.225.19.94) by\n\tUS01WEHTC2.internal.synopsys.com (10.12.239.237) with Microsoft SMTP\n\tServer (TLS) id 14.3.266.1; Thu, 31 Aug 2017 09:34:33 -0700","from DE02WEMBXB.internal.synopsys.com ([fe80::95ce:118a:8321:a099])\n\tby DE02WEHTCB.internal.synopsys.com ([::1]) with mapi id\n\t14.03.0266.001; Thu, 31 Aug 2017 18:34:30 +0200"],"DKIM-Signature":"v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;\n\td=lists.infradead.org; s=bombadil.20170209; h=Sender:\n\tContent-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post:\n\tList-Archive:List-Unsubscribe:List-Id:MIME-Version:Content-ID:In-Reply-To:\n\tReferences:Message-ID:Date:Subject:To:From:Reply-To:Content-Description:\n\tResent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:\n\tList-Owner; bh=52w3G9JkU4atex+ktq8mkGr676tg/vMdZscw4o1I3NY=;\n\tb=DAemaVuWFPq4Rb\n\tvFYfuz/vDcELc7/ZQL4aNlDD/gS0GrEd+YzuXgpQ4qnw2yCsE/hZhtQaNQNWuBM7e+UtcIFgRNoiY\n\t0aYac+OD46a+ETn0+Nll5KHXaGqnIVHkFWOYmTzRzzf7U1oTHjWXsVfbzY+Gqw3wzVU4QnVZNnI+3\n\tQda8vGkTakAvlu2HjnpO0n3hPkvD7SFARrMrwDiiwXysn8h92DX3EPZ39aKN6GNWnt3YxlsoLbUxy\n\tYmr9khvoOZNCYv3dhJ4qB4TNrFsdsqnggAFQkoPeRHVlTftSg6JyxqV0KC4jCc/tvK+hQd4eF+2K/\n\tzZ/zptyXkMPx7x1VIBoA==;","From":"Alexey Brodkin <Alexey.Brodkin@synopsys.com>","To":"Vineet Gupta <Vineet.Gupta1@synopsys.com>","Subject":"Re: [PATCH] arc: Flush and invalidate caches on start","Thread-Topic":"[PATCH] arc: Flush and invalidate caches on start","Thread-Index":"AQHTImSFFtUehpI7V0KxfIF57RuoqqKehuaAgAAA0QA=","Date":"Thu, 31 Aug 2017 16:34:29 +0000","Message-ID":"<1504197268.3799.8.camel@synopsys.com>","References":"<20170831142158.27245-1-abrodkin@synopsys.com>\n\t<7a5267e3-c012-7bfd-ced2-cfaa3f47524a@synopsys.com>","In-Reply-To":"<7a5267e3-c012-7bfd-ced2-cfaa3f47524a@synopsys.com>","Accept-Language":"en-US, ru-RU","Content-Language":"en-US","X-MS-Has-Attach":"","X-MS-TNEF-Correlator":"","x-originating-ip":"[10.121.8.86]","Content-ID":"<1AA90FF34FE45C449D52354E061A7616@internal.synopsys.com>","MIME-Version":"1.0","X-CRM114-Version":"20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 ","X-CRM114-CacheID":"sfid-20170831_093509_080445_1E500003 ","X-CRM114-Status":"GOOD (  11.53  )","X-Spam-Score":"-1.9 (-)","X-Spam-Report":"SpamAssassin version 3.4.1 on bombadil.infradead.org summary:\n\tContent analysis details:   (-1.9 points)\n\tpts rule name              description\n\t---- ----------------------\n\t--------------------------------------------------\n\t-0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/,\n\tno trust [198.182.60.111 listed in list.dnswl.org]\n\t-0.0 RP_MATCHES_RCVD Envelope sender domain matches handover relay\n\tdomain\n\t-1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%\n\t[score: 0.0000]","X-BeenThere":"linux-snps-arc@lists.infradead.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Id":"Linux on Synopsys ARC Processors\n\t<linux-snps-arc.lists.infradead.org>","List-Unsubscribe":"<http://lists.infradead.org/mailman/options/linux-snps-arc>, \n\t<mailto:linux-snps-arc-request@lists.infradead.org?subject=unsubscribe>","List-Archive":"<http://lists.infradead.org/pipermail/linux-snps-arc/>","List-Post":"<mailto:linux-snps-arc@lists.infradead.org>","List-Help":"<mailto:linux-snps-arc-request@lists.infradead.org?subject=help>","List-Subscribe":"<http://lists.infradead.org/mailman/listinfo/linux-snps-arc>, \n\t<mailto:linux-snps-arc-request@lists.infradead.org?subject=subscribe>","Cc":"\"linux-snps-arc@lists.infradead.org\"\n\t<linux-snps-arc@lists.infradead.org>, \n\t\"linux-kernel@vger.kernel.org\" <linux-kernel@vger.kernel.org>","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"base64","Sender":"\"linux-snps-arc\" <linux-snps-arc-bounces@lists.infradead.org>","Errors-To":"linux-snps-arc-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org"}},{"id":1805095,"web_url":"http://patchwork.ozlabs.org/comment/1805095/","msgid":"<1510759616.29843.39.camel@synopsys.com>","list_archive_url":null,"date":"2017-11-15T15:26:57","subject":"Re: [PATCH] arc: Flush and invalidate caches on start","submitter":{"id":23881,"url":"http://patchwork.ozlabs.org/api/people/23881/","name":"Alexey Brodkin","email":"Alexey.Brodkin@synopsys.com"},"content":"On Thu, 2017-08-31 at 16:34 +0000, Alexey Brodkin wrote:\r\n> Hi Vineet,\r\n> \r\n> On Thu, 2017-08-31 at 09:31 -0700, Vineet Gupta wrote:\r\n> > \r\n> > On 08/31/2017 07:22 AM, Alexey Brodkin wrote:\r\n> > > \r\n> > > \r\n> > > This is useful to make sure no stale data exists in caches after bootloaders.\r\n> > > The worst thing could be some lines of cache were locked in a bootloader\r\n> > > for example during DDR recalibration and never unlocked. This may lead\r\n> > > to really unpredictable issues later down the line.\r\n> > > \r\n> > > Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>\r\n> > > ---\r\n> > >   arch/arc/kernel/head.S | 16 ++++++++++++++++\r\n> > >   1 file changed, 16 insertions(+)\r\n> > > \r\n> > > diff --git a/arch/arc/kernel/head.S b/arch/arc/kernel/head.S\r\n> > > index 8b90d25a15cc..04e28b664183 100644\r\n> > > --- a/arch/arc/kernel/head.S\r\n> > > +++ b/arch/arc/kernel/head.S\r\n> > > @@ -34,6 +34,10 @@\r\n> > >   #endif\r\n> > >   \tsr\tr5, [ARC_REG_IC_CTRL]\r\n> > >   \r\n> > > +\t; Invalidate entire I$\r\n> > > +\tmov\tr5, 1\r\n> > > +\tsr\tr5, [ARC_REG_IC_IVIC]\r\n> > > +\r\n> > >   1:\r\n> > >   \tlr\tr5, [ARC_REG_DC_BCR]\r\n> > >   \tbreq    r5, 0, 1f\t\t; D$ doesn't exist\r\n> > > @@ -46,6 +50,18 @@\r\n> > >   #endif\r\n> > >   \tsr\tr5, [ARC_REG_DC_CTRL]\r\n> > >   \r\n> > > +\t; Flush entire D$\r\n> > > +\tmov\tr5, 1\r\n> > > +\tsr\tr5, [ARC_REG_DC_FLSH]\r\n> > > +\t; Wait for flush operation to complete\r\n> > > +1:\r\n> > > +\tlr\tr5, [ARC_REG_DC_CTRL]\r\n> > > +\tbbit1\tr5, DC_CTRL_FLUSH_STATUS, 1b\r\n\r\nLooking more at this stuff I think that on that early stage there's no point\r\nin flushing of D$, moreover it could be dangerous as if there's some garbage in there it\r\nwill contaminate DDR with good data.\r\n\r\n> > > +\t; Invalidate entire D$\r\n> > > +\tmov\tr5, 1\r\n> > > +\tsr\tr5, [ARC_REG_DC_IVDC]\r\n> > > +\r\n> > \r\n> > AFAIK uboot already flushes the caches before handing control over to kernel - so \r\n> > why do we need it here.\r\n> > If uboot is locking lines, it needs to fix that and not penalize the general case \r\n> > with or w/o uboot !\r\n> \r\n> U-Boot indeed flushes caches.. but doesn't invalidate them!\r\n> And only invalidation unlocks locked lines.\r\n> \r\n> That indeed should be added in U-Boot but I'd say above stuff doesn't\r\n> influence a lot code size or execution time while makes system more fool-proof.\r\n\r\nAs for invalidation that IMHO is really important especially for I$.\r\nSee even if we do proper invalidation of both caches in say U-Boot but keep caches\r\nenabled at least the last I$ line that contained last \"jump\" instruction will left\r\nin the cache. And now if we're unlucky enough we may execute code that overlaps location\r\nof that last \"jump\" and instead of expected instruction freshly loaded from DDR we'll execute\r\ngarbage left-over.\r\n\r\nNote this is not just a theory, we hit that problem trying to execute U-Boot from u-Boot\r\n(not kidding - we do self-upgrade that way).\r\n\r\nSimilar idea could be valid for D$ even though not very likely but still...\r\nGiven code in U-boot writen in C even in between dcache_flush() and icache_invalidate()\r\nmight happen some data accesses hidden in implementations of those functions.\r\nIn fact currently we do checks if SLC exist in those functions and that check is done\r\nvia polling a global var, so for sure some LD instructions are executed there.\r\n\r\nThat said if my explanation now makes more sense I'd be willing to send a v2 with\r\ninvalidation of all caches (I$, D$ and SLC).\r\n\r\n-Alexey","headers":{"Return-Path":"<linux-snps-arc-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org; spf=none (mailfrom)\n\tsmtp.mailfrom=lists.infradead.org (client-ip=65.50.211.133;\n\thelo=bombadil.infradead.org;\n\tenvelope-from=linux-snps-arc-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (2048-bit key;\n\tunprotected) header.d=lists.infradead.org\n\theader.i=@lists.infradead.org header.b=\"tFbvP8CT\"; \n\tdkim-atps=neutral"],"Received":["from bombadil.infradead.org (bombadil.infradead.org\n\t[65.50.211.133])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3ycSt70x30z9sBW\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 16 Nov 2017 02:27:27 +1100 (AEDT)","from localhost ([127.0.0.1] helo=bombadil.infradead.org)\n\tby bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux))\n\tid 1eEzb3-0005Ry-Qe; Wed, 15 Nov 2017 15:27:25 +0000","from smtprelay4.synopsys.com ([198.182.47.9]\n\thelo=smtprelay.synopsys.com)\n\tby bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux))\n\tid 1eEzb1-0005QT-GD for linux-snps-arc@lists.infradead.org;\n\tWed, 15 Nov 2017 15:27:25 +0000","from mailhost.synopsys.com (mailhost2.synopsys.com [10.13.184.66])\n\tby smtprelay.synopsys.com (Postfix) with ESMTP id 38EEA24E1FC3;\n\tWed, 15 Nov 2017 07:27:01 -0800 (PST)","from mailhost.synopsys.com (localhost [127.0.0.1])\n\tby mailhost.synopsys.com (Postfix) with ESMTP id E417CBC;\n\tWed, 15 Nov 2017 07:27:00 -0800 (PST)","from US01WEHTC3.internal.synopsys.com\n\t(us01wehtc3.internal.synopsys.com [10.15.84.232])\n\tby mailhost.synopsys.com (Postfix) with ESMTP id D772FBB;\n\tWed, 15 Nov 2017 07:27:00 -0800 (PST)","from DE02WEHTCB.internal.synopsys.com (10.225.19.94) by\n\tUS01WEHTC3.internal.synopsys.com (10.15.84.232) with Microsoft SMTP\n\tServer (TLS) id 14.3.266.1; Wed, 15 Nov 2017 07:27:00 -0800","from DE02WEMBXB.internal.synopsys.com ([fe80::95ce:118a:8321:a099])\n\tby DE02WEHTCB.internal.synopsys.com ([::1]) with mapi id\n\t14.03.0266.001; Wed, 15 Nov 2017 16:26:58 +0100"],"DKIM-Signature":"v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;\n\td=lists.infradead.org; s=bombadil.20170209; h=Sender:\n\tContent-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post:\n\tList-Archive:List-Unsubscribe:List-Id:MIME-Version:Content-ID:In-Reply-To:\n\tReferences:Message-ID:Date:Subject:To:From:Reply-To:Content-Description:\n\tResent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:\n\tList-Owner; bh=2Z7i8qOkozjWZnnBo0csT8hyd9VDR7SpMnOe6mLM1G4=;\n\tb=tFbvP8CTrQgdkw\n\tLmhMO9V2haFH4Y5ebWP6/r8oFdKizu0Tfurz5hzh3JzdMpLtyFKgo7h+KlG18XOyOQC3Py4MAiksn\n\tIO2KYRVJbTnopvvcgp/IjhNyCXVtv42BJRvYFPy1dgwKODF38MzoOs68OigG09WTNve6M0LNEhCCl\n\tAY6JHdnksGv12mHmxvoYwP/8PD4HHrwkhKckElvHmYY9nGTY7aJIn/hqP+XJe6i8o1ZND8QYRkccy\n\tCHVgN3FHmhMbjUgmQv9DNXwVunrMmtTuM84kVD6FCx0p3/vWtYWKU//PpVBCRHRB6/Hnm7FyqGli+\n\tHUaUGTEkmbtTkvcQ54Xg==;","From":"Alexey Brodkin <Alexey.Brodkin@synopsys.com>","To":"\"Vineet.Gupta1@synopsys.com\" <Vineet.Gupta1@synopsys.com>","Subject":"Re: [PATCH] arc: Flush and invalidate caches on start","Thread-Topic":"[PATCH] arc: Flush and invalidate caches on start","Thread-Index":"AQHTImSFFtUehpI7V0KxfIF57RuoqqKehuaAgAAA0QCAd28TAA==","Date":"Wed, 15 Nov 2017 15:26:57 +0000","Message-ID":"<1510759616.29843.39.camel@synopsys.com>","References":"<20170831142158.27245-1-abrodkin@synopsys.com>\n\t<7a5267e3-c012-7bfd-ced2-cfaa3f47524a@synopsys.com>\n\t<1504197268.3799.8.camel@synopsys.com>","In-Reply-To":"<1504197268.3799.8.camel@synopsys.com>","Accept-Language":"en-US, ru-RU","Content-Language":"en-US","X-MS-Has-Attach":"","X-MS-TNEF-Correlator":"","x-originating-ip":"[10.121.3.25]","Content-ID":"<6B9C626A161F8644BB4248CD3F30BDFD@internal.synopsys.com>","MIME-Version":"1.0","X-CRM114-Version":"20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 ","X-CRM114-CacheID":"sfid-20171115_072723_555150_D9801BDD ","X-CRM114-Status":"GOOD (  17.85  )","X-Spam-Score":"-1.9 (-)","X-Spam-Report":"SpamAssassin version 3.4.1 on bombadil.infradead.org summary:\n\tContent analysis details:   (-1.9 points)\n\tpts rule name              description\n\t---- ----------------------\n\t--------------------------------------------------\n\t-0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/,\n\tno trust [198.182.47.9 listed in list.dnswl.org]\n\t-0.0 RP_MATCHES_RCVD Envelope sender domain matches handover relay\n\tdomain\n\t-0.0 RCVD_IN_MSPIKE_H4      RBL: Very Good reputation (+4)\n\t[198.182.47.9 listed in wl.mailspike.net]\n\t-1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%\n\t[score: 0.0000]\n\t-0.0 RCVD_IN_MSPIKE_WL      Mailspike good senders","X-BeenThere":"linux-snps-arc@lists.infradead.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Id":"Linux on Synopsys ARC Processors\n\t<linux-snps-arc.lists.infradead.org>","List-Unsubscribe":"<http://lists.infradead.org/mailman/options/linux-snps-arc>, \n\t<mailto:linux-snps-arc-request@lists.infradead.org?subject=unsubscribe>","List-Archive":"<http://lists.infradead.org/pipermail/linux-snps-arc/>","List-Post":"<mailto:linux-snps-arc@lists.infradead.org>","List-Help":"<mailto:linux-snps-arc-request@lists.infradead.org?subject=help>","List-Subscribe":"<http://lists.infradead.org/mailman/listinfo/linux-snps-arc>, \n\t<mailto:linux-snps-arc-request@lists.infradead.org?subject=subscribe>","Cc":"\"linux-snps-arc@lists.infradead.org\"\n\t<linux-snps-arc@lists.infradead.org>, \n\tEugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>,\n\t\"linux-kernel@vger.kernel.org\" <linux-kernel@vger.kernel.org>","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"base64","Sender":"\"linux-snps-arc\" <linux-snps-arc-bounces@lists.infradead.org>","Errors-To":"linux-snps-arc-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org"}}]