drm/etnaviv: add pci device driver support
Subsystems (3)
v3 cover drm/etnaviv: add pci device driver support
From: Sui Jingfeng <[email protected]>
There is a Vivante GC1000(v5037) in LS2K1000 and LS7A1000, the gpu is a PCI device and it has 2D and 3D core in the same gpu device. Therefore, this patch trying to add PCI device driver support on the great works already done by etnaviv folks.
LS7A1000 is a bridge chip for LS3A5000(4 core 2.5Ghz loongarch cpu) and LS3A4000(4 core 1.8gHz Mips64r5 cpu), While LS2K1000 is just a slow SoC (2 core 1.0Ghz mips64r2). Loongson CPU support cached coherent caching mode, both the GPU and DC device snoop CPU cache by default firmware configuration.
Sui Jingfeng (6):
drm/etnaviv: add a dedicate function to register irq handler for the
gpu
drm/etnaviv: add a dedicate function to get clock drm/etnaviv: add dedicate functions to create and destroy platform
device
drm/etnaviv: add helpers for private data construction and destruction drm/etnaviv: expand driver support for the pci devices drm/etnaviv: allow usperspace create cached coherent bo
drivers/gpu/drm/etnaviv/Makefile | 1 + drivers/gpu/drm/etnaviv/etnaviv_drv.c | 183 +++++++++++++------ drivers/gpu/drm/etnaviv/etnaviv_drv.h | 7 + drivers/gpu/drm/etnaviv/etnaviv_gem.c | 22 ++- drivers/gpu/drm/etnaviv/etnaviv_gem_prime.c | 9 +- drivers/gpu/drm/etnaviv/etnaviv_gpu.c | 185 ++++++++++++++------ drivers/gpu/drm/etnaviv/etnaviv_gpu.h | 13 ++ drivers/gpu/drm/etnaviv/etnaviv_pci_drv.c | 88 ++++++++++ drivers/gpu/drm/etnaviv/etnaviv_pci_drv.h | 10 ++ include/uapi/drm/etnaviv_drm.h | 11 +- 10 files changed, 415 insertions(+), 114 deletions(-) create mode 100644 drivers/gpu/drm/etnaviv/etnaviv_pci_drv.c create mode 100644 drivers/gpu/drm/etnaviv/etnaviv_pci_drv.h
Signature · 1 line
2.25.1
PATCH v3 1/6 drm/etnaviv: add a dedicate function to register irq handler for the gpu
From: Sui Jingfeng <[email protected]>
Because get irq from a device is platform dependent, pci device has different method to get irq. This patch is a preparation before we introduce support for the pci device.
--- drivers/gpu/drm/etnaviv/etnaviv_gpu.c | 34 ++++++++++++++++++++------- 1 file changed, 25 insertions(+), 9 deletions(-)
drivers/gpu/drm/etnaviv/etnaviv_gpu.c +25 -9
@@ -1817,6 +1817,29 @@ static const struct of_device_id etnaviv_gpu_match[] = { };MODULE_DEVICE_TABLE (of, etnaviv_gpu_match); +static int etnaviv_gpu_register_irq (struct etnaviv_gpu *gpu,int irq) +{ +struct device *dev = gpu->dev; +int err; + +if (irq <0 ) { +dev_err (dev,"failed to get irq: %d\n" , irq); +return irq; + } + + err =devm_request_irq (dev, irq, irq_handler,0 ,dev_name (dev), gpu); +if (err) { +dev_err (dev,"failed to request IRQ %u: %d\n" , irq, err); +return err; + } + + gpu->irq = irq; + +dev_info (dev,"IRQ handler registered, irq = %d\n" , irq); + +return 0 ; +} +static int etnaviv_gpu_platform_probe (struct platform_device *pdev) {struct device *dev = &pdev->dev;
@@ -1837,16 +1860,9 @@ static int etnaviv_gpu_platform_probe(struct platform_device *pdev)return PTR_ERR (gpu->mmio);/* Get Interrupt: */ - gpu->irq =platform_get_irq (pdev,0 ); -if (gpu->irq <0 ) -return gpu->irq; - - err =devm_request_irq (&pdev->dev, gpu->irq, irq_handler,0 , -dev_name (gpu->dev), gpu); -if (err) { -dev_err (dev,"failed to request IRQ%u: %d\n" , gpu->irq, err); + err =etnaviv_gpu_register_irq (gpu,platform_get_irq (pdev,0 )); +if (err)return err; - }/* Get Clocks: */ gpu->clk_reg =devm_clk_get_optional (&pdev->dev,"reg" );
Signature · 1 line
2.25.1
PATCH v3 2/6 drm/etnaviv: add a dedicate function to get clock
In reply to Sui JingfengFrom: Sui Jingfeng <[email protected]>
Because it is also platform dependent, there are environment which without clk subsystem support, we don't want the driver rage quit because of no clk subsystem driver support. There are discrete graphics card which integrate vivante gpu IP.
For the GPU in ls7a1000 and lsak2000, working frequency of the gpu is changed by configuring the PLL register directly.
--- drivers/gpu/drm/etnaviv/etnaviv_gpu.c | 62 ++++++++++++++++++--------- drivers/gpu/drm/etnaviv/etnaviv_gpu.h | 1 + 2 files changed, 42 insertions(+), 21 deletions(-)
drivers/gpu/drm/etnaviv/etnaviv_gpu.c +41 -21
@@ -1565,10 +1565,45 @@ 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; + +if (gpu->no_clk) +return 0 ; + + 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; +if (gpu->no_clk) +return 0 ; + ret =clk_prepare_enable (gpu->clk_reg);if (ret)return ret;
@@ -1599,6 +1634,9 @@ static int etnaviv_gpu_clk_enable(struct etnaviv_gpu *gpu)static int etnaviv_gpu_clk_disable (struct etnaviv_gpu *gpu) { +if (gpu->no_clk) +return 0 ; +clk_disable_unprepare (gpu->clk_shader);clk_disable_unprepare (gpu->clk_core);clk_disable_unprepare (gpu->clk_bus);
@@ -1865,27 +1903,9 @@ static int etnaviv_gpu_platform_probe(struct platform_device *pdev)return err;/* 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);
drivers/gpu/drm/etnaviv/etnaviv_gpu.h +1 -0
@@ -148,6 +148,7 @@ struct etnaviv_gpu {struct clk *clk_reg;struct clk *clk_core;struct clk *clk_shader; +bool no_clk;unsigned int freq_scale;unsigned long base_rate_core;
Signature · 1 line
2.25.1
PATCH v3 3/6 drm/etnaviv: add dedicate functions to create and destroy platform device
In reply to Sui JingfengFrom: Sui Jingfeng <[email protected]>
Also rename the virtual master device as etnaviv_platform_device, for better reflection that it is a platform device, not the drm device control structure. Another benefit is that we no longer need to call of_node_put() for three different case. Instead, we only need call it once.
--- drivers/gpu/drm/etnaviv/etnaviv_drv.c | 56 +++++++++++++++++++-------- 1 file changed, 39 insertions(+), 17 deletions(-)
drivers/gpu/drm/etnaviv/etnaviv_drv.c +39 -17
@@ -697,12 +697,44 @@ static struct platform_driver etnaviv_platform_driver = { }, }; -static struct platform_device *etnaviv_drm; +static struct platform_device *etnaviv_platform_device; -static int __init etnaviv_init (void ) +static int etnaviv_create_platform_device (const char *name, +struct platform_device **ppdev) {struct platform_device *pdev;int ret; + + pdev =platform_device_alloc (name,PLATFORM_DEVID_NONE ); +if (!pdev) +return -ENOMEM ; + + ret =platform_device_add (pdev); +if (ret) { +platform_device_put (pdev); +return ret; + } + + *ppdev = pdev; + +return 0 ; +} + +static void etnaviv_destroy_platform_device (struct platform_device **ppdev) +{ +struct platform_device *pdev = *ppdev; + +if (!pdev) +return ; + + *ppdev =NULL ; + +platform_device_unregister (pdev); +} + +static int __init etnaviv_init (void ) +{ +int ret;struct device_node *np;etnaviv_validate_init ();
@@ -723,22 +755,12 @@ static int __init etnaviv_init(void)if (!of_device_is_available (np))continue ; - pdev =platform_device_alloc ("etnaviv" ,PLATFORM_DEVID_NONE ); -if (!pdev) { - ret = -ENOMEM ; -of_node_put (np); - goto unregister_platform_driver; - } - - ret =platform_device_add (pdev); -if (ret) { -platform_device_put (pdev); -of_node_put (np); + ret =etnaviv_create_platform_device ("etnaviv" , + &etnaviv_platform_device); +of_node_put (np); +if (ret) goto unregister_platform_driver; - } - etnaviv_drm = pdev; -of_node_put (np);break ; }
@@ -754,7 +776,7 @@ module_init(etnaviv_init); static void __exit etnaviv_exit(void) { -platform_device_unregister (etnaviv_drm); +etnaviv_destroy_platform_device (&etnaviv_platform_device);platform_driver_unregister (&etnaviv_platform_driver);platform_driver_unregister (&etnaviv_gpu_driver); }
Signature · 1 line
2.25.1
PATCH v3 4/6 drm/etnaviv: add helpers for private data construction and destruction
In reply to Sui JingfengFrom: Sui Jingfeng <[email protected]>
struct etnaviv_drm_private contains a lot of common resources that is shared by all GPUs, members of it is large enough. This patch introduce two dedicate functions which is for the construction and destruction of the instance of this structure. The idea is avoid to leak its members to outside, then the error handling code can be simplified.
--- drivers/gpu/drm/etnaviv/etnaviv_drv.c | 71 +++++++++++++++++---------- drivers/gpu/drm/etnaviv/etnaviv_drv.h | 4 ++ 2 files changed, 50 insertions(+), 25 deletions(-)
drivers/gpu/drm/etnaviv/etnaviv_drv.c +46 -25
@@ -539,28 +539,17 @@ static const struct drm_driver etnaviv_drm_driver = { .minor = 3, }; -/* -* Platform driver: -*/ -static int etnaviv_bind (struct device *dev) +static int etnaviv_alloc_private (struct device *dev, +struct etnaviv_drm_private **ppriv) {struct etnaviv_drm_private *priv; -struct drm_device *drm;int ret; - drm =drm_dev_alloc (&etnaviv_drm_driver, 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 ; - goto out_put; +return -ENOMEM ; } - drm->dev_private = priv; - -dma_set_max_seg_size (dev,SZ_2G );xa_init_flags (&priv->active_contexts,XA_FLAGS_ALLOC );
@@ -569,18 +558,55 @@ static int etnaviv_bind(struct device *dev) priv->num_gpus =0 ; priv->shm_gfp_mask =GFP_HIGHUSER | __GFP_RETRY_MAYFAIL | __GFP_NOWARN; - priv->cmdbuf_suballoc =etnaviv_cmdbuf_suballoc_new (drm->dev); + priv->cmdbuf_suballoc =etnaviv_cmdbuf_suballoc_new (dev);if (IS_ERR (priv->cmdbuf_suballoc)) { -dev_err (drm->dev,"Failed to create cmdbuf suballocator\n" ); +dev_err (dev,"Failed to create cmdbuf suballocator\n" ); ret =PTR_ERR (priv->cmdbuf_suballoc); - goto out_free_priv; +kfree (priv); +return ret; } + *ppriv = priv; + +return 0 ; +} + +static void etnaviv_free_private (struct etnaviv_drm_private *priv) +{ +etnaviv_cmdbuf_suballoc_destroy (priv->cmdbuf_suballoc); + +xa_destroy (&priv->active_contexts); + +kfree (priv); +} + +/* +* Platform driver: +*/ +static int etnaviv_bind (struct device *dev) +{ +struct etnaviv_drm_private *priv; +struct drm_device *drm; +int ret; + + drm =drm_dev_alloc (&etnaviv_drm_driver, dev); +if (IS_ERR (drm)) +return PTR_ERR (drm); + + ret =etnaviv_alloc_private (dev, &priv); +if (ret) + goto out_put; + + priv->drm = drm; + drm->dev_private = priv; + +dma_set_max_seg_size (dev,SZ_2G ); +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);
@@ -592,10 +618,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);
@@ -611,12 +635,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); }
drivers/gpu/drm/etnaviv/etnaviv_drv.h +4 -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;
@@ -45,6 +46,9 @@ struct etnaviv_drm_private {struct xarray active_contexts;u32 next_context_id; +/* hint for platform support cached coherent caching mode */ +bool has_cached_coherent; +/* list of GEM objects: */ struct mutex gem_lock;struct list_head gem_list;
Signature · 1 line
2.25.1
PATCH v3 5/6 drm/etnaviv: expand driver support for the pci devices
In reply to Sui JingfengFrom: Sui Jingfeng <[email protected]>
This patch add pci driver support to etnaviv on the top of what already have, take the gc1000 in ls7a1000 and ls2k1000 as the first instance of the generic pci device driver.
There is only one gpu core for the gc1000 in ls7a1000 and ls2k1000, component framework can be avoid on such a case. Because we want to bind the drm driver service to the pci gpu driver manually at a first. step.
We avoid to using component framework, because userspace lib use libpciaccess to find available GPU in the system before initialization, the virtual drm master device will not be get used without a force override. X server is one of the examples, yet, mesa loader will do the similar thing, it will try to find the pci device to use in the system by default and then get a gallium driver name from the pci device id. The idea of create a virtual master for the system with pci gpu cause unnecessary troubles.
I not saying that component framework is not impossible, it is just that the solo pci device should be the master. Creating a virtual platform device is still useful, as we can bind some software service to the real GPU master to control the dpendency or loading order.
This is not only for pci devices, platform gpu with single core can also choose to try the non componment code path.
--- drivers/gpu/drm/etnaviv/Makefile | 1 + drivers/gpu/drm/etnaviv/etnaviv_drv.c | 62 ++++++++++++--- drivers/gpu/drm/etnaviv/etnaviv_drv.h | 3 + drivers/gpu/drm/etnaviv/etnaviv_gpu.c | 97 ++++++++++++++++------- drivers/gpu/drm/etnaviv/etnaviv_gpu.h | 12 +++ drivers/gpu/drm/etnaviv/etnaviv_pci_drv.c | 88 ++++++++++++++++++++ drivers/gpu/drm/etnaviv/etnaviv_pci_drv.h | 10 +++ 7 files changed, 232 insertions(+), 41 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/Makefile +1 -0
@@ -13,6 +13,7 @@ etnaviv-y := \ etnaviv_iommu_v2.o \ etnaviv_iommu.o \ etnaviv_mmu.o \ + etnaviv_pci_drv.o \ etnaviv_perfmon.o \ etnaviv_sched.o
drivers/gpu/drm/etnaviv/etnaviv_drv.c +49 -13
128 lines not on this page · raw message
drivers/gpu/drm/etnaviv/etnaviv_drv.h +3 -0
@@ -86,6 +86,9 @@ 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_drm_bind (struct device *dev,bool component); +void etnaviv_drm_unbind (struct device *dev,bool component); +#ifdef CONFIG_DEBUG_FS void etnaviv_gem_describe_objects (struct etnaviv_drm_private *priv,struct seq_file *m);
drivers/gpu/drm/etnaviv/etnaviv_gpu.c +69 -28
163 lines not on this page · raw message
drivers/gpu/drm/etnaviv/etnaviv_gpu.h +12 -0
@@ -207,6 +207,18 @@ void etnaviv_gpu_pm_put(struct etnaviv_gpu *gpu);int etnaviv_gpu_wait_idle (struct etnaviv_gpu *gpu,unsigned int timeout_ms);void etnaviv_gpu_start_fe (struct etnaviv_gpu *gpu,u32 address,u16 prefetch); +typedef int (*pfn_gpu_init_t )(struct etnaviv_gpu *gpu,bool component); +typedef void (*pfn_gpu_fini_t )(struct etnaviv_gpu *gpu,bool component); + +int etnaviv_gpu_driver_create (struct device *dev,int irq,bool component, +bool no_clk,pfn_gpu_init_t post_init); +void etnaviv_gpu_driver_destroy (struct device *dev,bool component, +pfn_gpu_fini_t early_fini); + +int etnaviv_gpu_bind (struct device *dev,struct device *master,void *data); +void etnaviv_gpu_unbind (struct device *dev,struct device *master,void *data); +extern struct platform_driver etnaviv_gpu_driver; +extern const struct dev_pm_ops etnaviv_gpu_pm_ops;#endif /* __ETNAVIV_GPU_H__ */
drivers/gpu/drm/etnaviv/etnaviv_pci_drv.c new file +88 -0
88 lines not on this page · raw message
drivers/gpu/drm/etnaviv/etnaviv_pci_drv.h new file +10 -0
@@ -0,0 +1,10 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#ifndef __ETNAVIV_PCI_DRV_H__ +#define __ETNAVIV_PCI_DRV_H__ + +#include <linux/pci.h> + +extern struct pci_driver etnaviv_pci_driver; + +#endif
Signature · 1 line
2.25.1
kernel test robot
build botRe: [PATCH v3 5/6] drm/etnaviv: expand driver support for the pci devices
Thank you for the patch! Yet something to improve:
Hi Sui,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on drm-misc/drm-misc-next]
[also build test ERROR on drm/drm-next drm-intel/for-linux-next drm-intel/for-linux-next-fixes drm-tip/drm-tip linus/master v6.3-rc4 next-20230329] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Sui-Jingfeng/drm-etnaviv-add-a-dedicate-function-to-register-irq-handler-for-the-gpu/20230330-045519 base: git://anongit.freedesktop.org/drm/drm-misc drm-misc-next patch link: https://lore.kernel.org/r/20230329205129.1513734-6-15330273260%40189.cn patch subject: [PATCH v3 5/6] drm/etnaviv: expand driver support for the pci devices config: arc-randconfig-r043-20230329 (https://download.01.org/0day-ci/archive/20230330/[email protected]/config) compiler: arc-elf-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/cfc3554b9fbd8ca3f3f6731d45d811bfa7fdf777
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Sui-Jingfeng/drm-etnaviv-add-a-dedicate-function-to-register-irq-handler-for-the-gpu/20230330-045519 git checkout cfc3554b9fbd8ca3f3f6731d45d811bfa7fdf777
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=arc olddefconfig COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=arc SHELL=/bin/bash drivers/gpu/drm/etnaviv/
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>
| Link: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
drivers/gpu/drm/etnaviv/etnaviv_pci_drv.c: In function 'etnaviv_gpu_pci_fini':
>> drivers/gpu/drm/etnaviv/etnaviv_pci_drv.c:32:9: error: implicit declaration of function 'pci_clear_master'; did you mean 'pci_set_master'? [-Werror=implicit-function-declaration]
32 | pci_clear_master(pdev);
| ^~~~~~~~~~~~~~~~
| pci_set_mastercc1: some warnings being treated as errors
vim +32 drivers/gpu/drm/etnaviv/etnaviv_pci_drv.c
27
28 static void etnaviv_gpu_pci_fini(struct etnaviv_gpu *gpu, bool component)
29 {
30 struct pci_dev *pdev = to_pci_dev(gpu->dev);
31
> 32 pci_clear_master(pdev);
33
34 dev_dbg(gpu->dev, "component is %s\n",
35 component ? "enabled" : "disabled");
36 }
37 Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests
Re: [PATCH v3 5/6] drm/etnaviv: expand driver support for the pci devices
Hi, pci_clear_master is located at pci.h.
Added by commit 6a479079c07211bf348ac8a79754f26bea258f26 (PCI: Add pci_clear_master() as opposite of pci_set_master())
I don't know what the reason arc architecture can't use this.
Quoted 56 lines · kernel test robot
Hi Sui,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on drm-misc/drm-misc-next]
[also build test ERROR on drm/drm-next drm-intel/for-linux-next drm-intel/for-linux-next-fixes drm-tip/drm-tip linus/master v6.3-rc4 next-20230329] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]url: https://github.com/intel-lab-lkp/linux/commits/Sui-Jingfeng/drm-etnaviv-add-a-dedicate-function-to-register-irq-handler-for-the-gpu/20230330-045519 base: git://anongit.freedesktop.org/drm/drm-misc drm-misc-next patch link: https://lore.kernel.org/r/20230329205129.1513734-6-15330273260%40189.cn patch subject: [PATCH v3 5/6] drm/etnaviv: expand driver support for the pci devices config: arc-randconfig-r043-20230329 (https://download.01.org/0day-ci/archive/20230330/[email protected]/config) compiler: arc-elf-gcc (GCC) 12.1.0reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/cfc3554b9fbd8ca3f3f6731d45d811bfa7fdf777
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Sui-Jingfeng/drm-etnaviv-add-a-dedicate-function-to-register-irq-handler-for-the-gpu/20230330-045519 git checkoutcfc3554b9fbd8ca3f3f6731d45d811bfa7fdf777
# save the config file
mkdirbuild_dir&& cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=arc olddefconfig COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=arc SHELL=/bin/bashdrivers/gpu/drm/etnaviv/If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>
| Link: https://lore.kernel.org/oe-kbuild-all/[email protected]/All errors (new ones prefixed by >>):
drivers/gpu/drm/etnaviv/etnaviv_pci_drv.c: In function 'etnaviv_gpu_pci_fini':Quoted 1 line
Quoted 1 line
drivers/gpu/drm/etnaviv/etnaviv_pci_drv.c:32:9: error: implicit declaration of function 'pci_clear_master'; did you mean 'pci_set_master'? [-Werror=implicit-function-declaration]32 | pci_clear_master(pdev); | ^~~~~~~~~~~~~~~~ | pci_set_mastercc1: some warnings being treated as errors
vim +32
drivers/gpu/drm/etnaviv/etnaviv_pci_drv.c27 28 static void etnaviv_gpu_pci_fini(struct etnaviv_gpu *gpu, bool component) 29 { 30 struct pci_dev *pdev = to_pci_dev(gpu->dev); 31Quoted 1 line
32
pci_clear_master(pdev);33 34 dev_dbg(gpu->dev, "component is %s\n", 35 component ? "enabled" : "disabled"); 36 } 37
PATCH v3 6/6 drm/etnaviv: allow usperspace create cached coherent bo
In reply to Sui JingfengFrom: Sui Jingfeng <[email protected]>
As Lucas pointed, there should have some way to let mesa query the kernel about the host platform whether support cached coherent mode or not. This should touch the ioctl stuff I think, bad design may lead new mesa or libdrm crash old kernel. It need more instruction how to implement this, maybe another patch to do this. Making this driver works on loongson platform is far enough for me.
--- drivers/gpu/drm/etnaviv/etnaviv_drv.c | 2 +- drivers/gpu/drm/etnaviv/etnaviv_gem.c | 22 +++++++++++++++++++-- drivers/gpu/drm/etnaviv/etnaviv_gem_prime.c | 9 ++++++++- include/uapi/drm/etnaviv_drm.h | 11 ++++++----- 4 files changed, 35 insertions(+), 9 deletions(-)
drivers/gpu/drm/etnaviv/etnaviv_drv.c +1 -1
@@ -276,7 +276,7 @@ static int etnaviv_ioctl_gem_new(struct drm_device *dev, void *data,struct drm_etnaviv_gem_new *args = data;if (args->flags & ~(ETNA_BO_CACHED |ETNA_BO_WC |ETNA_BO_UNCACHED | -ETNA_BO_FORCE_MMU )) +ETNA_BO_CACHED_COHERENT |ETNA_BO_FORCE_MMU ))return -EINVAL ; return etnaviv_gem_new_handle(dev, file, args->size,
drivers/gpu/drm/etnaviv/etnaviv_gem.c +20 -2
@@ -343,6 +343,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);
@@ -350,8 +351,20 @@ 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_COHERENT : +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)
@@ -545,6 +558,7 @@ static const struct drm_gem_object_funcs etnaviv_gem_object_funcs = {static int etnaviv_gem_new_impl (struct drm_device *dev,u32 size,u32 flags,const struct etnaviv_gem_ops *ops,struct drm_gem_object **obj) { +struct etnaviv_drm_private *priv = dev->dev_private;struct etnaviv_gem_object *etnaviv_obj;unsigned sz =sizeof (*etnaviv_obj);bool valid = true;
@@ -555,6 +569,10 @@ static int etnaviv_gem_new_impl(struct drm_device *dev, u32 size, u32 flags,case ETNA_BO_CACHED :case ETNA_BO_WC :break ; +case ETNA_BO_CACHED_COHERENT : +if (priv->has_cached_coherent) +break ; + fallthrough;default : valid = false; }
drivers/gpu/drm/etnaviv/etnaviv_gem_prime.c +8 -1
@@ -104,11 +104,18 @@ static const struct etnaviv_gem_ops etnaviv_gem_prime_ops = {struct drm_gem_object *etnaviv_gem_prime_import_sg_table (struct drm_device *dev,struct dma_buf_attachment *attach,struct sg_table *sgt) { +struct etnaviv_drm_private *priv = dev->dev_private;struct etnaviv_gem_object *etnaviv_obj;size_t size =PAGE_ALIGN (attach->dmabuf->size); +u32 cache_flags;int ret, npages; - ret =etnaviv_gem_new_private (dev, size,ETNA_BO_WC , +if (priv->has_cached_coherent) + cache_flags =ETNA_BO_CACHED_COHERENT ; +else + cache_flags =ETNA_BO_WC ; + + ret =etnaviv_gem_new_private (dev, size, cache_flags, &etnaviv_gem_prime_ops, &etnaviv_obj);if (ret <0 )return ERR_PTR (ret);
include/uapi/drm/etnaviv_drm.h +6 -5
@@ -90,13 +90,14 @@ struct drm_etnaviv_param {* GEM buffers: */ -#define ETNA_BO_CACHE_MASK 0x000f0000 +#define ETNA_BO_CACHE_MASK 0x000f0000/* cache modes */ -#define ETNA_BO_CACHED 0x00010000 -#define ETNA_BO_WC 0x00020000 -#define ETNA_BO_UNCACHED 0x00040000 +#define ETNA_BO_CACHED 0x00010000 +#define ETNA_BO_WC 0x00020000 +#define ETNA_BO_UNCACHED 0x00040000 +#define ETNA_BO_CACHED_COHERENT 0x00080000/* map flags */ -#define ETNA_BO_FORCE_MMU 0x00100000 +#define ETNA_BO_FORCE_MMU 0x00100000struct drm_etnaviv_gem_new {__u64 size;/* in */
Signature · 1 line
2.25.1