dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Lubomir Rintel <lkundrak@v3.sk>
To: Russell King <rmk+kernel@armlinux.org.uk>
Cc: devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 2/3] drm/armada: add OF reserved memory support
Date: Tue, 18 Dec 2018 16:18:58 +0100	[thread overview]
Message-ID: <77130e281e078315d346d54b731c578c68f2ff04.camel@v3.sk> (raw)
In-Reply-To: <E1fcpoh-0003Z2-BB@rmk-PC.armlinux.org.uk>

On Tue, 2018-07-10 at 11:24 +0100, Russell King wrote:
> Existing Armada DRM makes use of reserved memory for allocating
> contiguous screen buffers, which currently prevents its use with
> DT systems.  Add support for this for DT systems.
> 
> Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
> ---
>  drivers/gpu/drm/armada/Makefile      |  3 +++
>  drivers/gpu/drm/armada/armada_drv.c  | 24 ++++++++++++++++--
>  drivers/gpu/drm/armada/armada_rmem.c | 49
> ++++++++++++++++++++++++++++++++++++
>  3 files changed, 74 insertions(+), 2 deletions(-)
>  create mode 100644 drivers/gpu/drm/armada/armada_rmem.c
> 
> diff --git a/drivers/gpu/drm/armada/Makefile
> b/drivers/gpu/drm/armada/Makefile
> index ecf25cf9f9f5..0b8bf3b8aa6a 100644
> --- a/drivers/gpu/drm/armada/Makefile
> +++ b/drivers/gpu/drm/armada/Makefile
> @@ -5,3 +5,6 @@ armada-y	+= armada_510.o
>  armada-$(CONFIG_DEBUG_FS) += armada_debugfs.o
>  
>  obj-$(CONFIG_DRM_ARMADA) := armada.o
> +
> +armada-rmem-$(CONFIG_DRM_ARMADA) += armada_rmem.o
> +obj-y += $(armada-rmem-y) $(armada-rmem-m)
> diff --git a/drivers/gpu/drm/armada/armada_drv.c
> b/drivers/gpu/drm/armada/armada_drv.c
> index 217f0590fd61..a9ee492a2810 100644
> --- a/drivers/gpu/drm/armada/armada_drv.c
> +++ b/drivers/gpu/drm/armada/armada_drv.c
> @@ -9,6 +9,7 @@
>  #include <linux/component.h>
>  #include <linux/module.h>
>  #include <linux/of_graph.h>
> +#include <linux/of_reserved_mem.h>
>  #include <drm/drm_crtc_helper.h>
>  #include <drm/drm_fb_helper.h>
>  #include <drm/drm_of.h>
> @@ -96,6 +97,9 @@ static int armada_drm_bind(struct device *dev)
>  			return -EINVAL;
>  	}
>  
> +	if (!mem && dev->of_node)
> +		mem = dev->platform_data;
> +
>  	if (!mem)
>  		return -ENXIO;
>  
> @@ -250,9 +254,17 @@ static int armada_drm_probe(struct
> platform_device *pdev)
>  	struct device *dev = &pdev->dev;
>  	int ret;
>  
> -	ret = drm_of_component_probe(dev, compare_dev_name,
> &armada_master_ops);
> -	if (ret != -EINVAL)
> +	if (dev->of_node) {
> +		ret = of_reserved_mem_device_init(dev);
> +		if (ret && ret != -ENODEV)
> +			return ret;
> +
> +		ret = drm_of_component_probe(dev, compare_of,
> +					     &armada_master_ops);
> +		if (ret)
> +			of_reserved_mem_device_release(dev);
>  		return ret;
> +	}
>  
>  	if (dev->platform_data) {
>  		char **devices = dev->platform_data;
> @@ -287,6 +299,7 @@ static int armada_drm_probe(struct
> platform_device *pdev)
>  static int armada_drm_remove(struct platform_device *pdev)
>  {
>  	component_master_del(&pdev->dev, &armada_master_ops);
> +	of_reserved_mem_device_release(&pdev->dev);
>  	return 0;
>  }
>  
> @@ -300,11 +313,18 @@ static const struct platform_device_id
> armada_drm_platform_ids[] = {
>  };
>  MODULE_DEVICE_TABLE(platform, armada_drm_platform_ids);
>  
> +static const struct of_device_id armada_drm_dt_ids[] = {
> +	{ .compatible = "marvell,dove-display-subsystem", },
> +	{ /* sentinel */ },
> +};
> +MODULE_DEVICE_TABLE(of, armada_drm_dt_ids);
> +
>  static struct platform_driver armada_drm_platform_driver = {
>  	.probe	= armada_drm_probe,
>  	.remove	= armada_drm_remove,
>  	.driver	= {
>  		.name	= "armada-drm",
> +		.of_match_table = armada_drm_dt_ids,
>  	},
>  	.id_table = armada_drm_platform_ids,
>  };
> diff --git a/drivers/gpu/drm/armada/armada_rmem.c
> b/drivers/gpu/drm/armada/armada_rmem.c
> new file mode 100644
> index 000000000000..36bb20e426b6
> --- /dev/null
> +++ b/drivers/gpu/drm/armada/armada_rmem.c
> @@ -0,0 +1,49 @@
> +// SPDX-License-Identifier: GPL-2.0
> +// Copyright (C) 2017 Russell King
> +#include <linux/errno.h>
> +#include <linux/of.h>
> +#include <linux/of_reserved_mem.h>
> +#include <linux/slab.h>
> +
> +static int armada_rmem_dev_init(struct reserved_mem *rmem, struct
> device *dev)
> +{
> +	struct resource *r;
> +
> +	if (dev->platform_data)
> +		return -EBUSY;
> +
> +	r = kzalloc(sizeof(*r), GFP_KERNEL);
> +	if (!r)
> +		return -ENOMEM;
> +
> +	r->start = rmem->base;
> +	r->end = rmem->base + rmem->size - 1;
> +	r->flags = IORESOURCE_MEM;
> +
> +	rmem->priv = r;
> +	dev->platform_data = r;
> +
> +	return 0;
> +}
> +
> +static void armada_rmem_dev_release(struct reserved_mem *rmem,
> +	struct device *dev)
> +{
> +	kfree(rmem->priv);
> +	rmem->priv = NULL;
> +	dev->platform_data = NULL;
> +}
> +
> +static const struct reserved_mem_ops armada_rmem_ops = {
> +	.device_init = armada_rmem_dev_init,
> +	.device_release = armada_rmem_dev_release,
> +};
> +
> +static int __init armada_rmem_init(struct reserved_mem *rmem)
> +{
> +	rmem->ops = &armada_rmem_ops;
> +	return 0;
> +}
> +
> +RESERVEDMEM_OF_DECLARE(armada_rmem, "marvell,dove-framebuffer",
> +			armada_rmem_init);

Hi,

wouldn't "marvell,armada-framebuffer" make more sense here?
The driver will do just well for MMP2 and perhaps more hardware that is
not Dove; the DTs could just say:

compatible = "marvell,dove-framebuffer", "marvell,armada-framebuffer";
compatible = "marvell,mmp2-framebuffer", "marvell,armada-framebuffer";

Lubo

  reply	other threads:[~2018-12-18 15:18 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-10 10:23 [PATCH 0/3] Finish Armada DRM DT support Russell King - ARM Linux
2018-07-10 10:24 ` [PATCH 1/3] drm/armada: fix compare_of() for LCD controllers Russell King
2018-07-10 10:24 ` [PATCH 2/3] drm/armada: add OF reserved memory support Russell King
2018-12-18 15:18   ` Lubomir Rintel [this message]
2018-07-10 10:24 ` [PATCH 3/3] ARM: dts: cubox: add LCD controller and TDA998x configuration Russell King
2018-07-18 14:53   ` Gregory CLEMENT
2018-07-10 10:31 ` [PATCH 00/17] Transition Armada DRM planes to atomic state Russell King - ARM Linux
2018-07-10 10:32   ` [PATCH 01/17] drm/armada: clean up armada_drm_crtc_page_flip() Russell King
2018-07-10 10:32   ` [PATCH 02/17] drm/armada: add rectangle helpers Russell King
2018-07-10 10:32   ` [PATCH 03/17] drm/armada: move mode set vblank handling and disable/enable Russell King
2018-07-10 10:32   ` [PATCH 04/17] drm/armada: use core of primary update_plane for mode set Russell King
2018-07-10 10:32   ` [PATCH 05/17] drm/armada: merge armada_drm_gra_plane_regs() into only caller Russell King
2018-07-10 10:32   ` [PATCH 06/17] drm/armada: reset all atomic state during driver initialisation Russell King
2018-07-10 10:32   ` [PATCH 07/17] drm/armada: convert primary plane to atomic state Russell King
2018-07-10 10:32   ` [PATCH 08/17] drm/armada: convert page_flip to use primary plane atomic_update() Russell King
2018-07-10 10:32   ` [PATCH 09/17] drm/armada: convert overlay plane to atomic state Russell King
2018-07-10 10:33   ` [PATCH 10/17] drm/armada: remove temporary crtc state Russell King
2018-07-10 10:33   ` [PATCH 11/17] drm/armada: use old_state for update tracking in atomic_update() Russell King
2018-07-10 10:33   ` [PATCH 12/17] drm/armada: move primary plane to separate file Russell King
2018-07-10 10:33   ` [PATCH 13/17] drm/armada: move plane works to overlay Russell King
2018-07-10 10:33   ` [PATCH 14/17] drm/armada: move CBSH properties into overlay plane state Russell King
2018-07-10 10:33   ` [PATCH 15/17] drm/armada: move colorkey " Russell King
2018-07-10 10:33   ` [PATCH 16/17] drm/armada: remove crtc YUV colourspace properties Russell King
2018-07-10 10:33   ` [PATCH 17/17] drm/armada: add plane colorspace properties Russell King
2018-07-10 10:40   ` [PATCH 00/20] Finish Armada DRM transition to atomic modeset Russell King - ARM Linux
2018-07-10 10:41     ` [PATCH 01/20] drm/armada: move armada_drm_mode_config_funcs to armada_drv.c Russell King
2018-07-10 10:41     ` [PATCH 02/20] drm/armada: pass plane state into armada_drm_plane_calc_addrs() Russell King
2018-07-10 10:41     ` [PATCH 03/20] drm/armada: provide pitches from armada_drm_plane_calc_addrs() Russell King
2018-07-10 10:41     ` [PATCH 04/20] drm/armada: push interlace calculation into armada_drm_plane_calc() Russell King
2018-07-10 10:41     ` [PATCH 05/20] drm/armada: move sync signal polarity to mode_set_nofb() method Russell King
2018-07-10 10:41     ` [PATCH 06/20] drm/armada: update debug in armada_drm_crtc_mode_set_nofb() Russell King
2018-07-10 10:41     ` [PATCH 07/20] drm/armada: clean up SPU_ADV_REG Russell King
2018-07-10 10:41     ` [PATCH 08/20] drm/armada: handle atomic modeset crtc events Russell King
2018-07-10 10:41     ` [PATCH 09/20] drm/armada: push responsibility for clock management to backend Russell King
2018-07-10 10:42     ` [PATCH 10/20] drm/armada: unhook dpms state from armada_drm_crtc_update() Russell King
2018-07-10 10:42     ` [PATCH 11/20] drm/armada: implement atomic_enable()/atomic_disable() methods Russell King
2018-07-10 10:42     ` [PATCH 12/20] drm/armada: enable atomic modeset support Russell King
2018-07-10 10:42     ` [PATCH 13/20] drm/armada: switch legacy modeset to atomic modeset Russell King
2018-07-10 10:42     ` [PATCH 14/20] drm/armada: switch primary plane " Russell King
2018-07-10 10:42     ` [PATCH 15/20] drm/armada: switch overlay " Russell King
2018-07-10 10:42     ` [PATCH 16/20] drm/armada: update planes after the dumb frame is complete Russell King
2018-07-10 10:42     ` [PATCH 17/20] drm/armada: update primary framebuffer parameters on mode change Russell King
2018-07-10 10:42     ` [PATCH 18/20] drm/armada: remove unnecessary armada_ovl_plane structure Russell King
2018-07-10 10:42     ` [PATCH 19/20] drm/armada: remove unnecessary armada_plane structure Russell King
2018-07-10 10:42     ` [PATCH 20/20] drm/armada: remove obsolete fb unreferencing kfifo and workqueue Russell King
2018-07-25 20:01     ` [PATCH 00/20] Finish Armada DRM transition to atomic modeset Dave Airlie
2018-12-18 15:21 ` [PATCH 0/3] Finish Armada DRM DT support Lubomir Rintel

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=77130e281e078315d346d54b731c578c68f2ff04.camel@v3.sk \
    --to=lkundrak@v3.sk \
    --cc=devicetree@vger.kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=rmk+kernel@armlinux.org.uk \
    /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;
as well as URLs for NNTP newsgroup(s).