From nobody Sun Dec 14 06:19:58 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7310DC00140 for ; Mon, 15 Aug 2022 18:44:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243430AbiHOSoJ (ORCPT ); Mon, 15 Aug 2022 14:44:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243799AbiHOSlY (ORCPT ); Mon, 15 Aug 2022 14:41:24 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC2562657; Mon, 15 Aug 2022 11:25:02 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id E646ACE125C; Mon, 15 Aug 2022 18:25:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EA1C6C433D6; Mon, 15 Aug 2022 18:24:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660587899; bh=XAE+/OLaoY0GXqpevQP/rGZXBm8MGtL2ZRz1sE5nkBk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LgS+1Q14uEfCUrlF67lidyvpe/f7bYe8iErpqbfuJeIzQCwnO5K/rgZ/UgFYRZNb2 c8ylAps7RxUYe0dMciKcJktztwtjVufrj4hchhroOPWg1d2EhQm0hJW6VgX3Rlp8je uwQZ81T+ceqZa6IFKcjh2lOvA+qM21LTs5S2M9mI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Thierry Reding , Sasha Levin Subject: [PATCH 5.15 231/779] pwm: lpc18xx-sct: Reduce number of devm memory allocations Date: Mon, 15 Aug 2022 19:57:55 +0200 Message-Id: <20220815180347.162000913@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180337.130757997@linuxfoundation.org> References: <20220815180337.130757997@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Uwe Kleine-K=C3=B6nig [ Upstream commit 20d9de9c4d6642bb40c935233697723b56573cbc ] Each devm allocations has an overhead of 24 bytes to store the related struct devres_node additionally to the fragmentation of the allocator. So allocating 16 struct lpc18xx_pwm_data (which only hold a single int) adds quite some overhead. Instead put the per-channel data into the driver data struct and allocate it in one go. Signed-off-by: Uwe Kleine-K=C3=B6nig Signed-off-by: Thierry Reding Signed-off-by: Sasha Levin --- drivers/pwm/pwm-lpc18xx-sct.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/pwm/pwm-lpc18xx-sct.c b/drivers/pwm/pwm-lpc18xx-sct.c index 8cc8ae16553c..6cf02554066c 100644 --- a/drivers/pwm/pwm-lpc18xx-sct.c +++ b/drivers/pwm/pwm-lpc18xx-sct.c @@ -76,6 +76,8 @@ #define LPC18XX_PWM_EVENT_PERIOD 0 #define LPC18XX_PWM_EVENT_MAX 16 =20 +#define LPC18XX_NUM_PWMS 16 + /* SCT conflict resolution */ enum lpc18xx_pwm_res_action { LPC18XX_PWM_RES_NONE, @@ -101,6 +103,7 @@ struct lpc18xx_pwm_chip { unsigned long event_map; struct mutex res_lock; struct mutex period_lock; + struct lpc18xx_pwm_data channeldata[LPC18XX_NUM_PWMS]; }; =20 static inline struct lpc18xx_pwm_chip * @@ -370,7 +373,7 @@ static int lpc18xx_pwm_probe(struct platform_device *pd= ev) =20 lpc18xx_pwm->chip.dev =3D &pdev->dev; lpc18xx_pwm->chip.ops =3D &lpc18xx_pwm_ops; - lpc18xx_pwm->chip.npwm =3D 16; + lpc18xx_pwm->chip.npwm =3D LPC18XX_NUM_PWMS; =20 /* SCT counter must be in unify (32 bit) mode */ lpc18xx_pwm_writel(lpc18xx_pwm, LPC18XX_PWM_CONFIG, @@ -400,12 +403,7 @@ static int lpc18xx_pwm_probe(struct platform_device *p= dev) =20 pwm =3D &lpc18xx_pwm->chip.pwms[i]; =20 - data =3D devm_kzalloc(lpc18xx_pwm->dev, sizeof(*data), - GFP_KERNEL); - if (!data) { - ret =3D -ENOMEM; - goto disable_pwmclk; - } + data =3D &lpc18xx_pwm->channeldata[i]; =20 pwm_set_chip_data(pwm, data); } --=20 2.35.1