* [PATCH] thermal: int340x: processor_thermal: Fix deadlock
@ 2023-03-03 16:19 Srinivas Pandruvada
2023-03-03 18:52 ` Greg KH
2023-03-03 19:36 ` Rafael J. Wysocki
0 siblings, 2 replies; 4+ messages in thread
From: Srinivas Pandruvada @ 2023-03-03 16:19 UTC (permalink / raw)
To: rafael, rui.zhang, daniel.lezcano
Cc: linux-pm, linux-kernel, Srinivas Pandruvada, stable
From: Srinivas Pandruvada <srinivas.pandruvada@intel.com>
When user space updates the trip point there is a deadlock, which results
in caller gets blocked forever.
Commit 05eeee2b51b4 ("thermal/core: Protect sysfs accesses to thermal
operations with thermal zone mutex"), added a mutex for tz->lock in the
function trip_point_temp_store(). Hence, trip set callback() can't
call any thermal zone API as they are protected with the same mutex lock.
The callback here calling thermal_zone_device_enable(), which will result
in deadlock.
Move the thermal_zone_device_enable() to proc_thermal_pci_probe() to
avoid this deadlock.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@intel.com>
Cc: stable@vger.kernel.org
---
The commit which caused this issue was added during v6.2 cycle.
.../intel/int340x_thermal/processor_thermal_device_pci.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci.c b/drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci.c
index bf1b1cdfade4..acc11ad56975 100644
--- a/drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci.c
+++ b/drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci.c
@@ -194,7 +194,6 @@ static int sys_set_trip_temp(struct thermal_zone_device *tzd, int trip, int temp
proc_thermal_mmio_write(pci_info, PROC_THERMAL_MMIO_THRES_0, _temp);
proc_thermal_mmio_write(pci_info, PROC_THERMAL_MMIO_INT_ENABLE_0, 1);
- thermal_zone_device_enable(tzd);
pci_info->stored_thres = temp;
return 0;
@@ -277,6 +276,10 @@ static int proc_thermal_pci_probe(struct pci_dev *pdev, const struct pci_device_
goto err_free_vectors;
}
+ ret = thermal_zone_device_enable(pci_info->tzone);
+ if (ret)
+ goto err_free_vectors;
+
return 0;
err_free_vectors:
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] thermal: int340x: processor_thermal: Fix deadlock
2023-03-03 16:19 [PATCH] thermal: int340x: processor_thermal: Fix deadlock Srinivas Pandruvada
@ 2023-03-03 18:52 ` Greg KH
2023-03-03 19:11 ` Rafael J. Wysocki
2023-03-03 19:36 ` Rafael J. Wysocki
1 sibling, 1 reply; 4+ messages in thread
From: Greg KH @ 2023-03-03 18:52 UTC (permalink / raw)
To: Srinivas Pandruvada
Cc: rafael, rui.zhang, daniel.lezcano, linux-pm, linux-kernel,
Srinivas Pandruvada, stable
On Fri, Mar 03, 2023 at 08:19:09AM -0800, Srinivas Pandruvada wrote:
> From: Srinivas Pandruvada <srinivas.pandruvada@intel.com>
>
> When user space updates the trip point there is a deadlock, which results
> in caller gets blocked forever.
>
> Commit 05eeee2b51b4 ("thermal/core: Protect sysfs accesses to thermal
> operations with thermal zone mutex"), added a mutex for tz->lock in the
> function trip_point_temp_store(). Hence, trip set callback() can't
> call any thermal zone API as they are protected with the same mutex lock.
>
> The callback here calling thermal_zone_device_enable(), which will result
> in deadlock.
>
> Move the thermal_zone_device_enable() to proc_thermal_pci_probe() to
> avoid this deadlock.
>
> Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@intel.com>
> Cc: stable@vger.kernel.org
> ---
> The commit which caused this issue was added during v6.2 cycle.
What commit exactly? Always list that as a Fixes: tag if you know this.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] thermal: int340x: processor_thermal: Fix deadlock
2023-03-03 18:52 ` Greg KH
@ 2023-03-03 19:11 ` Rafael J. Wysocki
0 siblings, 0 replies; 4+ messages in thread
From: Rafael J. Wysocki @ 2023-03-03 19:11 UTC (permalink / raw)
To: Greg KH
Cc: Srinivas Pandruvada, rafael, rui.zhang, daniel.lezcano, linux-pm,
linux-kernel, Srinivas Pandruvada, stable
On Fri, Mar 3, 2023 at 7:52 PM Greg KH <gregkh@linuxfoundation.org> wrote:
>
> On Fri, Mar 03, 2023 at 08:19:09AM -0800, Srinivas Pandruvada wrote:
> > From: Srinivas Pandruvada <srinivas.pandruvada@intel.com>
> >
> > When user space updates the trip point there is a deadlock, which results
> > in caller gets blocked forever.
> >
> > Commit 05eeee2b51b4 ("thermal/core: Protect sysfs accesses to thermal
> > operations with thermal zone mutex"), added a mutex for tz->lock in the
> > function trip_point_temp_store(). Hence, trip set callback() can't
> > call any thermal zone API as they are protected with the same mutex lock.
> >
> > The callback here calling thermal_zone_device_enable(), which will result
> > in deadlock.
> >
> > Move the thermal_zone_device_enable() to proc_thermal_pci_probe() to
> > avoid this deadlock.
> >
> > Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@intel.com>
> > Cc: stable@vger.kernel.org
> > ---
> > The commit which caused this issue was added during v6.2 cycle.
>
> What commit exactly? Always list that as a Fixes: tag if you know this.
It's there in the changelog above.
I'll add a Fixes: tag to this one when applying it.
Cheers!
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] thermal: int340x: processor_thermal: Fix deadlock
2023-03-03 16:19 [PATCH] thermal: int340x: processor_thermal: Fix deadlock Srinivas Pandruvada
2023-03-03 18:52 ` Greg KH
@ 2023-03-03 19:36 ` Rafael J. Wysocki
1 sibling, 0 replies; 4+ messages in thread
From: Rafael J. Wysocki @ 2023-03-03 19:36 UTC (permalink / raw)
To: Srinivas Pandruvada
Cc: rafael, rui.zhang, daniel.lezcano, linux-pm, linux-kernel,
Srinivas Pandruvada, stable
On Fri, Mar 3, 2023 at 5:19 PM Srinivas Pandruvada
<srinivas.pandruvada@linux.intel.com> wrote:
>
> From: Srinivas Pandruvada <srinivas.pandruvada@intel.com>
>
> When user space updates the trip point there is a deadlock, which results
> in caller gets blocked forever.
>
> Commit 05eeee2b51b4 ("thermal/core: Protect sysfs accesses to thermal
> operations with thermal zone mutex"), added a mutex for tz->lock in the
> function trip_point_temp_store(). Hence, trip set callback() can't
> call any thermal zone API as they are protected with the same mutex lock.
>
> The callback here calling thermal_zone_device_enable(), which will result
> in deadlock.
>
> Move the thermal_zone_device_enable() to proc_thermal_pci_probe() to
> avoid this deadlock.
>
> Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@intel.com>
> Cc: stable@vger.kernel.org
> ---
> The commit which caused this issue was added during v6.2 cycle.
>
> .../intel/int340x_thermal/processor_thermal_device_pci.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci.c b/drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci.c
> index bf1b1cdfade4..acc11ad56975 100644
> --- a/drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci.c
> +++ b/drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci.c
> @@ -194,7 +194,6 @@ static int sys_set_trip_temp(struct thermal_zone_device *tzd, int trip, int temp
> proc_thermal_mmio_write(pci_info, PROC_THERMAL_MMIO_THRES_0, _temp);
> proc_thermal_mmio_write(pci_info, PROC_THERMAL_MMIO_INT_ENABLE_0, 1);
>
> - thermal_zone_device_enable(tzd);
> pci_info->stored_thres = temp;
>
> return 0;
> @@ -277,6 +276,10 @@ static int proc_thermal_pci_probe(struct pci_dev *pdev, const struct pci_device_
> goto err_free_vectors;
> }
>
> + ret = thermal_zone_device_enable(pci_info->tzone);
> + if (ret)
> + goto err_free_vectors;
> +
> return 0;
>
> err_free_vectors:
> --
Now queued up for 6.3-rc with a Fixes: tag added, thanks!
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-03-03 19:36 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-03 16:19 [PATCH] thermal: int340x: processor_thermal: Fix deadlock Srinivas Pandruvada
2023-03-03 18:52 ` Greg KH
2023-03-03 19:11 ` Rafael J. Wysocki
2023-03-03 19:36 ` Rafael J. Wysocki
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox