From patchwork Tue May 31 06:31:36 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Valentin X-Patchwork-Id: 9143533 X-Patchwork-Delegate: rui.zhang@intel.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3072060761 for ; Tue, 31 May 2016 06:33:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2494927DA9 for ; Tue, 31 May 2016 06:33:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 19889281ED; Tue, 31 May 2016 06:33:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 98E7827DA9 for ; Tue, 31 May 2016 06:33:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755884AbcEaGcm (ORCPT ); Tue, 31 May 2016 02:32:42 -0400 Received: from mail-pf0-f196.google.com ([209.85.192.196]:33711 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755604AbcEaGci (ORCPT ); Tue, 31 May 2016 02:32:38 -0400 Received: by mail-pf0-f196.google.com with SMTP id b124so24261978pfb.0; Mon, 30 May 2016 23:32:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=mwemgw7QBGI2U+bBzqdwKgJOWoXGpuwlLV2R/pTGy+g=; b=NARakIYNMYH6VTDmFHAk7vlVbwrWkzbaDfT6hjmaYh3ez0jpQzC1QFNm4w4kIMyCSH o5bPaUiYGjOl6QmTdaNKchsLImB80n3Jkw0IsTrEMTFzun7CLGZhox0Nxb+X7G1W5aEW nar4dQzvMOr5cpvQ0HWpAF7c0nowi/qO2clkkWiJIu+nf1MB9muhXA6XdFIpRHh/Dkg4 4m6XyTls6AJBwCNEi4xp06BJmLwba9/acpvCans03xKX/Ai0lguuYGXFgL19nSu3+nvT p6rT9yQhnt7xISMUh3i4j3XQ8c55jj41sQsxpCa74WvDb/l7lqIA2ER+B6JLS2mE8TSN Sn/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=mwemgw7QBGI2U+bBzqdwKgJOWoXGpuwlLV2R/pTGy+g=; b=C8uzdAtpK4FdIcNyOQsTt7UV16w3778h88xPNr27Ty+t9oOvCoEo2Ojb52lqz9yzIi ytDYH5tdnqgmWTs3kiKoMlVK6biZnc3StjHNiqlnFNQauQKn+JKB18T1BM76FQ/RfQdC jBJcNzppQlO8J6jhcYRPQx0rj9su2c0s5IJnNz4G2WOb0BOj45W4mMcqnQfh3QzvkGlk P0OoMgRtKpZ8EauGBfjIx4vApeYh8VmS5AEweFzHO4eILVX0dj+vQQJov/MtECX1bQg7 ZQGnlF1S7s5OZw57BigBE9XgpuS4TSH+krqB+dKBGE9iD0wD+zHEWUt3G2daeaRvRzoX dnpQ== X-Gm-Message-State: ALyK8tJABvfCygjMEz+qDT6RhVDKqqP4qXBftWC4Vhxokd5ioLo7oFI7luuTfXxwdbE/3A== X-Received: by 10.98.14.147 with SMTP id 19mr52304771pfo.36.1464676352801; Mon, 30 May 2016 23:32:32 -0700 (PDT) Received: from localhost ([2601:b00:c501:3660:7256:81ff:febd:926d]) by smtp.gmail.com with ESMTPSA id t77sm37213433pfa.71.2016.05.30.23.32.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 May 2016 23:32:32 -0700 (PDT) From: Eduardo Valentin To: Rui Zhang Cc: Linux PM , LKML , Eduardo Valentin Subject: [PATCH 15/15] thermal: sysfs: add comments describing locking strategy Date: Mon, 30 May 2016 23:31:36 -0700 Message-Id: <1464676296-5610-16-git-send-email-edubezval@gmail.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1464676296-5610-1-git-send-email-edubezval@gmail.com> References: <1464676296-5610-1-git-send-email-edubezval@gmail.com> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The locking strategy of sysfs entries in thermal subsystem is to hold a lock to serialize access to struct thermal_zone_device and struct thermal_cooling_device data. Besides, the respective locks will also be held if calls to ops need to be done to fetch data or to trigger driver actions. The exception of the locking strategy are functions called during initialization of cdev and tz. Cc: Zhang Rui Cc: linux-pm@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Eduardo Valentin --- drivers/thermal/thermal_sysfs.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/drivers/thermal/thermal_sysfs.c b/drivers/thermal/thermal_sysfs.c index 31314be..743df50 100644 --- a/drivers/thermal/thermal_sysfs.c +++ b/drivers/thermal/thermal_sysfs.c @@ -23,7 +23,14 @@ #include "thermal_core.h" -/* sys I/F for thermal zone */ +/* + * sys I/F for thermal zone + * + * Note on locking. The sysfs interface will always first + * lock the zone to serialize data access and ops calls. + * All calls to thermal_core and thermal_helpers are assumed + * to handle locking properly. + */ static ssize_t type_show(struct device *dev, struct device_attribute *attr, char *buf) @@ -555,6 +562,9 @@ static const struct attribute_group *thermal_zone_attribute_groups[] = { * helper function to instantiate sysfs entries for every trip * point and its properties of a struct thermal_zone_device. * + * This function is assumed to be called only during probe, + * and therefore no locking in the thermal zone device is done. + * * Return: 0 on success, the proper error value otherwise. */ static int create_trip_attrs(struct thermal_zone_device *tz, int mask) @@ -770,6 +780,10 @@ static const struct attribute_group *cooling_device_attr_groups[] = { NULL, }; +/* + * Assumed to be called at the creation of the cooling device + * and for this reason, no locking is done + */ void thermal_cooling_device_setup_sysfs(struct thermal_cooling_device *cdev) { cdev->device.groups = cooling_device_attr_groups;