From patchwork Tue Apr 24 22:35:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 134203 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp121308lji; Tue, 24 Apr 2018 15:37:13 -0700 (PDT) X-Google-Smtp-Source: AIpwx49o/Yaa5rDt+Lhk+nDsudvrjQja8hm22Hn49TJbiAZflOOe7PbY7VP6KGwiYCbs6U/bE+H2 X-Received: by 2002:a17:902:b081:: with SMTP id p1-v6mr27306709plr.31.1524609432864; Tue, 24 Apr 2018 15:37:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524609432; cv=none; d=google.com; s=arc-20160816; b=xfZPLtEA0+4RcOHFn/UbriNoszPODlZzqFJ6Uh4dhwrIG4BFnkHXGcI7+FlfbAqOJ4 mxwPu+43ZkQ95XLL/Mq8/iqDeGtJGSkElsNbIUedt1gk7Vjko6oed6GM9lciollZbfWR fkkHwuZW68fRlDC6hQgMzhY9tRV/6GZx0AYh8pJ5zDB7w101fHog4A8tbBA3ojVK43K7 FtZlwyqz7QInp0OOYKqT3g+c8K8oK46CCX5vZMOKF3XnCNrapr3zwVWbLAwXgwiPwr+t ul3u+ALJE1zzp0i91XP4oYN10yJDUkpLl5+LipwfZhubKagvJu4ZXnXjeMOVkKNvVAGe QIIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=ymXyPh0uVSbIWiHrga/nZV/9JPCTRUyA32ovWL0SySg=; b=Iu7mzxxZZ/unWGZ2Z3k83AZBd/tRQk3l1bEHDC+755PC8QOdSARQzGAKAV4xTlRr/w 5lEsHyDPK7BuHp77lM0swOkvcXtHPH24jk70l6O4oKqJokqypDxz1FeWStgz8VUVK5VM I6yt1FjN23OolrEgs5ByNU9k+JXCY0W7aBiatDX6EKE/20GYLWJPzMfmbVRb728pABxr FSdzVGyrMAnCVK58Ke0RvuZXgqnVemDuLoQFu8wHCwoJpSs+YjpkeuWG5yvnBjXOJrU7 DH35+0u0/Qal73gux4+LZuagnfYrZR19OhN7/bzjaNiwgzAgV0CnuY+QmxZOcWPCVxhb rGYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Ikh2lJJ6; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p12si329007pgv.503.2018.04.24.15.37.12; Tue, 24 Apr 2018 15:37:12 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Ikh2lJJ6; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751588AbeDXWhJ (ORCPT + 29 others); Tue, 24 Apr 2018 18:37:09 -0400 Received: from mail-pf0-f193.google.com ([209.85.192.193]:45901 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751161AbeDXWf0 (ORCPT ); Tue, 24 Apr 2018 18:35:26 -0400 Received: by mail-pf0-f193.google.com with SMTP id l27so13451318pfk.12 for ; Tue, 24 Apr 2018 15:35:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ymXyPh0uVSbIWiHrga/nZV/9JPCTRUyA32ovWL0SySg=; b=Ikh2lJJ6epAjmZ6X6xBYTQC6KEuxODuRzHATZEslUwjsyHHhZtc0kFq0L8DWD21KxQ o1nAb2Fsn02OdpHBztxyhMfmbxGGXunl+GTpAEuvNZG88qPpa2E5MhU+V68Eg+Dhvs38 eemh2WRdobjp8iWnZ3xIX5nWeW6QKYdgBXHD0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ymXyPh0uVSbIWiHrga/nZV/9JPCTRUyA32ovWL0SySg=; b=QSdQSzv+8W7uqR73QubD9niMkwRrENovIFcrOKE+Tpt2wbHZLdWKWB0FBEX96JF3nJ B9rTRyWq9sSF9xzRfF67Y6zzibbc2UbjMt+Ckau2Px2ez6vM0BfQvCQRE0fjSrJ1OLfo bP6TqFA6yGjrF/WBUWEyEM0NnN0T9/v3ZCX6qrGXbq+sMGyOpUphhVBvK2hPEBNWCOMF g6YwAEgpL7rOlzzLZ040YsNaVsZo71cD0v2X+pvFFVNN+oN59GPJeW9+Ufty1/ehEGoH xT/pl2nzdM2Lxl4S07H/QRCZQlz1ZNQVaClS7Vd+KlPcgxmaEksAj85vmuXXMIWOJizz QWzw== X-Gm-Message-State: ALQs6tBGowI2QE6+hMDAA69eQmEUBZDKzDgx0zqSJ6aAgg2tErvna7LV ndFUD1mYAxNumJBiEeM7Z+3kZQ== X-Received: by 10.98.156.7 with SMTP id f7mr25575948pfe.104.1524609325846; Tue, 24 Apr 2018 15:35:25 -0700 (PDT) Received: from localhost.localdomain (104-188-17-28.lightspeed.sndgca.sbcglobal.net. [104.188.17.28]) by smtp.gmail.com with ESMTPSA id w26sm35856621pfi.17.2018.04.24.15.35.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Apr 2018 15:35:25 -0700 (PDT) From: Bjorn Andersson To: MyungJoo Ham , Kyungmin Park , Chanwoo Choi Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/6] PM / devfreq: Free devfreq upon set_freq_table error Date: Tue, 24 Apr 2018 15:35:16 -0700 Message-Id: <20180424223521.28193-2-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180424223521.28193-1-bjorn.andersson@linaro.org> References: <20180424223521.28193-1-bjorn.andersson@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When set_freq_table() fails we must still free the previously allocated devfreq context, so jump to the correct label for this. Also when this happens devfreq will always be non-NULL, so drop the unnecessary conditional. Also destroy the devfreq mutex as we're cleaning up the devfreq object. Signed-off-by: Bjorn Andersson --- drivers/devfreq/devfreq.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) -- 2.16.2 diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c index 2067cd229ce3..30a672397ff0 100644 --- a/drivers/devfreq/devfreq.c +++ b/drivers/devfreq/devfreq.c @@ -597,7 +597,7 @@ struct devfreq *devfreq_add_device(struct device *dev, mutex_unlock(&devfreq->lock); err = set_freq_table(devfreq); if (err < 0) - goto err_out; + goto err_dev; mutex_lock(&devfreq->lock); } @@ -669,8 +669,8 @@ struct devfreq *devfreq_add_device(struct device *dev, device_unregister(&devfreq->dev); err_dev: - if (devfreq) - kfree(devfreq); + mutex_destroy(&devfreq->lock); + kfree(devfreq); err_out: return ERR_PTR(err); } From patchwork Tue Apr 24 22:35:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 134201 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp120332lji; Tue, 24 Apr 2018 15:36:00 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+6dxJ+scpeDBJhW4OauoFAOANPefZUcM5gqdHoNQGGviQVLVI+hx9l1y42MMiojmlmEtDU X-Received: by 10.101.92.134 with SMTP id a6mr6173081pgt.273.1524609360095; Tue, 24 Apr 2018 15:36:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524609360; cv=none; d=google.com; s=arc-20160816; b=rGe4akad+V/cWb79QiahA0jvvgJQTmeoE+JUap/rTka91byGV2SV41Yf8GzXUzhWcv UWZ1qIeLxJombF1oXWQZWUmlipBvotZwNr2QTT99zAHWX4fYBUkY0am5eBsHrYAtuvu7 JhtXM/LMcnyUjLkjEDmadMMIztBb1hAJ/VZvkCdQkKRhmLZb7R3EJCHNnVfwtZARAfBd nVjxaeyjpvexby8cemTO56iIZprMC1JFN3pzEBeUcWIPQ6m19RpocrjLfwTYIF2pt0b6 W5Ow6rR6NmOQcsAXokWJE8Da0cePq3aPoxvec2LTDWs8eSP0j/27FqrB50tc2P0/+5WK Q2RQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=dCVCBP4Fi4hvlrP/9WWWKbOXx90UzgpZRfevYYm1Z3c=; b=n92ppDx9cLcsAEFZMBr6WFiYUCCdjFLRPq/2BHetI1skD3vIJ4V0aBiQ/BnvlBETDP zksfrAnrC7u5b7GNaloJWW09PclPI5YWxH0KVOz/1r87iUkyOMLyPpUDwrBwK0rSDWRI qZTdZo00fqNDMPTe5pMka7poiSpbkKvmH2TNw4GpfERswC1ymqKl0ku/E47eionP6caN F6HG4ntqRLYMfamB+IBvjKUQGDdJ882g/XJi0/7EfSje1jSZHVpuZnQhA64mjmXXQCMN k5aKnTe7gHaPte60jidXd+j2nxooyns3KEYLEpExRtRoCNXqhh7/J9P81auJYW9fWofT qp6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MCuUZiq1; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v29si9213576pgo.483.2018.04.24.15.35.59; Tue, 24 Apr 2018 15:36:00 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MCuUZiq1; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751365AbeDXWf6 (ORCPT + 29 others); Tue, 24 Apr 2018 18:35:58 -0400 Received: from mail-pf0-f194.google.com ([209.85.192.194]:33323 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751255AbeDXWfb (ORCPT ); Tue, 24 Apr 2018 18:35:31 -0400 Received: by mail-pf0-f194.google.com with SMTP id f15so13463678pfn.0 for ; Tue, 24 Apr 2018 15:35:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=dCVCBP4Fi4hvlrP/9WWWKbOXx90UzgpZRfevYYm1Z3c=; b=MCuUZiq1zOCMaYBFJ7guY3VV0VQxe8U6eXevD7Nk0tGMTn+R/C7A2A+bql124GHFEV Dr7HvWwAudbiHt20UvCrCl8VBGvwodK5+4lyfEEOGw0yOQ+MZAZQQ2HoqneoyymgUYCa Mf9B8gzq5bYSvJruWzBiGRy+sOYP8ERCsC/uw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=dCVCBP4Fi4hvlrP/9WWWKbOXx90UzgpZRfevYYm1Z3c=; b=Rvs23FglcaQ12XxhspBFYvVes+VbAR7Adu388+o1Yk3XrrvJ5yZBEIyipYsTDaBNYF obSR0lW3bqAml5Qrtp3oZ8jsUfb0EX5pQRGQRgR4V3/iz3v93h1hMskZFC8vp3BH55ct mXjkk6/y+e/1wKnY1VrY7hBlTail9dQ11RGSCBdvZFCyB+1BtIjK13dyCim9GFdVuzJP 90wMZlGtKYr6czqF1GcE0di7suaapdNSz1YfEC7uBPUfGI5OSDrlv4pe1l4JVb3wQ79q /LiLqMQ0EaT0IgAxPMwc9QifPSCr5o7jlAUvpSAHWkgNKU0YVt1OS3nk6YBnCzhRmC6Y oqpg== X-Gm-Message-State: ALQs6tCV1yznBbJeMSgCIsf0FDUqLeqTRjSz9RDvRO+sf16t3wo1nOfq fK0GlU9STDifdXwyRwUGbYPwVQ== X-Received: by 10.101.70.141 with SMTP id h13mr21820259pgr.166.1524609331091; Tue, 24 Apr 2018 15:35:31 -0700 (PDT) Received: from localhost.localdomain (104-188-17-28.lightspeed.sndgca.sbcglobal.net. [104.188.17.28]) by smtp.gmail.com with ESMTPSA id w26sm35856621pfi.17.2018.04.24.15.35.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Apr 2018 15:35:30 -0700 (PDT) From: Bjorn Andersson To: MyungJoo Ham , Kyungmin Park , Chanwoo Choi Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 6/6] PM / devfreq: Reject client provided freq_table Date: Tue, 24 Apr 2018 15:35:21 -0700 Message-Id: <20180424223521.28193-7-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180424223521.28193-1-bjorn.andersson@linaro.org> References: <20180424223521.28193-1-bjorn.andersson@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The devfreq profile's freq_table is an internal resource used to keep track of all levels described in the associated opp table, in order to support levels being enabled and disabled in runtime by e.g. devfreq_cooling. As it is required by the implementation that the device has an associated opp table and expected that the freq_table matches this, it is not possible for clients to provide a freq_table through the devfreq profile. Check for this in devfreq_add_device() and remove the unnecessary conditional generation of the internal freq_table. Signed-off-by: Bjorn Andersson --- drivers/devfreq/devfreq.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) -- 2.16.2 diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c index c804bd72a644..3d1f6a2edf68 100644 --- a/drivers/devfreq/devfreq.c +++ b/drivers/devfreq/devfreq.c @@ -557,7 +557,7 @@ struct devfreq *devfreq_add_device(struct device *dev, static atomic_t devfreq_no = ATOMIC_INIT(-1); int err = 0; - if (!dev || !profile || !governor_name) { + if (!dev || !profile || !governor_name || profile->freq_table) { dev_err(dev, "%s: Invalid parameters.\n", __func__); return ERR_PTR(-EINVAL); } @@ -590,11 +590,9 @@ struct devfreq *devfreq_add_device(struct device *dev, devfreq->data = data; devfreq->nb.notifier_call = devfreq_notifier_call; - if (!devfreq->profile->max_state && !devfreq->profile->freq_table) { - err = set_freq_table(devfreq); - if (err < 0) - goto err_dev; - } + err = set_freq_table(devfreq); + if (err < 0) + goto err_dev; devfreq->min_freq = find_available_min_freq(devfreq); if (!devfreq->min_freq) {