From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.3 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7E54AC4CEC4 for ; Thu, 19 Sep 2019 00:20:22 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 51DF2218AE for ; Thu, 19 Sep 2019 00:20:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="PdR3O0YE"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="J0Do6o5A" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 51DF2218AE Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=zjG4lFJe3+HXohkutSRkrPlmnIxRfvddc1K4UbFGZR0=; b=PdR3O0YE6prjKu jpzDuOfcNtlzcyJJLq28kKkd7u/kYCLSykPXcytAflvbsfIoM9Q2wM1J5+kCF3xlSSQrgdMPaMias /SHKpM9Jp/fO7a9zGW+yYIYoei0yx5W/F4D++wUk2CYU5EOrhM+0wfgYgj21rwEj7rSwrtA1gaiEt BEqARkhLnVzKFYVd8jZD10r1Z5wT5CtVoym6dCtpAARdsyZpNpnY4CWwQ9pP49bXv7t6p7X+p/hxe JXAK5gMem6VnUsMfN4YHvIvcK2gwUF2bGIiwdiNI9tFYzohYGNtpww3zSnX/lA04VwQvHilwK0MsB bpULzx12QklxLlZ97W7Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.2 #3 (Red Hat Linux)) id 1iAkBJ-0001RW-KI; Thu, 19 Sep 2019 00:20:21 +0000 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]) by bombadil.infradead.org with esmtps (Exim 4.92.2 #3 (Red Hat Linux)) id 1iAkBG-0001QH-CK for linux-arm-kernel@lists.infradead.org; Thu, 19 Sep 2019 00:20:19 +0000 Received: by mail-pg1-x542.google.com with SMTP id z12so789298pgp.9 for ; Wed, 18 Sep 2019 17:20:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=tHO8idxYvCXO7Xl0b0Brpx8nnJ3dAZiCIzv0ysrkpR8=; b=J0Do6o5AerwDtZyl8dLc9miEApIwpFWAOanu8xKsifMz54iwBW/mgpw+1gwHLYcYhb GfIBEIxKedStctxiR2NJ+SRy5b/TDIbRGkDJV9aMApwkXSq8rUwJJlnrm7Cs9dl6FfEE CpXtOy7mw+Gop6f/TGdPWDRX0OAHy3Ib5A/Qg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=tHO8idxYvCXO7Xl0b0Brpx8nnJ3dAZiCIzv0ysrkpR8=; b=YhBfiVLyOHaxSVR3OSwRErD2jtOpg47HxoBPIdWclpGvMV7JBym3G7y5DOqHhemtW0 w6VRDpkaz5rqAxJsLlHRcmWNgW8IZujBcMoHHsND3FfkdvOHdDhRKS6Fqx6naaDat4Xd HQI+w0UR77wAWc+VxVPkD+lZsh3LyTWeqeED0Gwfo6el9ysJxwb52HYe4g64RG+ASH8Y 2Cn60eq7Pv2s229r5VmrVYaulykwBBqUbZLFnjswvLI+YW7r0kH2p1gDGnecJ7fnSva6 lCcH6EjhkFv5qYJYGiZBfKNFZv/gA/zeN/yige50x0jp7ZA6y2JDEXkmsvlO0AwtFOtQ 4XkQ== X-Gm-Message-State: APjAAAUid+i+Jmy9xwbzoQrPUH6Y7kzyt6TwFVtgXskF5uJ1NE4p06g0 5WAez9c0OixEVHLO9PZFtkCjXA== X-Google-Smtp-Source: APXvYqxQXGfAj7Tm6yt4FaTaG/b5TVZyScNcObutnzEEg2k7jmyKhq+EBKSb/IemFBLdTCyPk6sZrA== X-Received: by 2002:a63:4857:: with SMTP id x23mr6593458pgk.142.1568852417268; Wed, 18 Sep 2019 17:20:17 -0700 (PDT) Received: from localhost ([2620:15c:202:1:75a:3f6e:21d:9374]) by smtp.gmail.com with ESMTPSA id 1sm7888373pff.39.2019.09.18.17.20.15 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 18 Sep 2019 17:20:15 -0700 (PDT) Date: Wed, 18 Sep 2019 17:20:13 -0700 From: Matthias Kaehlcke To: Leonard Crestez Subject: Re: [PATCH 4/8] PM / devfreq: Don't take lock in devfreq_add_device Message-ID: <20190919002013.GR133864@google.com> References: <2fe8d1000bed5de70b08ed77fc8360d159ae4434.1568764439.git.leonard.crestez@nxp.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <2fe8d1000bed5de70b08ed77fc8360d159ae4434.1568764439.git.leonard.crestez@nxp.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190918_172018_448970_FFCF6752 X-CRM114-Status: GOOD ( 14.95 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Artur =?utf-8?B?xZp3aWdvxYQ=?= , Abel Vesa , Saravana Kannan , linux-pm@vger.kernel.org, Viresh Kumar , Krzysztof Kozlowski , Chanwoo Choi , Kyungmin Park , MyungJoo Ham , Alexandre Bailon , Georgi Djakov , linux-arm-kernel@lists.infradead.org, Jacky Bai Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, Sep 18, 2019 at 03:18:23AM +0300, Leonard Crestez wrote: > A device usually doesn't need to lock itself during initialization > because it is not yet reachable from other threads. > > This simplifies the code and helps avoid recursive lock warnings. > > Signed-off-by: Leonard Crestez > --- > drivers/devfreq/devfreq.c | 10 ---------- > 1 file changed, 10 deletions(-) > > diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c > index 57a217fc92de..860cbbab476c 100644 > --- a/drivers/devfreq/devfreq.c > +++ b/drivers/devfreq/devfreq.c > @@ -634,11 +634,10 @@ struct devfreq *devfreq_add_device(struct device *dev, > err = -ENOMEM; > goto err_out; > } > > mutex_init(&devfreq->lock); > - mutex_lock(&devfreq->lock); > devfreq->dev.parent = dev; > devfreq->dev.class = devfreq_class; > devfreq->dev.release = devfreq_dev_release; > INIT_LIST_HEAD(&devfreq->node); > devfreq->profile = profile; > @@ -647,28 +646,24 @@ struct devfreq *devfreq_add_device(struct device *dev, > devfreq->last_status.current_frequency = profile->initial_freq; > devfreq->data = data; > devfreq->nb.notifier_call = devfreq_notifier_call; > > if (!devfreq->profile->max_state && !devfreq->profile->freq_table) { > - mutex_unlock(&devfreq->lock); > err = set_freq_table(devfreq); > if (err < 0) > goto err_dev; > - mutex_lock(&devfreq->lock); > } > > devfreq->scaling_min_freq = find_available_min_freq(devfreq); > if (!devfreq->scaling_min_freq) { > - mutex_unlock(&devfreq->lock); > err = -EINVAL; > goto err_dev; > } > devfreq->min_freq = devfreq->scaling_min_freq; > > devfreq->scaling_max_freq = find_available_max_freq(devfreq); > if (!devfreq->scaling_max_freq) { > - mutex_unlock(&devfreq->lock); > err = -EINVAL; > goto err_dev; > } > devfreq->max_freq = devfreq->scaling_max_freq; > > @@ -679,20 +674,18 @@ struct devfreq *devfreq_add_device(struct device *dev, > array3_size(sizeof(unsigned int), > devfreq->profile->max_state, > devfreq->profile->max_state), > GFP_KERNEL); > if (!devfreq->trans_table) { > - mutex_unlock(&devfreq->lock); > err = -ENOMEM; > goto err_dev; > } > > devfreq->time_in_state = kcalloc(devfreq->profile->max_state, > sizeof(unsigned long), > GFP_KERNEL); > if (!devfreq->time_in_state) { > - mutex_unlock(&devfreq->lock); > err = -ENOMEM; > goto err_dev; > } > > devfreq->last_stat_updated = jiffies; > @@ -701,17 +694,14 @@ struct devfreq *devfreq_add_device(struct device *dev, > > dev_set_name(&devfreq->dev, "devfreq%d", > atomic_inc_return(&devfreq_no)); > err = device_register(&devfreq->dev); > if (err) { > - mutex_unlock(&devfreq->lock); > put_device(&devfreq->dev); > goto err_out; > } > > - mutex_unlock(&devfreq->lock); > - > mutex_lock(&devfreq_list_lock); > > governor = try_then_request_governor(devfreq->governor_name); > if (IS_ERR(governor)) { > dev_err(dev, "%s: Unable to find governor for the device\n", Reviewed-by: Matthias Kaehlcke _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel