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.4 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham 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 72F8CC4CEC4 for ; Wed, 18 Sep 2019 21:41:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3A0F921925 for ; Wed, 18 Sep 2019 21:41:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="XTmEYrvs" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387523AbfIRVlP (ORCPT ); Wed, 18 Sep 2019 17:41:15 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:34567 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387521AbfIRVlP (ORCPT ); Wed, 18 Sep 2019 17:41:15 -0400 Received: by mail-pg1-f196.google.com with SMTP id n9so616957pgc.1 for ; Wed, 18 Sep 2019 14:41:15 -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=pIZyn+G+bA7XtEVOcWB74dsFb9Insi2abCRrDc2HQeE=; b=XTmEYrvsMQthzUKL3yBYx8caiWqf/wT7Mr0lti3P3Za6WgWm/KTDYD7Zu4T/3PSV6c 6Pj2pf3uecVmf0b1+RV6odqfUtL0q9gYfJISIKf/RTlROVHtyef4GgYwh4ySp10lwyrF 4RgLTcieZkkdZIUrlF98yG0jD43EUE/+n2i80= 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=pIZyn+G+bA7XtEVOcWB74dsFb9Insi2abCRrDc2HQeE=; b=S/X9lhqL1hk4tHX69ajdZNhE9sjVjC5xdMK7i8oL6MPt2eE7ewyT5mAVpnzimKdap8 UzeMmX92Zqv8Ac9EJU9KJzNSFLtTR5rRNbUCFzReCxCxiYM5EhsnhHJ675w/RCK0abA+ 8C681ntix0TT0QobY7DZKgi7/5AT2iHq11IE3yKikIbkx169HbH7kiBoYYMbiQx3GNxA jHTDqsUoqxe10/p6xpzTOgS/AsXbk82xKh4l6kb9E1vRGGCjUmUmZrKHQD57iHC4v4Di mPy3eccs0QBiXIUDJySdIbNJ1n8RY3Mm0316hpifXNR+kNycxSh4iak6uMYOqr8l9kZo s6rA== X-Gm-Message-State: APjAAAVRjLoloCEqV+CPWLk1aTCgE2fiH2nSuz+1lPXiiLcIg2brYBY+ FLAD2ZHl60Tty8kATqTCYucXvQ== X-Google-Smtp-Source: APXvYqw5kQ6N+iHQn1rHpL/B5Vq2EZxlSiSCFgV/INYo3Ec4YEO5FWuja1lQ6g05sCXgKtq/2YOszQ== X-Received: by 2002:a63:b954:: with SMTP id v20mr5995525pgo.140.1568842874736; Wed, 18 Sep 2019 14:41:14 -0700 (PDT) Received: from localhost ([2620:15c:202:1:75a:3f6e:21d:9374]) by smtp.gmail.com with ESMTPSA id k95sm3616293pje.10.2019.09.18.14.41.13 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 18 Sep 2019 14:41:14 -0700 (PDT) Date: Wed, 18 Sep 2019 14:41:11 -0700 From: Matthias Kaehlcke To: Leonard Crestez Cc: MyungJoo Ham , Kyungmin Park , Chanwoo Choi , Artur =?utf-8?B?xZp3aWdvxYQ=?= , Saravana Kannan , Krzysztof Kozlowski , Alexandre Bailon , Georgi Djakov , Abel Vesa , Jacky Bai , Viresh Kumar , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH 2/8] PM / devfreq: Don't fail devfreq_dev_release if not in list Message-ID: <20190918214111.GO133864@google.com> References: <60f8aa909fe209632734b6c637dffbc7554f996c.1568764439.git.leonard.crestez@nxp.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <60f8aa909fe209632734b6c637dffbc7554f996c.1568764439.git.leonard.crestez@nxp.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org On Wed, Sep 18, 2019 at 03:18:21AM +0300, Leonard Crestez wrote: > Right now devfreq_dev_release will print a warning and abort the rest of > the cleanup if the devfreq instance is not part of the global > devfreq_list. But this is a valid scenario, for example it can happen if > the governor can't be found or on any other init error that happens > after device_register. > > Initialize devfreq->node to an empty list head in devfreq_add_device so > that list_del becomes a safe noop inside devfreq_dev_release and we can > continue the rest of the cleanup. > > Signed-off-by: Leonard Crestez > --- > drivers/devfreq/devfreq.c | 6 +----- > 1 file changed, 1 insertion(+), 5 deletions(-) > > diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c > index 665575228c4f..a715f27f35fd 100644 > --- a/drivers/devfreq/devfreq.c > +++ b/drivers/devfreq/devfreq.c > @@ -582,15 +582,10 @@ static int devfreq_notifier_call(struct notifier_block *nb, unsigned long type, > static void devfreq_dev_release(struct device *dev) > { > struct devfreq *devfreq = to_devfreq(dev); > > mutex_lock(&devfreq_list_lock); > - if (IS_ERR(find_device_devfreq(devfreq->dev.parent))) { > - mutex_unlock(&devfreq_list_lock); > - dev_warn(&devfreq->dev, "releasing devfreq which doesn't exist\n"); > - return; > - } > list_del(&devfreq->node); > mutex_unlock(&devfreq_list_lock); > > if (devfreq->profile->exit) > devfreq->profile->exit(devfreq->dev.parent); > @@ -641,10 +636,11 @@ struct devfreq *devfreq_add_device(struct device *dev, > 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; > strncpy(devfreq->governor_name, governor_name, DEVFREQ_NAME_LEN); > devfreq->previous_freq = profile->initial_freq; > devfreq->last_status.current_frequency = profile->initial_freq; > devfreq->data = data; Reviewed-by: Matthias Kaehlcke 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 C7CE9C4CEC9 for ; Wed, 18 Sep 2019 21:41:24 +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 9638621924 for ; Wed, 18 Sep 2019 21:41:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="KH8na1Hm"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="XTmEYrvs" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9638621924 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=DcaPBjBA4bxsllV/O9pstcE3usoG+TQpC8TvcNRIMWs=; b=KH8na1HmLtCeSK M4mJk+TWYD6t1L2tv2b579bl/xfgikX1nSASL/yheDo7UoFvyGH1elQzGaIlwTRNnB98iaVh5d5gz RGGmM+kFzJ5tkgJmg6FplMdfarnvK8NOJo1X5Vm94KEqbEcApBcF9L9l4KNd6PioGXGuDNMl6v2EH NoZnnnXlWZPx2nV9LNnuEGpRB3MlxkoFVAzHTPj4XwDPvFMOAP6OWmbqF3nZ0EYZ2cqblid6g4xNg Q6NR3eKYKgXN7oqNXNLxDKKa/J5zsQTzz/zQV/iJwFlDPgKPyXg2OUwRPqv5VW+dqEWykgTKBxa3v 0mlo3cswxzxTPxhl8UjQ==; 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 1iAhhP-0001wQ-2c; Wed, 18 Sep 2019 21:41:19 +0000 Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]) by bombadil.infradead.org with esmtps (Exim 4.92.2 #3 (Red Hat Linux)) id 1iAhhL-0001w2-J8 for linux-arm-kernel@lists.infradead.org; Wed, 18 Sep 2019 21:41:16 +0000 Received: by mail-pf1-x443.google.com with SMTP id q10so865980pfl.0 for ; Wed, 18 Sep 2019 14:41:15 -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=pIZyn+G+bA7XtEVOcWB74dsFb9Insi2abCRrDc2HQeE=; b=XTmEYrvsMQthzUKL3yBYx8caiWqf/wT7Mr0lti3P3Za6WgWm/KTDYD7Zu4T/3PSV6c 6Pj2pf3uecVmf0b1+RV6odqfUtL0q9gYfJISIKf/RTlROVHtyef4GgYwh4ySp10lwyrF 4RgLTcieZkkdZIUrlF98yG0jD43EUE/+n2i80= 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=pIZyn+G+bA7XtEVOcWB74dsFb9Insi2abCRrDc2HQeE=; b=VfdXbKF0U7+wBMpDBnDkvg8fY6dwAMWOtFICK7NUfFcYT/QTibSa0i8QsDJmPQe/we +s/bJoJDwpNC+pSnP/8Tvf2/hPxwMJFB/uiIiR6fxAUCiLhKpXiZppZAkdy+SeurLTgZ Iju7F7LffMqbZelfx5sQRN/ZWeSKE1ZX8C4irjQa1vqII5u2N0bcSnGmAhGWZ9xRSUFd jjo0pXMaPf1kWT5USHqTXn5dxlSuBmeBv35J09O8+qee7NAn6ao0tqvu86OEvWEyLavZ Z9FDjnC/PX11hx7G6eQ2vu8swR4LwYVZxzia0rrF9a6Eq7MiZNT+nHwwD77i16whIlBe lF/A== X-Gm-Message-State: APjAAAXTL8O6CBJan+fr9h2wlIKMiVbxHY7SrbbUf059bTTvCYRkQ0vH jwG85bDIr1lavYnK1boASBU9Yg== X-Google-Smtp-Source: APXvYqw5kQ6N+iHQn1rHpL/B5Vq2EZxlSiSCFgV/INYo3Ec4YEO5FWuja1lQ6g05sCXgKtq/2YOszQ== X-Received: by 2002:a63:b954:: with SMTP id v20mr5995525pgo.140.1568842874736; Wed, 18 Sep 2019 14:41:14 -0700 (PDT) Received: from localhost ([2620:15c:202:1:75a:3f6e:21d:9374]) by smtp.gmail.com with ESMTPSA id k95sm3616293pje.10.2019.09.18.14.41.13 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 18 Sep 2019 14:41:14 -0700 (PDT) Date: Wed, 18 Sep 2019 14:41:11 -0700 From: Matthias Kaehlcke To: Leonard Crestez Subject: Re: [PATCH 2/8] PM / devfreq: Don't fail devfreq_dev_release if not in list Message-ID: <20190918214111.GO133864@google.com> References: <60f8aa909fe209632734b6c637dffbc7554f996c.1568764439.git.leonard.crestez@nxp.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <60f8aa909fe209632734b6c637dffbc7554f996c.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_144115_657754_A3227305 X-CRM114-Status: GOOD ( 19.36 ) 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:21AM +0300, Leonard Crestez wrote: > Right now devfreq_dev_release will print a warning and abort the rest of > the cleanup if the devfreq instance is not part of the global > devfreq_list. But this is a valid scenario, for example it can happen if > the governor can't be found or on any other init error that happens > after device_register. > > Initialize devfreq->node to an empty list head in devfreq_add_device so > that list_del becomes a safe noop inside devfreq_dev_release and we can > continue the rest of the cleanup. > > Signed-off-by: Leonard Crestez > --- > drivers/devfreq/devfreq.c | 6 +----- > 1 file changed, 1 insertion(+), 5 deletions(-) > > diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c > index 665575228c4f..a715f27f35fd 100644 > --- a/drivers/devfreq/devfreq.c > +++ b/drivers/devfreq/devfreq.c > @@ -582,15 +582,10 @@ static int devfreq_notifier_call(struct notifier_block *nb, unsigned long type, > static void devfreq_dev_release(struct device *dev) > { > struct devfreq *devfreq = to_devfreq(dev); > > mutex_lock(&devfreq_list_lock); > - if (IS_ERR(find_device_devfreq(devfreq->dev.parent))) { > - mutex_unlock(&devfreq_list_lock); > - dev_warn(&devfreq->dev, "releasing devfreq which doesn't exist\n"); > - return; > - } > list_del(&devfreq->node); > mutex_unlock(&devfreq_list_lock); > > if (devfreq->profile->exit) > devfreq->profile->exit(devfreq->dev.parent); > @@ -641,10 +636,11 @@ struct devfreq *devfreq_add_device(struct device *dev, > 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; > strncpy(devfreq->governor_name, governor_name, DEVFREQ_NAME_LEN); > devfreq->previous_freq = profile->initial_freq; > devfreq->last_status.current_frequency = profile->initial_freq; > devfreq->data = data; Reviewed-by: Matthias Kaehlcke _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel