Received: by 2002:a05:7412:8598:b0:f9:33c2:5753 with SMTP id n24csp490522rdh; Tue, 19 Dec 2023 05:18:37 -0800 (PST) X-Google-Smtp-Source: AGHT+IEXp9yekbm8NCppgaYDSua4doCkOUYI5q44XcVZvv/kzMau3LqmO9S6OtvJhnOrsxOV5CfJ X-Received: by 2002:a05:6a20:7f97:b0:191:8955:ce4c with SMTP id d23-20020a056a207f9700b001918955ce4cmr1422607pzj.60.1702991916884; Tue, 19 Dec 2023 05:18:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702991916; cv=none; d=google.com; s=arc-20160816; b=njxvcSj9L1PqyD9QmFCbM9kGxblc/LdG0zT6Tdks0xJ8Aj9bMLreIFgEH0aO0Fz8Fy Hgw46r/RmeqPxF+1s6u6q0P1mxvVhR7U97d0whVvFRNcF6Or4sS2JF4BuqaHei5SBzm4 ydeDAWHWe05f6YOaXUU6IFoXLGbxvN5l973NxR9OY0Ip+wZNgsaMvWv/DUZM+aVxbRVo rgWhSRwfuAxWV159k0F9UQbveRwMB9cnsE3zU4ugRl1QiOGEEB3IRapHFxdpSelQp4ot vvJde1jcVmNGZW7t8fNGTMK1bFOlY22fp7saSXW4uljxiH62pxmuaRZ8oAuhvDPlrT3o q0nQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=ZP/o9NaZwtOMn7Kmjqr6jKqMOgM+eG8tN+FB/YPt7vs=; fh=Z7Bswg0wipPI13DHQPOpxFL/nWO9PLk4OlFtC952Nd8=; b=j+oTA371wIxzr8nETfkl/GyLWIEzQCEpjW9HKvGovdUu0BHeSwIwnDVMUnqe1kqxN9 J92SqqspxPURw4OpndmgfM3ZbjItBZTSAM9uTR1kIvzj6bpHHW+z/vmmG5xM3WDMTUGW 2UGNRjca9CKvnSfWBtZWGfhavX6L5n+ZV4btOHjcIwstTHbTEMlo1Kbne3nbGJgSB4Xa +yNC/zxQzSEMC9c21Um0wtWf5tgjFMI+1KOZu4bHMZk8WexDQOeUJ3UX6cQOH/Cu3C5e VC5yoP/aD29QS21VJfXB+ELadiEpw+H65MUc+0Ilg6f3esHWPVBoZDmNMA0ZO2hgGt3J cksA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-5246-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5246-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id g19-20020a62e313000000b006d6c7ef990fsi3902737pfh.94.2023.12.19.05.18.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 05:18:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-5246-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-5246-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5246-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 8962A283165 for ; Tue, 19 Dec 2023 13:18:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0B3FE18E25; Tue, 19 Dec 2023 13:18:31 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2438C18E1D; Tue, 19 Dec 2023 13:18:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 9109B1FB; Tue, 19 Dec 2023 05:19:11 -0800 (PST) Received: from [10.57.85.227] (unknown [10.57.85.227]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 08D163F5A1; Tue, 19 Dec 2023 05:18:24 -0800 (PST) Message-ID: <00f6f550-0f60-4f62-a301-2af94c68b7f8@arm.com> Date: Tue, 19 Dec 2023 13:19:30 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v5 07/23] PM: EM: Refactor how the EM table is allocated and populated Content-Language: en-US To: Dietmar Eggemann Cc: rui.zhang@intel.com, amit.kucheria@verdurent.com, linux-kernel@vger.kernel.org, amit.kachhap@gmail.com, daniel.lezcano@linaro.org, viresh.kumar@linaro.org, len.brown@intel.com, pavel@ucw.cz, mhiramat@kernel.org, qyousef@layalina.io, wvw@google.com, linux-pm@vger.kernel.org, rafael@kernel.org References: <20231129110853.94344-1-lukasz.luba@arm.com> <20231129110853.94344-8-lukasz.luba@arm.com> From: Lukasz Luba In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 12/12/23 18:50, Dietmar Eggemann wrote: > On 29/11/2023 12:08, Lukasz Luba wrote: >> Split the process of allocation and data initialization for the EM table. >> The upcoming changes for modifiable EM will use it. >> >> This change is not expected to alter the general functionality. > > NIT: IMHO, I guess you wanted to say: "No functional changes > introduced"? I.e. all not only general functionality ... > Yes 'no functional changes'. Rafael gave me that sense once - and I use in such cases. > [...] > >> static int em_create_pd(struct device *dev, int nr_states, >> @@ -234,11 +234,15 @@ static int em_create_pd(struct device *dev, int nr_states, >> return -ENOMEM; >> } >> >> - ret = em_create_perf_table(dev, pd, nr_states, cb, flags); >> - if (ret) { >> - kfree(pd); >> - return ret; >> - } >> + pd->nr_perf_states = nr_states; > > Why does `pd->nr_perf_states = nr_states;` have to move from > em_create_perf_table() to em_create_pd()? Because I have split the old code which did allocation and initialization w/ data the in em_create_perf_table(). Now we are going to have separate: 1. allocation of a new table (which can be re-used later) 2. initialization of the data (power, freq, etc) in registration code path It will allow to also allow to introduce update data function, and simply use the same allocation function for both cases: - EM registration code path - update EM code path > >> + >> + ret = em_allocate_perf_table(pd, nr_states); >> + if (ret) >> + goto free_pd; >> + >> + ret = em_create_perf_table(dev, pd, pd->table, nr_states, cb, flags); > > If you set it in em_create_pd() then you can use 'pd->nr_perf_states' in > em_create_perf_table() and doesn't have to pass `nr_states`. > > [...] That's true. I could further refactor that function and remove that 'nr_states' argument. I'll do this in v6. Thanks!