Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp443023imu; Fri, 11 Jan 2019 03:14:02 -0800 (PST) X-Google-Smtp-Source: ALg8bN78Fh+BWULVjOEkmfOUi1qIkKKVv2+xtkcftLth/VRTGsIOa8LKrNQyNIFpZy7JyRYeNwIv X-Received: by 2002:a17:902:5a86:: with SMTP id r6mr13724261pli.301.1547205242830; Fri, 11 Jan 2019 03:14:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547205242; cv=none; d=google.com; s=arc-20160816; b=yJLzUFjjGo4S0fNhx8qFV/Jvww+xNJR8yXkCbjRt2AUgs5pfKZ0OBUM08As0OfmdhF R/Lhdqnr98o1HV4tDHe7A73SIJwRhp4ui9aaclKd+rNcbgcHeVTkSSR2CLlShcN2bPsU Xb2h/KuwAcqFfxNjU8QxzuR9xPJX36Iij8lWUxecHHdOocUms1PybopazH+FmcqoJxKD Ka1fKkHkS0QI7yo1uC7b0YXxExb8wBtxYKqN1p0i4U94w1Wa7ZKxxT7bW/WR+QSD4kt4 csPI7gu5LvguLwBwuWGn6FcsV3vdTq1CojzI2WfSqb8RPPtk/waR/hcKZSOhOLhnYV36 u5qQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=YNNc+I//fGgGHf2/DmMQQgUxOSVY/t7jXXQDjNkMK2o=; b=AAlhHF42QHC1cR3kAjxCtyxH/KUNFxI9i1vpdH/MJmQieZDGY4EaWoEaQE6sU/8LSx MyEA+W53LkM505/w+sbFbHcCIEKqiy3jn3gq/duV2puEzwJlTCVHqAIJ3rsBP1trAhBQ LULNAG8QtLjLCafJdopJ0AwIxnDc+gpYvutYDem/lXiif064LKHQz2U7Nvs7EZ1ZAoV+ 0qB9IFKlcw8ZdrQLOd1tSGqXFe/r+/nMqPByKlCNj4o0M1kAPuhTsDbjPa63w5xDk839 uOYoJX1dSEnkuuHvj0mQjC8OPkA86zv3YaBsnlJ3lRdE8HserMBt0SHYBYzBLNbSIyl5 8Arg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m35si59851364pgb.246.2019.01.11.03.13.46; Fri, 11 Jan 2019 03:14:02 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731953AbfAKKxl (ORCPT + 99 others); Fri, 11 Jan 2019 05:53:41 -0500 Received: from cloudserver094114.home.pl ([79.96.170.134]:64250 "EHLO cloudserver094114.home.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725789AbfAKKxl (ORCPT ); Fri, 11 Jan 2019 05:53:41 -0500 Received: from 79.184.254.168.ipv4.supernova.orange.pl (79.184.254.168) (HELO aspire.rjw.lan) by serwer1319399.home.pl (79.96.170.134) with SMTP (IdeaSmtpServer 0.83.183) id 0b5c9bc25c66d993; Fri, 11 Jan 2019 11:53:39 +0100 From: "Rafael J. Wysocki" To: Ulf Hansson Cc: Daniel Lezcano , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , Linux PM , "Raju P . L . S . S . S . N" , Stephen Boyd , Tony Lindgren , Kevin Hilman , Lina Iyer , Viresh Kumar , Vincent Guittot , Geert Uytterhoeven , Linux ARM , linux-arm-msm , Linux Kernel Mailing List Subject: Re: [PATCH v10 01/27] PM / Domains: Add generic data pointer to genpd_power_state struct Date: Fri, 11 Jan 2019 11:52:52 +0100 Message-ID: <5682777.oKQsr9mDaT@aspire.rjw.lan> In-Reply-To: References: <20181129174700.16585-1-ulf.hansson@linaro.org> <81caa4b6-d0ac-f351-2ecf-47fb0f7dcc74@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tuesday, December 18, 2018 12:53:28 PM CET Ulf Hansson wrote: > On Tue, 18 Dec 2018 at 11:39, Daniel Lezcano wrote: > > > > On 29/11/2018 18:46, Ulf Hansson wrote: > > > Let's add a data pointer to the genpd_power_state struct, to allow a genpd > > > backend driver to store per state specific data. In order to introduce the > > > pointer, we also need to adopt how genpd frees the allocated data for the > > > default genpd_power_state struct, that it may allocate at pm_genpd_init(). > > > > > > More precisely, let's use an internal genpd flag to understand when the > > > states needs to be freed by genpd. When freeing the states data in > > > genpd_remove(), let's also clear the corresponding genpd->states pointer > > > and reset the genpd->state_count. In this way, a genpd backend driver > > > becomes aware of when there is state specific data for it to free. > > > > > > Cc: Lina Iyer > > > Co-developed-by: Lina Iyer > > > Signed-off-by: Ulf Hansson > > > --- > > > > > > Changes in v10: > > > - Update the patch allow backend drivers to free the states specific > > > data during genpd removal. Due to this added complexity, I decided to > > > keep the patch separate, rather than fold it into the patch that makes > > > use of the new void pointer, which was suggested by Rafael. > > > - Claim authorship of the patch as lots of changes has been done since > > > the original pick up from Lina Iyer. > > > > > > --- > > > drivers/base/power/domain.c | 8 ++++++-- > > > include/linux/pm_domain.h | 3 ++- > > > 2 files changed, 8 insertions(+), 3 deletions(-) > > > > > > diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c > > > index 7f38a92b444a..e27b91d36a2a 100644 > > > --- a/drivers/base/power/domain.c > > > +++ b/drivers/base/power/domain.c > > > @@ -1620,7 +1620,7 @@ static int genpd_set_default_power_state(struct generic_pm_domain *genpd) > > > > > > genpd->states = state; > > > genpd->state_count = 1; > > > - genpd->free = state; > > > + genpd->free_state = true; > > > > > > return 0; > > > } > > > @@ -1736,7 +1736,11 @@ static int genpd_remove(struct generic_pm_domain *genpd) > > > list_del(&genpd->gpd_list_node); > > > genpd_unlock(genpd); > > > cancel_work_sync(&genpd->power_off_work); > > > - kfree(genpd->free); > > > + if (genpd->free_state) { > > > + kfree(genpd->states); > > > + genpd->states = NULL; > > > + genpd->state_count = 0; > > > > Why these two initializations? After genpd_remove, this structure > > shouldn't be used anymore, no ? > > Correct. > > > > > > + } > > > > Instead of a flag, replacing the 'free' pointer to a 'free' callback > > will allow to keep the free path self-encapsulated in domain.c > > > > genpd->free(genpd->states); > > Right, I get your idea and it makes sense. Let me convert to that. OK, so I'm expecting an update here.