From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on0607.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe02::607]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id E830C81E89 for ; Thu, 19 Jan 2017 04:29:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector1-arm-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=WJxWUIGdcqT1dae5s2dQfbsHnu0P53uWtml5tK9PF+8=; b=jfcq3K+6mCqf7geabmufa27Z5VPLOvzu6vDrgYNECM8wNOvlf8WJnsjRPwoh90rEd2uqlbiP9jLEF9M3N2WjkmHuMTkQLFz9s4EF4D7mAldT2i/fyk88Sx0DWC9qIJBnvKYEi27PC7fR9c2zPvo1KtXTn81tzURQk8Zo3J/YGoQ= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Achin.Gupta@arm.com; Received: from e102648.cambridge.arm.com (217.140.96.140) by DB5PR08MB1189.eurprd08.prod.outlook.com (10.166.174.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.845.12; Thu, 19 Jan 2017 12:29:00 +0000 Date: Thu, 19 Jan 2017 12:31:36 +0000 From: Achin Gupta To: Leif Lindholm , CC: , , , Supreeth Venkatesh Message-ID: <20170119123135.GB24076@e102648.cambridge.arm.com> References: <1484771046-21296-1-git-send-email-achin.gupta@arm.com> <20170118220500.GW25883@bivouac.eciton.net> MIME-Version: 1.0 In-Reply-To: <20170118220500.GW25883@bivouac.eciton.net> User-Agent: Mutt/1.5.21 (2010-09-15) X-Originating-IP: [217.140.96.140] X-ClientProxiedBy: AM5PR0402CA0020.eurprd04.prod.outlook.com (10.175.37.30) To DB5PR08MB1189.eurprd08.prod.outlook.com (10.166.174.146) X-MS-Office365-Filtering-Correlation-Id: 9ab443ff-0cfa-4c11-7e7c-08d44066c252 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:DB5PR08MB1189; X-Microsoft-Exchange-Diagnostics: 1; DB5PR08MB1189; 3:BuAkLNnUKMpRZiZxeEhbQruwdW55RYsU3cC6n+ni7tFai4/MLHI+H0l4JbJmdY7brI4XT/FWF9A4DkWz1GXrDrE2QCiMZ7sIYCswCLMzzVeTpB7Mdu/RHgCodav/KT4Fi1kfyWB9t5QtvVSo0gygSFFfyQeXscY5CxGAFaYeYwdD3wAdotOZbKd8wIllKRimpbYHcWLnGLgCXz+7ZbYx2z/JEv09ZdbaHcVImdkR4+b886/1mg26btJjNPAeymibwy7M2bNZYKlP4SCFVh5zaQ== X-Microsoft-Exchange-Diagnostics: 1; DB5PR08MB1189; 25:QpqQgewrDHW5rejdbMzDLX4ApWFZ5YFMtsQjY92UhMSld6v7XFYSen4RmZDhc5xD9mLnwQGsX6S9R2C/bZeNTRmKNBqGdeA0UZIvGijvsAYEsdUGUtRck01ka1RLOISQSKmDO619NUl5wnYzA5UUcAe32M8P1xfAAhtP2Tqz9vjA08HU0jnE+1oleyeiSiCJETl9J3CMdGoVXSPQ6C2hY0hn25otVomNgEEhEPmNuR+hg3Imw7OlgWLtpA5QlIXWB3oL1i8YdHqve3+wPXrPaHAk2C/K5kb2cdKO3Q9FbtW25RQOZy5+5e1aPf2uTlgXwyHFMAocQ3RVzQRhr2wpqq0mBtEogbag9ajFDl+Xg/LO0rLBe5suF+SS7xW2glatXbkoghVA48JmXz56VJNXkfetN/Ft1VKozFEyx1AYkqD0pELsTxczibVaG4SXjOp2MlTUG2adXeSXFS0UzfQHFCX6dRwp4cVms5B7/jS26zOm8J/qUfqEkrZuoJ7HLMvpnA4SuBYNCTqVvQJXT+cr/ekfa/0HOd9jaF9xBVL46hUsF2GJrjTertUABprF9p+RKj2MgHJbEQEOpAE/E2VmuloTAa1ZZTSun9YaCZq7fvehlxDId281ZHK2BjI7m0GqaiUEA/Vvhb6rxe7hXQVU5oRQI73NCpbPqJXUIfCpKe3FPZhmFMetGlpmMylHtn9OdYUovDPnV+qjlmE827xvSc8zpm1HkU5fgaPBkcrIcsphnlB4/Ja9QFGs7SAG/O8BrKkv3PXTBRwLcM+9UTBfsRM3n9xn6DlFPba7sRdSAAOBZur0alD5SfiH8KHHq41xE4yWRQVo6uD3vJ+7Wof+7a+uLMfPhplu9qZVZojdw51h/I7x4j4z8yZVxOQfDeF9guTMD8EMSJEmZuiyA7/1gg== X-LD-Processed: f34e5979-57d9-4aaa-ad4d-b122a662184d,ExtAddr X-Microsoft-Exchange-Diagnostics: 1; DB5PR08MB1189; 31:m91l9pkZZi/uZi5I0WAFevjTnVTbmAiRE+Of3GyMIya0wcE3vLaMJ2mMfpYaISJ0SslO2njIlBUfOsgYP1Gz09NsGJj9DUU6CRCcJTL1MDmTFQdu7MbC0YCCnwedIbX+tv+3oThMEUZsjV9B317QVT55odG9et8A3g/GPtfhF7f+soAbHWX02l/5er/K6yAqx4WlFb7yrST1g7czUQJ/Y1f/DuLiUrXuWmWSKdaYder6v4pkUJhNl/Q2aYWD0hSFK5RcZm3+dmR46BGSb3EZLA==; 20:F8BxPDps8zZS6jLtEmPvgBIgEzQqXKQ6ATRPfWeUr1ZhYFEQiB9+i2VzvtZxppAWQAoYEq5uyGRZS28fXA25bHb4PWSO7rLsp0x+MZDo+HO1QZqn8HgilIW/zQvGZI1Oc6HUV/dK8l2z+dF+ReupXiBmKUNoEObp40NqeAjmTsg= NoDisclaimer: True X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(180628864354917)(166708455590820); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040375)(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046)(6055026)(6041248)(20161123558021)(20161123560025)(20161123564025)(20161123562025)(20161123555025)(6072148); SRVR:DB5PR08MB1189; BCL:0; PCL:0; RULEID:; SRVR:DB5PR08MB1189; X-Microsoft-Exchange-Diagnostics: 1; DB5PR08MB1189; 4:hxOHFW9dZ5G392ym/vNE1s0x81LOFC/igUVd3g5j2lopfsV0pCGNvHYIEZt+o/jsU62EoI/nXbMIEjUxUeeW84BeQnz3lwyU3CPsAOD3RWb+6H7BCs6aj8pXAxYULnMm2hJbwTw0f67mvjGEODw4m46WwH+mbwkuTRkeNybN6tjSLCk/jsEunak2MLrVZUUZPM6ofBa7Y6NOkljAzu3ulQdtMQdrT3VkSwmxOlx727+W+dlZumhUEv6kf41P/uRvyMfNvGmH3D9LXVGpXAKxtSDwv0orS8Vf0t0XhGd49egNQMBx6AKIiuXKnasrPjsZjZZ1NLOFeRYixoMWrvDeeBXmHISIO+2WTkQuZcZYj7KH7DuNva+eW8Q1BhG70j8XjAveE667R/1dPxtco1WChsAcJBH10LSG6YlMjjKxoZRsba63REYHwn90GBp6BsR6bi8YvCByKxPmkKpU8+28dNRiI4K1wRD8JoIHePjDk7Mlvp+QmJu+hN/m2vnn4eGWObpQ2MPF2JU8Fo82JD5wqshcNPirby3Xa+4xq/ZOeWMPh11RVca/XnjSF0XkyPVnCrGyfVFbN2v5+i9bIe8g8+6tYRl2tH7On9kFyHVKaDXI640SDVwI0PDdPvrBntjf4hxf6NR9n6q/4you2ZrXQaoRSFr1gEqSnrChAhKyw5KTbIkDxKwPB8lcjhAGGSduX8U4xSZoycZjh5MsyWtu+w== X-Forefront-PRVS: 0192E812EC X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(7916002)(39860400002)(39840400002)(39410400002)(39450400003)(39850400002)(24454002)(199003)(189002)(42186005)(101416001)(54906002)(68736007)(2906002)(54356999)(25786008)(76176999)(6306002)(55016002)(106356001)(23726003)(1076002)(3846002)(33656002)(97736004)(4326007)(50986999)(6116002)(105586002)(4001350100001)(5001770100001)(5660300001)(2950100002)(6666003)(92566002)(38730400001)(305945005)(189998001)(229853002)(47776003)(50466002)(66066001)(53936002)(46406003)(86362001)(8676002)(81166006)(81156014)(97756001)(83506001)(7736002)(18370500001); DIR:OUT; SFP:1101; SCL:1; SRVR:DB5PR08MB1189; H:e102648.cambridge.arm.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: arm.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DB5PR08MB1189; 23:yez71DvLHwCb+fCtEZpnWcwTJKtGpf48xngWlyqvN?= =?us-ascii?Q?WJ13JO9HTMlzOqTJbHI12jffvUqMrk8BwCGxdaaJ+d1TAoS6Td8lhwDhF2Fn?= =?us-ascii?Q?uZucH6ysITE8yVJyHodjdWAXxg1KrU/8fulJJXSx0M9tgnOvWjLqE9aoO933?= =?us-ascii?Q?V8pDttfeGjMOgaajc5MPrqEg+Srcv3foTXSklXZtcr8G/7yUYhrNlfd7nsVY?= =?us-ascii?Q?X3Hze8WkxJuw5LD8fzyFaN7hmWqn/tTKxjFsXQ6TsuE2TkzSehJPB9P/zPb+?= =?us-ascii?Q?wK8iqoYNtmBAiicr/kp97hjzrCnOPIJLPLuA/PYI9ChWsfhV4REJ830bJIvI?= =?us-ascii?Q?15cUQ2G/qagIXaDrAEDj1weZXH9x1kGsi3d85GFAVJle3abtdgnPXruwQRca?= =?us-ascii?Q?znKT4hGiDTMzFq/Hfjn+qYk7/xhksQz44I2JWX+DV0+lHcRA1n20DxQJQpyt?= =?us-ascii?Q?DSg7u2uXy8RACpQbrCUnXUPdYmhU49Sis0KsLTamYPZELM+cBlzraAmFs2W/?= =?us-ascii?Q?9e2zJG1wL6+vCT4fkv0vR5Ji7k1wVXNR0ecATvBv/Z5GBpN5nRZu4kqeQacJ?= =?us-ascii?Q?2nHxBr3QCmEvoLDhtaMjwU09e1PodK28Gf5KbmppqAQn8PrRYtI8OyiCFDwT?= =?us-ascii?Q?9m9QupzkjYclWcuPclOBpAlQmbSnlKYkPFw0OUqv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orOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jan 2017 12:29:00.3657 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB5PR08MB1189 Subject: Re: [PATCH] ArmPlatformPkg/ArmVExpressPkg: Fix memory attributes for NOR Flash X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Jan 2017 12:29:09 -0000 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline Hi Leif/Ard, On Wed, Jan 18, 2017 at 10:05:00PM +0000, Leif Lindholm wrote: > Hi Achin, > > On Wed, Jan 18, 2017 at 08:24:06PM +0000, achin.gupta@arm.com wrote: > > From: Achin Gupta > > > > The NOR flash banks were being mapped in the translation tables with the same > > memory attributes as RAM in the system. These attributes mark the region as > > Normal Memory and could additionally be cacheable or non-cacheable. > > > > Either type of attributes are unsuitable for NOR Flash since write operations > > could be performed on it. Normal Memory does not guarantee ordering of > > transactions that Device memory does. So the commands sent to the Flash device > > may not arrive in the right order unless barriers are used. Commands might not > > get past the CPU caches in case the region has been mapped with cacheable > > attributes. > > > > This patch fixes the problem by mapping the NOR Flash memory region with Device > > memory attributes. > > To add some background to Ard's comment - this was not unintentionally > done: > https://github.com/tianocore/edk2/commit/19bb46c411279dcd30d540c56e5993c5f771c319 Thanks! I missed this commit. There is some background to the problem I am facing below. > > Was the reasoning behind this commit incorrect - do you have a > (pre-DXE?) use-case that creates a problem? AFAIU, The current memory attributes for NOR Flash work only for reads. They should additionally be RO to flag any unexpected writes. Mine is a DXE use case! In NorFlashDxe.c, commands are send to the Flash (erase block etc.). They might never reach the device if there is a write-back cache in between. So either device or Normal memory with non-cacheable/write-through attributes and barriers should work. If I turn on cache state modelling in the Base FVP, the code gets stuck in NorFlashReadStatusRegister() in the below loop in NorFlashEraseSingleBlock(): // Wait until the status register gives us the all clear do { StatusRegister = NorFlashReadStatusRegister (Instance, BlockAddress); } while ((StatusRegister & P30_SR_BIT_WRITE) != P30_SR_BIT_WRITE); I think the SEND_NOR_COMMANDs at the beginning of the function get stuck in the cache. Changing the flash memory attributes as per this patch solves the problem. The original patch from Ard mentions that the NOR Flash DXE driver should change the attributes of the region it wants to write to. Is this what is missing? Please do let me know if I am missing any subtleties of the driver. I am not a NOR flash expert :( cheers, Achin > > Regards, > > Leif > > > Contributed-under: TianoCore Contribution Agreement 1.0 > > Signed-off-by: Achin Gupta > > --- > > ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/RTSMMem.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/RTSMMem.c b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/RTSMMem.c > > index 14c7e8e..2685114 100644 > > --- a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/RTSMMem.c > > +++ b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/RTSMMem.c > > @@ -116,7 +116,7 @@ ArmPlatformGetVirtualMemoryMap ( > > VirtualMemoryTable[++Index].PhysicalBase = ARM_VE_SMB_NOR0_BASE; > > VirtualMemoryTable[Index].VirtualBase = ARM_VE_SMB_NOR0_BASE; > > VirtualMemoryTable[Index].Length = ARM_VE_SMB_NOR0_SZ + ARM_VE_SMB_NOR1_SZ; > > - VirtualMemoryTable[Index].Attributes = CacheAttributes; > > + VirtualMemoryTable[Index].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_DEVICE; > > > > // SMB CS2 - SRAM > > VirtualMemoryTable[++Index].PhysicalBase = ARM_VE_SMB_SRAM_BASE; > > -- > > 1.9.1 > >