Re: [PATCH 6/6] i2c: Make remove callback return void

2022-06-29 Thread Maximilian Luz

On 6/28/22 16:03, Uwe Kleine-König wrote:

From: Uwe Kleine-König 

The value returned by an i2c driver's remove function is mostly ignored.
(Only an error message is printed if the value is non-zero that the
error is ignored.)

So change the prototype of the remove function to return no value. This
way driver authors are not tempted to assume that passing an error to
the upper layer is a good idea. All drivers are adapted accordingly.
There is no intended change of behaviour, all callbacks were prepared to
return 0 before.

Signed-off-by: Uwe Kleine-König 


[...]

  drivers/platform/surface/surface3_power.c | 4 +---


[...]


diff --git a/drivers/platform/surface/surface3_power.c 
b/drivers/platform/surface/surface3_power.c
index 444ec81ba02d..3b20dddeb815 100644
--- a/drivers/platform/surface/surface3_power.c
+++ b/drivers/platform/surface/surface3_power.c
@@ -554,7 +554,7 @@ static int mshw0011_probe(struct i2c_client *client)
return error;
  }
  
-static int mshw0011_remove(struct i2c_client *client)

+static void mshw0011_remove(struct i2c_client *client)
  {
struct mshw0011_data *cdata = i2c_get_clientdata(client);
  
@@ -564,8 +564,6 @@ static int mshw0011_remove(struct i2c_client *client)

kthread_stop(cdata->poll_task);
  
  	i2c_unregister_device(cdata->bat0);

-
-   return 0;
  }
  
  static const struct acpi_device_id mshw0011_acpi_match[] = {


For the quoted above:

Reviewed-by: Maximilian Luz 


[PATCH] drm/msm: Fix double pm_runtime_disable() call

2022-06-06 Thread Maximilian Luz
Following commit 17e822f7591f ("drm/msm: fix unbalanced
pm_runtime_enable in adreno_gpu_{init, cleanup}"), any call to
adreno_unbind() will disable runtime PM twice, as indicated by the call
trees below:

  adreno_unbind()
   -> pm_runtime_force_suspend()
   -> pm_runtime_disable()

  adreno_unbind()
   -> gpu->funcs->destroy() [= aNxx_destroy()]
   -> adreno_gpu_cleanup()
   -> pm_runtime_disable()

Note that pm_runtime_force_suspend() is called right before
gpu->funcs->destroy() and both functions are called unconditionally.

With recent addition of the eDP AUX bus code, this problem manifests
itself when the eDP panel cannot be found yet and probing is deferred.
On the first probe attempt, we disable runtime PM twice as described
above. This then causes any later probe attempt to fail with

  [drm:adreno_load_gpu [msm]] *ERROR* Couldn't power up the GPU: -13

preventing the driver from loading.

As there seem to be scenarios where the aNxx_destroy() functions are not
called from adreno_unbind(), simply removing pm_runtime_disable() from
inside adreno_unbind() does not seem to be the proper fix. This is what
commit 17e822f7591f ("drm/msm: fix unbalanced pm_runtime_enable in
adreno_gpu_{init, cleanup}") intended to fix. Therefore, instead check
whether runtime PM is still enabled, and only disable it in that case.

Fixes: 17e822f7591f ("drm/msm: fix unbalanced pm_runtime_enable in 
adreno_gpu_{init, cleanup}")
Signed-off-by: Maximilian Luz 
---
 drivers/gpu/drm/msm/adreno/adreno_gpu.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/msm/adreno/adreno_gpu.c 
b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
index 4e665c806a14..f944b69e2a25 100644
--- a/drivers/gpu/drm/msm/adreno/adreno_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
@@ -1057,7 +1057,8 @@ void adreno_gpu_cleanup(struct adreno_gpu *adreno_gpu)
for (i = 0; i < ARRAY_SIZE(adreno_gpu->info->fw); i++)
release_firmware(adreno_gpu->fw[i]);
 
-   pm_runtime_disable(&priv->gpu_pdev->dev);
+   if (pm_runtime_enabled(&priv->gpu_pdev->dev))
+   pm_runtime_disable(&priv->gpu_pdev->dev);
 
msm_gpu_cleanup(&adreno_gpu->base);
 }
-- 
2.36.1