public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Sudeep Holla" <sudeep.holla@arm.com>
To: devel@edk2.groups.io
Cc: Sudeep Holla <sudeep.holla@arm.com>,
	Leif Lindholm <quic_llindhol@quicinc.com>,
	Ard Biesheuvel <ardb+tianocore@kernel.org>,
	Pierre Gondois <Pierre.Gondois@arm.com>,
	Girish Pathak <girish.pathak@arm.com>,
	Jeff Brasen <jbrasen@nvidia.com>,
	Sami Mujawar <sami.mujawar@arm.com>
Subject: [PATCH] ArmPkg/ArmScmiDxe: Fix the calculation of RequiredArraySize in ClockDescribeRates()
Date: Thu,  2 Feb 2023 14:30:15 +0000	[thread overview]
Message-ID: <20230202143015.3066988-1-sudeep.holla@arm.com> (raw)

As per the SCMI specification, section CLOCK_DESCRIBE_RATES mentions that
the value of num_rates_flags[11:0] in the response must be 3 if the return
format is the triplet. Due to the buggy firmware, this was not noticed for
long time. The firmware is now fixed resulting in ClockDescribeRates() to
fail with "Buffer Too Small" error as the RequiredArraySize gets miscalculated
as 72 instead of 24.

Fix the issue by reusing the logic for both the return format which must
work if num_rates_flags has correct value as expected from the specification.

Cc: Pierre Gondois <Pierre.Gondois@arm.com>
Cc: Girish Pathak <girish.pathak@arm.com>
Cc: Jeff Brasen <jbrasen@nvidia.com>
Reported-by: Sami Mujawar <sami.mujawar@arm.com>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
---
 ArmPkg/Drivers/ArmScmiDxe/ScmiClockProtocol.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

Hi All,

Sorry for the resend, I hadn't subscribed before so resending after the
subscription.

Regards,
Sudeep

diff --git a/ArmPkg/Drivers/ArmScmiDxe/ScmiClockProtocol.c b/ArmPkg/Drivers/ArmScmiDxe/ScmiClockProtocol.c
index 12a7e6df5d43..1412717bc227 100644
--- a/ArmPkg/Drivers/ArmScmiDxe/ScmiClockProtocol.c
+++ b/ArmPkg/Drivers/ArmScmiDxe/ScmiClockProtocol.c
@@ -236,12 +236,7 @@ ClockDescribeRates (
       *TotalRates = NUM_RATES (DescribeRates->NumRatesFlags)
                     + NUM_REMAIN_RATES (DescribeRates->NumRatesFlags);
 
-      if (*Format == ScmiClockRateFormatDiscrete) {
-        RequiredArraySize = (*TotalRates) * sizeof (UINT64);
-      } else {
-        // We need to return triplet of 64 bit value for each rate
-        RequiredArraySize = (*TotalRates) * 3 * sizeof (UINT64);
-      }
+      RequiredArraySize = (*TotalRates) * sizeof (UINT64);
 
       if (RequiredArraySize > (*RateArraySize)) {
         *RateArraySize = RequiredArraySize;
-- 
2.39.1


             reply	other threads:[~2023-02-02 14:30 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-02 14:30 Sudeep Holla [this message]
2023-02-03 11:10 ` [PATCH] ArmPkg/ArmScmiDxe: Fix the calculation of RequiredArraySize in ClockDescribeRates() PierreGondois
2023-02-03 11:20   ` Sudeep Holla
2023-02-03 12:27     ` [edk2-devel] " 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=20230202143015.3066988-1-sudeep.holla@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