drm/etnaviv: Add driver wrapper for vivante GPUs attached on PCI(e) device
Subsystems (3)
v14 cover drm/etnaviv: Add driver wrapper for vivante GPUs attached on PCI(e) device
drm/etnaviv use the component framework to bind multiple GPU cores to a virtual master, the virtual master is manually create during driver load time. This works well for various SoCs, yet there are some PCIe card has the vivante GPU cores integrated. The driver lacks the support for PCIe devices currently.
Adds PCIe driver wrapper on the top of what drm/etnaviv already has, the component framework is still being used to bind subdevices, even though there is only one GPU core. But the process is going to be reversed, we create virtual platform device for each of the vivante GPU IP core shipped by the PCIe master. The PCIe master is real, bind all the virtual child to the master with component framework.
v6:
* Fix build issue on system without CONFIG_PCI enabled
v7:
* Add a separate patch for the platform driver rearrangement (Bjorn)
* Switch to runtime check if the GPU is dma coherent or not (Lucas)
* Add ETNAVIV_PARAM_GPU_COHERENT to allow userspace to query (Lucas)
* Remove etnaviv_gpu.no_clk member (Lucas)
* Fix Various typos and coding style fixed (Bjorn)
v8:
* Fix typos and remove unnecessary header included (Bjorn).
* Add a dedicated function to create the virtual master platform device.
v9:
* Use PCI_VDEVICE() macro (Bjorn)
* Add trivial stubs for the PCI driver (Bjorn)
* Remove a redundant dev_err() usage (Bjorn)
* Clean up etnaviv_pdev_probe() with etnaviv_of_first_available_node()
v10:
* Add one more cleanup patch
* Resolve the conflict with a patch from Rob
* Make the dummy PCI stub inlined
* Print only if the platform is dma-coherrent
V11:
* Drop unnecessary changes (Lucas)
* Tweak according to other reviews of v10.
V12:
* Create a virtual platform device for the subcomponent GPU cores
* Bind all subordinate GPU cores to the real PCI master via component.
V13:
* Drop the non-component code path, always use the component framework to bind subcomponent GPU core. Even though there is only one core.
* Defer the irq handler register.
* Rebase and improve the commit message
V14:
* Rebase onto etnaviv-next and improve commit message.
Tested with JD9230P GPU and LingJiu GP102 GPU.
Sui Jingfeng (8):
drm/etnaviv: Add a dedicated helper function to get various clocks drm/etnaviv: Add constructor and destructor for the
etnaviv_drm_private structure
drm/etnaviv: Embed struct drm_device into struct etnaviv_drm_private drm/etnaviv: Fix wrong cache property being used for vmap() drm/etnaviv: Add support for cached coherent caching mode drm/etnaviv: Replace the '&pdev->dev' with 'dev' drm/etnaviv: Allow creating subdevices and pass platform specific data drm/etnaviv: Add support for vivante GPU cores attached via PCIe
device
drivers/gpu/drm/etnaviv/Kconfig | 8 + drivers/gpu/drm/etnaviv/Makefile | 2 + drivers/gpu/drm/etnaviv/etnaviv_drv.c | 159 ++++++++++------ drivers/gpu/drm/etnaviv/etnaviv_drv.h | 27 +++ drivers/gpu/drm/etnaviv/etnaviv_gem.c | 22 ++- drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c | 2 +- drivers/gpu/drm/etnaviv/etnaviv_gpu.c | 144 +++++++++----- drivers/gpu/drm/etnaviv/etnaviv_gpu.h | 4 + drivers/gpu/drm/etnaviv/etnaviv_mmu.c | 4 +- drivers/gpu/drm/etnaviv/etnaviv_pci_drv.c | 187 +++++++++++++++++++ drivers/gpu/drm/etnaviv/etnaviv_pci_drv.h | 18 ++ include/uapi/drm/etnaviv_drm.h | 1 + 12 files changed, 468 insertions(+), 110 deletions(-) create mode 100644 drivers/gpu/drm/etnaviv/etnaviv_pci_drv.c create mode 100644 drivers/gpu/drm/etnaviv/etnaviv_pci_drv.h
base-commit: 52272bfff15ee70c7bd5be9368f175948fb8ecfd
Signature · 1 line
2.34.1
PATCH v14 1/8 drm/etnaviv: Add a dedicated helper function to get various clocks
Because the current implementation is DT-based, this only works when the host platform has the DT support. The problem is that some host platforms does not provide DT-based clocks drivers, as a result, the driver rage quit.
PLL hardwares are typically provided by the host platform, which is part of the entire clock tree. The PLL hardware provide clock pulse to the GPU core, but it's not belong to the GPU corei itself. PLL registers can be manipulated directly by the device driver. Hence, it may need dedicated clock driver.
Add a the etnaviv_gpu_clk_get() function to group similar code blocks, which make it easier to call this function on the platform where it works.
--- drivers/gpu/drm/etnaviv/etnaviv_gpu.c | 53 ++++++++++++++++----------- 1 file changed, 32 insertions(+), 21 deletions(-)
drivers/gpu/drm/etnaviv/etnaviv_gpu.c +32 -21
@@ -1605,6 +1605,35 @@ static irqreturn_t irq_handler(int irq, void *data)return ret; } +static int etnaviv_gpu_clk_get (struct etnaviv_gpu *gpu) +{ +struct device *dev = gpu->dev; + + gpu->clk_reg =devm_clk_get_optional (dev,"reg" ); +DBG ("clk_reg: %p" , gpu->clk_reg); +if (IS_ERR (gpu->clk_reg)) +return PTR_ERR (gpu->clk_reg); + + gpu->clk_bus =devm_clk_get_optional (dev,"bus" ); +DBG ("clk_bus: %p" , gpu->clk_bus); +if (IS_ERR (gpu->clk_bus)) +return PTR_ERR (gpu->clk_bus); + + gpu->clk_core =devm_clk_get (dev,"core" ); +DBG ("clk_core: %p" , gpu->clk_core); +if (IS_ERR (gpu->clk_core)) +return PTR_ERR (gpu->clk_core); + gpu->base_rate_core =clk_get_rate (gpu->clk_core); + + gpu->clk_shader =devm_clk_get_optional (dev,"shader" ); +DBG ("clk_shader: %p" , gpu->clk_shader); +if (IS_ERR (gpu->clk_shader)) +return PTR_ERR (gpu->clk_shader); + gpu->base_rate_shader =clk_get_rate (gpu->clk_shader); + +return 0 ; +} +static int etnaviv_gpu_clk_enable (struct etnaviv_gpu *gpu) {int ret;
@@ -1880,27 +1909,9 @@ static int etnaviv_gpu_platform_probe(struct platform_device *pdev) }/* Get Clocks: */ - gpu->clk_reg =devm_clk_get_optional (&pdev->dev,"reg" ); -DBG ("clk_reg: %p" , gpu->clk_reg); -if (IS_ERR (gpu->clk_reg)) -return PTR_ERR (gpu->clk_reg); - - gpu->clk_bus =devm_clk_get_optional (&pdev->dev,"bus" ); -DBG ("clk_bus: %p" , gpu->clk_bus); -if (IS_ERR (gpu->clk_bus)) -return PTR_ERR (gpu->clk_bus); - - gpu->clk_core =devm_clk_get (&pdev->dev,"core" ); -DBG ("clk_core: %p" , gpu->clk_core); -if (IS_ERR (gpu->clk_core)) -return PTR_ERR (gpu->clk_core); - gpu->base_rate_core =clk_get_rate (gpu->clk_core); - - gpu->clk_shader =devm_clk_get_optional (&pdev->dev,"shader" ); -DBG ("clk_shader: %p" , gpu->clk_shader); -if (IS_ERR (gpu->clk_shader)) -return PTR_ERR (gpu->clk_shader); - gpu->base_rate_shader =clk_get_rate (gpu->clk_shader); + err =etnaviv_gpu_clk_get (gpu); +if (err) +return err;/* TODO: figure out max mapped size */ dev_set_drvdata (dev, gpu);
Signature · 1 line
2.34.1
PATCH v14 2/8 drm/etnaviv: Add constructor and destructor for the etnaviv_drm_private structure
In reply to Sui JingfengBecause there are a lot of data members in the struct etnaviv_drm_private, which are intended to be shared by all GPU cores. It can be lengthy and daunting on error handling, the 'gem_lock' of struct etnaviv_drm_private just be forgeten to destroy on driver leave.
Switch to use the dedicated helpers introduced, etnaviv_bind() and etnaviv_unbind() gets simplified. Another potential benefit is that we could put the struct drm_device into struct etnaviv_drm_private in the future, which made them share the same life time.
--- drivers/gpu/drm/etnaviv/etnaviv_drv.c | 72 +++++++++++++++++---------- 1 file changed, 46 insertions(+), 26 deletions(-)
drivers/gpu/drm/etnaviv/etnaviv_drv.c +46 -26
@@ -41,6 +41,45 @@ static struct device_node *etnaviv_of_first_available_node(void)return NULL ; } +static struct etnaviv_drm_private *etnaviv_alloc_private (struct device *dev) +{ +struct etnaviv_drm_private *priv; + + priv =kzalloc (sizeof (*priv),GFP_KERNEL ); +if (!priv) +return ERR_PTR (-ENOMEM ); + +xa_init_flags (&priv->active_contexts,XA_FLAGS_ALLOC ); + +mutex_init (&priv->gem_lock); +INIT_LIST_HEAD (&priv->gem_list); + priv->num_gpus =0 ; + priv->shm_gfp_mask =GFP_HIGHUSER | __GFP_RETRY_MAYFAIL | __GFP_NOWARN; + + priv->cmdbuf_suballoc =etnaviv_cmdbuf_suballoc_new (dev); +if (IS_ERR (priv->cmdbuf_suballoc)) { +kfree (priv); +dev_err (dev,"Failed to create cmdbuf suballocator\n" ); +return ERR_PTR (-ENOMEM ); + } + +return priv; +} + +static void etnaviv_free_private (struct etnaviv_drm_private *priv) +{ +if (!priv) +return ; + +mutex_destroy (&priv->gem_lock); + +etnaviv_cmdbuf_suballoc_destroy (priv->cmdbuf_suballoc); + +xa_destroy (&priv->active_contexts); + +kfree (priv); +} +static void load_gpu (struct drm_device *dev) {struct etnaviv_drm_private *priv = dev->dev_private;
@@ -521,35 +560,21 @@ static int etnaviv_bind(struct device *dev)if (IS_ERR (drm))return PTR_ERR (drm); - priv =kzalloc (sizeof (*priv),GFP_KERNEL ); -if (!priv) { -dev_err (dev,"failed to allocate private data\n" ); - ret = -ENOMEM ; + priv =etnaviv_alloc_private (dev); +if (IS_ERR (priv)) { + ret =PTR_ERR (priv); goto out_put; } + drm->dev_private = priv;dma_set_max_seg_size (dev,SZ_2G ); -xa_init_flags (&priv->active_contexts,XA_FLAGS_ALLOC ); - -mutex_init (&priv->gem_lock); -INIT_LIST_HEAD (&priv->gem_list); - priv->num_gpus =0 ; - priv->shm_gfp_mask =GFP_HIGHUSER | __GFP_RETRY_MAYFAIL | __GFP_NOWARN; - - priv->cmdbuf_suballoc =etnaviv_cmdbuf_suballoc_new (drm->dev); -if (IS_ERR (priv->cmdbuf_suballoc)) { -dev_err (drm->dev,"Failed to create cmdbuf suballocator\n" ); - ret =PTR_ERR (priv->cmdbuf_suballoc); - goto out_free_priv; - } -dev_set_drvdata (dev, drm); ret =component_bind_all (dev, drm);if (ret <0 ) - goto out_destroy_suballoc; + goto out_free_priv;load_gpu (drm);
@@ -561,10 +586,8 @@ static int etnaviv_bind(struct device *dev) out_unbind:component_unbind_all (dev, drm); -out_destroy_suballoc: -etnaviv_cmdbuf_suballoc_destroy (priv->cmdbuf_suballoc); out_free_priv: -kfree (priv); +etnaviv_free_private (priv); out_put:drm_dev_put (drm);
@@ -580,12 +603,9 @@ static void etnaviv_unbind(struct device *dev)component_unbind_all (dev, drm); -etnaviv_cmdbuf_suballoc_destroy (priv->cmdbuf_suballoc); - -xa_destroy (&priv->active_contexts); +etnaviv_free_private (priv); drm->dev_private =NULL ; -kfree (priv);drm_dev_put (drm); }
Signature · 1 line
2.34.1
PATCH v14 3/8 drm/etnaviv: Embed struct drm_device into struct etnaviv_drm_private
In reply to Sui JingfengBoth the instance of struct drm_device and the instance of struct etnaviv_drm_private are intended to be shared by all GPU cores, both have only one instance created across drm/etnaviv driver. After embedded in, the whole structure can be allocated with devm_drm_dev_alloc(). And the DRM device created is automatically put on driver detach, so we don't need to call drm_dev_put() explicitly on driver leave. It's also eliminate the need to use the .dev_private member, which is deprecated according to the drm document. We can also use container_of() to retrieve pointer for the containing structure.
--- drivers/gpu/drm/etnaviv/etnaviv_drv.c | 65 ++++++++------------ drivers/gpu/drm/etnaviv/etnaviv_drv.h | 7 +++ drivers/gpu/drm/etnaviv/etnaviv_gem.c | 6 +- drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c | 2 +- drivers/gpu/drm/etnaviv/etnaviv_gpu.c | 6 +- drivers/gpu/drm/etnaviv/etnaviv_mmu.c | 4 +- 6 files changed, 40 insertions(+), 50 deletions(-)
drivers/gpu/drm/etnaviv/etnaviv_drv.c +24 -41
@@ -41,14 +41,9 @@ static struct device_node *etnaviv_of_first_available_node(void)return NULL ; } -static struct etnaviv_drm_private *etnaviv_alloc_private (struct device *dev) +static int etnaviv_private_init (struct device *dev, +struct etnaviv_drm_private *priv) { -struct etnaviv_drm_private *priv; - - priv =kzalloc (sizeof (*priv),GFP_KERNEL ); -if (!priv) -return ERR_PTR (-ENOMEM ); -xa_init_flags (&priv->active_contexts,XA_FLAGS_ALLOC );mutex_init (&priv->gem_lock);
@@ -58,15 +53,14 @@ static struct etnaviv_drm_private *etnaviv_alloc_private(struct device *dev) priv->cmdbuf_suballoc =etnaviv_cmdbuf_suballoc_new (dev);if (IS_ERR (priv->cmdbuf_suballoc)) { -kfree (priv);dev_err (dev,"Failed to create cmdbuf suballocator\n" ); -return ERR_PTR (-ENOMEM ); +return -ENOMEM ; } -return priv; +return 0 ; } -static void etnaviv_free_private (struct etnaviv_drm_private *priv) +static void etnaviv_private_fini (struct etnaviv_drm_private *priv) {if (!priv)return ;
@@ -76,13 +70,11 @@ static void etnaviv_free_private(struct etnaviv_drm_private *priv)etnaviv_cmdbuf_suballoc_destroy (priv->cmdbuf_suballoc);xa_destroy (&priv->active_contexts); - -kfree (priv); }static void load_gpu (struct drm_device *dev) { -struct etnaviv_drm_private *priv = dev->dev_private; +struct etnaviv_drm_private *priv =to_etnaviv_priv (dev);unsigned int i;for (i =0 ; i <ETNA_MAX_PIPES ; i++) {
@@ -100,7 +92,7 @@ static void load_gpu(struct drm_device *dev)static int etnaviv_open (struct drm_device *dev,struct drm_file *file) { -struct etnaviv_drm_private *priv = dev->dev_private; +struct etnaviv_drm_private *priv =to_etnaviv_priv (dev);struct etnaviv_file_private *ctx;int ret, i;
@@ -143,7 +135,7 @@ static int etnaviv_open(struct drm_device *dev, struct drm_file *file)static void etnaviv_postclose (struct drm_device *dev,struct drm_file *file) { -struct etnaviv_drm_private *priv = dev->dev_private; +struct etnaviv_drm_private *priv =to_etnaviv_priv (dev);struct etnaviv_file_private *ctx = file->driver_priv;unsigned int i;
@@ -168,7 +160,7 @@ static void etnaviv_postclose(struct drm_device *dev, struct drm_file *file)#ifdef CONFIG_DEBUG_FS static int etnaviv_gem_show (struct drm_device *dev,struct seq_file *m) { -struct etnaviv_drm_private *priv = dev->dev_private; +struct etnaviv_drm_private *priv =to_etnaviv_priv (dev);etnaviv_gem_describe_objects (priv, m);
@@ -262,7 +254,7 @@ static int show_each_gpu(struct seq_file *m, void *arg) {struct drm_info_node *node = (struct drm_info_node *) m->private;struct drm_device *dev = node->minor->dev; -struct etnaviv_drm_private *priv = dev->dev_private; +struct etnaviv_drm_private *priv =to_etnaviv_priv (dev);struct etnaviv_gpu *gpu;int (*show)(struct etnaviv_gpu *gpu,struct seq_file *m) = node->info_ent->data;
@@ -305,7 +297,7 @@ static void etnaviv_debugfs_init(struct drm_minor *minor)static int etnaviv_ioctl_get_param (struct drm_device *dev,void *data,struct drm_file *file) { -struct etnaviv_drm_private *priv = dev->dev_private; +struct etnaviv_drm_private *priv =to_etnaviv_priv (dev);struct drm_etnaviv_param *args = data;struct etnaviv_gpu *gpu;
@@ -398,7 +390,7 @@ static int etnaviv_ioctl_wait_fence(struct drm_device *dev, void *data, struct drm_file *file) {struct drm_etnaviv_wait_fence *args = data; -struct etnaviv_drm_private *priv = dev->dev_private; +struct etnaviv_drm_private *priv =to_etnaviv_priv (dev);struct drm_etnaviv_timespec *timeout = &args->timeout;struct etnaviv_gpu *gpu;
@@ -446,7 +438,7 @@ static int etnaviv_ioctl_gem_userptr(struct drm_device *dev, void *data,static int etnaviv_ioctl_gem_wait (struct drm_device *dev,void *data,struct drm_file *file) { -struct etnaviv_drm_private *priv = dev->dev_private; +struct etnaviv_drm_private *priv =to_etnaviv_priv (dev);struct drm_etnaviv_gem_wait *args = data;struct drm_etnaviv_timespec *timeout = &args->timeout;struct drm_gem_object *obj;
@@ -480,7 +472,7 @@ static int etnaviv_ioctl_gem_wait(struct drm_device *dev, void *data,static int etnaviv_ioctl_pm_query_dom (struct drm_device *dev,void *data,struct drm_file *file) { -struct etnaviv_drm_private *priv = dev->dev_private; +struct etnaviv_drm_private *priv =to_etnaviv_priv (dev);struct drm_etnaviv_pm_domain *args = data;struct etnaviv_gpu *gpu;
@@ -497,7 +489,7 @@ static int etnaviv_ioctl_pm_query_dom(struct drm_device *dev, void *data,static int etnaviv_ioctl_pm_query_sig (struct drm_device *dev,void *data,struct drm_file *file) { -struct etnaviv_drm_private *priv = dev->dev_private; +struct etnaviv_drm_private *priv =to_etnaviv_priv (dev);struct drm_etnaviv_pm_signal *args = data;struct etnaviv_gpu *gpu;
@@ -556,17 +548,14 @@ static int etnaviv_bind(struct device *dev)struct drm_device *drm;int ret; - drm =drm_dev_alloc (&etnaviv_drm_driver, dev); -if (IS_ERR (drm)) -return PTR_ERR (drm); + priv =devm_drm_dev_alloc (dev, &etnaviv_drm_driver, + struct etnaviv_drm_private, drm); +if (IS_ERR (priv)) +return PTR_ERR (priv); - priv =etnaviv_alloc_private (dev); -if (IS_ERR (priv)) { - ret =PTR_ERR (priv); - goto out_put; - } +etnaviv_private_init (dev, priv); - drm->dev_private = priv; + drm = &priv->drm;dma_set_max_seg_size (dev,SZ_2G );
@@ -587,9 +576,7 @@ static int etnaviv_bind(struct device *dev) out_unbind:component_unbind_all (dev, drm); out_free_priv: -etnaviv_free_private (priv); -out_put: -drm_dev_put (drm); +etnaviv_private_fini (priv);return ret; }
@@ -597,17 +584,13 @@ static int etnaviv_bind(struct device *dev)static void etnaviv_unbind (struct device *dev) {struct drm_device *drm =dev_get_drvdata (dev); -struct etnaviv_drm_private *priv = drm->dev_private; +struct etnaviv_drm_private *priv =to_etnaviv_priv (drm);drm_dev_unregister (drm);component_unbind_all (dev, drm); -etnaviv_free_private (priv); - - drm->dev_private =NULL ; - -drm_dev_put (drm); +etnaviv_private_fini (priv); }static const struct component_master_ops etnaviv_master_ops = {
drivers/gpu/drm/etnaviv/etnaviv_drv.h +7 -0
@@ -35,6 +35,7 @@ struct etnaviv_file_private { };struct etnaviv_drm_private { +struct drm_device drm;int num_gpus;struct etnaviv_gpu *gpu[ETNA_MAX_PIPES ];gfp_t shm_gfp_mask;
@@ -50,6 +51,12 @@ struct etnaviv_drm_private {struct list_head gem_list; }; +static inline struct etnaviv_drm_private * +to_etnaviv_priv (struct drm_device *ddev) +{ + return container_of(ddev, struct etnaviv_drm_private, drm); +} +int etnaviv_ioctl_gem_submit (struct drm_device *dev,void *data,struct drm_file *file);
drivers/gpu/drm/etnaviv/etnaviv_gem.c +3 -3
@@ -486,7 +486,7 @@ static const struct etnaviv_gem_ops etnaviv_gem_shmem_ops = {void etnaviv_gem_free_object (struct drm_gem_object *obj) {struct etnaviv_gem_object *etnaviv_obj =to_etnaviv_bo (obj); -struct etnaviv_drm_private *priv = obj->dev->dev_private; +struct etnaviv_drm_private *priv =to_etnaviv_priv (obj->dev);struct etnaviv_vram_mapping *mapping, *tmp;/* object should not be active */
@@ -517,7 +517,7 @@ void etnaviv_gem_free_object(struct drm_gem_object *obj)void etnaviv_gem_obj_add (struct drm_device *dev,struct drm_gem_object *obj) { -struct etnaviv_drm_private *priv = dev->dev_private; +struct etnaviv_drm_private *priv =to_etnaviv_priv (dev);struct etnaviv_gem_object *etnaviv_obj =to_etnaviv_bo (obj);mutex_lock (&priv->gem_lock);
@@ -584,7 +584,7 @@ static int etnaviv_gem_new_impl(struct drm_device *dev, u32 flags,int etnaviv_gem_new_handle (struct drm_device *dev,struct drm_file *file,u32 size,u32 flags,u32 *handle) { -struct etnaviv_drm_private *priv = dev->dev_private; +struct etnaviv_drm_private *priv =to_etnaviv_priv (dev);struct drm_gem_object *obj =NULL ;int ret;
drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c +1 -1
@@ -413,7 +413,7 @@ int etnaviv_ioctl_gem_submit(struct drm_device *dev, void *data, struct drm_file *file) {struct etnaviv_file_private *ctx = file->driver_priv; -struct etnaviv_drm_private *priv = dev->dev_private; +struct etnaviv_drm_private *priv =to_etnaviv_priv (dev);struct drm_etnaviv_gem_submit *args = data;struct drm_etnaviv_gem_submit_reloc *relocs;struct drm_etnaviv_gem_submit_pmr *pmrs;
drivers/gpu/drm/etnaviv/etnaviv_gpu.c +3 -3
@@ -38,7 +38,7 @@ static const struct platform_device_id gpu_ids[] = {int etnaviv_gpu_get_param (struct etnaviv_gpu *gpu,u32 param,u64 *value) { -struct etnaviv_drm_private *priv = gpu->drm->dev_private; +struct etnaviv_drm_private *priv =to_etnaviv_priv (gpu->drm);switch (param) {case ETNAVIV_PARAM_GPU_MODEL :
@@ -789,7 +789,7 @@ static void etnaviv_gpu_hw_init(struct etnaviv_gpu *gpu)int etnaviv_gpu_init (struct etnaviv_gpu *gpu) { -struct etnaviv_drm_private *priv = gpu->drm->dev_private; +struct etnaviv_drm_private *priv =to_etnaviv_priv (gpu->drm);dma_addr_t cmdbuf_paddr;int ret, i;
@@ -1779,7 +1779,7 @@ static int etnaviv_gpu_bind(struct device *dev, struct device *master, void *data) {struct drm_device *drm = data; -struct etnaviv_drm_private *priv = drm->dev_private; +struct etnaviv_drm_private *priv =to_etnaviv_priv (drm);struct etnaviv_gpu *gpu =dev_get_drvdata (dev);int ret;
drivers/gpu/drm/etnaviv/etnaviv_mmu.c +2 -2
@@ -490,7 +490,7 @@ void etnaviv_iommu_dump(struct etnaviv_iommu_context *context, void *buf)int etnaviv_iommu_global_init (struct etnaviv_gpu *gpu) {enum etnaviv_iommu_version version =ETNAVIV_IOMMU_V1 ; -struct etnaviv_drm_private *priv = gpu->drm->dev_private; +struct etnaviv_drm_private *priv =to_etnaviv_priv (gpu->drm);struct etnaviv_iommu_global *global;struct device *dev = gpu->drm->dev;
@@ -550,7 +550,7 @@ int etnaviv_iommu_global_init(struct etnaviv_gpu *gpu)void etnaviv_iommu_global_fini (struct etnaviv_gpu *gpu) { -struct etnaviv_drm_private *priv = gpu->drm->dev_private; +struct etnaviv_drm_private *priv =to_etnaviv_priv (gpu->drm);struct etnaviv_iommu_global *global = priv->mmu_global;if (!global)
Signature · 1 line
2.34.1
PATCH v14 4/8 drm/etnaviv: Fix wrong cache property being used for vmap()
In reply to Sui JingfengIn the etnaviv_gem_vmap_impl() function, the driver vmap whatever buffers with Write-Combine page property. This is unreasonable, as some platforms are cached coherent. And cached buffers should be mapped with cached page property.
--- drivers/gpu/drm/etnaviv/etnaviv_gem.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)
drivers/gpu/drm/etnaviv/etnaviv_gem.c +14 -2
@@ -342,6 +342,7 @@ void *etnaviv_gem_vmap(struct drm_gem_object *obj)static void *etnaviv_gem_vmap_impl (struct etnaviv_gem_object *obj) {struct page **pages; +pgprot_t prot;lockdep_assert_held (&obj->lock);
@@ -349,8 +350,19 @@ static void *etnaviv_gem_vmap_impl(struct etnaviv_gem_object *obj)if (IS_ERR (pages))return NULL ; -return vmap (pages, obj->base.size >>PAGE_SHIFT , -VM_MAP ,pgprot_writecombine (PAGE_KERNEL )); +switch (obj->flags) { +case ETNA_BO_CACHED : + prot =PAGE_KERNEL ; +break ; +case ETNA_BO_UNCACHED : + prot =pgprot_noncached (PAGE_KERNEL ); +break ; +case ETNA_BO_WC : +default : + prot =pgprot_writecombine (PAGE_KERNEL ); + } + +return vmap (pages, obj->base.size >>PAGE_SHIFT ,VM_MAP , prot); }static inline enum dma_data_direction etnaviv_op_to_dma_dir (u32 op)
Signature · 1 line
2.34.1
PATCH v14 5/8 drm/etnaviv: Add support for cached coherent caching mode
In reply to Sui JingfengMany modern CPUs and/or platforms choose to define their peripheral devices as cached coherent by default, to be specific, the PCH is capable of snooping CPU's cache. When hit the peripheral devices will access data directly from CPU's cache. This means that device drivers do not need to maintain the coherency issue between a processor and peripheral I/O for the cached buffers. Hence, it dosen't need us to sync manually on the software side, which is useful to avoid some overheads, especially for userspace, but userspace is not known yet.
Probe the hardware maintained cached coherent support of the host platform with the dev_is_dma_coherent() function, and store the result in struct etnaviv_drm_private. As this is a platform implementation-defined hardware feature and again is meant to be shared by all GPU cores. And expose it via etnaviv parameter mechanism to let userspace know.
Please note that write-combine mapping out of scope of the discussion and therefore is not being addressed.
--- drivers/gpu/drm/etnaviv/etnaviv_drv.c | 3 +++ drivers/gpu/drm/etnaviv/etnaviv_drv.h | 9 +++++++++ drivers/gpu/drm/etnaviv/etnaviv_gpu.c | 4 ++++ include/uapi/drm/etnaviv_drm.h | 1 + 4 files changed, 17 insertions(+)
drivers/gpu/drm/etnaviv/etnaviv_drv.c +3 -0
@@ -5,6 +5,7 @@#include <linux/component.h> #include <linux/dma-mapping.h> +#include <linux/dma-map-ops.h> #include <linux/module.h> #include <linux/of.h> #include <linux/of_device.h>
@@ -57,6 +58,8 @@ static int etnaviv_private_init(struct device *dev,return -ENOMEM ; } + priv->cached_coherent =dev_is_dma_coherent (dev); +return 0 ; }
drivers/gpu/drm/etnaviv/etnaviv_drv.h +9 -0
@@ -46,6 +46,15 @@ struct etnaviv_drm_private {struct xarray active_contexts;u32 next_context_id; +/* +* If true, the cached mapping is consistent for all CPU cores and +* peripheral bus masters in the system. It means that both of the +* CPU and GPU will see the same data if the buffer being accessed +* is cached. And the coherency is guaranteed by the host platform +* specific hardwares. +*/ +bool cached_coherent; +/* list of GEM objects: */ struct mutex gem_lock;struct list_head gem_list;
drivers/gpu/drm/etnaviv/etnaviv_gpu.c +4 -0
@@ -164,6 +164,10 @@ int etnaviv_gpu_get_param(struct etnaviv_gpu *gpu, u32 param, u64 *value) *value = gpu->identity.eco_id;break ; +case ETNAVIV_PARAM_CACHED_COHERENT : + *value = priv->cached_coherent; +break ; +default :DBG ("%s: invalid param: %u" ,dev_name (gpu->dev), param);return -EINVAL ;
include/uapi/drm/etnaviv_drm.h +1 -0
@@ -77,6 +77,7 @@ struct drm_etnaviv_timespec {#define ETNAVIV_PARAM_GPU_PRODUCT_ID 0x1c#define ETNAVIV_PARAM_GPU_CUSTOMER_ID 0x1d#define ETNAVIV_PARAM_GPU_ECO_ID 0x1e +#define ETNAVIV_PARAM_CACHED_COHERENT 0x1f#define ETNA_MAX_PIPES 4
Signature · 1 line
2.34.1
PATCH v14 6/8 drm/etnaviv: Replace the '&pdev->dev' with 'dev'
In reply to Sui JingfengIn the etnaviv_pdev_probe(), etnaviv_gpu_platform_probe() function, the value of '&pdev->dev' has been cached to the 'dev' local auto variable. But part of callers use 'dev' as argument, while the rest use '&pdev->dev'.
To keep it consistent, use 'dev' uniformly.
--- drivers/gpu/drm/etnaviv/etnaviv_drv.c | 10 +++++----- drivers/gpu/drm/etnaviv/etnaviv_gpu.c | 16 ++++++++-------- 2 files changed, 13 insertions(+), 13 deletions(-)
drivers/gpu/drm/etnaviv/etnaviv_drv.c +5 -5
@@ -614,7 +614,7 @@ static int etnaviv_pdev_probe(struct platform_device *pdev)if (!of_device_is_available (core_node))continue ; -drm_of_component_match_add (&pdev->dev, &match, +drm_of_component_match_add (dev, &match, component_compare_of, core_node); } }else {
@@ -637,9 +637,9 @@ static int etnaviv_pdev_probe(struct platform_device *pdev)* bit to make sure we are allocating the command buffers and * TLBs in the lower 4 GiB address space. */ -if (dma_set_mask (&pdev->dev,DMA_BIT_MASK (40 )) || -dma_set_coherent_mask (&pdev->dev,DMA_BIT_MASK (32 ))) { -dev_dbg (&pdev->dev,"No suitable DMA available\n" ); +if (dma_set_mask (dev,DMA_BIT_MASK (40 )) || +dma_set_coherent_mask (dev,DMA_BIT_MASK (32 ))) { +dev_dbg (dev,"No suitable DMA available\n" );return -ENODEV ; }
@@ -650,7 +650,7 @@ static int etnaviv_pdev_probe(struct platform_device *pdev)*/ first_node =etnaviv_of_first_available_node ();if (first_node) { -of_dma_configure (&pdev->dev, first_node, true); +of_dma_configure (dev, first_node, true);of_node_put (first_node); }
drivers/gpu/drm/etnaviv/etnaviv_gpu.c +8 -8
@@ -1891,7 +1891,7 @@ static int etnaviv_gpu_platform_probe(struct platform_device *pdev)if (!gpu)return -ENOMEM ; - gpu->dev = &pdev->dev; + gpu->dev = dev;mutex_init (&gpu->lock);mutex_init (&gpu->sched_lock);
@@ -1905,8 +1905,8 @@ static int etnaviv_gpu_platform_probe(struct platform_device *pdev)if (gpu->irq <0 )return gpu->irq; - err =devm_request_irq (&pdev->dev, gpu->irq, irq_handler,0 , -dev_name (gpu->dev), gpu); + err =devm_request_irq (dev, gpu->irq, irq_handler,0 , +dev_name (dev), gpu);if (err) {dev_err (dev,"failed to request IRQ%u: %d\n" , gpu->irq, err);return err;
@@ -1925,13 +1925,13 @@ static int etnaviv_gpu_platform_probe(struct platform_device *pdev)* autosuspend delay is rather arbitary: no measurements have * yet been performed to determine an appropriate value. */ -pm_runtime_use_autosuspend (gpu->dev); -pm_runtime_set_autosuspend_delay (gpu->dev,200 ); -pm_runtime_enable (gpu->dev); +pm_runtime_use_autosuspend (dev); +pm_runtime_set_autosuspend_delay (dev,200 ); +pm_runtime_enable (dev); - err =component_add (&pdev->dev, &gpu_ops); + err =component_add (dev, &gpu_ops);if (err <0 ) { -dev_err (&pdev->dev,"failed to register component: %d\n" , err); +dev_err (dev,"failed to register component: %d\n" , err);return err; }
Signature · 1 line
2.34.1
PATCH v14 7/8 drm/etnaviv: Allow creating subdevices and pass platform specific data
In reply to Sui JingfengBecause some hardware are too complex to be managed by a monolithic driver, a split of the functionality into child devices can helps to achieve better modularity.
We will use this function to create subdevice as a repensentation of a single hardware ip block, so that the same modular approach that works for ARM-SoC can also works for PCIe cards.
--- drivers/gpu/drm/etnaviv/etnaviv_drv.c | 33 +++++++++++++++++++++++---- drivers/gpu/drm/etnaviv/etnaviv_drv.h | 9 ++++++++ 2 files changed, 37 insertions(+), 5 deletions(-)
drivers/gpu/drm/etnaviv/etnaviv_drv.c +28 -5
@@ -670,16 +670,36 @@ static struct platform_driver etnaviv_platform_driver = { }, }; -static int etnaviv_create_platform_device (const char *name, -struct platform_device **ppdev) +int etnaviv_create_platform_device (struct device *parent, +const char *name,int id, +struct resource *pres, +void *data, +struct platform_device **ppdev) {struct platform_device *pdev;int ret; - pdev =platform_device_alloc (name,PLATFORM_DEVID_NONE ); + pdev =platform_device_alloc (name, id);if (!pdev)return -ENOMEM ; + pdev->dev.parent = parent; + +if (pres) { + ret =platform_device_add_resources (pdev, pres,1 ); +if (ret) { +platform_device_put (pdev); +return ret; + } + } + +if (data) { +void *pdata =kmalloc (sizeof (void *),GFP_KERNEL ); + + *(void **)pdata = data; + pdev->dev.platform_data = pdata; + } + ret =platform_device_add (pdev);if (ret) {platform_device_put (pdev);
@@ -691,7 +711,7 @@ static int etnaviv_create_platform_device(const char *name,return 0 ; } -static void etnaviv_destroy_platform_device (struct platform_device **ppdev) +void etnaviv_destroy_platform_device (struct platform_device **ppdev) {struct platform_device *pdev = *ppdev;
@@ -728,7 +748,10 @@ static int __init etnaviv_init(void)if (np) {of_node_put (np); - ret =etnaviv_create_platform_device ("etnaviv" , &etnaviv_drm); + ret =etnaviv_create_platform_device (NULL ,"etnaviv" , +PLATFORM_DEVID_NONE , +NULL ,NULL , + &etnaviv_drm);if (ret) goto unregister_platform_driver; }
drivers/gpu/drm/etnaviv/etnaviv_drv.h +9 -0
@@ -9,6 +9,7 @@#include <linux/io.h> #include <linux/list.h> #include <linux/mm_types.h> +#include <linux/platform_device.h> #include <linux/sizes.h> #include <linux/time64.h> #include <linux/types.h>
@@ -98,6 +99,14 @@ bool etnaviv_cmd_validate_one(struct etnaviv_gpu *gpu, u32 *stream, unsigned int size, struct drm_etnaviv_gem_submit_reloc *relocs, unsigned int reloc_size); +int etnaviv_create_platform_device (struct device *parent, +const char *name,int id, +struct resource *pres, +void *data, +struct platform_device **ppdev); + +void etnaviv_destroy_platform_device (struct platform_device **ppdev); +#ifdef CONFIG_DEBUG_FS void etnaviv_gem_describe_objects (struct etnaviv_drm_private *priv,struct seq_file *m);
Signature · 1 line
2.34.1
PATCH v14 8/8 drm/etnaviv: Add support for vivante GPU cores attached via PCIe device
In reply to Sui JingfengPreviouly, the component framework is being used to bind multiple platform GPU devices to a virtual master. The virtual master is manually created by the driver, and is also a platform device. This is fine and works well for various SoCs, yet there some hardware venders integrate Vivante GPU cores into PCIe card and the driver lacks the support for PCIe devices.
Create virtual platform devices as a representation for each GPU IP core, the manually created platform devices are functional as subcomponent, and all of them are child of the PCIe master device. The master is real for PCIe devices, as the PCIe device has already been created by the time the etnaviv.ko is loaded. Hence, bind all of the virtual child to the real master, this design reflects the hardware layout perfectly and is extensible.
--- drivers/gpu/drm/etnaviv/Kconfig | 9 ++ drivers/gpu/drm/etnaviv/Makefile | 2 + drivers/gpu/drm/etnaviv/etnaviv_drv.c | 12 +- drivers/gpu/drm/etnaviv/etnaviv_drv.h | 2 + drivers/gpu/drm/etnaviv/etnaviv_gpu.c | 75 ++++++++-- drivers/gpu/drm/etnaviv/etnaviv_gpu.h | 4 + drivers/gpu/drm/etnaviv/etnaviv_pci_drv.c | 161 ++++++++++++++++++++++ drivers/gpu/drm/etnaviv/etnaviv_pci_drv.h | 44 ++++++ 8 files changed, 293 insertions(+), 16 deletions(-) create mode 100644 drivers/gpu/drm/etnaviv/etnaviv_pci_drv.c create mode 100644 drivers/gpu/drm/etnaviv/etnaviv_pci_drv.h
drivers/gpu/drm/etnaviv/Kconfig +9 -0
@@ -15,6 +15,15 @@ config DRM_ETNAVIV help DRM driver for Vivante GPUs. +config DRM_ETNAVIV_PCI_DRIVER + bool "enable ETNAVIV PCI driver support" + depends on DRM_ETNAVIV + depends on PCI + default n + help + Compile in support for Vivante GPUs attached via PCIe card. + Say Y if you have such hardwares. + config DRM_ETNAVIV_THERMAL bool "enable ETNAVIV thermal throttling" depends on DRM_ETNAVIV
drivers/gpu/drm/etnaviv/Makefile +2 -0
@@ -16,4 +16,6 @@ etnaviv-y := \ etnaviv_perfmon.o \ etnaviv_sched.o +etnaviv-$(CONFIG_DRM_ETNAVIV_PCI_DRIVER) += etnaviv_pci_drv.o + obj-$(CONFIG_DRM_ETNAVIV) += etnaviv.o
drivers/gpu/drm/etnaviv/etnaviv_drv.c +11 -1
@@ -24,6 +24,7 @@#include "etnaviv_gpu.h" #include "etnaviv_gem.h" #include "etnaviv_mmu.h" +#include "etnaviv_pci_drv.h" #include "etnaviv_perfmon.h" /*
@@ -568,6 +569,10 @@ static int etnaviv_bind(struct device *dev)if (ret <0 ) goto out_free_priv; + ret =etnaviv_register_irq_handler (dev, priv); +if (ret) + goto out_unbind; +load_gpu (drm); ret =drm_dev_register (drm,0 );
@@ -596,7 +601,7 @@ static void etnaviv_unbind(struct device *dev)etnaviv_private_fini (priv); } -static const struct component_master_ops etnaviv_master_ops = { +const struct component_master_ops etnaviv_master_ops = { .bind = etnaviv_bind, .unbind = etnaviv_unbind, };
@@ -740,6 +745,10 @@ static int __init etnaviv_init(void)if (ret !=0 ) goto unregister_gpu_driver; + ret =etnaviv_register_pci_driver (); +if (ret) + goto unregister_platform_driver; +/* * If the DT contains at least one available GPU device, instantiate * the DRM platform device.
@@ -769,6 +778,7 @@ module_init(etnaviv_init); static void __exit etnaviv_exit(void) {etnaviv_destroy_platform_device (&etnaviv_drm); +etnaviv_unregister_pci_driver ();platform_driver_unregister (&etnaviv_platform_driver);platform_driver_unregister (&etnaviv_gpu_driver); }
drivers/gpu/drm/etnaviv/etnaviv_drv.h +2 -0
@@ -27,6 +27,8 @@ struct etnaviv_gem_object;struct etnaviv_gem_submit ;struct etnaviv_iommu_global ; +extern const struct component_master_ops etnaviv_master_ops; +#define ETNAVIV_SOFTPIN_START_ADDRESS SZ_4M/* must be >= SUBALLOC_SIZE */ struct etnaviv_file_private {
drivers/gpu/drm/etnaviv/etnaviv_gpu.c +60 -15
118 lines not on this page · raw message
drivers/gpu/drm/etnaviv/etnaviv_gpu.h +4 -0
@@ -196,6 +196,10 @@ static inline u32 gpu_read_power(struct etnaviv_gpu *gpu, u32 reg)int etnaviv_gpu_get_param (struct etnaviv_gpu *gpu,u32 param,u64 *value);int etnaviv_gpu_init (struct etnaviv_gpu *gpu); + +int etnaviv_register_irq_handler (struct device *dev, +struct etnaviv_drm_private *priv); +bool etnaviv_fill_identity_from_hwdb (struct etnaviv_gpu *gpu);#ifdef CONFIG_DEBUG_FS
drivers/gpu/drm/etnaviv/etnaviv_pci_drv.c new file +161 -0
161 lines not on this page · raw message
drivers/gpu/drm/etnaviv/etnaviv_pci_drv.h new file +44 -0
44 lines not on this page · raw message
Signature · 1 line
2.34.1
Hi
Quoted 51 lines
drm/etnaviv use the component framework to bind multiple GPU cores to a virtual master, the virtual master is manually create during driver load time. This works well for various SoCs, yet there are some PCIe card has the vivante GPU cores integrated. The driver lacks the support for PCIe devices currently.
Adds PCIe driver wrapper on the top of what drm/etnaviv already has, the component framework is still being used to bind subdevices, even though there is only one GPU core. But the process is going to be reversed, we create virtual platform device for each of the vivante GPU IP core shipped by the PCIe master. The PCIe master is real, bind all the virtual child to the master with component framework.
v6:
* Fix build issue on system withoutCONFIG_PCIenabled
v7:
* Add a separate patch for the platform driver rearrangement (Bjorn)
* Switch to runtime check if the GPU is dma coherent or not (Lucas)
* AddETNAVIV_PARAM_GPU_COHERENTto allow userspace to query (Lucas)
* Remove etnaviv_gpu.no_clk member (Lucas)
* Fix Various typos and coding style fixed (Bjorn)
v8:
* Fix typos and remove unnecessary header included (Bjorn).
* Add a dedicated function to create the virtual master platform device.
v9:
* UsePCI_VDEVICE()macro (Bjorn)
* Add trivial stubs for the PCI driver (Bjorn)
* Remove a redundantdev_err()usage (Bjorn)
* Clean upetnaviv_pdev_probe()withetnaviv_of_first_available_node()
v10:
* Add one more cleanup patch
* Resolve the conflict with a patch from Rob
* Make the dummy PCI stub inlined
* Print only if the platform is dma-coherrent
V11:
* Drop unnecessary changes (Lucas)
* Tweak according to other reviews of v10.V12:
* Create a virtual platform device for the subcomponent GPU cores
* Bind all subordinate GPU cores to the real PCI master via component.V13:
* Drop the non-component code path, always use the component framework to bind subcomponent GPU core. Even though there is only one core.
* Defer the irq handler register.
* Rebase and improve the commit message
Quoted 5 lines
V14:
* Rebase onto etnaviv-next and improve commit message.Tested with JD9230P GPU and LingJiu GP102 GPU.
I was able to test this series and will do a review in the next few days. Hopefully this series will land anytime.
[ 6.783267] etnaviv 0000:0c:00.0: enabling device (0000 -> 0003) [ 6.783324] etnaviv 0000:0c:00.0: JingJia Micro JM9100 has 1 GPU cores [ 6.783459] etnaviv 0000:0c:00.0: bound etnaviv-gpu,3d.0 (ops gpu_ops [etnaviv]) [ 6.783502] etnaviv-gpu etnaviv-gpu,3d.0: model: GC9200, revision: 6304 [ 6.783635] [drm] Initialized etnaviv 1.4.0 20151214 for
0000:0c:00.0 on minor 1
Quoted 33 lines
Sui Jingfeng (8):
drm/etnaviv: Add a dedicated helper function to get various clocks drm/etnaviv: Add constructor and destructor for the
etnaviv_drm_privatestructure
drm/etnaviv: Embed structdrm_deviceinto structetnaviv_drm_privatedrm/etnaviv: Fix wrong cache property being used forvmap()drm/etnaviv: Add support for cached coherent caching mode drm/etnaviv: Replace the '&pdev->dev' with 'dev' drm/etnaviv: Allow creating subdevices and pass platform specific data drm/etnaviv: Add support for vivante GPU cores attached via PCIe
devicedrivers/gpu/drm/etnaviv/Kconfig | 8 + drivers/gpu/drm/etnaviv/Makefile | 2 + drivers/gpu/drm/etnaviv/etnaviv_drv.c | 159 ++++++++++------ drivers/gpu/drm/etnaviv/etnaviv_drv.h | 27 +++ drivers/gpu/drm/etnaviv/etnaviv_gem.c | 22 ++- drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c | 2 +- drivers/gpu/drm/etnaviv/etnaviv_gpu.c | 144 +++++++++----- drivers/gpu/drm/etnaviv/etnaviv_gpu.h | 4 + drivers/gpu/drm/etnaviv/etnaviv_mmu.c | 4 +- drivers/gpu/drm/etnaviv/etnaviv_pci_drv.c | 187 +++++++++++++++++++ drivers/gpu/drm/etnaviv/etnaviv_pci_drv.h | 18 ++ include/uapi/drm/etnaviv_drm.h | 1 + 12 files changed, 468 insertions(+), 110 deletions(-) create mode 100644 drivers/gpu/drm/etnaviv/etnaviv_pci_drv.c create mode 100644 drivers/gpu/drm/etnaviv/etnaviv_pci_drv.hbase-commit:
52272bfff15ee70c7bd5be9368f175948fb8ecfd--
2.34.1
Signature · 5 lines
greets -- Christian Gmeiner, MSc https://christian-gmeiner.info/privacypolicy
Quoted 68 lines · 在 2024-05-20星期一的 00:53 +0800,Sui Jingfeng写道:
drm/etnaviv use the component framework to bind multiple GPU cores to a
virtual master, the virtual master is manually create during driver load
time. This works well for various SoCs, yet there are some PCIe card has
the vivante GPU cores integrated. The driver lacks the support for PCIe
devices currently.Adds PCIe driver wrapper on the top of what drm/etnaviv already has, the
component framework is still being used to bind subdevices, even though
there is only one GPU core. But the process is going to be reversed, we
create virtual platform device for each of the vivante GPU IP core shipped
by the PCIe master. The PCIe master is real, bind all the virtual child
to the master with component framework.v6:
* Fix build issue on system withoutCONFIG_PCIenabled v7:
* Add a separate patch for the platform driver rearrangement (Bjorn)
* Switch to runtime check if the GPU is dma coherent or not (Lucas)
* AddETNAVIV_PARAM_GPU_COHERENTto allow userspace to query (Lucas)
* Remove etnaviv_gpu.no_clk member (Lucas)
* Fix Various typos and coding style fixed (Bjorn) v8:
* Fix typos and remove unnecessary header included (Bjorn).
* Add a dedicated function to create the virtual master platform
device.
v9:
* UsePCI_VDEVICE()macro (Bjorn)
* Add trivial stubs for the PCI driver (Bjorn)
* Remove a redundantdev_err()usage (Bjorn)
* Clean upetnaviv_pdev_probe()withetnaviv_of_first_available_node()
v10:
* Add one more cleanup patch
* Resolve the conflict with a patch from Rob
* Make the dummy PCI stub inlined
* Print only if the platform is dma-coherrent V11:
* Drop unnecessary changes (Lucas)
* Tweak according to other reviews of v10.V12:
* Create a virtual platform device for the subcomponent GPU cores
* Bind all subordinate GPU cores to the real PCI master via component.V13:
* Drop the non-component code path, always use the component framework
to bind subcomponent GPU core. Even though there is only one core.
* Defer the irq handler register.
* Rebase and improve the commit message
Quoted 4 lines
V14:
* Rebase onto etnaviv-next and improve commit message.Tested with JD9230P GPU and LingJiu GP102 GPU.
BTW how should VRAM and displayed related parts be handled on these dGPUs?
Quoted 34 lines
Sui Jingfeng (8):
drm/etnaviv: Add a dedicated helper function to get various clocks drm/etnaviv: Add constructor and destructor for theetnaviv_drm_privatestructure
drm/etnaviv: Embed structdrm_deviceinto structetnaviv_drm_private
drm/etnaviv: Fix wrong cache property being used forvmap()drm/etnaviv: Add support for cached coherent caching mode drm/etnaviv: Replace the '&pdev->dev' with 'dev' drm/etnaviv: Allow creating subdevices and pass platform specific data
drm/etnaviv: Add support for vivante GPU cores attached via PCIe devicedrivers/gpu/drm/etnaviv/Kconfig | 8 + drivers/gpu/drm/etnaviv/Makefile | 2 +
drivers/gpu/drm/etnaviv/etnaviv_drv.c | 159 ++++++++++------ drivers/gpu/drm/etnaviv/etnaviv_drv.h | 27 +++ drivers/gpu/drm/etnaviv/etnaviv_gem.c | 22 ++- drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c | 2 +- drivers/gpu/drm/etnaviv/etnaviv_gpu.c | 144 +++++++++----- drivers/gpu/drm/etnaviv/etnaviv_gpu.h | 4 + drivers/gpu/drm/etnaviv/etnaviv_mmu.c | 4 +-drivers/gpu/drm/etnaviv/etnaviv_pci_drv.c | 187
+++++++++++++++++++
drivers/gpu/drm/etnaviv/etnaviv_pci_drv.h | 18 ++ include/uapi/drm/etnaviv_drm.h | 1 +12 files changed, 468 insertions(+), 110 deletions(-)create mode 100644
drivers/gpu/drm/etnaviv/etnaviv_pci_drv.ccreate mode 100644drivers/gpu/drm/etnaviv/etnaviv_pci_drv.hbase-commit:
52272bfff15ee70c7bd5be9368f175948fb8ecfd
Hi,
Quoted 69 lines · Icenowy Zheng
Quoted 68 lines · 在 2024-05-20星期一的 00:53 +0800,Sui Jingfeng写道:
drm/etnaviv use the component framework to bind multiple GPU cores to a
virtual master, the virtual master is manually create during driver load
time. This works well for various SoCs, yet there are some PCIe card has
the vivante GPU cores integrated. The driver lacks the support for PCIe
devices currently.Adds PCIe driver wrapper on the top of what drm/etnaviv already has, the
component framework is still being used to bind subdevices, even though
there is only one GPU core. But the process is going to be reversed, we
create virtual platform device for each of the vivante GPU IP core shipped
by the PCIe master. The PCIe master is real, bind all the virtual child
to the master with component framework.v6:
* Fix build issue on system withoutCONFIG_PCIenabled
v7:
* Add a separate patch for the platform driver rearrangement
(Bjorn)
* Switch to runtime check if the GPU is dma coherent or not
(Lucas)
* AddETNAVIV_PARAM_GPU_COHERENTto allow userspace to query
(Lucas)
* Remove etnaviv_gpu.no_clk member (Lucas)
* Fix Various typos and coding style fixed (Bjorn)
v8:
* Fix typos and remove unnecessary header included (Bjorn).
* Add a dedicated function to create the virtual master
platform
device.
v9:
* UsePCI_VDEVICE()macro (Bjorn)
* Add trivial stubs for the PCI driver (Bjorn)
* Remove a redundantdev_err()usage (Bjorn)
* Clean upetnaviv_pdev_probe()withetnaviv_of_first_available_node()
v10:
* Add one more cleanup patch
* Resolve the conflict with a patch from Rob
* Make the dummy PCI stub inlined
* Print only if the platform is dma-coherrent
V11:
* Drop unnecessary changes (Lucas)
* Tweak according to other reviews of v10.V12:
* Create a virtual platform device for the subcomponent GPU
cores
* Bind all subordinate GPU cores to the real PCI master via
component.V13:
* Drop the non-component code path, always use the component
framework
to bind subcomponent GPU core. Even though there is only
one core.
* Defer the irq handler register.
* Rebase and improve the commit message
Quoted 7 lines
Quoted 4 lines
V14:
* Rebase onto etnaviv-next and improve commit message.Tested with JD9230P GPU and LingJiu GP102 GPU.
BTW how should VRAM and displayed related parts be handled on these dGPUs?
Emm, I can only say I have no ideas.
Thanks for Christian's tested-by, but I'm a bit worry about if etnaviv
folks really like(or need) this. In the past, we started to contribute
before we know the policy/framework very well. I have to managed to
make things work before knowing the full picture. We developing drivers
in a rather rapid way and rather wild. Sometime, we do it just for fun. As the card don't has a usable driver, we want do something and we do have already learned the framework and knowledge.
But now as we know a bit more, I actually don't intend to brings concerns to other people. So only first 6 patch (or only part of them) are requested to be merged, patch 0007 or patch 0008 can just leave it there to be reviewed a bit longer if something is unsure.
Its totally up to etnaviv folks, I don't mind. Thanks for the nice project.
Signature · 2 lines
Best regards Sui
Lucas Stach
maintainerAm Dienstag, dem 25.06.2024 um 11:18 +0800 schrieb Icenowy Zheng:
Quoted 69 lines · 在 2024-05-20星期一的 00:53 +0800,Sui Jingfeng写道:
Quoted 68 lines
drm/etnaviv use the component framework to bind multiple GPU cores to a
virtual master, the virtual master is manually create during driver load
time. This works well for various SoCs, yet there are some PCIe card has
the vivante GPU cores integrated. The driver lacks the support for PCIe
devices currently.Adds PCIe driver wrapper on the top of what drm/etnaviv already has, the
component framework is still being used to bind subdevices, even though
there is only one GPU core. But the process is going to be reversed, we
create virtual platform device for each of the vivante GPU IP core shipped
by the PCIe master. The PCIe master is real, bind all the virtual child
to the master with component framework.v6:
* Fix build issue on system withoutCONFIG_PCIenabled v7:
* Add a separate patch for the platform driver rearrangement (Bjorn)
* Switch to runtime check if the GPU is dma coherent or not (Lucas)
* AddETNAVIV_PARAM_GPU_COHERENTto allow userspace to query (Lucas)
* Remove etnaviv_gpu.no_clk member (Lucas)
* Fix Various typos and coding style fixed (Bjorn) v8:
* Fix typos and remove unnecessary header included (Bjorn).
* Add a dedicated function to create the virtual master platform
device.
v9:
* UsePCI_VDEVICE()macro (Bjorn)
* Add trivial stubs for the PCI driver (Bjorn)
* Remove a redundantdev_err()usage (Bjorn)
* Clean upetnaviv_pdev_probe()withetnaviv_of_first_available_node()
v10:
* Add one more cleanup patch
* Resolve the conflict with a patch from Rob
* Make the dummy PCI stub inlined
* Print only if the platform is dma-coherrent V11:
* Drop unnecessary changes (Lucas)
* Tweak according to other reviews of v10.V12:
* Create a virtual platform device for the subcomponent GPU cores
* Bind all subordinate GPU cores to the real PCI master via component.V13:
* Drop the non-component code path, always use the component framework
to bind subcomponent GPU core. Even though there is only one core.
* Defer the irq handler register.
* Rebase and improve the commit message
Quoted 8 lines
Quoted 4 lines
V14:
* Rebase onto etnaviv-next and improve commit message.Tested with JD9230P GPU and LingJiu GP102 GPU.
BTW how should VRAM and displayed related parts be handled on these dGPUs?
The only way to handle VRAM properly would be to rewrite our GEM internals using TTM.
Regards,
Lucas
Quoted 35 lines
Quoted 34 lines
Sui Jingfeng (8):
drm/etnaviv: Add a dedicated helper function to get various clocks drm/etnaviv: Add constructor and destructor for theetnaviv_drm_privatestructure
drm/etnaviv: Embed structdrm_deviceinto structetnaviv_drm_private
drm/etnaviv: Fix wrong cache property being used forvmap()drm/etnaviv: Add support for cached coherent caching mode drm/etnaviv: Replace the '&pdev->dev' with 'dev' drm/etnaviv: Allow creating subdevices and pass platform specific data
drm/etnaviv: Add support for vivante GPU cores attached via PCIe devicedrivers/gpu/drm/etnaviv/Kconfig | 8 + drivers/gpu/drm/etnaviv/Makefile | 2 +
drivers/gpu/drm/etnaviv/etnaviv_drv.c | 159 ++++++++++------ drivers/gpu/drm/etnaviv/etnaviv_drv.h | 27 +++ drivers/gpu/drm/etnaviv/etnaviv_gem.c | 22 ++- drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c | 2 +- drivers/gpu/drm/etnaviv/etnaviv_gpu.c | 144 +++++++++----- drivers/gpu/drm/etnaviv/etnaviv_gpu.h | 4 + drivers/gpu/drm/etnaviv/etnaviv_mmu.c | 4 +-drivers/gpu/drm/etnaviv/etnaviv_pci_drv.c | 187
+++++++++++++++++++
drivers/gpu/drm/etnaviv/etnaviv_pci_drv.h | 18 ++ include/uapi/drm/etnaviv_drm.h | 1 +12 files changed, 468 insertions(+), 110 deletions(-)create mode 100644
drivers/gpu/drm/etnaviv/etnaviv_pci_drv.ccreate mode 100644drivers/gpu/drm/etnaviv/etnaviv_pci_drv.hbase-commit:
52272bfff15ee70c7bd5be9368f175948fb8ecfd
Quoted 88 lines · 在 2024-06-25星期二的 14:01 +0200,Lucas Stach写道:
Am Dienstag, dem 25.06.2024 um 11:18 +0800 schrieb Icenowy Zheng:
Quoted 87 lines · 在 2024-05-20星期一的 00:53 +0800,Sui Jingfeng写道:
Quoted 86 lines
drm/etnaviv use the component framework to bind multiple GPU cores to
a
virtual master, the virtual master is manually create during driver
load
time. This works well for various SoCs, yet there are some PCIe card
has
the vivante GPU cores integrated. The driver lacks the support for
PCIe
devices currently.Adds PCIe driver wrapper on the top of what drm/etnaviv already has,
the
component framework is still being used to bind subdevices, even though
there is only one GPU core. But the process is going to be reversed,
we
create virtual platform device for each of the vivante GPU IP core
shipped
by the PCIe master. The PCIe master is real, bind all the virtual child
to the master with component framework.v6:
* Fix build issue on system withoutCONFIG_PCIenabled v7:
* Add a separate patch for the platform driver rearrangement
(Bjorn)
* Switch to runtime check if the GPU is dma coherent or not
(Lucas)
* AddETNAVIV_PARAM_GPU_COHERENTto allow userspace to query
(Lucas)
* Remove etnaviv_gpu.no_clk member (Lucas)
* Fix Various typos and coding style fixed (Bjorn) v8:
* Fix typos and remove unnecessary header included (Bjorn).
* Add a dedicated function to create the virtual master platform
device.
v9:
* UsePCI_VDEVICE()macro (Bjorn)
* Add trivial stubs for the PCI driver (Bjorn)
* Remove a redundantdev_err()usage (Bjorn)
* Clean upetnaviv_pdev_probe()withetnaviv_of_first_available_node()
v10:
* Add one more cleanup patch
* Resolve the conflict with a patch from Rob
* Make the dummy PCI stub inlined
* Print only if the platform is dma-coherrent V11:
* Drop unnecessary changes (Lucas)
* Tweak according to other reviews of v10.V12:
* Create a virtual platform device for the subcomponent GPU
cores
* Bind all subordinate GPU cores to the real PCI master via
component.V13:
* Drop the non-component code path, always use the component
framework
to bind subcomponent GPU core. Even though there is only
one core.
* Defer the irq handler register.
* Rebase and improve the commit messageV14:
* Rebase onto etnaviv-next and improve commit message.
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
Tested with JD9230P GPU and LingJiu GP102 GPU.
BTW how should VRAM and displayed related parts be handled on these dGPUs?
The only way to handle VRAM properly would be to rewrite our GEM internals using TTM.
I suggest for these kind of dGPU to create a brand new driver instead.
BTW, Jingfeng, what's the situation of the Loongson 7A1000 GPU? Do it share the same address space with the CPU?
(The display of 7A is another virtual PCI device that is already handled in loongson-drm driver and don't need to be worried)
Quoted 45 lines
Regards,
LucasQuoted 40 lines
Quoted 39 lines
Sui Jingfeng (8):
drm/etnaviv: Add a dedicated helper function to get various clocks
drm/etnaviv: Add constructor and destructor for theetnaviv_drm_privatestructure
drm/etnaviv: Embed structdrm_deviceinto structetnaviv_drm_private
drm/etnaviv: Fix wrong cache property being used forvmap()drm/etnaviv: Add support for cached coherent caching mode drm/etnaviv: Replace the '&pdev->dev' with 'dev' drm/etnaviv: Allow creating subdevices and pass platform specific
data
drm/etnaviv: Add support for vivante GPU cores attached via PCIe
devicedrivers/gpu/drm/etnaviv/Kconfig | 8 + drivers/gpu/drm/etnaviv/Makefile | 2 + drivers/gpu/drm/etnaviv/etnaviv_drv.c | 159 ++++++++++---
---
drivers/gpu/drm/etnaviv/etnaviv_drv.h | 27 +++ drivers/gpu/drm/etnaviv/etnaviv_gem.c | 22 ++-drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c| 2 +- drivers/gpu/drm/etnaviv/etnaviv_gpu.c | 144 +++++++++---- -
drivers/gpu/drm/etnaviv/etnaviv_gpu.h | 4 + drivers/gpu/drm/etnaviv/etnaviv_mmu.c | 4 +- drivers/gpu/drm/etnaviv/etnaviv_pci_drv.c | 187
+++++++++++++++++++
drivers/gpu/drm/etnaviv/etnaviv_pci_drv.h | 18 ++ include/uapi/drm/etnaviv_drm.h | 1 +12 files changed, 468 insertions(+), 110 deletions(-)create mode 100644
drivers/gpu/drm/etnaviv/etnaviv_pci_drv.ccreate mode 100644drivers/gpu/drm/etnaviv/etnaviv_pci_drv.hbase-commit:
52272bfff15ee70c7bd5be9368f175948fb8ecfd