Linux ARM-MSM sub-architecture
 help / color / mirror / Atom feed
* [PATCH] power: supply: qcom_battmgr: Ignore extra __le32 in info payload
@ 2024-07-12 10:00 Stephan Gerhold
  2024-07-12 11:07 ` Johan Hovold
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Stephan Gerhold @ 2024-07-12 10:00 UTC (permalink / raw)
  To: Sebastian Reichel
  Cc: linux-arm-msm, linux-pm, linux-kernel, Bjorn Andersson, Abel Vesa,
	Johan Hovold, Srinivas Kandagatla

Some newer ADSP firmware versions on X1E80100 report an extra __le32 at the
end of the battery information request payload, causing qcom_battmgr to
fail to initialize. Adjust the check to ignore the extra field in the info
payload so we can support both old and newer firmware versions.

Tested-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Signed-off-by: Stephan Gerhold <stephan.gerhold@linaro.org>
---
 drivers/power/supply/qcom_battmgr.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/power/supply/qcom_battmgr.c b/drivers/power/supply/qcom_battmgr.c
index 46f36dcb185c..a5b5f1251af1 100644
--- a/drivers/power/supply/qcom_battmgr.c
+++ b/drivers/power/supply/qcom_battmgr.c
@@ -1007,7 +1007,9 @@ static void qcom_battmgr_sc8280xp_callback(struct qcom_battmgr *battmgr,
 		battmgr->error = 0;
 		break;
 	case BATTMGR_BAT_INFO:
-		if (payload_len != sizeof(resp->info)) {
+		/* some firmware versions report an extra __le32 at the end of the payload */
+		if (payload_len != sizeof(resp->info) &&
+		    payload_len != (sizeof(resp->info) + sizeof(__le32))) {
 			dev_warn(battmgr->dev,
 				 "invalid payload length for battery information request: %zd\n",
 				 payload_len);

---
base-commit: 3fe121b622825ff8cc995a1e6b026181c48188db
change-id: 20240711-x1e80100-battmgr-1eaab3b8f024

Best regards,
-- 
Stephan Gerhold <stephan.gerhold@linaro.org>


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] power: supply: qcom_battmgr: Ignore extra __le32 in info payload
  2024-07-12 10:00 [PATCH] power: supply: qcom_battmgr: Ignore extra __le32 in info payload Stephan Gerhold
@ 2024-07-12 11:07 ` Johan Hovold
  2024-07-13 16:17 ` Dmitry Baryshkov
  2024-07-26 22:39 ` Sebastian Reichel
  2 siblings, 0 replies; 6+ messages in thread
From: Johan Hovold @ 2024-07-12 11:07 UTC (permalink / raw)
  To: Stephan Gerhold
  Cc: Sebastian Reichel, linux-arm-msm, linux-pm, linux-kernel,
	Bjorn Andersson, Abel Vesa, Srinivas Kandagatla

On Fri, Jul 12, 2024 at 12:00:03PM +0200, Stephan Gerhold wrote:
> Some newer ADSP firmware versions on X1E80100 report an extra __le32 at the
> end of the battery information request payload, causing qcom_battmgr to
> fail to initialize. Adjust the check to ignore the extra field in the info
> payload so we can support both old and newer firmware versions.
> 
> Tested-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
> Signed-off-by: Stephan Gerhold <stephan.gerhold@linaro.org>

Can confirm that the old fw still works (didn't really look at the
patch):

Tested-by: Johan Hovold <johan+linaro@kernel.org>

Johan

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] power: supply: qcom_battmgr: Ignore extra __le32 in info payload
  2024-07-12 10:00 [PATCH] power: supply: qcom_battmgr: Ignore extra __le32 in info payload Stephan Gerhold
  2024-07-12 11:07 ` Johan Hovold
@ 2024-07-13 16:17 ` Dmitry Baryshkov
  2024-07-15  9:15   ` Stephan Gerhold
  2024-07-26 22:39 ` Sebastian Reichel
  2 siblings, 1 reply; 6+ messages in thread
From: Dmitry Baryshkov @ 2024-07-13 16:17 UTC (permalink / raw)
  To: Stephan Gerhold
  Cc: Sebastian Reichel, linux-arm-msm, linux-pm, linux-kernel,
	Bjorn Andersson, Abel Vesa, Johan Hovold, Srinivas Kandagatla

On Fri, Jul 12, 2024 at 12:00:03PM GMT, Stephan Gerhold wrote:
> Some newer ADSP firmware versions on X1E80100 report an extra __le32 at the
> end of the battery information request payload, causing qcom_battmgr to
> fail to initialize. Adjust the check to ignore the extra field in the info
> payload so we can support both old and newer firmware versions.
> 
> Tested-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
> Signed-off-by: Stephan Gerhold <stephan.gerhold@linaro.org>
> ---
>  drivers/power/supply/qcom_battmgr.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/power/supply/qcom_battmgr.c b/drivers/power/supply/qcom_battmgr.c
> index 46f36dcb185c..a5b5f1251af1 100644
> --- a/drivers/power/supply/qcom_battmgr.c
> +++ b/drivers/power/supply/qcom_battmgr.c
> @@ -1007,7 +1007,9 @@ static void qcom_battmgr_sc8280xp_callback(struct qcom_battmgr *battmgr,
>  		battmgr->error = 0;
>  		break;
>  	case BATTMGR_BAT_INFO:
> -		if (payload_len != sizeof(resp->info)) {
> +		/* some firmware versions report an extra __le32 at the end of the payload */

Any useful information in that extra?

> +		if (payload_len != sizeof(resp->info) &&
> +		    payload_len != (sizeof(resp->info) + sizeof(__le32))) {
>  			dev_warn(battmgr->dev,
>  				 "invalid payload length for battery information request: %zd\n",
>  				 payload_len);
> 
> ---
> base-commit: 3fe121b622825ff8cc995a1e6b026181c48188db
> change-id: 20240711-x1e80100-battmgr-1eaab3b8f024
> 
> Best regards,
> -- 
> Stephan Gerhold <stephan.gerhold@linaro.org>
> 

-- 
With best wishes
Dmitry

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] power: supply: qcom_battmgr: Ignore extra __le32 in info payload
  2024-07-13 16:17 ` Dmitry Baryshkov
@ 2024-07-15  9:15   ` Stephan Gerhold
  2024-07-15 10:45     ` Dmitry Baryshkov
  0 siblings, 1 reply; 6+ messages in thread
From: Stephan Gerhold @ 2024-07-15  9:15 UTC (permalink / raw)
  To: Dmitry Baryshkov
  Cc: Sebastian Reichel, linux-arm-msm, linux-pm, linux-kernel,
	Bjorn Andersson, Abel Vesa, Johan Hovold, Srinivas Kandagatla

On Sat, Jul 13, 2024 at 07:17:51PM +0300, Dmitry Baryshkov wrote:
> On Fri, Jul 12, 2024 at 12:00:03PM GMT, Stephan Gerhold wrote:
> > Some newer ADSP firmware versions on X1E80100 report an extra __le32 at the
> > end of the battery information request payload, causing qcom_battmgr to
> > fail to initialize. Adjust the check to ignore the extra field in the info
> > payload so we can support both old and newer firmware versions.
> > 
> > Tested-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
> > Signed-off-by: Stephan Gerhold <stephan.gerhold@linaro.org>
> > ---
> >  drivers/power/supply/qcom_battmgr.c | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/power/supply/qcom_battmgr.c b/drivers/power/supply/qcom_battmgr.c
> > index 46f36dcb185c..a5b5f1251af1 100644
> > --- a/drivers/power/supply/qcom_battmgr.c
> > +++ b/drivers/power/supply/qcom_battmgr.c
> > @@ -1007,7 +1007,9 @@ static void qcom_battmgr_sc8280xp_callback(struct qcom_battmgr *battmgr,
> >  		battmgr->error = 0;
> >  		break;
> >  	case BATTMGR_BAT_INFO:
> > -		if (payload_len != sizeof(resp->info)) {
> > +		/* some firmware versions report an extra __le32 at the end of the payload */
> 
> Any useful information in that extra?
> 

No, I don't think so. I think we can just ignore it.

Thanks,
Stephan

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] power: supply: qcom_battmgr: Ignore extra __le32 in info payload
  2024-07-15  9:15   ` Stephan Gerhold
@ 2024-07-15 10:45     ` Dmitry Baryshkov
  0 siblings, 0 replies; 6+ messages in thread
From: Dmitry Baryshkov @ 2024-07-15 10:45 UTC (permalink / raw)
  To: Stephan Gerhold
  Cc: Sebastian Reichel, linux-arm-msm, linux-pm, linux-kernel,
	Bjorn Andersson, Abel Vesa, Johan Hovold, Srinivas Kandagatla

On Mon, Jul 15, 2024 at 11:15:16AM GMT, Stephan Gerhold wrote:
> On Sat, Jul 13, 2024 at 07:17:51PM +0300, Dmitry Baryshkov wrote:
> > On Fri, Jul 12, 2024 at 12:00:03PM GMT, Stephan Gerhold wrote:
> > > Some newer ADSP firmware versions on X1E80100 report an extra __le32 at the
> > > end of the battery information request payload, causing qcom_battmgr to
> > > fail to initialize. Adjust the check to ignore the extra field in the info
> > > payload so we can support both old and newer firmware versions.
> > > 
> > > Tested-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
> > > Signed-off-by: Stephan Gerhold <stephan.gerhold@linaro.org>
> > > ---
> > >  drivers/power/supply/qcom_battmgr.c | 4 +++-
> > >  1 file changed, 3 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/drivers/power/supply/qcom_battmgr.c b/drivers/power/supply/qcom_battmgr.c
> > > index 46f36dcb185c..a5b5f1251af1 100644
> > > --- a/drivers/power/supply/qcom_battmgr.c
> > > +++ b/drivers/power/supply/qcom_battmgr.c
> > > @@ -1007,7 +1007,9 @@ static void qcom_battmgr_sc8280xp_callback(struct qcom_battmgr *battmgr,
> > >  		battmgr->error = 0;
> > >  		break;
> > >  	case BATTMGR_BAT_INFO:
> > > -		if (payload_len != sizeof(resp->info)) {
> > > +		/* some firmware versions report an extra __le32 at the end of the payload */
> > 
> > Any useful information in that extra?
> > 
> 
> No, I don't think so. I think we can just ignore it.

If that's the case,


Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>


-- 
With best wishes
Dmitry

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] power: supply: qcom_battmgr: Ignore extra __le32 in info payload
  2024-07-12 10:00 [PATCH] power: supply: qcom_battmgr: Ignore extra __le32 in info payload Stephan Gerhold
  2024-07-12 11:07 ` Johan Hovold
  2024-07-13 16:17 ` Dmitry Baryshkov
@ 2024-07-26 22:39 ` Sebastian Reichel
  2 siblings, 0 replies; 6+ messages in thread
From: Sebastian Reichel @ 2024-07-26 22:39 UTC (permalink / raw)
  To: Sebastian Reichel, Stephan Gerhold
  Cc: linux-arm-msm, linux-pm, linux-kernel, Bjorn Andersson, Abel Vesa,
	Johan Hovold, Srinivas Kandagatla


On Fri, 12 Jul 2024 12:00:03 +0200, Stephan Gerhold wrote:
> Some newer ADSP firmware versions on X1E80100 report an extra __le32 at the
> end of the battery information request payload, causing qcom_battmgr to
> fail to initialize. Adjust the check to ignore the extra field in the info
> payload so we can support both old and newer firmware versions.
> 
> 

Applied, thanks!

[1/1] power: supply: qcom_battmgr: Ignore extra __le32 in info payload
      commit: d6cca7631a4b54a8995e3bc53e5afb11d3b0c8ff

Best regards,
-- 
Sebastian Reichel <sebastian.reichel@collabora.com>


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-07-26 22:39 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-12 10:00 [PATCH] power: supply: qcom_battmgr: Ignore extra __le32 in info payload Stephan Gerhold
2024-07-12 11:07 ` Johan Hovold
2024-07-13 16:17 ` Dmitry Baryshkov
2024-07-15  9:15   ` Stephan Gerhold
2024-07-15 10:45     ` Dmitry Baryshkov
2024-07-26 22:39 ` Sebastian Reichel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox