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 9D18332ED5C for ; Thu, 11 Jun 2026 15:49:25 +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=1781192968; cv=none; b=VAPZDl+T+GHWZgSrQHTr+oE97Nhq+3jO8inLUdNHHqBF2MfQAebGQ8YJDILtXQ3DaRYuwgv+v0xXnJYYBrvKatLDtkQxk5pU1WUr2CqeJRc3LUTW60MGmOTVzn8oRtKFnEll7+g9NdOjgVjI5Qp614LYE/ldEzo5rcdw7kCgMuE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781192968; c=relaxed/simple; bh=AAOh/RJo7nNSkQR8BQ9V87bX6Y+TZZtett4JP3LpdgA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=j+2JQJ3V/eGYVysYO/6AkxkMLMf/2XEbcG/J2D6SGeVUDgcw0+E6LVMRsTRkS0IMQY8t36JXwGk6Uj4yw8EdEwAZnrVX1TKUCw/suvQBoVoKqJHyW2hd3YQ2Qc7CD36cimX5n/220G8trkfS+aa9oO7Lh32izcGQ8flkvNkkFsw= 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; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b=NYAw8l/b; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="NYAw8l/b" 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 F2FD72D97 for ; Thu, 11 Jun 2026 08:49:19 -0700 (PDT) Received: from [192.168.0.1] (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 832CC3FB90 for ; Thu, 11 Jun 2026 08:49:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1781192964; bh=AAOh/RJo7nNSkQR8BQ9V87bX6Y+TZZtett4JP3LpdgA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=NYAw8l/b2+wnGjdJrty6CYlUO+PW4bbG+t5j/SdpitOBletH5rfP5Jb/iA+MGPyp3 1rLvI4YLQKcb5ej6ZDOXGgqWzO920qi88jvTIO9LKPX0kkcB7woT1yi4Im6iuptuC7 qzURZe1Kh/LpuUCVbt3CrDGxebtC/ou04E5DPYjs= Date: Thu, 11 Jun 2026 16:49:15 +0100 From: Liviu Dudau To: Gustavo Kenji =?utf-8?B?TWVuZG9uw6dh?= Kaneko Cc: dri-devel@lists.freedesktop.org, maarten.lankhorst@linux.intel.com, mripard@kernel.org, tzimmermann@suse.de, airlied@gmail.com, simona@ffwll.ch, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] drm/arm/malidp: use clk_bulk API in runtime PM resume and suspend Message-ID: References: <20260609130812.1065699-1-kaneko.dev@pm.me> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20260609130812.1065699-1-kaneko.dev@pm.me> On Tue, Jun 09, 2026 at 01:08:19PM +0000, Gustavo Kenji Mendonça Kaneko wrote: > malidp_runtime_pm_resume() calls clk_prepare_enable() three times > without checking the return value. If any clock fails to enable, the > driver silently proceeds with unclocked hardware, leading to undefined > behavior. > > Convert both the resume and suspend paths to use the clk_bulk API: > clk_bulk_prepare_enable() in resume checks the return value and rolls > back any successfully enabled clocks on failure; > clk_bulk_disable_unprepare() in suspend keeps the two paths symmetric. > > This issue was found by code review without access to Mali DP hardware. > > Signed-off-by: Gustavo Kenji Mendonça Kaneko Reviewed-by: Liviu Dudau Best regards, Liviu > --- > Changes in v2: > - Also convert malidp_runtime_pm_suspend() to clk_bulk_disable_unprepare() > to make both paths truly symmetric (Liviu Dudau) > - Drop the incorrect claim about existing clk_bulk usage in the suspend > path from the commit message (Liviu Dudau) > > drivers/gpu/drm/arm/malidp_drv.c | 22 ++++++++++++++++------ > 1 file changed, 16 insertions(+), 6 deletions(-) > > diff --git a/drivers/gpu/drm/arm/malidp_drv.c b/drivers/gpu/drm/arm/malidp_drv.c > index b765f6c9eea4..90e7f14aacec 100644 > --- a/drivers/gpu/drm/arm/malidp_drv.c > +++ b/drivers/gpu/drm/arm/malidp_drv.c > @@ -670,6 +670,11 @@ static int malidp_runtime_pm_suspend(struct device *dev) > struct drm_device *drm = dev_get_drvdata(dev); > struct malidp_drm *malidp = drm_to_malidp(drm); > struct malidp_hw_device *hwdev = malidp->dev; > + struct clk_bulk_data clks[] = { > + { .clk = hwdev->pclk }, > + { .clk = hwdev->aclk }, > + { .clk = hwdev->mclk }, > + }; > > /* we can only suspend if the hardware is in config mode */ > WARN_ON(!hwdev->hw->in_config_mode(hwdev)); > @@ -677,9 +682,7 @@ static int malidp_runtime_pm_suspend(struct device *dev) > malidp_se_irq_fini(hwdev); > malidp_de_irq_fini(hwdev); > hwdev->pm_suspended = true; > - clk_disable_unprepare(hwdev->mclk); > - clk_disable_unprepare(hwdev->aclk); > - clk_disable_unprepare(hwdev->pclk); > + clk_bulk_disable_unprepare(ARRAY_SIZE(clks), clks); > > return 0; > } > @@ -689,10 +692,17 @@ static int malidp_runtime_pm_resume(struct device *dev) > struct drm_device *drm = dev_get_drvdata(dev); > struct malidp_drm *malidp = drm_to_malidp(drm); > struct malidp_hw_device *hwdev = malidp->dev; > + struct clk_bulk_data clks[] = { > + { .clk = hwdev->pclk }, > + { .clk = hwdev->aclk }, > + { .clk = hwdev->mclk }, > + }; > + int err; > + > + err = clk_bulk_prepare_enable(ARRAY_SIZE(clks), clks); > + if (err) > + return err; > > - clk_prepare_enable(hwdev->pclk); > - clk_prepare_enable(hwdev->aclk); > - clk_prepare_enable(hwdev->mclk); > hwdev->pm_suspended = false; > malidp_de_irq_hw_init(hwdev); > malidp_se_irq_hw_init(hwdev); > -- > 2.54.0 > > -- ==================== | I would like to | | fix the world, | | but they're not | | giving me the | \ source code! / --------------- ¯\_(ツ)_/¯