From patchwork Fri Feb 20 13:04:10 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rajkumar Manoharan X-Patchwork-Id: 5855921 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 CD853BF440 for ; Fri, 20 Feb 2015 13:06:08 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E30F820379 for ; Fri, 20 Feb 2015 13:06:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id ECBE620377 for ; Fri, 20 Feb 2015 13:06:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754228AbbBTNFR (ORCPT ); Fri, 20 Feb 2015 08:05:17 -0500 Received: from sabertooth02.qualcomm.com ([65.197.215.38]:42133 "EHLO sabertooth02.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754214AbbBTNFH (ORCPT ); Fri, 20 Feb 2015 08:05:07 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=qti.qualcomm.com; i=@qti.qualcomm.com; q=dns/txt; s=qcdkim; t=1424437507; x=1455973507; h=from:to:cc:subject:date:message-id:mime-version; bh=lDcRFW49Tz0A70s8F3OmhaVYlvNBSfatVHAWdfVVtYo=; b=Lfzu00rilFtcSgSXp0/ZgVJ0Dv7Fo+5dJbITxAIty9YNDceEyCO2KYl9 s6fy1IDuqpCk9RGiVKVNkJxRm1JahXtmiQi/5bL7TE1hMfkYb0RguhqRb VJvEUDpyWwjpBB2khtkyebakfl0WCdkOiN/jitl61bn6JxXrpjW72+j1s s=; X-IronPort-AV: E=McAfee;i="5600,1067,7717"; a="84370470" Received: from ironmsg01-lv.qualcomm.com ([10.47.202.180]) by sabertooth02.qualcomm.com with ESMTP; 20 Feb 2015 05:05:06 -0800 X-IronPort-AV: E=Sophos;i="5.09,614,1418112000"; d="scan'208";a="32428971" Received: from nasanexm01c.na.qualcomm.com ([10.85.0.83]) by ironmsg01-lv.qualcomm.com with ESMTP/TLS/RC4-SHA; 20 Feb 2015 05:05:06 -0800 Received: from APHYDEXM01E.ap.qualcomm.com (10.252.127.13) by NASANEXM01C.na.qualcomm.com (10.85.0.83) with Microsoft SMTP Server (TLS) id 15.0.995.29; Fri, 20 Feb 2015 05:05:04 -0800 Received: from qcmail1.qualcomm.com (10.80.80.8) by APHYDEXM01E.ap.qualcomm.com (10.252.127.13) with Microsoft SMTP Server (TLS) id 15.0.995.29; Fri, 20 Feb 2015 05:04:55 -0800 Received: by qcmail1.qualcomm.com (sSMTP sendmail emulation); Fri, 20 Feb 2015 18:34:48 +0530 From: Rajkumar Manoharan To: CC: , Rajkumar Manoharan Subject: [PATCH 1/3] ath10k: add sysfs entry to configure quiet period Date: Fri, 20 Feb 2015 18:34:10 +0530 Message-ID: <1424437452-28161-1-git-send-email-rmanohar@qti.qualcomm.com> X-Mailer: git-send-email 2.3.0 MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: NASANEXM01F.na.qualcomm.com (10.85.0.32) To APHYDEXM01E.ap.qualcomm.com (10.252.127.13) Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,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 Add support to configure quiet period via sysfs entry. This will be helpful to experiment different quiet period values along with different duty cycle ratio. To configure quiet period as 30ms, echo 30 >/sys/class/ieee80211/phyX/device/quiet_period Signed-off-by: Rajkumar Manoharan --- drivers/net/wireless/ath/ath10k/thermal.c | 57 +++++++++++++++++++++++++++++-- drivers/net/wireless/ath/ath10k/thermal.h | 1 + 2 files changed, 55 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/ath/ath10k/thermal.c b/drivers/net/wireless/ath/ath10k/thermal.c index 0d89ab5..8992c17 100644 --- a/drivers/net/wireless/ath/ath10k/thermal.c +++ b/drivers/net/wireless/ath/ath10k/thermal.c @@ -96,8 +96,7 @@ static int ath10k_thermal_set_cur_dutycycle(struct thermal_cooling_device *cdev, ret = -ENETDOWN; goto out; } - period = max(ATH10K_QUIET_PERIOD_MIN, - (ATH10K_QUIET_PERIOD_DEFAULT / num_bss)); + period = ar->thermal.quiet_period; duration = (period * (100 - duty_cycle)) / 100; enabled = duration ? 1 : 0; @@ -184,6 +183,48 @@ static struct attribute *ath10k_hwmon_attrs[] = { }; ATTRIBUTE_GROUPS(ath10k_hwmon); +static ssize_t ath10k_thermal_show_quiet_period(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct ath10k *ar = dev_get_drvdata(dev); + u32 period; + + mutex_lock(&ar->conf_mutex); + period = ar->thermal.quiet_period; + mutex_unlock(&ar->conf_mutex); + + return sprintf(buf, "%u\n", period); +} + +static ssize_t ath10k_thermal_store_quiet_period(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct ath10k *ar = dev_get_drvdata(dev); + u32 period; + int ret; + + ret = kstrtou32(buf, 0, &period); + if (ret) + return ret; + + if (period < ATH10K_QUIET_PERIOD_MIN) { + ath10k_warn(ar, "Quiet period %u can not be lesser than 25ms\n", + period); + return -EINVAL; + } + mutex_lock(&ar->conf_mutex); + ar->thermal.quiet_period = period; + mutex_unlock(&ar->conf_mutex); + + return count; +} + +static DEVICE_ATTR(quiet_period, S_IRUGO | S_IWUSR, + ath10k_thermal_show_quiet_period, + ath10k_thermal_store_quiet_period); + int ath10k_thermal_register(struct ath10k *ar) { struct thermal_cooling_device *cdev; @@ -208,6 +249,13 @@ int ath10k_thermal_register(struct ath10k *ar) ar->thermal.cdev = cdev; + ret = sysfs_create_file(&ar->dev->kobj, &dev_attr_quiet_period.attr); + if (ret) { + ath10k_err(ar, "failed to create quiet period sysfs entry\n"); + goto err_remove_link; + } + ar->thermal.quiet_period = ATH10K_QUIET_PERIOD_DEFAULT; + /* Do not register hwmon device when temperature reading is not * supported by firmware */ @@ -226,10 +274,12 @@ int ath10k_thermal_register(struct ath10k *ar) ath10k_err(ar, "failed to register hwmon device: %ld\n", PTR_ERR(hwmon_dev)); ret = -EINVAL; - goto err_remove_link; + goto err_remove_file; } return 0; +err_remove_file: + sysfs_remove_file(&ar->dev->kobj, &dev_attr_quiet_period.attr); err_remove_link: sysfs_remove_link(&ar->dev->kobj, "thermal_sensor"); err_cooling_destroy: @@ -241,4 +291,5 @@ void ath10k_thermal_unregister(struct ath10k *ar) { thermal_cooling_device_unregister(ar->thermal.cdev); sysfs_remove_link(&ar->dev->kobj, "cooling_device"); + sysfs_remove_file(&ar->dev->kobj, &dev_attr_quiet_period.attr); } diff --git a/drivers/net/wireless/ath/ath10k/thermal.h b/drivers/net/wireless/ath/ath10k/thermal.h index 5e87d9a..050f41d 100644 --- a/drivers/net/wireless/ath/ath10k/thermal.h +++ b/drivers/net/wireless/ath/ath10k/thermal.h @@ -29,6 +29,7 @@ struct ath10k_thermal { /* protected by conf_mutex */ u32 duty_cycle; + u32 quiet_period; /* temperature value in Celcius degree * protected by data_lock */