From: Michael Bode <michael@bumbleB.de>
To: Jyri Sarha <jsarha@ti.com>, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] drm/tilcdc: Allocate register storage based on the actual number registers
Date: Fri, 03 Jul 2015 23:10:47 +0200 [thread overview]
Message-ID: <5596FA57.8070400@bumbleB.de> (raw)
In-Reply-To: <1435920328-22822-1-git-send-email-jsarha@ti.com>
[-- Attachment #1.1: Type: text/plain, Size: 2831 bytes --]
Reviewed-By: Michael Bode <michael@bumbleB.de>
Jyri,
good idea to allocate the space for registers dynamically.
This eliminates the need of synchronizing driver and header file in an
elegant way.
Only thing I personally don't like, is potentially passing a NULL
pointer to kfree.
But I learned that this is valid kernel code.
Br,
Michael
On 07/03/2015 12:45 PM, Jyri Sarha wrote:
> Allocate suspend/resume register storage based on the actual number
> registers the driver is aware of. The static allocation for register
> storage had falen behind badly.
>
> Reported-by: Michael Bode <michael@bumbleB.de>
> Signed-off-by: Jyri Sarha <jsarha@ti.com>
> ---
> drivers/gpu/drm/tilcdc/tilcdc_drv.c | 20 +++++++++++++++++++-
> drivers/gpu/drm/tilcdc/tilcdc_drv.h | 2 +-
> 2 files changed, 20 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.c b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
> index 4908c1f..2f87263 100644
> --- a/drivers/gpu/drm/tilcdc/tilcdc_drv.c
> +++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
> @@ -139,11 +139,14 @@ static int tilcdc_unload(struct drm_device *dev)
>
> pm_runtime_disable(dev->dev);
>
> + kfree(priv->saved_register);
> kfree(priv);
>
> return 0;
> }
>
> +static size_t tilcdc_num_regs(void);
> +
> static int tilcdc_load(struct drm_device *dev, unsigned long flags)
> {
> struct platform_device *pdev = dev->platformdev;
> @@ -155,7 +158,11 @@ static int tilcdc_load(struct drm_device *dev, unsigned long flags)
> int ret;
>
> priv = kzalloc(sizeof(*priv), GFP_KERNEL);
> - if (!priv) {
> + if (priv)
> + priv->saved_register = kcalloc(sizeof(*priv->saved_register),
> + tilcdc_num_regs(), GFP_KERNEL);
> + if (!priv || !priv->saved_register) {
> + kfree(priv);
> dev_err(dev->dev, "failed to allocate private data\n");
> return -ENOMEM;
> }
> @@ -345,6 +352,7 @@ fail_free_wq:
>
> fail_free_priv:
> dev->dev_private = NULL;
> + kfree(priv->saved_register);
> kfree(priv);
> return ret;
> }
> @@ -467,6 +475,16 @@ static const struct {
> REG(2, true, LCDC_INT_ENABLE_SET_REG),
> #undef REG
> };
> +
> +static size_t tilcdc_num_regs(void)
> +{
> + return ARRAY_SIZE(registers);
> +}
> +#else
> +static size_t tilcdc_num_regs(void)
> +{
> + return 0;
> +}
> #endif
>
> #ifdef CONFIG_DEBUG_FS
> diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.h b/drivers/gpu/drm/tilcdc/tilcdc_drv.h
> index e863ad0..bc94835 100644
> --- a/drivers/gpu/drm/tilcdc/tilcdc_drv.h
> +++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.h
> @@ -67,7 +67,7 @@ struct tilcdc_drm_private {
> uint32_t max_width;
>
> /* register contents saved across suspend/resume: */
> - u32 saved_register[12];
> + u32 *saved_register;
>
> #ifdef CONFIG_CPU_FREQ
> struct notifier_block freq_transition;
[-- Attachment #1.2: Type: text/html, Size: 3594 bytes --]
[-- Attachment #2: Type: text/plain, Size: 159 bytes --]
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel
prev parent reply other threads:[~2015-07-03 21:10 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-03 10:45 [PATCH] drm/tilcdc: Allocate register storage based on the actual number registers Jyri Sarha
2015-07-03 21:10 ` Michael Bode [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5596FA57.8070400@bumbleB.de \
--to=michael@bumbleb.de \
--cc=dri-devel@lists.freedesktop.org \
--cc=jsarha@ti.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox