Message ID | 20230303161910.3195805-1-srinivas.pandruvada@linux.intel.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp500094wrd; Fri, 3 Mar 2023 08:22:27 -0800 (PST) X-Google-Smtp-Source: AK7set8nKDD+LpQO3h6XTbXsFWn22Vz2oZFA2HMaUV8EJg7QzWf1tHODdINyEyMx/BWPqYbyTTtA X-Received: by 2002:a17:907:8a0c:b0:8b1:800b:d2e9 with SMTP id sc12-20020a1709078a0c00b008b1800bd2e9mr2643057ejc.56.1677860547770; Fri, 03 Mar 2023 08:22:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677860547; cv=none; d=google.com; s=arc-20160816; b=wCGI2bE0kfK99nrcHQf9+NlYE2jLnn93fhuvFDsCJGQvXOXx7BevdGHYKN5EN9akcb VENq4SMNGjQayTwLcFQx4cfk5odzpD7kytohc3EKYBbccheu0CZnFhL3JpsWAyx2kkL7 b1JRG/5c/gM5u+Mw7cTTn18BBsMSyhYpk2f8tgnWpYBqKFPK4TpyGrZ+gwazLcb9tCs7 r8YhoP0IuAO4pKKdJeKMR2egLGPVzdrtyGjQ4Ym43f7HA+1xJ0MGlL9Me9rOu45TtWsF zibLKgiPwm9UL3qgDpdkSqeQGRe3HnkBXZ7fJkj7ndGTgtX9Ap1bKgWUkWMa4TXQSziV 55CA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=bpX9ttlzaPvAjCyEnNbsEbr9J/ExwOaV94Hu09ywQnA=; b=HcRqru+tPfLAuhV4kB5sAFqTa+xjN/rkA98HZBpiyZ8y6SPNfRYh1zOVB6F/poaE8R 1l7CC6OWO+kmam224gvSQoy4Q5kEYLiIno/AYc+esnDKvCMEAqcAlYfWRKOge/k/pdgp lYR+9jvyWkAcr7PXgfX4giAJRcSwxS2YXaUNVdGFp/wXRna8+bsQ6iUhYwekihgpthFe eEJ1OF6OdY7l3+fI5FuABDOxq64tpaxNpFMJ2sSc/1cpkcSJKzVAXSfIFhuNy9mP4v1W Oa0XykZqei8V0YQNlHqy3gl+ro6uEGTADmyMMF8J0HnPrGZcuU9rv6qogzJ5Ck0d7AM/ XfUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=a9qjSxGb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ia24-20020a170907a07800b008b17879ce7asi2598528ejc.914.2023.03.03.08.22.04; Fri, 03 Mar 2023 08:22:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=a9qjSxGb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231330AbjCCQTg (ORCPT <rfc822;davidbtadokoro@gmail.com> + 99 others); Fri, 3 Mar 2023 11:19:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231290AbjCCQTa (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 3 Mar 2023 11:19:30 -0500 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A84F323679; Fri, 3 Mar 2023 08:19:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1677860355; x=1709396355; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=ek6XqKRjAwHSqFxYlwA0ot0sijMnK5XWyd+WPWb4jEI=; b=a9qjSxGbbAcYO710Lon2yPUdH9349k+XLd5B9E+VTThmfPWktSN39wUn 67dWczqj7r8DDveqYxC7JXwodf7V/hH+Il1QJfcuErKz/IOAFNMGQelXV Gy5JVXav2O/s8PDzR7JJVutj93LqCBKefIYBmTZipu5S/cSOKf3iKBlJa 906bcQiZEpNzTkr6c2V1D+O5zkPzs+Rx5b/xF9gJjPfe0yPvEZus+veR+ TfhQF4gEJC+Tb24fLQqaKIx3CbbbhGwy9pkGGwWR/mK0lV9l1Jshu43dc GT3ujsrHsbXb/jTSoGX4YwguPw3kgRUFfMbyZxDzumbCCB7i/+JPUri7E A==; X-IronPort-AV: E=McAfee;i="6500,9779,10638"; a="397667308" X-IronPort-AV: E=Sophos;i="5.98,231,1673942400"; d="scan'208";a="397667308" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Mar 2023 08:19:15 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10638"; a="675425096" X-IronPort-AV: E=Sophos;i="5.98,231,1673942400"; d="scan'208";a="675425096" Received: from spandruv-desk.jf.intel.com ([10.54.75.8]) by orsmga002.jf.intel.com with ESMTP; 03 Mar 2023 08:19:14 -0800 From: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> To: rafael@kernel.org, rui.zhang@intel.com, daniel.lezcano@linaro.org Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Srinivas Pandruvada <srinivas.pandruvada@intel.com>, stable@vger.kernel.org Subject: [PATCH] thermal: int340x: processor_thermal: Fix deadlock Date: Fri, 3 Mar 2023 08:19:09 -0800 Message-Id: <20230303161910.3195805-1-srinivas.pandruvada@linux.intel.com> X-Mailer: git-send-email 2.39.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759364302062432214?= X-GMAIL-MSGID: =?utf-8?q?1759364302062432214?= |
Series |
thermal: int340x: processor_thermal: Fix deadlock
|
|
Commit Message
srinivas pandruvada
March 3, 2023, 4:19 p.m. UTC
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(-)
Comments
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
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!
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!
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: