From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 711A35C99; Tue, 26 Mar 2024 10:51:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711450279; cv=none; b=u0InjfrMX1CUOdoVzHnyxKjsynupVZB+NzfYIe/w6zHWUgLIJWMDvReKoWvQGUHKP+M3DCfUK34BGPdvadTUzbsu6KXv1uuckzIBPetl4A1ptUgQ94iiZlLk3VfwRASUroJFDrbTJZ3lM23ChsA2UU15eCOc4ltt6zCShqbAFKM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711450279; c=relaxed/simple; bh=OI7JQ835ZCR5Y7ozOfvQut7gIaPuGOPU6h6L2IuhnbY=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=IT3sbMmYXTJPHHp2xXI595sgEutFketBQT/GBaPLQY7vgi+pWbpVgFVaDEE/2McvblxDwxkoFusKTstksPJ74vXcYrE2iHNUD7jcAy1hbriO8HQU+hAsadJDduzvlYfA/W5qUoGORgoVCNjgxBgZP3xRkDrAFEBXbDMyxbQqowY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 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 55CA22F4; Tue, 26 Mar 2024 03:51:50 -0700 (PDT) Received: from [192.168.178.6] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C88923F64C; Tue, 26 Mar 2024 03:51:14 -0700 (PDT) Message-ID: Date: Tue, 26 Mar 2024 11:51:09 +0100 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: [RESEND][PATCH v2 2/4] PM: EM: Change the em_adjust_new_capacity() to re-use code Content-Language: en-US To: Lukasz Luba , linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, sboyd@kernel.org, nm@ti.com, linux-samsung-soc@vger.kernel.org, daniel.lezcano@linaro.org, rafael@kernel.org, viresh.kumar@linaro.org, krzysztof.kozlowski@linaro.org, alim.akhtar@samsung.com, m.szyprowski@samsung.com, mhiramat@kernel.org References: <20240322110850.77086-1-lukasz.luba@arm.com> <20240322110850.77086-3-lukasz.luba@arm.com> From: Dietmar Eggemann In-Reply-To: <20240322110850.77086-3-lukasz.luba@arm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 22/03/2024 12:08, Lukasz Luba wrote: Maybe better : "PM: EM: Refactoring em_adjust_new_capacity()" ? > There is going to be a new update function addressing chip binning. > Therefore, some common code which can be refactored and called from > upcoming changes and em_adjust_new_capacity(). In this way the code > duplication can be avoided. IMHO, that's hard to digest. Extract em_table_dup() and em_recalc_and_update() from em_adjust_new_capacity(). Both functions will be later reused by the 'update EM due to chip binning' functionality. [...] > +static int em_recalc_and_update(struct device *dev, struct em_perf_domain *pd, > + struct em_perf_table __rcu *em_table) > +{ > + int ret; > + > + ret = em_compute_costs(dev, em_table->state, NULL, pd->nr_perf_states, > pd->flags); > - if (ret) { > - dev_warn(dev, "EM: compute costs failed\n"); > - return; > - } > + if (ret) > + goto free_em_table; There seems to be a subtle change in this patch. When em_compute_costs() fails now em_table_free() is called. This wasn't the case before when em_compute_costs() was directly called from em_adjust_new_capacity(). [...]