From patchwork Wed Mar 11 18:04:54 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rajkumar Manoharan X-Patchwork-Id: 5988191 Return-Path: X-Original-To: patchwork-ath10k@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id EFC05BF90F for ; Wed, 11 Mar 2015 18:05:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1EC7E203AA for ; Wed, 11 Mar 2015 18:05:53 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3D0C820395 for ; Wed, 11 Mar 2015 18:05:51 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1YVl0q-00066j-Hl; Wed, 11 Mar 2015 18:05:44 +0000 Received: from wolverine01.qualcomm.com ([199.106.114.254]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YVl0m-0005tG-6R for ath10k@lists.infradead.org; Wed, 11 Mar 2015 18:05:40 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=qti.qualcomm.com; i=@qti.qualcomm.com; q=dns/txt; s=qcdkim; t=1426097140; x=1457633140; h=from:to:cc:subject:date:message-id:mime-version; bh=/YHHNMXpJvMQUDXIWTIPfk3j+PMlvuYVybY2nJh6eJg=; b=ww4p6Ybq4pwvT7EPb9+m3QLU/a4mkzWoIsNk86vjwqEu6XnnGwEDrleK 6d6ZzFy/wzknjrU+opCpFGoaIdtiS2La1UG4tyKvnq4z4px3ZWZot3g1B VABiDyPs2AJPxcS5MmwsKqykcfiBFDdNGyPEQ6nQnao12qr8p7L6fUFMZ w=; X-IronPort-AV: E=McAfee;i="5600,1067,7736"; a="107455766" Received: from ironmsg03-l.qualcomm.com ([172.30.48.18]) by wolverine01.qualcomm.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 11 Mar 2015 11:05:16 -0700 X-IronPort-AV: E=Sophos;i="5.11,382,1422950400"; d="scan'208";a="859260713" Received: from nasanexm02h.na.qualcomm.com ([10.85.0.89]) by Ironmsg03-L.qualcomm.com with ESMTP/TLS/RC4-SHA; 11 Mar 2015 11:05:15 -0700 Received: from aphydexm01b.ap.qualcomm.com (10.252.127.11) by nasanexm02h.na.qualcomm.com (10.85.0.89) with Microsoft SMTP Server (TLS) id 15.0.995.29; Wed, 11 Mar 2015 11:05:14 -0700 Received: from qcmail1.qualcomm.com (10.80.80.8) by aphydexm01b.ap.qualcomm.com (10.252.127.11) with Microsoft SMTP Server (TLS) id 15.0.995.29; Wed, 11 Mar 2015 11:05:06 -0700 Received: by qcmail1.qualcomm.com (sSMTP sendmail emulation); Wed, 11 Mar 2015 23:34:55 +0530 From: Rajkumar Manoharan To: Subject: [PATCH] ath10k: move driver state check before setting throttle Date: Wed, 11 Mar 2015 23:34:54 +0530 Message-ID: <1426097094-6225-1-git-send-email-rmanohar@qti.qualcomm.com> X-Mailer: git-send-email 2.3.2 MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanexm01a.na.qualcomm.com (10.85.0.81) To aphydexm01b.ap.qualcomm.com (10.252.127.11) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150311_110540_299948_580DFCBB X-CRM114-Status: GOOD ( 10.98 ) X-Spam-Score: -5.1 (-----) Cc: linux-wireless@vger.kernel.org, Rajkumar Manoharan X-BeenThere: ath10k@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "ath10k" Errors-To: ath10k-bounces+patchwork-ath10k=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Since thermal daemon is unaware of the device state, it might try to adjust the throttle state when the device is powered down. So the driver caches the value and will configure it while powering up the target. The cached value will be programed later once the device is brought up. In such case, returning error status is confusing and misleading the user application. Hence moving the driver state check before sending wmi command to target. Reported-by: Matthias Kaehlcke Signed-off-by: Rajkumar Manoharan --- drivers/net/wireless/ath/ath10k/thermal.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/drivers/net/wireless/ath/ath10k/thermal.c b/drivers/net/wireless/ath/ath10k/thermal.c index 3720c86..c9475ac 100644 --- a/drivers/net/wireless/ath/ath10k/thermal.c +++ b/drivers/net/wireless/ath/ath10k/thermal.c @@ -50,7 +50,6 @@ ath10k_thermal_set_cur_throttle_state(struct thermal_cooling_device *cdev, unsigned long throttle_state) { struct ath10k *ar = cdev->devdata; - int ret = 0; if (throttle_state > ATH10K_THERMAL_THROTTLE_MAX) { ath10k_warn(ar, "throttle state %ld is exceeding the limit %d\n", @@ -59,16 +58,9 @@ ath10k_thermal_set_cur_throttle_state(struct thermal_cooling_device *cdev, } mutex_lock(&ar->conf_mutex); ar->thermal.throttle_state = throttle_state; - - if (ar->state != ATH10K_STATE_ON) { - ret = -ENETDOWN; - goto out; - } - ath10k_thermal_set_throttling(ar); -out: mutex_unlock(&ar->conf_mutex); - return ret; + return 0; } static struct thermal_cooling_device_ops ath10k_thermal_ops = { @@ -190,6 +182,9 @@ void ath10k_thermal_set_throttling(struct ath10k *ar) lockdep_assert_held(&ar->conf_mutex); + if (ar->state != ATH10K_STATE_ON) + return; + period = ar->thermal.quiet_period; duration = (period * ar->thermal.throttle_state) / 100; enabled = duration ? 1 : 0;