From: Girish Pathak <girish.pathak@arm.com>
To: edk2-devel@lists.01.org
Cc: ard.biesheuvel@linaro.org, leif.lindholm@linaro.org,
Matteo.Carlini@arm.com, Stephanie.Hughes-Fitt@arm.com,
Sudeep.Holla@arm.com, nd@arm.com
Subject: [PATCH v2 2/2] ArmPkg/ArmScmiDxe: Dynamically allocate buffer for protocol ids
Date: Tue, 19 Jun 2018 14:53:53 +0100 [thread overview]
Message-ID: <20180619135353.40176-3-girish.pathak@arm.com> (raw)
In-Reply-To: <20180619135353.40176-1-girish.pathak@arm.com>
Dynamically allocate the buffer to receive the SCMI protocol list.
This makes MAX_PROTOCOLS redundant, so it is removed.
It also fixes one minor code alignment issue and removes an unused
macro PROTOCOL_MASK.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Girish Pathak <girish.pathak@arm.com>
Tested-by: Sudeep Holla <sudeep.holla@arm.com>
---
Notes:
v2:
- Remove change-id [Ard]
Done [Girish]
ArmPkg/Drivers/ArmScmiDxe/Scmi.c | 5 ----
ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.c | 27 +++++++++++++++-----
ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.h | 1 -
3 files changed, 21 insertions(+), 12 deletions(-)
diff --git a/ArmPkg/Drivers/ArmScmiDxe/Scmi.c b/ArmPkg/Drivers/ArmScmiDxe/Scmi.c
index 1e279f69cf615428dbb6477b8ac7de3258628df3..d247d3a932fe9f197460a95e9afa88681742e4b4 100644
--- a/ArmPkg/Drivers/ArmScmiDxe/Scmi.c
+++ b/ArmPkg/Drivers/ArmScmiDxe/Scmi.c
@@ -22,11 +22,6 @@
#include "ScmiPrivate.h"
-// SCMI Specification 1.0
-#define MAX_PROTOCOLS 6
-
-#define PROTOCOL_MASK 0xF
-
// Arbitrary timeout value 20ms.
#define RESPONSE_TIMEOUT 20000
diff --git a/ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.c b/ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.c
index a56c7b21d5f09d41a110826b7b9db14ac34451de..0400799b5c521dcfa2ce866b0ffd48530e8cf0d1 100644
--- a/ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.c
+++ b/ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.c
@@ -63,8 +63,8 @@ ArmScmiDxeEntryPoint (
UINT32 Index;
UINT32 NumProtocols;
UINT32 ProtocolIndex;
- UINT8 SupportedList[MAX_PROTOCOLS];
- UINT32 SupportedListSize = sizeof (SupportedList);
+ UINT8 *SupportedList;
+ UINT32 SupportedListSize;
// Every SCMI implementation must implement the base protocol.
ASSERT (Protocols[0].Id == SCMI_PROTOCOL_ID_BASE);
@@ -108,13 +108,26 @@ ArmScmiDxeEntryPoint (
ASSERT (NumProtocols != 0);
+ SupportedListSize = (NumProtocols * sizeof (*SupportedList));
+
+ Status = gBS->AllocatePool (
+ EfiBootServicesData,
+ SupportedListSize,
+ (VOID**)&SupportedList
+ );
+ if (EFI_ERROR (Status)) {
+ ASSERT (FALSE);
+ return Status;
+ }
+
// Get the list of protocols supported by SCP firmware on the platform.
Status = BaseProtocol->DiscoverListProtocols (
- BaseProtocol,
- &SupportedListSize,
- SupportedList
- );
+ BaseProtocol,
+ &SupportedListSize,
+ SupportedList
+ );
if (EFI_ERROR (Status)) {
+ gBS->FreePool (SupportedList);
ASSERT (FALSE);
return Status;
}
@@ -134,5 +147,7 @@ ArmScmiDxeEntryPoint (
}
}
+ gBS->FreePool (SupportedList);
+
return EFI_SUCCESS;
}
diff --git a/ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.h b/ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.h
index 222e54f4dca558d9b1fedddf3f96fd977898c7b2..c9a9072579e32c06cc231d388fb3f2fe8d37eb21 100644
--- a/ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.h
+++ b/ArmPkg/Drivers/ArmScmiDxe/ScmiDxe.h
@@ -19,7 +19,6 @@
#include "ScmiPrivate.h"
-#define MAX_PROTOCOLS 6
#define MAX_VENDOR_LEN SCMI_MAX_STR_LEN
/** Pointer to protocol initialization function.
--
'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'
next prev parent reply other threads:[~2018-06-19 13:54 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-19 13:53 [PATCH v2 0/2] ArmPkg/ArmScmiDxe: Fix a bug uncovered with the new SCP firmware Girish Pathak
2018-06-19 13:53 ` [PATCH v2 1/2] ArmPkg/ArmScmiDxe: Fix ASSERT error in SCMI DXE Girish Pathak
2018-06-19 13:53 ` Girish Pathak [this message]
2018-06-22 6:23 ` [PATCH v2 0/2] ArmPkg/ArmScmiDxe: Fix a bug uncovered with the new SCP firmware Ard Biesheuvel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180619135353.40176-3-girish.pathak@arm.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox