diff mbox series

[1/5] thermal: tegra-bpmp: Handle errors in BPMP response

Message ID 20210915085517.1669675-1-mperttunen@nvidia.com
State Accepted
Commit 1a7c9213d5f9bfd5e1bf4f87df1abc166ce48ffc
Headers show
Series [1/5] thermal: tegra-bpmp: Handle errors in BPMP response | expand

Commit Message

Mikko Perttunen Sept. 15, 2021, 8:55 a.m. UTC
The return value from tegra_bpmp_transfer indicates the success or
failure of the IPC transaction with BPMP. If the transaction
succeeded, we also need to check the actual command's result code.
Add code to do this.

Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>
---
 drivers/thermal/tegra/tegra-bpmp-thermal.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

Comments

Krzysztof Kozlowski Sept. 20, 2021, 8:34 a.m. UTC | #1
On Wed, 15 Sep 2021 11:55:15 +0300, Mikko Perttunen wrote:
> The return value from tegra_bpmp_transfer indicates the success or

> failure of the IPC transaction with BPMP. If the transaction

> succeeded, we also need to check the actual command's result code.

> Add code to do this.

> 

> 


Applied, thanks!

[3/5] memory: tegra186-emc: Handle errors in BPMP response
      commit: 13324edbe9269e6fbca4d0f5146b18ef8478c958

Best regards,
-- 
Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
Thierry Reding Oct. 7, 2021, 6:20 p.m. UTC | #2
On Wed, Sep 15, 2021 at 11:55:13AM +0300, Mikko Perttunen wrote:
> The return value from tegra_bpmp_transfer indicates the success or

> failure of the IPC transaction with BPMP. If the transaction

> succeeded, we also need to check the actual command's result code.

> Add code to do this.

> 

> Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>

> ---

>  drivers/thermal/tegra/tegra-bpmp-thermal.c | 13 ++++++++++++-

>  1 file changed, 12 insertions(+), 1 deletion(-)


Perhaps this should be moved into tegra_bpmp_transfer() or some new
helper to make sure we can keep this consistent across all callers.

For instance, I'm not sure -EINVAL is the right (or best) error code in
all the cases. Either way, seems fine in this case and this is certainly
an improvement, so:

Acked-by: Thierry Reding <treding@nvidia.com>
Thierry Reding Oct. 7, 2021, 6:21 p.m. UTC | #3
On Wed, Sep 15, 2021 at 11:55:17AM +0300, Mikko Perttunen wrote:
> The return value from tegra_bpmp_transfer indicates the success or

> failure of the IPC transaction with BPMP. If the transaction

> succeeded, we also need to check the actual command's result code.

> Add code to do this.

> 

> Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>

> ---

>  drivers/pci/controller/dwc/pcie-tegra194.c | 9 ++++++++-

>  1 file changed, 8 insertions(+), 1 deletion(-)


Acked-by: Thierry Reding <treding@nvidia.com>
Lorenzo Pieralisi Feb. 3, 2022, 12:22 p.m. UTC | #4
On Mon, Nov 29, 2021 at 12:19:18PM +0000, Lorenzo Pieralisi wrote:
> On Wed, Oct 13, 2021 at 01:59:56PM +0100, Lorenzo Pieralisi wrote:
> > On Thu, Oct 07, 2021 at 08:21:11PM +0200, Thierry Reding wrote:
> > > On Wed, Sep 15, 2021 at 11:55:17AM +0300, Mikko Perttunen wrote:
> > > > The return value from tegra_bpmp_transfer indicates the success or
> > > > failure of the IPC transaction with BPMP. If the transaction
> > > > succeeded, we also need to check the actual command's result code.
> > > > Add code to do this.
> > > > 
> > > > Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>
> > > > ---
> > > >  drivers/pci/controller/dwc/pcie-tegra194.c | 9 ++++++++-
> > > >  1 file changed, 8 insertions(+), 1 deletion(-)
> > > 
> > > Acked-by: Thierry Reding <treding@nvidia.com>
> > 
> > Hi Thierry,
> > 
> > can I pull this patch into the PCI tree ? Or if you want the series
> > to go via another tree:
> > 
> > Acked-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
> 
> Hi,
> 
> I would like to ask please how you want this series to be handled.

Should I apply this patch stand-alone ?

I will mark all other patches in this series as Not Applicable in
the PCI queue.

Thanks,
Lorenzo
Daniel Lezcano Feb. 25, 2022, 12:22 p.m. UTC | #5
On 07/10/2021 20:20, Thierry Reding wrote:
> On Wed, Sep 15, 2021 at 11:55:13AM +0300, Mikko Perttunen wrote:
>> The return value from tegra_bpmp_transfer indicates the success or
>> failure of the IPC transaction with BPMP. If the transaction
>> succeeded, we also need to check the actual command's result code.
>> Add code to do this.
>>
>> Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>
>> ---
>>   drivers/thermal/tegra/tegra-bpmp-thermal.c | 13 ++++++++++++-
>>   1 file changed, 12 insertions(+), 1 deletion(-)
> 
> Perhaps this should be moved into tegra_bpmp_transfer() or some new
> helper to make sure we can keep this consistent across all callers.
> 
> For instance, I'm not sure -EINVAL is the right (or best) error code in
> all the cases. Either way, seems fine in this case and this is certainly
> an improvement, so:
> 
> Acked-by: Thierry Reding <treding@nvidia.com>

Applied, thanks
diff mbox series

Patch

diff --git a/drivers/thermal/tegra/tegra-bpmp-thermal.c b/drivers/thermal/tegra/tegra-bpmp-thermal.c
index 94f1da1dcd69..5affc3d196be 100644
--- a/drivers/thermal/tegra/tegra-bpmp-thermal.c
+++ b/drivers/thermal/tegra/tegra-bpmp-thermal.c
@@ -52,6 +52,8 @@  static int tegra_bpmp_thermal_get_temp(void *data, int *out_temp)
 	err = tegra_bpmp_transfer(zone->tegra->bpmp, &msg);
 	if (err)
 		return err;
+	if (msg.rx.ret)
+		return -EINVAL;
 
 	*out_temp = reply.get_temp.temp;
 
@@ -63,6 +65,7 @@  static int tegra_bpmp_thermal_set_trips(void *data, int low, int high)
 	struct tegra_bpmp_thermal_zone *zone = data;
 	struct mrq_thermal_host_to_bpmp_request req;
 	struct tegra_bpmp_message msg;
+	int err;
 
 	memset(&req, 0, sizeof(req));
 	req.type = CMD_THERMAL_SET_TRIP;
@@ -76,7 +79,13 @@  static int tegra_bpmp_thermal_set_trips(void *data, int low, int high)
 	msg.tx.data = &req;
 	msg.tx.size = sizeof(req);
 
-	return tegra_bpmp_transfer(zone->tegra->bpmp, &msg);
+	err = tegra_bpmp_transfer(zone->tegra->bpmp, &msg);
+	if (err)
+		return err;
+	if (msg.rx.ret)
+		return -EINVAL;
+
+	return 0;
 }
 
 static void tz_device_update_work_fn(struct work_struct *work)
@@ -140,6 +149,8 @@  static int tegra_bpmp_thermal_get_num_zones(struct tegra_bpmp *bpmp,
 	err = tegra_bpmp_transfer(bpmp, &msg);
 	if (err)
 		return err;
+	if (msg.rx.ret)
+		return -EINVAL;
 
 	*num_zones = reply.get_num_zones.num;