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: 5988181 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: X-Original-To: patchwork-linux-wireless@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 7535CBF90F for ; Wed, 11 Mar 2015 18:05:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9BF66203AA for ; Wed, 11 Mar 2015 18:05:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A7B0420395 for ; Wed, 11 Mar 2015 18:05:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752608AbbCKSFS (ORCPT ); Wed, 11 Mar 2015 14:05:18 -0400 Received: from wolverine02.qualcomm.com ([199.106.114.251]:23515 "EHLO wolverine02.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752596AbbCKSFQ (ORCPT ); Wed, 11 Mar 2015 14:05:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=qti.qualcomm.com; i=@qti.qualcomm.com; q=dns/txt; s=qcdkim; t=1426097116; x=1457633116; h=from:to:cc:subject:date:message-id:mime-version; bh=/YHHNMXpJvMQUDXIWTIPfk3j+PMlvuYVybY2nJh6eJg=; b=JSVN2oXX1581PqOgKeHTslB65qHRwShy2oo21g7M2u20HyLH2fv+g4qv wD0TNHI7oKp5jBtWfIE1yISSTLwRTCQzLkchjFXGaRgrRT71L0M9bH8lW y4+roPzB2EulDPGoWGEgY/F+p2z4IQRvZ/8dCzqID+k0einVm/iU2y+ui 8=; X-IronPort-AV: E=McAfee;i="5600,1067,7737"; a="199562989" Received: from ironmsg03-l.qualcomm.com ([172.30.48.18]) by wolverine02.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: CC: , Rajkumar Manoharan 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) Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,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;