Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3765791imu; Tue, 18 Dec 2018 03:56:33 -0800 (PST) X-Google-Smtp-Source: AFSGD/WBgVbaSAh7uDE1A5YeROPOBNglO8D6p/38TQQ/VRD5KeLn+8aOZ2A0HFjaWAyVH8BlW6Yq X-Received: by 2002:a17:902:2aaa:: with SMTP id j39mr16560194plb.335.1545134192955; Tue, 18 Dec 2018 03:56:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545134192; cv=none; d=google.com; s=arc-20160816; b=PV0siGevn8onyuWk2R6ofs1NCi13DguXxzuS16fDyq55OTAXay9w4vs9+rBP9S7heQ /9ecFhZLYnQk8D0ogfFCblmp9EROf8Do+f5w0bjYZR0eMfsYP6m3zGoMb1XIRq3wJzhp qxjCCq7/FwECHz0ZD3GfGERtRFbl53Vj9kmtODaXJ8PEOFdCqCR3m1xFCzOIUCiAmsQN ODpkn8WvVxPWltVV2vl9pA41mOVTXbHN7fhTODypCL2bdFFRpUEzjubEFZ54mH2A2Z7a qtEiD3cm/GG+f+bLMzTzOv1l1CKDx57atGcS0BpPUHxjQEFOpqoTJIvIpA0yWjGwZctA WtzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=mU4UBYgCjkb6XraI/BZfL8VEXjzHaubB0pTaEcFYDu0=; b=ja+XoSmFguUPkCY2Aw6+pN05u42FPax4tQpc3SXNfv4O5LJgXSu6mBl8aZdxq/8s0P 2FaRgVX2tdWSmc5VV+//EfNQr4UcvHrD0OtljtBjy/EjHo8xZkNEMD0Izq3x+19L614L an/gj5dyIG7XivUzSw7TF7ZFzwhlYRbg/Q9WJUp/ERNziPQw+wPCh23W6SfK7pwqrAJK 4qhx0eMELOpRHARw4K4Hv4xXbc2//wDII0Sm7hME0l5DfYhW7Y/59evvGiKwSpsMYZ6b WyB9eOwafGsPHxJ1Yml2YveOTS5iAKgslewDiLsuct3Qdnthx5sTMfldpx68SKHCoVNy K9qg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NRHOJ4YZ; 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 101si13879559pld.22.2018.12.18.03.56.17; Tue, 18 Dec 2018 03:56:32 -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; dkim=pass header.i=@linaro.org header.s=google header.b=NRHOJ4YZ; 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 S1726715AbeLRLyK (ORCPT + 99 others); Tue, 18 Dec 2018 06:54:10 -0500 Received: from mail-ua1-f66.google.com ([209.85.222.66]:43824 "EHLO mail-ua1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726672AbeLRLyF (ORCPT ); Tue, 18 Dec 2018 06:54:05 -0500 Received: by mail-ua1-f66.google.com with SMTP id z11so5590448uaa.10 for ; Tue, 18 Dec 2018 03:54:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=mU4UBYgCjkb6XraI/BZfL8VEXjzHaubB0pTaEcFYDu0=; b=NRHOJ4YZzaOVZTO6CTq1b2fkn9TAyEN50NB/vSGGY4dRpyJp5CpxZpi4PAcsDsT7pg 85Ok1IecZVIWGINIh2RkLD/XVZ4b86rEXFoBjcfW4z5v6Rc2nTW7QryzXH6iPDPaspTF Jj4pj4WUnBKw3RorIKw99hhVPQW1NRSDbxxno= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=mU4UBYgCjkb6XraI/BZfL8VEXjzHaubB0pTaEcFYDu0=; b=NVuHLcAvSpV2nQbhkrD0nDuF5GTvqONdfAQPxcM/E7OqnO/XElXcPD6b1r+4qwsW/1 A3uHlopwLyrL6Ot7oR91c6NDwpltqAjJTQFjoJEisBGbtgk8Pjqj2y+CRmP78wB3Eoap QZ1/dCWYaIOzYKGVJdC0zJZTTYdIQok8eGuYGbU+FK7pxoG+tgsRZIR9QPqkEfLpHLNc N58+/AzD4Tp7BhvNLoEahSXZw+MSrNmz23ZOOzqaW+Ii331I9pEYk0qnVV/ilCqphnAY +rRx7TM0ZP8yx3q2tNDoILGjnSXJ1XoIV01r4CCMRlxUN2grvT+SXgCghfkGzNiWvp3X vdYQ== X-Gm-Message-State: AA+aEWZEURk5VvGBuRV0Udvpio61hhPX6Gf5r+IqfJOlUBxCY9vFImK8 BT9kyxBqOszqdQyvz6lawSA7cwI/NU1q5Ci46CuamSu9 X-Received: by 2002:ab0:526:: with SMTP id 35mr8012867uax.25.1545134044074; Tue, 18 Dec 2018 03:54:04 -0800 (PST) MIME-Version: 1.0 References: <20181129174700.16585-1-ulf.hansson@linaro.org> <20181129174700.16585-2-ulf.hansson@linaro.org> <81caa4b6-d0ac-f351-2ecf-47fb0f7dcc74@linaro.org> In-Reply-To: <81caa4b6-d0ac-f351-2ecf-47fb0f7dcc74@linaro.org> From: Ulf Hansson Date: Tue, 18 Dec 2018 12:53:28 +0100 Message-ID: Subject: Re: [PATCH v10 01/27] PM / Domains: Add generic data pointer to genpd_power_state struct To: Daniel Lezcano Cc: "Rafael J . Wysocki" , 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 Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. > > Patch 18/27 can fill this field with its specific free pointer. Yep! [...] Thanks for reviewing! Kind regards Uffe