From patchwork Fri May 6 04:35:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 67249 Delivered-To: patches@linaro.org Received: by 10.140.92.199 with SMTP id b65csp127221qge; Thu, 5 May 2016 21:35:47 -0700 (PDT) X-Received: by 10.98.23.150 with SMTP id 144mr26098966pfx.96.1462509347786; Thu, 05 May 2016 21:35:47 -0700 (PDT) Return-Path: Received: from mail-pf0-x22f.google.com (mail-pf0-x22f.google.com. [2607:f8b0:400e:c00::22f]) by mx.google.com with ESMTPS id 15si15272394pfw.133.2016.05.05.21.35.47 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 May 2016 21:35:47 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 2607:f8b0:400e:c00::22f as permitted sender) client-ip=2607:f8b0:400e:c00::22f; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: domain of john.stultz@linaro.org designates 2607:f8b0:400e:c00::22f as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: by mail-pf0-x22f.google.com with SMTP id c189so46715543pfb.3 for ; Thu, 05 May 2016 21:35:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=NkNUjb3k8phf+cL7eBbqXGji66RIKRf4Iuw3Qp4nisg=; b=Bvn6P5vbtP5BCEX1ZEuhWdVwccL5ZYvGB2pXFucIJQInEcioAjV+6+AoMlrhcD3QZ1 Otm0HpXwNz5wE3cEsQTiGW2QlxQxMVN9bgNkbuOJkRCV4SMJyq0vEOgRjfqRuGV/nesd wgDVqngrMdXGEerzTcqcvNdZg7j95JCpcUWRk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=NkNUjb3k8phf+cL7eBbqXGji66RIKRf4Iuw3Qp4nisg=; b=E3SV4o8NxWvteszTb5JXTCICaJ+S0iiTDOWgM9JWwgv8egKNpa5ydhmxV+jMbKywtk J+t41xUlll85nA2phv4UT3XZeXaxqNSkpjUqJuZdtOotgEtP3ZRl6a4PsChNpnYPhd69 WKQDTmacH4LFACmNffdvsG7XRMr2cVZLc6eHLG0vyXy+oTkul6Wb1h2VCFv62MfG8FWl 3BwGhSuwSoTRQvg0tbVuxW9ChFFF/60FJCJS7A/5zgzb4snFIcGVGIZVyWg1Jdm5dytg pZncrHoizFLk6n59RA6Xa74HWIglaLoy179U3I7DZg1qNUy4/AP4vhvX5B1EWEVscF3i mdjA== X-Gm-Message-State: AOPr4FW/iYrtJhJQGOsuK1dya0xdMi1DVbOX80T6EN3fPkORQIoXT93IgGzRspPCjl9DoMrsm9o= X-Received: by 10.98.102.74 with SMTP id a71mr25745283pfc.139.1462509347401; Thu, 05 May 2016 21:35:47 -0700 (PDT) Return-Path: Received: from localhost.localdomain (c-73-67-244-238.hsd1.or.comcast.net. [73.67.244.238]) by smtp.gmail.com with ESMTPSA id zn7sm17207805pac.41.2016.05.05.21.35.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 05 May 2016 21:35:46 -0700 (PDT) From: John Stultz To: linaro-uefi@lists.linaro.org, edk2-devel@lists.01.org Cc: John Stultz , Olivier Martin , Haojian Zhuang , Vishal Bhoj Subject: [RFC][PATCH] OpenPlatformPkg: HiKeyMem: Initialize the base system memory HOB before trying to create reservations Date: Thu, 5 May 2016 21:35:38 -0700 Message-Id: <1462509338-8467-1-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.9.1 In the current edk2 code, as of 40a3f38f67cee ("ArmPlatformPkg/MemoryInitPei: Check if the main System Memory resource has been declared"), ArmPlatformGetVirtualMemoryMap() is now called before the base system memory HOB is created in MemoryPeim(). This causes the logic in HiKey's ArmPlatformGetVirtualMemoryMap() which tries to chop up that base HOB to fail, as there's nothing to chop up at that time. The calling code is smart enough to check if a base system memory HOB is already present before creating one, so we can just set it up ourselves here before we try to make our reservations. This avoids problems seen in the kernel with the current logic, where none of the reservations were actually being made. Note: I'm a total newbie with this codebase (I just recently figured out what HOB stood for). So feedback would be greatly appreciated! CC: Olivier Martin Cc: Haojian Zhuang Cc: Vishal Bhoj Signed-off-by: John Stultz --- Platforms/Hisilicon/HiKey/Library/HiKeyLib/HiKeyMem.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) -- 1.9.1 diff --git a/Platforms/Hisilicon/HiKey/Library/HiKeyLib/HiKeyMem.c b/Platforms/Hisilicon/HiKey/Library/HiKeyLib/HiKeyMem.c index a5ce05b..2d118e0 100644 --- a/Platforms/Hisilicon/HiKey/Library/HiKeyLib/HiKeyMem.c +++ b/Platforms/Hisilicon/HiKey/Library/HiKeyLib/HiKeyMem.c @@ -89,6 +89,24 @@ ArmPlatformGetVirtualMemoryMap ( MemorySize = HiKeyInitMemorySize (); + ResourceAttributes = ( + EFI_RESOURCE_ATTRIBUTE_PRESENT | + EFI_RESOURCE_ATTRIBUTE_INITIALIZED | + EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE | + EFI_RESOURCE_ATTRIBUTE_WRITE_COMBINEABLE | + EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE | + EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE | + EFI_RESOURCE_ATTRIBUTE_TESTED + ); + + // Create initial Base Hob for system memory. + BuildResourceDescriptorHob ( + EFI_RESOURCE_SYSTEM_MEMORY, + ResourceAttributes, + PcdGet64 (PcdSystemMemoryBase), + PcdGet64 (PcdSystemMemorySize) + ); + NextHob.Raw = GetHobList (); Count = sizeof (HiKeyReservedMemoryBuffer) / sizeof (struct HiKeyReservedMemory); while ((NextHob.Raw = GetNextHob (EFI_HOB_TYPE_RESOURCE_DESCRIPTOR, NextHob.Raw)) != NULL)