drm/nouveau: support for platform devices
Subsystems (5)
PATCH 1/1 drm/nouveau: support for platform devices
Upcoming mobile Kepler GPUs (such as GK20A) use the platform bus instead of PCI to which Nouveau is tightly dependent. This patch allows Nouveau to handle platform devices by:
- abstracting PCI-dependent functions that were typically used for resource querying and page mapping,
- introducing a nv_device_is_pci() function that allows to make PCI-dependent code conditional,
- providing a nouveau_drm_platform_probe() function that takes a GPU platform device to be probed.
Core code as well as engine/subdev drivers are updated wherever possible to make use of these functions. Some older drivers are too dependent on PCI to be properly updated, but all newer code on which future chips may depend should now at least be runnable with platform devices.
---
Sending this ahead since this has received no objections in the RFC and should be a no-op for PCI devices anyway. My hope is to get it merged quickly since many subsystems are touched and this makes maintainance difficult.
Squashed everything into one patch for convenience - most of the code is simple replacements, and it is one single logical change really. This version is more aggressive than the RFC in making code PCI-independent, since we ran into issues when code we didn't expect to be executed happened to be and was complaining about the absence of device->pdev.
drivers/gpu/drm/nouveau/core/engine/device/base.c | 104 ++++++++++++++++++++- drivers/gpu/drm/nouveau/core/engine/falcon.c | 6 +- drivers/gpu/drm/nouveau/core/engine/fifo/base.c | 2 +- drivers/gpu/drm/nouveau/core/engine/graph/nv20.c | 2 +- drivers/gpu/drm/nouveau/core/engine/graph/nv40.c | 2 +- drivers/gpu/drm/nouveau/core/engine/graph/nvc0.c | 4 +- drivers/gpu/drm/nouveau/core/engine/xtensa.c | 2 +- drivers/gpu/drm/nouveau/core/include/core/device.h | 30 ++++++ .../gpu/drm/nouveau/core/include/engine/device.h | 10 ++ drivers/gpu/drm/nouveau/core/include/subdev/mc.h | 1 + drivers/gpu/drm/nouveau/core/os.h | 1 + drivers/gpu/drm/nouveau/core/subdev/bar/base.c | 4 +- drivers/gpu/drm/nouveau/core/subdev/bar/nv50.c | 4 +- drivers/gpu/drm/nouveau/core/subdev/bar/nvc0.c | 15 ++- .../gpu/drm/nouveau/core/subdev/devinit/fbmem.h | 8 +- drivers/gpu/drm/nouveau/core/subdev/devinit/nv04.c | 2 +- drivers/gpu/drm/nouveau/core/subdev/devinit/nv05.c | 2 +- drivers/gpu/drm/nouveau/core/subdev/devinit/nv10.c | 2 +- drivers/gpu/drm/nouveau/core/subdev/devinit/nv20.c | 2 +- drivers/gpu/drm/nouveau/core/subdev/fb/nv50.c | 9 +- drivers/gpu/drm/nouveau/core/subdev/fb/nvc0.c | 9 +- drivers/gpu/drm/nouveau/core/subdev/i2c/base.c | 2 +- drivers/gpu/drm/nouveau/core/subdev/instmem/nv40.c | 7 +- drivers/gpu/drm/nouveau/core/subdev/mc/base.c | 39 +++++--- drivers/gpu/drm/nouveau/core/subdev/mxm/base.c | 2 +- drivers/gpu/drm/nouveau/nouveau_abi16.c | 13 ++- drivers/gpu/drm/nouveau/nouveau_bo.c | 22 +++-- drivers/gpu/drm/nouveau/nouveau_chan.c | 2 +- drivers/gpu/drm/nouveau/nouveau_display.c | 3 +- drivers/gpu/drm/nouveau/nouveau_drm.c | 75 ++++++++++++--- drivers/gpu/drm/nouveau/nouveau_sysfs.c | 8 +- drivers/gpu/drm/nouveau/nouveau_ttm.c | 31 +++--- 32 files changed, 318 insertions(+), 107 deletions(-)
drivers/gpu/drm/nouveau/core/engine/device/base.c +102 -2
@@ -131,8 +131,8 @@ nouveau_devobj_ctor(struct nouveau_object *parent,if (ret)return ret; - mmio_base =pci_resource_start (device->pdev,0 ); - mmio_size =pci_resource_len (device->pdev,0 ); + mmio_base =nv_device_resource_start (device,0 ); + mmio_size =nv_device_resource_len (device,0 );/* translate api disable mask into internal mapping */ disable = args->debug0;
@@ -446,6 +446,72 @@ nouveau_device_dtor(struct nouveau_object *object)nouveau_engine_destroy (&device->base); } +resource_size_t +nv_device_resource_start (struct nouveau_device *device,unsigned int bar) +{ +if (nv_device_is_pci (device)) { +return pci_resource_start (device->pdev, bar); + }else { +struct resource *res; + res =platform_get_resource (device->platformdev, +IORESOURCE_MEM , bar); +if (!res) +return 0 ; +return res->start; + } +} + +resource_size_t +nv_device_resource_len (struct nouveau_device *device,unsigned int bar) +{ +if (nv_device_is_pci (device)) { +return pci_resource_len (device->pdev, bar); + }else { +struct resource *res; + res =platform_get_resource (device->platformdev, +IORESOURCE_MEM , bar); +if (!res) +return 0 ; +return resource_size (res); + } +} + +dma_addr_t +nv_device_map_page (struct nouveau_device *device,struct page *page) +{ +dma_addr_t ret; + +if (nv_device_is_pci (device)) { + ret =pci_map_page (device->pdev, page,0 ,PAGE_SIZE , +PCI_DMA_BIDIRECTIONAL ); +if (pci_dma_mapping_error (device->pdev, ret)) + ret =0 ; + }else { + ret =page_to_phys (page); + } + +return ret; +} + +void +nv_device_unmap_page (struct nouveau_device *device,dma_addr_t addr) +{ +if (nv_device_is_pci (device)) +pci_unmap_page (device->pdev, addr,PAGE_SIZE , +PCI_DMA_BIDIRECTIONAL ); +} + +int +nv_device_get_irq (struct nouveau_device *device,bool stall) +{ +if (nv_device_is_pci (device)) { +return device->pdev->irq; + }else { +return platform_get_irq_byname (device->platformdev, + stall ?"stall" :"nonstall" ); + } +} +static struct nouveau_oclass nouveau_device_oclass = { .handle =NV_ENGINE (DEVICE ,0x00 ),
@@ -489,3 +555,37 @@ done:mutex_unlock (&nv_devices_mutex);return ret; } + +int +nouveau_device_platform_create_ (struct platform_device *pdev,u64 name, +const char *sname,const char *cfg, +const char *dbg,int length,void **pobject) +{ +struct nouveau_device *device; +int ret = -EEXIST ; + +mutex_lock (&nv_devices_mutex); +list_for_each_entry (device, &nv_devices, head) { +if (device->handle == name) + goto done; + } + + ret =nouveau_engine_create_ (NULL ,NULL , &nouveau_device_oclass, true, +"DEVICE" ,"device" , length, pobject); + device = *pobject; +if (ret) + goto done; + + device->platformdev = pdev; + device->handle = name; + device->cfgopt = cfg; + device->dbgopt = dbg; + device->name = sname; + +nv_subdev (device)->debug =nouveau_dbgopt (device->dbgopt,"DEVICE" ); +nv_engine (device)->sclass = nouveau_device_sclass; +list_add (&device->head, &nv_devices); +done: +mutex_unlock (&nv_devices_mutex); +return ret; +}
drivers/gpu/drm/nouveau/core/engine/falcon.c +3 -3
@@ -119,7 +119,7 @@ _nouveau_falcon_init(struct nouveau_object *object)snprintf (name,sizeof (name),"nouveau/nv%02x_fuc%03x" , device->chipset, falcon->addr >>12 ); - ret =request_firmware (&fw, name, &device->pdev->dev); + ret =request_firmware (&fw, name,nv_device_base (device));if (ret ==0 ) { falcon->code.data =vmemdup (fw->data, fw->size); falcon->code.size = fw->size;
@@ -138,7 +138,7 @@ _nouveau_falcon_init(struct nouveau_object *object)snprintf (name,sizeof (name),"nouveau/nv%02x_fuc%03xd" , device->chipset, falcon->addr >>12 ); - ret =request_firmware (&fw, name, &device->pdev->dev); + ret =request_firmware (&fw, name,nv_device_base (device));if (ret) {nv_error (falcon,"unable to load firmware data\n" );return ret;
@@ -153,7 +153,7 @@ _nouveau_falcon_init(struct nouveau_object *object)snprintf (name,sizeof (name),"nouveau/nv%02x_fuc%03xc" , device->chipset, falcon->addr >>12 ); - ret =request_firmware (&fw, name, &device->pdev->dev); + ret =request_firmware (&fw, name,nv_device_base (device));if (ret) {nv_error (falcon,"unable to load firmware code\n" );return ret;
drivers/gpu/drm/nouveau/core/engine/fifo/base.c +1 -1
@@ -86,7 +86,7 @@ nouveau_fifo_channel_create_(struct nouveau_object *parent, }/* map fifo control registers */ - chan->user =ioremap (pci_resource_start (device->pdev, bar) + addr + + chan->user =ioremap (nv_device_resource_start (device, bar) + addr + (chan->chid * size), size);if (!chan->user)return -EFAULT ;
drivers/gpu/drm/nouveau/core/engine/graph/nv20.c +1 -1
@@ -349,7 +349,7 @@ nv20_graph_init(struct nouveau_object *object)nv_wr32 (priv,NV10_PGRAPH_SURFACE , tmp);/* begin RAM config */ - vramsz =pci_resource_len (nv_device (priv)->pdev,0 ) -1 ; + vramsz =nv_device_resource_len (nv_device (priv),0 ) -1 ;nv_wr32 (priv,0x4009A4 ,nv_rd32 (priv,0x100200 ));nv_wr32 (priv,0x4009A8 ,nv_rd32 (priv,0x100204 ));nv_wr32 (priv,NV10_PGRAPH_RDI_INDEX ,0x00EA0000 );
drivers/gpu/drm/nouveau/core/engine/graph/nv40.c +1 -1
@@ -484,7 +484,7 @@ nv40_graph_init(struct nouveau_object *object) engine->tile_prog (engine, i);/* begin RAM config */ - vramsz =pci_resource_len (nv_device (priv)->pdev,0 ) -1 ; + vramsz =nv_device_resource_len (nv_device (priv),0 ) -1 ;switch (nv_device (priv)->chipset) {case 0x40 :nv_wr32 (priv,0x4009A4 ,nv_rd32 (priv,0x100200 ));
drivers/gpu/drm/nouveau/core/engine/graph/nvc0.c +2 -2
@@ -1091,10 +1091,10 @@ nvc0_graph_ctor_fw(struct nvc0_graph_priv *priv, const char *fwname,int ret;snprintf (f,sizeof (f),"nouveau/nv%02x_%s" , device->chipset, fwname); - ret =request_firmware (&fw, f, &device->pdev->dev); + ret =request_firmware (&fw, f,nv_device_base (device));if (ret) {snprintf (f,sizeof (f),"nouveau/%s" , fwname); - ret =request_firmware (&fw, f, &device->pdev->dev); + ret =request_firmware (&fw, f,nv_device_base (device));if (ret) {nv_error (priv,"failed to load %s\n" , fwname);return ret;
drivers/gpu/drm/nouveau/core/engine/xtensa.c +1 -1
@@ -112,7 +112,7 @@ _nouveau_xtensa_init(struct nouveau_object *object)snprintf (name,sizeof (name),"nouveau/nv84_xuc%03x" , xtensa->addr >>12 ); - ret =request_firmware (&fw, name, &device->pdev->dev); + ret =request_firmware (&fw, name,nv_device_base (device));if (ret) {nv_warn (xtensa,"unable to load firmware %s\n" , name);return ret;
drivers/gpu/drm/nouveau/core/include/core/device.h +30 -0
@@ -65,6 +65,7 @@ struct nouveau_device {struct list_head head;struct pci_dev *pdev; +struct platform_device *platformdev;u64 handle;const char *cfgopt;
@@ -140,4 +141,33 @@ nv_device_match(struct nouveau_object *object, u16 dev, u16 ven, u16 sub) device->pdev->subsystem_device == sub; } +static inline bool +nv_device_is_pci (struct nouveau_device *device) +{ +return device->pdev !=NULL ; +} + +static inline struct device * +nv_device_base (struct nouveau_device *device) +{ +return nv_device_is_pci (device) ? &device->pdev->dev : + &device->platformdev->dev; +} + +resource_size_t +nv_device_resource_start (struct nouveau_device *device,unsigned int bar); + +resource_size_t +nv_device_resource_len (struct nouveau_device *device,unsigned int bar); + +dma_addr_t +nv_device_map_page (struct nouveau_device *device,struct page *page); + +void +nv_device_unmap_page (struct nouveau_device *device,dma_addr_t addr); + +int +nv_device_get_irq (struct nouveau_device *device,bool stall); +#endif +
drivers/gpu/drm/nouveau/core/include/engine/device.h +10 -0
@@ -3,12 +3,22 @@#include <core/device.h> +struct platform_device ; +#define nouveau_device_create (p,n,s,c,d,u) \ nouveau_device_create_((p), (n), (s), (c), (d), sizeof(**u), (void **)u)int nouveau_device_create_ (struct pci_dev *,u64 name,const char *sname,const char *cfg,const char *dbg,int ,void **); +#define nouveau_device_platform_create (p,n,s,c,d,u) \ + nouveau_device_platform_create_((p), (n), (s), (c), (d), sizeof(**u), \ + (void **)u) + +int nouveau_device_platform_create_ (struct platform_device *pdev,u64 name, +const char *sname,const char *cfg, +const char *dbg,int ,void **); +int nv04_identify (struct nouveau_device *);int nv10_identify (struct nouveau_device *);int nv20_identify (struct nouveau_device *);
drivers/gpu/drm/nouveau/core/include/subdev/mc.h +1 -0
@@ -12,6 +12,7 @@ struct nouveau_mc_intr {struct nouveau_mc {struct nouveau_subdev base;bool use_msi; +unsigned int irq; }; static inline struct nouveau_mc *
drivers/gpu/drm/nouveau/core/os.h +1 -0
@@ -5,6 +5,7 @@#include <linux/slab.h> #include <linux/mutex.h> #include <linux/pci.h> +#include <linux/platform_device.h> #include <linux/printk.h> #include <linux/bitops.h> #include <linux/firmware.h>
drivers/gpu/drm/nouveau/core/subdev/bar/base.c +2 -2
@@ -118,8 +118,8 @@ nouveau_bar_create_(struct nouveau_object *parent,if (ret)return ret; - bar->iomem =ioremap (pci_resource_start (device->pdev,3 ), -pci_resource_len (device->pdev,3 )); + bar->iomem =ioremap (nv_device_resource_start (device,3 ), +nv_device_resource_len (device,3 ));return 0 ; }
drivers/gpu/drm/nouveau/core/subdev/bar/nv50.c +2 -2
@@ -139,7 +139,7 @@ nv50_bar_ctor(struct nouveau_object *parent, struct nouveau_object *engine,/* BAR3 */ start =0x0100000000ULL ; - limit = start +pci_resource_len (device->pdev,3 ); + limit = start +nv_device_resource_len (device,3 ); ret =nouveau_vm_new (device, start, limit, start, &vm);if (ret)
@@ -173,7 +173,7 @@ nv50_bar_ctor(struct nouveau_object *parent, struct nouveau_object *engine,/* BAR1 */ start =0x0000000000ULL ; - limit = start +pci_resource_len (device->pdev,1 ); + limit = start +nv_device_resource_len (device,1 ); ret =nouveau_vm_new (device, start, limit--, start, &vm);if (ret)
drivers/gpu/drm/nouveau/core/subdev/bar/nvc0.c +7 -8
@@ -84,7 +84,6 @@ nvc0_bar_ctor(struct nouveau_object *parent, struct nouveau_object *engine, struct nouveau_object **pobject) {struct nouveau_device *device =nv_device (parent); -struct pci_dev *pdev = device->pdev;struct nvc0_bar_priv *priv;struct nouveau_gpuobj *mem;struct nouveau_vm *vm;
@@ -107,14 +106,14 @@ nvc0_bar_ctor(struct nouveau_object *parent, struct nouveau_object *engine,if (ret)return ret; - ret =nouveau_vm_new (device,0 ,pci_resource_len (pdev,3 ),0 , &vm); + ret =nouveau_vm_new (device,0 ,nv_device_resource_len (device,3 ),0 , &vm);if (ret)return ret;atomic_inc (&vm->engref[NVDEV_SUBDEV_BAR ]); ret =nouveau_gpuobj_new (nv_object (priv),NULL , - (pci_resource_len (pdev,3 ) >>12 ) *8 , + (nv_device_resource_len (device,3 ) >>12 ) *8 ,0x1000 ,NVOBJ_FLAG_ZERO_ALLOC , &vm->pgt[0 ].obj[0 ]); vm->pgt[0 ].refcount[0 ] =1 ;
@@ -128,8 +127,8 @@ nvc0_bar_ctor(struct nouveau_object *parent, struct nouveau_object *engine,nv_wo32 (mem,0x0200 ,lower_32_bits (priv->bar[0 ].pgd->addr));nv_wo32 (mem,0x0204 ,upper_32_bits (priv->bar[0 ].pgd->addr)); -nv_wo32 (mem,0x0208 ,lower_32_bits (pci_resource_len (pdev,3 ) -1 )); -nv_wo32 (mem,0x020c ,upper_32_bits (pci_resource_len (pdev,3 ) -1 )); +nv_wo32 (mem,0x0208 ,lower_32_bits (nv_device_resource_len (device,3 ) -1 )); +nv_wo32 (mem,0x020c ,upper_32_bits (nv_device_resource_len (device,3 ) -1 ));/* BAR1 */ ret = nouveau_gpuobj_new(nv_object(priv), NULL, 0x1000, 0, 0,
@@ -143,7 +142,7 @@ nvc0_bar_ctor(struct nouveau_object *parent, struct nouveau_object *engine,if (ret)return ret; - ret =nouveau_vm_new (device,0 ,pci_resource_len (pdev,1 ),0 , &vm); + ret =nouveau_vm_new (device,0 ,nv_device_resource_len (device,1 ),0 , &vm);if (ret)return ret;
@@ -156,8 +155,8 @@ nvc0_bar_ctor(struct nouveau_object *parent, struct nouveau_object *engine,nv_wo32 (mem,0x0200 ,lower_32_bits (priv->bar[1 ].pgd->addr));nv_wo32 (mem,0x0204 ,upper_32_bits (priv->bar[1 ].pgd->addr)); -nv_wo32 (mem,0x0208 ,lower_32_bits (pci_resource_len (pdev,1 ) -1 )); -nv_wo32 (mem,0x020c ,upper_32_bits (pci_resource_len (pdev,1 ) -1 )); +nv_wo32 (mem,0x0208 ,lower_32_bits (nv_device_resource_len (device,1 ) -1 )); +nv_wo32 (mem,0x020c ,upper_32_bits (nv_device_resource_len (device,1 ) -1 )); priv->base.alloc = nouveau_bar_alloc; priv->base.kmap = nvc0_bar_kmap;
drivers/gpu/drm/nouveau/core/subdev/devinit/fbmem.h +5 -3
@@ -24,6 +24,8 @@* */ +#include <core/device.h> +#define NV04_PFB_BOOT_0 0x00100000# define NV04_PFB_BOOT_0_RAM_AMOUNT 0x00000003# define NV04_PFB_BOOT_0_RAM_AMOUNT_32MB 0x00000000
@@ -60,10 +62,10 @@# define NV10_PFB_REFCTRL_VALID_1 (1 << 31)static inline struct io_mapping * -fbmem_init (struct pci_dev *pdev) +fbmem_init (struct nouveau_device *dev) { -return io_mapping_create_wc (pci_resource_start (pdev,1 ), -pci_resource_len (pdev,1 )); +return io_mapping_create_wc (nv_device_resource_start (dev,1 ), +nv_device_resource_len (dev,1 )); } static inline void
drivers/gpu/drm/nouveau/core/subdev/devinit/nv04.c +1 -1
@@ -38,7 +38,7 @@ nv04_devinit_meminit(struct nouveau_devinit *devinit)int i;/* Map the framebuffer aperture */ - fb =fbmem_init (nv_device (priv)->pdev); + fb =fbmem_init (nv_device (priv));if (!fb) {nv_error (priv,"failed to map fb\n" );return ;
drivers/gpu/drm/nouveau/core/subdev/devinit/nv05.c +1 -1
@@ -53,7 +53,7 @@ nv05_devinit_meminit(struct nouveau_devinit *devinit)int i, v;/* Map the framebuffer aperture */ - fb =fbmem_init (nv_device (priv)->pdev); + fb =fbmem_init (nv_device (priv));if (!fb) {nv_error (priv,"failed to map fb\n" );return ;
drivers/gpu/drm/nouveau/core/subdev/devinit/nv10.c +1 -1
@@ -46,7 +46,7 @@ nv10_devinit_meminit(struct nouveau_devinit *devinit) mem_width_count =2 ;/* Map the framebuffer aperture */ - fb =fbmem_init (nv_device (priv)->pdev); + fb =fbmem_init (nv_device (priv));if (!fb) {nv_error (priv,"failed to map fb\n" );return ;
drivers/gpu/drm/nouveau/core/subdev/devinit/nv20.c +1 -1
@@ -37,7 +37,7 @@ nv20_devinit_meminit(struct nouveau_devinit *devinit)struct io_mapping *fb;/* Map the framebuffer aperture */ - fb =fbmem_init (nv_device (priv)->pdev); + fb =fbmem_init (nv_device (priv));if (!fb) {nv_error (priv,"failed to map fb\n" );return ;
drivers/gpu/drm/nouveau/core/subdev/fb/nv50.c +3 -6
@@ -250,10 +250,8 @@ nv50_fb_ctor(struct nouveau_object *parent, struct nouveau_object *engine, priv->r100c08_page =alloc_page (GFP_KERNEL | __GFP_ZERO);if (priv->r100c08_page) { - priv->r100c08 =pci_map_page (device->pdev, priv->r100c08_page, -0 ,PAGE_SIZE , -PCI_DMA_BIDIRECTIONAL ); -if (pci_dma_mapping_error (device->pdev, priv->r100c08)) + priv->r100c08 =nv_device_map_page (device, priv->r100c08_page); +if (!priv->r100c08)nv_warn (priv,"failed 0x100c08 page map\n" ); }else {nv_warn (priv,"failed 0x100c08 page alloc\n" );
@@ -270,8 +268,7 @@ nv50_fb_dtor(struct nouveau_object *object)struct nv50_fb_priv *priv = (void *)object;if (priv->r100c08_page) { -pci_unmap_page (device->pdev, priv->r100c08,PAGE_SIZE , -PCI_DMA_BIDIRECTIONAL ); +nv_device_unmap_page (device, priv->r100c08);__free_page (priv->r100c08_page); }
drivers/gpu/drm/nouveau/core/subdev/fb/nvc0.c +3 -6
@@ -70,8 +70,7 @@ nvc0_fb_dtor(struct nouveau_object *object)struct nvc0_fb_priv *priv = (void *)object;if (priv->r100c10_page) { -pci_unmap_page (device->pdev, priv->r100c10,PAGE_SIZE , -PCI_DMA_BIDIRECTIONAL ); +nv_device_unmap_page (device, priv->r100c10);__free_page (priv->r100c10_page); }
@@ -94,10 +93,8 @@ nvc0_fb_ctor(struct nouveau_object *parent, struct nouveau_object *engine, priv->r100c10_page =alloc_page (GFP_KERNEL | __GFP_ZERO);if (priv->r100c10_page) { - priv->r100c10 =pci_map_page (device->pdev, priv->r100c10_page, -0 ,PAGE_SIZE , -PCI_DMA_BIDIRECTIONAL ); -if (pci_dma_mapping_error (device->pdev, priv->r100c10)) + priv->r100c10 =nv_device_map_page (device, priv->r100c10_page); +if (!priv->r100c10)return -EFAULT ; }
drivers/gpu/drm/nouveau/core/subdev/i2c/base.c +1 -1
@@ -111,7 +111,7 @@ nouveau_i2c_port_create_(struct nouveau_object *parent,snprintf (port->adapter.name,sizeof (port->adapter.name),"nouveau-%s-%d" , device->name, index); port->adapter.owner =THIS_MODULE ; - port->adapter.dev.parent = &device->pdev->dev; + port->adapter.dev.parent =nv_device_base (device); port->index = index; port->func = func;i2c_set_adapdata (&port->adapter, i2c);
drivers/gpu/drm/nouveau/core/subdev/instmem/nv40.c +3 -4
@@ -50,7 +50,6 @@ nv40_instmem_ctor(struct nouveau_object *parent, struct nouveau_object *engine, struct nouveau_object **pobject) {struct nouveau_device *device =nv_device (parent); -struct pci_dev *pdev = device->pdev;struct nv04_instmem_priv *priv;int ret, bar, vs;
@@ -60,13 +59,13 @@ nv40_instmem_ctor(struct nouveau_object *parent, struct nouveau_object *engine,return ret;/* map bar */ -if (pci_resource_len (pdev,2 )) +if (nv_device_resource_len (device,2 )) bar =2 ;else bar =3 ; - priv->iomem =ioremap (pci_resource_start (pdev, bar), -pci_resource_len (pdev, bar)); + priv->iomem =ioremap (nv_device_resource_start (device, bar), +nv_device_resource_len (device, bar));if (!priv->iomem) {nv_error (priv,"unable to map PRAMIN BAR\n" );return -EFAULT ;
drivers/gpu/drm/nouveau/core/subdev/mc/base.c +24 -15
@@ -93,8 +93,8 @@ _nouveau_mc_dtor(struct nouveau_object *object) {struct nouveau_device *device =nv_device (object);struct nouveau_mc *pmc = (void *)object; -free_irq (device->pdev->irq, pmc); -if (pmc->use_msi) +free_irq (pmc->irq, pmc); +if (nv_device_is_pci (device) && pmc->use_msi)pci_disable_msi (device->pdev);nouveau_subdev_destroy (&pmc->base); }
@@ -114,22 +114,25 @@ nouveau_mc_create_(struct nouveau_object *parent, struct nouveau_object *engine,if (ret)return ret; -switch (device->pdev->device &0x0ff0 ) { -case 0x00f0 : -case 0x02e0 : -/* BR02? NFI how these would be handled yet exactly */ -break ; -default : -switch (device->chipset) { -case 0xaa :break ;/* reported broken, nv also disable it */ -default : - pmc->use_msi = true; +if (nv_device_is_pci (device)) +switch (device->pdev->device &0x0ff0 ) { +case 0x00f0 : +case 0x02e0 : +/* BR02? NFI how these would be handled yet exactly */ break ; +default : +switch (device->chipset) { +case 0xaa : +/* reported broken, nv also disable it */ +break ; +default : + pmc->use_msi = true; +break ; } } pmc->use_msi =nouveau_boolopt (device->cfgopt,"NvMSI" , pmc->use_msi); -if (pmc->use_msi && oclass->msi_rearm) { +if (nv_device_is_pci (device) && pmc->use_msi && oclass->msi_rearm) { pmc->use_msi =pci_enable_msi (device->pdev) ==0 ;if (pmc->use_msi) {nv_info (pmc,"MSI interrupts enabled\n" );
@@ -139,8 +142,14 @@ nouveau_mc_create_(struct nouveau_object *parent, struct nouveau_object *engine, pmc->use_msi = false; } - ret =request_irq (device->pdev->irq, nouveau_mc_intr, -IRQF_SHARED ,"nouveau" , pmc); + ret =nv_device_get_irq (device, true); +if (ret <0 ) +return ret; + pmc->irq = ret; + + ret =request_irq (pmc->irq, nouveau_mc_intr,IRQF_SHARED ,"nouveau" , + pmc); +if (ret <0 )return ret;
drivers/gpu/drm/nouveau/core/subdev/mxm/base.c +1 -1
@@ -96,7 +96,7 @@ mxm_shadow_dsm(struct nouveau_mxm *mxm, u8 version)acpi_handle handle;int rev; - handle =ACPI_HANDLE (&device->pdev->dev); + handle =ACPI_HANDLE (nv_device_base (device));if (!handle)return false;
drivers/gpu/drm/nouveau/nouveau_abi16.c +11 -2
@@ -179,12 +179,21 @@ nouveau_abi16_ioctl_getparam(ABI16_IOCTL_ARGS) getparam->value = device->chipset;break ;case NOUVEAU_GETPARAM_PCI_VENDOR : - getparam->value = dev->pdev->vendor; +if (nv_device_is_pci (device)) + getparam->value = dev->pdev->vendor; +else + getparam->value =0 ;break ;case NOUVEAU_GETPARAM_PCI_DEVICE : - getparam->value = dev->pdev->device; +if (nv_device_is_pci (device)) + getparam->value = dev->pdev->device; +else + getparam->value =0 ;break ;case NOUVEAU_GETPARAM_BUS_TYPE : +if (!nv_device_is_pci (device)) + getparam->value =3 ; +else if (drm_pci_device_is_agp (dev)) getparam->value =0 ;else
drivers/gpu/drm/nouveau/nouveau_bo.c +12 -10
@@ -1255,7 +1255,7 @@ nouveau_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_mem_reg *mem)/* fallthrough, tiled memory */ case TTM_PL_VRAM : mem->bus.offset = mem->start <<PAGE_SHIFT ; - mem->bus.base =pci_resource_start (dev->pdev,1 ); + mem->bus.base =nv_device_resource_start (nouveau_dev (dev),1 ); mem->bus.is_iomem = true;if (nv_device (drm->device)->card_type >=NV_50 ) {struct nouveau_bar *bar =nouveau_bar (drm->device);
@@ -1293,7 +1293,7 @@ nouveau_ttm_fault_reserve_notify(struct ttm_buffer_object *bo)struct nouveau_drm *drm =nouveau_bdev (bo->bdev);struct nouveau_bo *nvbo =nouveau_bo (bo);struct nouveau_device *device =nv_device (drm->device); -u32 mappable =pci_resource_len (device->pdev,1 ) >>PAGE_SHIFT ; +u32 mappable =nv_device_resource_len (device,1 ) >>PAGE_SHIFT ;int ret;/* as long as the bo isn't in vram, and isn't tiled, we've got
@@ -1331,6 +1331,7 @@ nouveau_ttm_tt_populate(struct ttm_tt *ttm) {struct ttm_dma_tt *ttm_dma = (void *)ttm;struct nouveau_drm *drm; +struct nouveau_device *device;struct drm_device *dev;unsigned i;int r;
@@ -1348,6 +1349,7 @@ nouveau_ttm_tt_populate(struct ttm_tt *ttm) } drm =nouveau_bdev (ttm->bdev); + device =nv_device (drm->device); dev = drm->dev;#if __OS_HAS_AGP
@@ -1368,13 +1370,12 @@ nouveau_ttm_tt_populate(struct ttm_tt *ttm) }for (i =0 ; i < ttm->num_pages; i++) { - ttm_dma->dma_address[i] =pci_map_page (dev->pdev, ttm->pages[i], -0 ,PAGE_SIZE , -PCI_DMA_BIDIRECTIONAL ); -if (pci_dma_mapping_error (dev->pdev, ttm_dma->dma_address[i])) { + ttm_dma->dma_address[i] =nv_device_map_page (device, + ttm->pages[i]); +if (!ttm_dma->dma_address[i]) {while (--i) { -pci_unmap_page (dev->pdev, ttm_dma->dma_address[i], -PAGE_SIZE ,PCI_DMA_BIDIRECTIONAL ); +nv_device_unmap_page (device, + ttm_dma->dma_address[i]); ttm_dma->dma_address[i] =0 ; }ttm_pool_unpopulate (ttm);
@@ -1389,6 +1390,7 @@ nouveau_ttm_tt_unpopulate(struct ttm_tt *ttm) {struct ttm_dma_tt *ttm_dma = (void *)ttm;struct nouveau_drm *drm; +struct nouveau_device *device;struct drm_device *dev;unsigned i;bool slave = !!(ttm->page_flags &TTM_PAGE_FLAG_SG );
@@ -1397,6 +1399,7 @@ nouveau_ttm_tt_unpopulate(struct ttm_tt *ttm)return ; drm =nouveau_bdev (ttm->bdev); + device =nv_device (drm->device); dev = drm->dev;#if __OS_HAS_AGP
@@ -1415,8 +1418,7 @@ nouveau_ttm_tt_unpopulate(struct ttm_tt *ttm)for (i =0 ; i < ttm->num_pages; i++) {if (ttm_dma->dma_address[i]) { -pci_unmap_page (dev->pdev, ttm_dma->dma_address[i], -PAGE_SIZE ,PCI_DMA_BIDIRECTIONAL ); +nv_device_unmap_page (device, ttm_dma->dma_address[i]); } }
drivers/gpu/drm/nouveau/nouveau_chan.c +1 -1
@@ -154,7 +154,7 @@ nouveau_channel_prep(struct nouveau_drm *drm, struct nouveau_cli *cli,* nfi why this exists, it came from the -nv ddx. */ args.flags =NV_DMA_TARGET_PCI |NV_DMA_ACCESS_RDWR ; - args.start =pci_resource_start (device->pdev,1 ); + args.start =nv_device_resource_len (device,1 ); args.limit = args.start + limit; }else { args.flags =NV_DMA_TARGET_VRAM |NV_DMA_ACCESS_RDWR ;
drivers/gpu/drm/nouveau/nouveau_display.c +2 -1
@@ -339,6 +339,7 @@ int nouveau_display_create(struct drm_device *dev) {struct nouveau_drm *drm =nouveau_drm (dev); +struct nouveau_device *device =nouveau_dev (dev);struct nouveau_display *disp;int ret, gen;
@@ -379,7 +380,7 @@ nouveau_display_create(struct drm_device *dev) } dev->mode_config.funcs = &nouveau_mode_config_funcs; - dev->mode_config.fb_base =pci_resource_start (dev->pdev,1 ); + dev->mode_config.fb_base =nv_device_resource_start (device,1 ); dev->mode_config.min_width =0 ; dev->mode_config.min_height =0 ;
drivers/gpu/drm/nouveau/nouveau_drm.c +61 -14
148 lines not on this page · raw message
drivers/gpu/drm/nouveau/nouveau_sysfs.c +5 -3
@@ -30,7 +30,7 @@static inline struct drm_device *drm_device (struct device *d) { -return pci_get_drvdata (to_pci_dev (d)); +return dev_get_drvdata (d); } #define snappendf(p,r,f,a...) do { \
@@ -132,9 +132,10 @@ nouveau_sysfs_fini(struct drm_device *dev) {struct nouveau_sysfs *sysfs =nouveau_sysfs (dev);struct nouveau_drm *drm =nouveau_drm (dev); +struct nouveau_device *device =nv_device (drm->device);if (sysfs->ctrl) { -device_remove_file (&dev->pdev->dev, &dev_attr_pstate); +device_remove_file (nv_device_base (device), &dev_attr_pstate);nouveau_object_del (nv_object (drm),NVDRM_DEVICE ,NVDRM_CONTROL ); }
@@ -146,6 +147,7 @@ int nouveau_sysfs_init(struct drm_device *dev) {struct nouveau_drm *drm =nouveau_drm (dev); +struct nouveau_device *device =nv_device (drm->device);struct nouveau_sysfs *sysfs;int ret;
@@ -156,7 +158,7 @@ nouveau_sysfs_init(struct drm_device *dev) ret =nouveau_object_new (nv_object (drm),NVDRM_DEVICE ,NVDRM_CONTROL ,NV_CONTROL_CLASS ,NULL ,0 , &sysfs->ctrl);if (ret ==0 ) -device_create_file (&dev->pdev->dev, &dev_attr_pstate); +device_create_file (nv_device_base (device), &dev_attr_pstate);return 0 ; }
drivers/gpu/drm/nouveau/nouveau_ttm.c +18 -13
@@ -354,21 +354,26 @@ int nouveau_ttm_init(struct nouveau_drm *drm) {struct drm_device *dev = drm->dev; +struct nouveau_device *device =nv_device (drm->device);u32 bits;int ret; bits =nouveau_vmmgr (drm->device)->dma_bits; -if ( drm->agp.stat ==ENABLED || - !pci_dma_supported (dev->pdev,DMA_BIT_MASK (bits))) - bits =32 ; - - ret =pci_set_dma_mask (dev->pdev,DMA_BIT_MASK (bits)); -if (ret) -return ret; - - ret =pci_set_consistent_dma_mask (dev->pdev,DMA_BIT_MASK (bits)); -if (ret) -pci_set_consistent_dma_mask (dev->pdev,DMA_BIT_MASK (32 )); +if (nv_device_is_pci (device)) { +if (drm->agp.stat ==ENABLED || + !pci_dma_supported (dev->pdev,DMA_BIT_MASK (bits))) + bits =32 ; + + ret =pci_set_dma_mask (dev->pdev,DMA_BIT_MASK (bits)); +if (ret) +return ret; + + ret =pci_set_consistent_dma_mask (dev->pdev, +DMA_BIT_MASK (bits)); +if (ret) +pci_set_consistent_dma_mask (dev->pdev, +DMA_BIT_MASK (32 )); + } ret =nouveau_ttm_global_init (drm);if (ret)
@@ -394,8 +399,8 @@ nouveau_ttm_init(struct nouveau_drm *drm)return ret; } - drm->ttm.mtrr =arch_phys_wc_add (pci_resource_start (dev->pdev,1 ), -pci_resource_len (dev->pdev,1 )); + drm->ttm.mtrr =arch_phys_wc_add (nv_device_resource_start (device,1 ), +nv_device_resource_len (device,1 ));/* GART init */ if (drm->agp.stat !=ENABLED ) {
Signature · 1 line
1.8.5.4
On Mon, Feb 10, 2014 at 02:53:00PM +0900, Alexandre Courbot wrote:
[...]
Quoted 1 line
drivers/gpu/drm/nouveau/core/engine/device/base.c +0
-0
[...]
Quoted 19 lines
drivers/gpu/drm/nouveau/core/engine/device/base.c +19
-0+resource_size_t +nv_device_resource_start (struct nouveau_device *device,unsigned int bar) +{ +if (nv_device_is_pci (device)) { +return pci_resource_start (device->pdev, bar); + }else { +struct resource *res; + res =platform_get_resource (device->platformdev, +IORESOURCE_MEM , bar); +if (!res) +return 0 ; +return res->start; + } +} + +resource_size_t +nv_device_resource_len (struct nouveau_device *device,unsigned int bar) +{ +if (nv_device_is_pci (device)) {
drivers/gpu/drm/nouveau/core/engine/device/base.c nouveau_device_dtor(struct nouveau_object *object) · line 477
Quoted 10 lines
drivers/gpu/drm/nouveau/core/engine/device/base.c +10
-0+return pci_resource_len (device->pdev, bar); + }else { +struct resource *res; + res =platform_get_resource (device->platformdev, +IORESOURCE_MEM , bar); +if (!res) +return 0 ; +return resource_size (res); + } +}
Perhaps instead of these two, something like this could be done:
const struct resource *
nv_device_resource(struct nouveau_device *device, unsigned int bar)
{
if (nv_device_is_pci(device)
return &device->pdev->resource[bar];
else
return platform_get_resource(device->platformdev,
IORESOURCE_MEM, bar);
}Then the more generic resource_size() can be used directly on the returned struct resource *. Doing so may come in handy if you ever need to display the resource for debugging purposes, since you could simply use the %pR format specifier. It could also be slightly more efficient, since the structure doesn't have to be looked up twice. But perhaps the compiler will be clever enough to optimize that away and it's not like this is called from a hot path.
I do see that pci_resource_len() does additional checking for BARs that have zero size (start == 0 && end == start), so it's not exactly the same, but I think there's another issue with that, see below.
Quoted 23 lines
drivers/gpu/drm/nouveau/core/engine/device/base.c +23
-0+int +nouveau_device_platform_create_ (struct platform_device *pdev,u64 name, +const char *sname,const char *cfg, +const char *dbg,int length,void **pobject) +{ +struct nouveau_device *device; +int ret = -EEXIST ; + +mutex_lock (&nv_devices_mutex); +list_for_each_entry (device, &nv_devices, head) { +if (device->handle == name) + goto done; + } + + ret =nouveau_engine_create_ (NULL ,NULL , &nouveau_device_oclass, true, +"DEVICE" ,"device" , length, pobject); + device = *pobject; +if (ret) + goto done; + + device->platformdev = pdev; + device->handle = name; + device->cfgopt = cfg;
drivers/gpu/drm/nouveau/core/engine/device/base.c done: · line 591
Quoted 10 lines
drivers/gpu/drm/nouveau/core/engine/device/base.c +10
-0+ device->dbgopt = dbg; + device->name = sname; + +nv_subdev (device)->debug =nouveau_dbgopt (device->dbgopt,"DEVICE" ); +nv_engine (device)->sclass = nouveau_device_sclass; +list_add (&device->head, &nv_devices); +done: +mutex_unlock (&nv_devices_mutex); +return ret; +}
I think there's some potential for refactoring here, since the only difference that I can spot is in whether the pdev or the platformdev fields are assigned.
drivers/gpu/drm/nouveau/core/engine/graph/nv20.c nv20_graph_init(struct nouveau_object *object) · line 352
Quoted 10 lines
drivers/gpu/drm/nouveau/core/engine/graph/nv20.c +1
-1@@ -349,7 +349,7 @@ nv20_graph_init(struct nouveau_object *object)nv_wr32 (priv,NV10_PGRAPH_SURFACE , tmp);/* begin RAM config */ - vramsz =pci_resource_len (nv_device (priv)->pdev,0 ) -1 ; + vramsz =nv_device_resource_len (nv_device (priv),0 ) -1 ;
In case BAR0 is of size zero (start == 0, end == start), this will cause underflow in the case of a PCI device, because pci_resource_len() will return 0. I suspect that this never happens since that code's been there since the dawn of time.
drivers/gpu/drm/nouveau/core/include/core/device.h struct nouveau_device { · line 68
Quoted 9 lines
drivers/gpu/drm/nouveau/core/include/core/device.h +1
-0@@ -65,6 +65,7 @@ struct nouveau_device {struct list_head head;struct pci_dev *pdev; +struct platform_device *platformdev;
I'm generally wondering if perhaps a better abstraction would be to store a struct device * here, perhaps with a struct nouveau_device_ops * or similar to abstract away the differences between PCI and platform devices.
nouveau_device_create_() could then take a struct device * and a struct nouveau_device_ops *, and upcasting can therefore be done within these operations, rather than sprinkling nv_device_is_pci() code everywhere.
Quoted 1 line
drivers/gpu/drm/nouveau/nouveau_abi16.c +0
-0
[...]
drivers/gpu/drm/nouveau/nouveau_abi16.c nouveau_abi16_ioctl_getparam(ABI16_IOCTL_ARGS) · line 199
Quoted 7 lines
drivers/gpu/drm/nouveau/nouveau_abi16.c +3
-0case NOUVEAU_GETPARAM_BUS_TYPE : +if (!nv_device_is_pci (device)) + getparam->value =3 ; +else if (drm_pci_device_is_agp (dev)) getparam->value =0 ;else
This is more of a general note since this patch doesn't introduce the parameter. Perhaps it would be good to expose a symbolic name for the various types of busses in a public header?
drivers/gpu/drm/nouveau/nouveau_chan.c nouveau_channel_prep(struct nouveau_drm *drm, struct nouveau_cli *cli, · line 157
Quoted 10 lines
drivers/gpu/drm/nouveau/nouveau_chan.c +1
-1@@ -154,7 +154,7 @@ nouveau_channel_prep(struct nouveau_drm *drm, struct nouveau_cli *cli,* nfi why this exists, it came from the -nv ddx. */ args.flags =NV_DMA_TARGET_PCI |NV_DMA_ACCESS_RDWR ; - args.start =pci_resource_start (device->pdev,1 ); + args.start =nv_device_resource_len (device,1 );
Should this have been nv_device_resource_start()?
Quoted 1 line
drivers/gpu/drm/nouveau/nouveau_drm.c +0
-0
[...]
drivers/gpu/drm/nouveau/nouveau_drm.c nouveau_drm_load(struct drm_device *dev, unsigned long flags) · line 371
Quoted 6 lines
drivers/gpu/drm/nouveau/nouveau_drm.c +1
-1@@ -345,7 +368,7 @@ nouveau_drm_load(struct drm_device *dev, unsigned long flags)/* make sure AGP controller is in a consistent state before we * (possibly) execute vbios init tables (see nouveau_agp.h) */ -if (drm_pci_device_is_agp (dev) && dev->agp) { +if (pdev &&drm_pci_device_is_agp (dev) && dev->agp) {
Perhaps move the check for valid PCI device into drm_pci_device_is_agp() rather than requiring callers to check explicitly?
drivers/gpu/drm/nouveau/nouveau_drm.c nouveau_drm_load(struct drm_device *dev, unsigned long flags) · line 413
Quoted 10 lines
drivers/gpu/drm/nouveau/nouveau_drm.c +4
-2@@ -384,8 +407,10 @@ nouveau_drm_load(struct drm_device *dev, unsigned long flags)if (nv_device (drm->device)->chipset ==0xc1 )nv_mask (device,0x00088080 ,0x00000800 ,0x00000000 ); -nouveau_vga_init (drm); -nouveau_agp_init (drm); +if (pdev) { +nouveau_vga_init (drm); +nouveau_agp_init (drm); + }
Same here. And if you make the above change, then nouveau_agp_init() will do the right thing already.
Quoted 4 lines
drivers/gpu/drm/nouveau/nouveau_drm.c +0
-0if (device->card_type >=NV_50 ) { ret = nouveau_vm_new(nv_device(drm->device), 0, (1ULL << 40),@@ -398,9 +423,11 @@ nouveau_drm_load(struct drm_device *dev, unsigned long flags)if (ret)
drivers/gpu/drm/nouveau/nouveau_drm.c nouveau_drm_load(struct drm_device *dev, unsigned long flags) · line 430
Quoted 10 lines
drivers/gpu/drm/nouveau/nouveau_drm.c +5
-3goto fail_ttm; - ret =nouveau_bios_init (dev); -if (ret) - goto fail_bios; +if (pdev) { + ret =nouveau_bios_init (dev); +if (ret) + goto fail_bios; + }
nouveau_bios_init() could also check internally and return 0 if the device isn't a PCI device. One less conditional in this function.
drivers/gpu/drm/nouveau/nouveau_drm.c nouveau_drm_pci_driver = { · line 994
Quoted 5 lines
drivers/gpu/drm/nouveau/nouveau_drm.c +1
-0@@ -963,6 +991,25 @@ nouveau_drm_pci_driver = { .driver.pm = &nouveau_pm_ops, }; +
This adds a spurious newline.
Quoted 7 lines
drivers/gpu/drm/nouveau/nouveau_drm.c +7
-0+int nouveau_drm_platform_probe (struct platform_device *pdev) +{ +struct nouveau_device *device; +int ret; + + ret = nouveau_device_platform_create(pdev, nouveau_platform_name(pdev), + dev_name(&pdev->dev), nouveau_config,
drivers/gpu/drm/nouveau/nouveau_drm.c nouveau_drm_pci_driver = { · line 1011
Quoted 10 lines
drivers/gpu/drm/nouveau/nouveau_drm.c +10
-0+ nouveau_debug, &device); + + ret =drm_platform_init (&driver, pdev); +if (ret) { +nouveau_object_ref (NULL , (struct nouveau_object **)&device); +return ret; + } + +return ret; +}
I think we should move the whole of gk20a probing into nouveau. Keeping one part in tegra-drm and one part in nouveau is confusing, and I can't see a reason why we'd have to keep it that way.
Thierry
Quoted 46 lines · Thierry Reding
On Mon, Feb 10, 2014 at 02:53:00PM +0900, Alexandre Courbot wrote:
[...]Quoted 1 line
drivers/gpu/drm/nouveau/core/engine/device/base.c +0
-0[...]
Quoted 19 lines
drivers/gpu/drm/nouveau/core/engine/device/base.c +19
-0+resource_size_t +nv_device_resource_start (struct nouveau_device *device,unsigned int bar) +{ +if (nv_device_is_pci (device)) { +return pci_resource_start (device->pdev, bar); + }else { +struct resource *res; + res =platform_get_resource (device->platformdev, +IORESOURCE_MEM , bar); +if (!res) +return 0 ; +return res->start; + } +} + +resource_size_t +nv_device_resource_len (struct nouveau_device *device,unsigned int bar) +{ +if (nv_device_is_pci (device)) {drivers/gpu/drm/nouveau/core/engine/device/base.c nouveau_device_dtor(struct nouveau_object *object) · line 477
Quoted 10 lines
drivers/gpu/drm/nouveau/core/engine/device/base.c +10
-0+return pci_resource_len (device->pdev, bar); + }else { +struct resource *res; + res =platform_get_resource (device->platformdev, +IORESOURCE_MEM , bar); +if (!res) +return 0 ; +return resource_size (res); + } +}Perhaps instead of these two, something like this could be done:
const struct resource * nv_device_resource(struct nouveau_device *device, unsigned int bar) { if (nv_device_is_pci(device) return &device->pdev->resource[bar]; else return platform_get_resource(device->platformdev, IORESOURCE_MEM, bar); }
Quoted 7 lines
Then the more generic
resource_size()can be used directly on the returned struct resource *. Doing so may come in handy if you ever need to display the resource for debugging purposes, since you could simply use the %pR format specifier. It could also be slightly more efficient, since the structure doesn't have to be looked up twice. But perhaps the compiler will be clever enough to optimize that away and it's not like this is called from a hot path.
I would agree with returning raw resource * if some of the consumer code did make use of struct resource * directly, but AFAICT this is not the case at all. So I thought we would better continue providing exactly what the code needs, instead of forcing it to dererence the resource itself. Also by doing so we might return NULL pointers in some code paths that do not check whether a resource is valid or not (granted, returning 0 would probably only make the code crash later).
Quoted 34 lines
I do see that
pci_resource_len()does additional checking for BARs that have zero size (start == 0 && end == start), so it's not exactly the same, but I think there's another issue with that, see below.Quoted 29 lines
drivers/gpu/drm/nouveau/core/engine/device/base.c +29
-0+int +nouveau_device_platform_create_ (struct platform_device *pdev,u64 name, +const char *sname,const char *cfg, +const char *dbg,int length,void **pobject) +{ +struct nouveau_device *device; +int ret = -EEXIST ; + +mutex_lock (&nv_devices_mutex); +list_for_each_entry (device, &nv_devices, head) { +if (device->handle == name) + goto done; + } + + ret =nouveau_engine_create_ (NULL ,NULL , &nouveau_device_oclass, true, +"DEVICE" ,"device" , length, pobject); + device = *pobject; +if (ret) + goto done; + + device->platformdev = pdev; + device->handle = name; + device->cfgopt = cfg; + device->dbgopt = dbg; + device->name = sname; + +nv_subdev (device)->debug =nouveau_dbgopt (device->dbgopt,"DEVICE" ); +nv_engine (device)->sclass = nouveau_device_sclass; +list_add (&device->head, &nv_devices);
Quoted 8 lines
drivers/gpu/drm/nouveau/core/engine/device/base.c done: · line 591
Quoted 4 lines
drivers/gpu/drm/nouveau/core/engine/device/base.c +4
-0+done: +mutex_unlock (&nv_devices_mutex); +return ret; +}I think there's some potential for refactoring here, since the only difference that I can spot is in whether the pdev or the platformdev fields are assigned.
That's true. Actually I wonder if it would not make more sense for nouveau_device_platform_create_() to take a void pointer and a type saying whether the device is PCI or platform, otherwise we will end up duplicating the mutex code in two functions, ending up with even more code than my current version.
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/nouveau/core/engine/graph/nv20.c +0
-0@@ -349,7 +349,7 @@ nv20_graph_init(struct nouveau_object *object)nv_wr32 (priv,NV10_PGRAPH_SURFACE , tmp);
Quoted 8 lines
drivers/gpu/drm/nouveau/core/engine/graph/nv20.c nv20_graph_init(struct nouveau_object *object) · line 352
Quoted 3 lines
drivers/gpu/drm/nouveau/core/engine/graph/nv20.c +1
-1/* begin RAM config */ - vramsz =pci_resource_len (nv_device (priv)->pdev,0 ) -1 ; + vramsz =nv_device_resource_len (nv_device (priv),0 ) -1 ;In case BAR0 is of size zero (start == 0, end == start), this will cause underflow in the case of a PCI device, because
pci_resource_len()will return 0. I suspect that this never happens since that code's been there since the dawn of time.
Yes, I guess for particular chips it is ok to make assumptions such as the presence of a given BAR that are, anyway, properties inherent to that chip.
Quoted 15 lines
drivers/gpu/drm/nouveau/core/include/core/device.h struct nouveau_device { · line 68
Quoted 9 lines
drivers/gpu/drm/nouveau/core/include/core/device.h +1
-0@@ -65,6 +65,7 @@ struct nouveau_device {struct list_head head;struct pci_dev *pdev; +struct platform_device *platformdev;I'm generally wondering if perhaps a better abstraction would be to store a struct device * here, perhaps with a struct
nouveau_device_ops* or similar to abstract away the differences between PCI and platform devices.
Quoted 3 lines
nouveau_device_create_()could then take a struct device * and a structnouveau_device_ops*, and upcasting can therefore be done within these operations, rather than sprinklingnv_device_is_pci()code everywhere.
At some point I was considering having the bus abstracted as a subdev, but that sounded overkill. :) A nouveau_device_ops * would provide a nicer abstraction, but at the end of the day we would still be calling accessor functions on a nouveau_device * and this would not change much for consumer code. It would also deprive PCI-dependent code (there is still a bunch) of a convenient way to access the pci_dev * since it would need to be upcasted. And the only place where this would remove nv_device_is_pci() is device/base.c.
IMHO the current situation is still sustainable for two buses. If we had three or more, I'd go for the nouveau_device_ops * solution though.
Quoted 11 lines
Quoted 2 lines
drivers/gpu/drm/nouveau/nouveau_abi16.c +0
-0[...]
drivers/gpu/drm/nouveau/nouveau_abi16.c nouveau_abi16_ioctl_getparam(ABI16_IOCTL_ARGS) · line 199
Quoted 7 lines
case
NOUVEAU_GETPARAM_BUS_TYPE:drivers/gpu/drm/nouveau/nouveau_abi16.c +3
-0+if (!nv_device_is_pci (device)) + getparam->value =3 ; +else if (drm_pci_device_is_agp (dev)) getparam->value =0 ;else
Quoted 3 lines
This is more of a general note since this patch doesn't introduce the parameter. Perhaps it would be good to expose a symbolic name for the various types of busses in a public header?
Maybe as a separate patch, yes. Also the value of "3" for non-PCI devices is completely arbitrary.
Quoted 13 lines
drivers/gpu/drm/nouveau/nouveau_chan.c nouveau_channel_prep(struct nouveau_drm *drm, struct nouveau_cli *cli, · line 157
Quoted 11 lines
drivers/gpu/drm/nouveau/nouveau_chan.c +1
-1@@ -154,7 +154,7 @@ nouveau_channel_prep(struct nouveau_drm *drm, struct nouveau_cli *cli,* nfi why this exists, it came from the -nv ddx. */ args.flags =NV_DMA_TARGET_PCI |NV_DMA_ACCESS_RDWR ; - args.start =pci_resource_start (device->pdev,1 ); + args.start =nv_device_resource_len (device,1 );Should this have been
nv_device_resource_start()?
Absolutely. Thanks.
Quoted 12 lines
Quoted 2 lines
drivers/gpu/drm/nouveau/nouveau_drm.c +0
-0[...]
drivers/gpu/drm/nouveau/nouveau_drm.c nouveau_drm_load(struct drm_device *dev, unsigned long flags) · line 371
Quoted 6 lines
drivers/gpu/drm/nouveau/nouveau_drm.c +1
-1@@ -345,7 +368,7 @@ nouveau_drm_load(struct drm_device *dev, unsigned long flags)/* make sure AGP controller is in a consistent state before we * (possibly) execute vbios init tables (see nouveau_agp.h) */ -if (drm_pci_device_is_agp (dev) && dev->agp) { +if (pdev &&drm_pci_device_is_agp (dev) && dev->agp) {Perhaps move the check for valid PCI device into
drm_pci_device_is_agp()rather than requiring callers to check explicitly?
I *think* drm_pci_device_is_agp() assumes a PCI device on purpose and that the burden of checking is on the caller. Changing this behavior would imply doing the same on many other functions of drmP.h.
Quoted 5 lines
Quoted 5 lines
drivers/gpu/drm/nouveau/nouveau_drm.c +0
-0@@ -384,8 +407,10 @@ nouveau_drm_load(struct drm_device *dev, unsigned long flags)if (nv_device (drm->device)->chipset ==0xc1 )nv_mask (device,0x00088080 ,0x00000800 ,0x00000000 );
Quoted 9 lines
drivers/gpu/drm/nouveau/nouveau_drm.c nouveau_drm_load(struct drm_device *dev, unsigned long flags) · line 413
Quoted 6 lines
drivers/gpu/drm/nouveau/nouveau_drm.c +4
-2-nouveau_vga_init (drm); -nouveau_agp_init (drm); +if (pdev) { +nouveau_vga_init (drm); +nouveau_agp_init (drm); + }Same here. And if you make the above change, then
nouveau_agp_init()will do the right thing already.
Indeed, we can probably check drm_device::pdev in the functions themselves.
Quoted 7 lines
Quoted 7 lines
drivers/gpu/drm/nouveau/nouveau_drm.c +0
-0if (device->card_type >=NV_50 ) { ret = nouveau_vm_new(nv_device(drm->device), 0, (1ULL << 40),@@ -398,9 +423,11 @@ nouveau_drm_load(struct drm_device *dev, unsigned long flags)if (ret) goto fail_ttm;
Quoted 11 lines
drivers/gpu/drm/nouveau/nouveau_drm.c nouveau_drm_load(struct drm_device *dev, unsigned long flags) · line 430
Quoted 8 lines
drivers/gpu/drm/nouveau/nouveau_drm.c +5
-3- ret =nouveau_bios_init (dev); -if (ret) - goto fail_bios; +if (pdev) { + ret =nouveau_bios_init (dev); +if (ret) + goto fail_bios; + }
nouveau_bios_init()could also check internally and return 0 if the device isn't a PCI device. One less conditional in this function.
Agreed.
Quoted 8 lines
drivers/gpu/drm/nouveau/nouveau_drm.c nouveau_drm_pci_driver = { · line 994
Quoted 6 lines
drivers/gpu/drm/nouveau/nouveau_drm.c +1
-0@@ -963,6 +991,25 @@ nouveau_drm_pci_driver = { .driver.pm = &nouveau_pm_ops, }; +This adds a spurious newline.
Removed.
Quoted 14 lines
Quoted 14 lines
drivers/gpu/drm/nouveau/nouveau_drm.c +13
-0+int nouveau_drm_platform_probe (struct platform_device *pdev) +{ +struct nouveau_device *device; +int ret; + + ret =nouveau_device_platform_create (pdev,nouveau_platform_name (pdev), +dev_name (&pdev->dev), nouveau_config, + nouveau_debug, &device); + + ret =drm_platform_init (&driver, pdev); +if (ret) { +nouveau_object_ref (NULL , (struct nouveau_object **)&device); +return ret;
Quoted 8 lines
drivers/gpu/drm/nouveau/nouveau_drm.c nouveau_drm_pci_driver = { · line 1011
Quoted 4 lines
drivers/gpu/drm/nouveau/nouveau_drm.c +4
-0+ } + +return ret; +}I think we should move the whole of gk20a probing into nouveau. Keeping one part in tegra-drm and one part in nouveau is confusing, and I can't see a reason why we'd have to keep it that way.
Yes, the current probing scheme is definitely not what we want. However since some clocks probably need to be enabled before GK20A's registers (including BOOT0) can be read, this will probably require some more changes which we need to think about, and is not directly within the scope of this patch.
Thanks for the review! I will post a v2 tomorrow.
Alex.
PATCH v2 1/1 drm/nouveau: support for platform devices
Upcoming mobile Kepler GPUs (such as GK20A) use the platform bus instead of PCI to which Nouveau is tightly dependent. This patch allows Nouveau to handle platform devices by:
- abstracting PCI-dependent functions that were typically used for resource querying and page mapping,
- introducing a nv_device_is_pci() function that allows to make PCI-dependent code conditional,
- providing a nouveau_drm_platform_probe() function that takes a GPU platform device to be probed.
Core code as well as engine/subdev drivers are updated wherever possible to make use of these functions. Some older drivers are too dependent on PCI to be properly updated, but all newer code on which future chips may depend should at least be runnable with platform devices.
---
Changes since v1:
- Refactored nouveau_device_create_() to take an additional bus type argument instead of having two versions of it that duplicate code.
- Fixed a typo when substituting pci_resource_* with nv_device_resource_*
- Check whether devices are PCI in relevant functions instead of nouveau_drm_load().
drivers/gpu/drm/nouveau/core/engine/device/base.c | 83 ++++++++++++++++++++-- drivers/gpu/drm/nouveau/core/engine/falcon.c | 6 +- drivers/gpu/drm/nouveau/core/engine/fifo/base.c | 2 +- drivers/gpu/drm/nouveau/core/engine/graph/nv20.c | 2 +- drivers/gpu/drm/nouveau/core/engine/graph/nv40.c | 2 +- drivers/gpu/drm/nouveau/core/engine/graph/nvc0.c | 4 +- drivers/gpu/drm/nouveau/core/engine/xtensa.c | 2 +- drivers/gpu/drm/nouveau/core/include/core/device.h | 30 ++++++++ .../gpu/drm/nouveau/core/include/engine/device.h | 17 +++-- drivers/gpu/drm/nouveau/core/include/subdev/mc.h | 1 + drivers/gpu/drm/nouveau/core/os.h | 1 + drivers/gpu/drm/nouveau/core/subdev/bar/base.c | 4 +- drivers/gpu/drm/nouveau/core/subdev/bar/nv50.c | 4 +- drivers/gpu/drm/nouveau/core/subdev/bar/nvc0.c | 15 ++-- .../gpu/drm/nouveau/core/subdev/devinit/fbmem.h | 8 ++- drivers/gpu/drm/nouveau/core/subdev/devinit/nv04.c | 2 +- drivers/gpu/drm/nouveau/core/subdev/devinit/nv05.c | 2 +- drivers/gpu/drm/nouveau/core/subdev/devinit/nv10.c | 2 +- drivers/gpu/drm/nouveau/core/subdev/devinit/nv20.c | 2 +- drivers/gpu/drm/nouveau/core/subdev/fb/nv50.c | 9 +-- drivers/gpu/drm/nouveau/core/subdev/fb/nvc0.c | 9 +-- drivers/gpu/drm/nouveau/core/subdev/i2c/base.c | 2 +- drivers/gpu/drm/nouveau/core/subdev/instmem/nv40.c | 7 +- drivers/gpu/drm/nouveau/core/subdev/mc/base.c | 39 ++++++---- drivers/gpu/drm/nouveau/core/subdev/mxm/base.c | 2 +- drivers/gpu/drm/nouveau/nouveau_abi16.c | 13 +++- drivers/gpu/drm/nouveau/nouveau_agp.c | 2 +- drivers/gpu/drm/nouveau/nouveau_bios.c | 4 ++ drivers/gpu/drm/nouveau/nouveau_bo.c | 22 +++--- drivers/gpu/drm/nouveau/nouveau_chan.c | 2 +- drivers/gpu/drm/nouveau/nouveau_display.c | 3 +- drivers/gpu/drm/nouveau/nouveau_drm.c | 59 ++++++++++++--- drivers/gpu/drm/nouveau/nouveau_sysfs.c | 8 ++- drivers/gpu/drm/nouveau/nouveau_ttm.c | 31 ++++---- drivers/gpu/drm/nouveau/nouveau_vga.c | 5 ++ 35 files changed, 297 insertions(+), 109 deletions(-)
drivers/gpu/drm/nouveau/core/engine/device/base.c +78 -5
@@ -131,8 +131,8 @@ nouveau_devobj_ctor(struct nouveau_object *parent,if (ret)return ret; - mmio_base =pci_resource_start (device->pdev,0 ); - mmio_size =pci_resource_len (device->pdev,0 ); + mmio_base =nv_device_resource_start (device,0 ); + mmio_size =nv_device_resource_len (device,0 );/* translate api disable mask into internal mapping */ disable = args->debug0;
@@ -446,6 +446,72 @@ nouveau_device_dtor(struct nouveau_object *object)nouveau_engine_destroy (&device->base); } +resource_size_t +nv_device_resource_start (struct nouveau_device *device,unsigned int bar) +{ +if (nv_device_is_pci (device)) { +return pci_resource_start (device->pdev, bar); + }else { +struct resource *res; + res =platform_get_resource (device->platformdev, +IORESOURCE_MEM , bar); +if (!res) +return 0 ; +return res->start; + } +} + +resource_size_t +nv_device_resource_len (struct nouveau_device *device,unsigned int bar) +{ +if (nv_device_is_pci (device)) { +return pci_resource_len (device->pdev, bar); + }else { +struct resource *res; + res =platform_get_resource (device->platformdev, +IORESOURCE_MEM , bar); +if (!res) +return 0 ; +return resource_size (res); + } +} + +dma_addr_t +nv_device_map_page (struct nouveau_device *device,struct page *page) +{ +dma_addr_t ret; + +if (nv_device_is_pci (device)) { + ret =pci_map_page (device->pdev, page,0 ,PAGE_SIZE , +PCI_DMA_BIDIRECTIONAL ); +if (pci_dma_mapping_error (device->pdev, ret)) + ret =0 ; + }else { + ret =page_to_phys (page); + } + +return ret; +} + +void +nv_device_unmap_page (struct nouveau_device *device,dma_addr_t addr) +{ +if (nv_device_is_pci (device)) +pci_unmap_page (device->pdev, addr,PAGE_SIZE , +PCI_DMA_BIDIRECTIONAL ); +} + +int +nv_device_get_irq (struct nouveau_device *device,bool stall) +{ +if (nv_device_is_pci (device)) { +return device->pdev->irq; + }else { +return platform_get_irq_byname (device->platformdev, + stall ?"stall" :"nonstall" ); + } +} +static struct nouveau_oclass nouveau_device_oclass = { .handle =NV_ENGINE (DEVICE ,0x00 ),
@@ -457,8 +523,8 @@ nouveau_device_oclass = { };int -nouveau_device_create_ (struct pci_dev *pdev,u64 name,const char *sname, -const char *cfg,const char *dbg, +nouveau_device_create_ (void *dev,enum nv_bus_type type,u64 name, +const char *sname,const char *cfg,const char *dbg,int length,void **pobject) {struct nouveau_device *device;
@@ -476,7 +542,14 @@ nouveau_device_create_(struct pci_dev *pdev, u64 name, const char *sname,if (ret) goto done; - device->pdev = pdev; +switch (type) { +case NOUVEAU_BUS_PCI : + device->pdev = dev; +break ; +case NOUVEAU_BUS_PLATFORM : + device->platformdev = dev; +break ; + } device->handle = name; device->cfgopt = cfg; device->dbgopt = dbg;
drivers/gpu/drm/nouveau/core/engine/falcon.c +3 -3
@@ -119,7 +119,7 @@ _nouveau_falcon_init(struct nouveau_object *object)snprintf (name,sizeof (name),"nouveau/nv%02x_fuc%03x" , device->chipset, falcon->addr >>12 ); - ret =request_firmware (&fw, name, &device->pdev->dev); + ret =request_firmware (&fw, name,nv_device_base (device));if (ret ==0 ) { falcon->code.data =vmemdup (fw->data, fw->size); falcon->code.size = fw->size;
@@ -138,7 +138,7 @@ _nouveau_falcon_init(struct nouveau_object *object)snprintf (name,sizeof (name),"nouveau/nv%02x_fuc%03xd" , device->chipset, falcon->addr >>12 ); - ret =request_firmware (&fw, name, &device->pdev->dev); + ret =request_firmware (&fw, name,nv_device_base (device));if (ret) {nv_error (falcon,"unable to load firmware data\n" );return ret;
@@ -153,7 +153,7 @@ _nouveau_falcon_init(struct nouveau_object *object)snprintf (name,sizeof (name),"nouveau/nv%02x_fuc%03xc" , device->chipset, falcon->addr >>12 ); - ret =request_firmware (&fw, name, &device->pdev->dev); + ret =request_firmware (&fw, name,nv_device_base (device));if (ret) {nv_error (falcon,"unable to load firmware code\n" );return ret;
drivers/gpu/drm/nouveau/core/engine/fifo/base.c +1 -1
@@ -86,7 +86,7 @@ nouveau_fifo_channel_create_(struct nouveau_object *parent, }/* map fifo control registers */ - chan->user =ioremap (pci_resource_start (device->pdev, bar) + addr + + chan->user =ioremap (nv_device_resource_start (device, bar) + addr + (chan->chid * size), size);if (!chan->user)return -EFAULT ;
drivers/gpu/drm/nouveau/core/engine/graph/nv20.c +1 -1
@@ -349,7 +349,7 @@ nv20_graph_init(struct nouveau_object *object)nv_wr32 (priv,NV10_PGRAPH_SURFACE , tmp);/* begin RAM config */ - vramsz =pci_resource_len (nv_device (priv)->pdev,0 ) -1 ; + vramsz =nv_device_resource_len (nv_device (priv),0 ) -1 ;nv_wr32 (priv,0x4009A4 ,nv_rd32 (priv,0x100200 ));nv_wr32 (priv,0x4009A8 ,nv_rd32 (priv,0x100204 ));nv_wr32 (priv,NV10_PGRAPH_RDI_INDEX ,0x00EA0000 );
drivers/gpu/drm/nouveau/core/engine/graph/nv40.c +1 -1
@@ -484,7 +484,7 @@ nv40_graph_init(struct nouveau_object *object) engine->tile_prog (engine, i);/* begin RAM config */ - vramsz =pci_resource_len (nv_device (priv)->pdev,0 ) -1 ; + vramsz =nv_device_resource_len (nv_device (priv),0 ) -1 ;switch (nv_device (priv)->chipset) {case 0x40 :nv_wr32 (priv,0x4009A4 ,nv_rd32 (priv,0x100200 ));
drivers/gpu/drm/nouveau/core/engine/graph/nvc0.c +2 -2
@@ -1091,10 +1091,10 @@ nvc0_graph_ctor_fw(struct nvc0_graph_priv *priv, const char *fwname,int ret;snprintf (f,sizeof (f),"nouveau/nv%02x_%s" , device->chipset, fwname); - ret =request_firmware (&fw, f, &device->pdev->dev); + ret =request_firmware (&fw, f,nv_device_base (device));if (ret) {snprintf (f,sizeof (f),"nouveau/%s" , fwname); - ret =request_firmware (&fw, f, &device->pdev->dev); + ret =request_firmware (&fw, f,nv_device_base (device));if (ret) {nv_error (priv,"failed to load %s\n" , fwname);return ret;
drivers/gpu/drm/nouveau/core/engine/xtensa.c +1 -1
@@ -112,7 +112,7 @@ _nouveau_xtensa_init(struct nouveau_object *object)snprintf (name,sizeof (name),"nouveau/nv84_xuc%03x" , xtensa->addr >>12 ); - ret =request_firmware (&fw, name, &device->pdev->dev); + ret =request_firmware (&fw, name,nv_device_base (device));if (ret) {nv_warn (xtensa,"unable to load firmware %s\n" , name);return ret;
drivers/gpu/drm/nouveau/core/include/core/device.h +30 -0
@@ -65,6 +65,7 @@ struct nouveau_device {struct list_head head;struct pci_dev *pdev; +struct platform_device *platformdev;u64 handle;const char *cfgopt;
@@ -140,4 +141,33 @@ nv_device_match(struct nouveau_object *object, u16 dev, u16 ven, u16 sub) device->pdev->subsystem_device == sub; } +static inline bool +nv_device_is_pci (struct nouveau_device *device) +{ +return device->pdev !=NULL ; +} + +static inline struct device * +nv_device_base (struct nouveau_device *device) +{ +return nv_device_is_pci (device) ? &device->pdev->dev : + &device->platformdev->dev; +} + +resource_size_t +nv_device_resource_start (struct nouveau_device *device,unsigned int bar); + +resource_size_t +nv_device_resource_len (struct nouveau_device *device,unsigned int bar); + +dma_addr_t +nv_device_map_page (struct nouveau_device *device,struct page *page); + +void +nv_device_unmap_page (struct nouveau_device *device,dma_addr_t addr); + +int +nv_device_get_irq (struct nouveau_device *device,bool stall); +#endif +
drivers/gpu/drm/nouveau/core/include/engine/device.h +13 -4
@@ -3,11 +3,20 @@#include <core/device.h> -#define nouveau_device_create (p,n,s,c,d,u) \ - nouveau_device_create_((p), (n), (s), (c), (d), sizeof(**u), (void **)u) +struct platform_device ; -int nouveau_device_create_ (struct pci_dev *,u64 name,const char *sname, -const char *cfg,const char *dbg,int ,void **); +enum nv_bus_type { +NOUVEAU_BUS_PCI , +NOUVEAU_BUS_PLATFORM , +}; + +#define nouveau_device_create (p,t,n,s,c,d,u) \ + nouveau_device_create_((void *)(p), (t), (n), (s), (c), (d), \ + sizeof(**u), (void **)u) + +int nouveau_device_create_ (void *,enum nv_bus_type type,u64 name, +const char *sname,const char *cfg,const char *dbg, +int ,void **);int nv04_identify (struct nouveau_device *);int nv10_identify (struct nouveau_device *);
drivers/gpu/drm/nouveau/core/include/subdev/mc.h +1 -0
@@ -12,6 +12,7 @@ struct nouveau_mc_intr {struct nouveau_mc {struct nouveau_subdev base;bool use_msi; +unsigned int irq; }; static inline struct nouveau_mc *
drivers/gpu/drm/nouveau/core/os.h +1 -0
@@ -5,6 +5,7 @@#include <linux/slab.h> #include <linux/mutex.h> #include <linux/pci.h> +#include <linux/platform_device.h> #include <linux/printk.h> #include <linux/bitops.h> #include <linux/firmware.h>
drivers/gpu/drm/nouveau/core/subdev/bar/base.c +2 -2
@@ -118,8 +118,8 @@ nouveau_bar_create_(struct nouveau_object *parent,if (ret)return ret; - bar->iomem =ioremap (pci_resource_start (device->pdev,3 ), -pci_resource_len (device->pdev,3 )); + bar->iomem =ioremap (nv_device_resource_start (device,3 ), +nv_device_resource_len (device,3 ));return 0 ; }
drivers/gpu/drm/nouveau/core/subdev/bar/nv50.c +2 -2
@@ -139,7 +139,7 @@ nv50_bar_ctor(struct nouveau_object *parent, struct nouveau_object *engine,/* BAR3 */ start =0x0100000000ULL ; - limit = start +pci_resource_len (device->pdev,3 ); + limit = start +nv_device_resource_len (device,3 ); ret =nouveau_vm_new (device, start, limit, start, &vm);if (ret)
@@ -173,7 +173,7 @@ nv50_bar_ctor(struct nouveau_object *parent, struct nouveau_object *engine,/* BAR1 */ start =0x0000000000ULL ; - limit = start +pci_resource_len (device->pdev,1 ); + limit = start +nv_device_resource_len (device,1 ); ret =nouveau_vm_new (device, start, limit--, start, &vm);if (ret)
drivers/gpu/drm/nouveau/core/subdev/bar/nvc0.c +7 -8
@@ -84,7 +84,6 @@ nvc0_bar_ctor(struct nouveau_object *parent, struct nouveau_object *engine, struct nouveau_object **pobject) {struct nouveau_device *device =nv_device (parent); -struct pci_dev *pdev = device->pdev;struct nvc0_bar_priv *priv;struct nouveau_gpuobj *mem;struct nouveau_vm *vm;
@@ -107,14 +106,14 @@ nvc0_bar_ctor(struct nouveau_object *parent, struct nouveau_object *engine,if (ret)return ret; - ret =nouveau_vm_new (device,0 ,pci_resource_len (pdev,3 ),0 , &vm); + ret =nouveau_vm_new (device,0 ,nv_device_resource_len (device,3 ),0 , &vm);if (ret)return ret;atomic_inc (&vm->engref[NVDEV_SUBDEV_BAR ]); ret =nouveau_gpuobj_new (nv_object (priv),NULL , - (pci_resource_len (pdev,3 ) >>12 ) *8 , + (nv_device_resource_len (device,3 ) >>12 ) *8 ,0x1000 ,NVOBJ_FLAG_ZERO_ALLOC , &vm->pgt[0 ].obj[0 ]); vm->pgt[0 ].refcount[0 ] =1 ;
@@ -128,8 +127,8 @@ nvc0_bar_ctor(struct nouveau_object *parent, struct nouveau_object *engine,nv_wo32 (mem,0x0200 ,lower_32_bits (priv->bar[0 ].pgd->addr));nv_wo32 (mem,0x0204 ,upper_32_bits (priv->bar[0 ].pgd->addr)); -nv_wo32 (mem,0x0208 ,lower_32_bits (pci_resource_len (pdev,3 ) -1 )); -nv_wo32 (mem,0x020c ,upper_32_bits (pci_resource_len (pdev,3 ) -1 )); +nv_wo32 (mem,0x0208 ,lower_32_bits (nv_device_resource_len (device,3 ) -1 )); +nv_wo32 (mem,0x020c ,upper_32_bits (nv_device_resource_len (device,3 ) -1 ));/* BAR1 */ ret = nouveau_gpuobj_new(nv_object(priv), NULL, 0x1000, 0, 0,
@@ -143,7 +142,7 @@ nvc0_bar_ctor(struct nouveau_object *parent, struct nouveau_object *engine,if (ret)return ret; - ret =nouveau_vm_new (device,0 ,pci_resource_len (pdev,1 ),0 , &vm); + ret =nouveau_vm_new (device,0 ,nv_device_resource_len (device,1 ),0 , &vm);if (ret)return ret;
@@ -156,8 +155,8 @@ nvc0_bar_ctor(struct nouveau_object *parent, struct nouveau_object *engine,nv_wo32 (mem,0x0200 ,lower_32_bits (priv->bar[1 ].pgd->addr));nv_wo32 (mem,0x0204 ,upper_32_bits (priv->bar[1 ].pgd->addr)); -nv_wo32 (mem,0x0208 ,lower_32_bits (pci_resource_len (pdev,1 ) -1 )); -nv_wo32 (mem,0x020c ,upper_32_bits (pci_resource_len (pdev,1 ) -1 )); +nv_wo32 (mem,0x0208 ,lower_32_bits (nv_device_resource_len (device,1 ) -1 )); +nv_wo32 (mem,0x020c ,upper_32_bits (nv_device_resource_len (device,1 ) -1 )); priv->base.alloc = nouveau_bar_alloc; priv->base.kmap = nvc0_bar_kmap;
drivers/gpu/drm/nouveau/core/subdev/devinit/fbmem.h +5 -3
@@ -24,6 +24,8 @@* */ +#include <core/device.h> +#define NV04_PFB_BOOT_0 0x00100000# define NV04_PFB_BOOT_0_RAM_AMOUNT 0x00000003# define NV04_PFB_BOOT_0_RAM_AMOUNT_32MB 0x00000000
@@ -60,10 +62,10 @@# define NV10_PFB_REFCTRL_VALID_1 (1 << 31)static inline struct io_mapping * -fbmem_init (struct pci_dev *pdev) +fbmem_init (struct nouveau_device *dev) { -return io_mapping_create_wc (pci_resource_start (pdev,1 ), -pci_resource_len (pdev,1 )); +return io_mapping_create_wc (nv_device_resource_start (dev,1 ), +nv_device_resource_len (dev,1 )); } static inline void
drivers/gpu/drm/nouveau/core/subdev/devinit/nv04.c +1 -1
@@ -38,7 +38,7 @@ nv04_devinit_meminit(struct nouveau_devinit *devinit)int i;/* Map the framebuffer aperture */ - fb =fbmem_init (nv_device (priv)->pdev); + fb =fbmem_init (nv_device (priv));if (!fb) {nv_error (priv,"failed to map fb\n" );return ;
drivers/gpu/drm/nouveau/core/subdev/devinit/nv05.c +1 -1
@@ -53,7 +53,7 @@ nv05_devinit_meminit(struct nouveau_devinit *devinit)int i, v;/* Map the framebuffer aperture */ - fb =fbmem_init (nv_device (priv)->pdev); + fb =fbmem_init (nv_device (priv));if (!fb) {nv_error (priv,"failed to map fb\n" );return ;
drivers/gpu/drm/nouveau/core/subdev/devinit/nv10.c +1 -1
@@ -46,7 +46,7 @@ nv10_devinit_meminit(struct nouveau_devinit *devinit) mem_width_count =2 ;/* Map the framebuffer aperture */ - fb =fbmem_init (nv_device (priv)->pdev); + fb =fbmem_init (nv_device (priv));if (!fb) {nv_error (priv,"failed to map fb\n" );return ;
drivers/gpu/drm/nouveau/core/subdev/devinit/nv20.c +1 -1
@@ -37,7 +37,7 @@ nv20_devinit_meminit(struct nouveau_devinit *devinit)struct io_mapping *fb;/* Map the framebuffer aperture */ - fb =fbmem_init (nv_device (priv)->pdev); + fb =fbmem_init (nv_device (priv));if (!fb) {nv_error (priv,"failed to map fb\n" );return ;
drivers/gpu/drm/nouveau/core/subdev/fb/nv50.c +3 -6
@@ -250,10 +250,8 @@ nv50_fb_ctor(struct nouveau_object *parent, struct nouveau_object *engine, priv->r100c08_page =alloc_page (GFP_KERNEL | __GFP_ZERO);if (priv->r100c08_page) { - priv->r100c08 =pci_map_page (device->pdev, priv->r100c08_page, -0 ,PAGE_SIZE , -PCI_DMA_BIDIRECTIONAL ); -if (pci_dma_mapping_error (device->pdev, priv->r100c08)) + priv->r100c08 =nv_device_map_page (device, priv->r100c08_page); +if (!priv->r100c08)nv_warn (priv,"failed 0x100c08 page map\n" ); }else {nv_warn (priv,"failed 0x100c08 page alloc\n" );
@@ -270,8 +268,7 @@ nv50_fb_dtor(struct nouveau_object *object)struct nv50_fb_priv *priv = (void *)object;if (priv->r100c08_page) { -pci_unmap_page (device->pdev, priv->r100c08,PAGE_SIZE , -PCI_DMA_BIDIRECTIONAL ); +nv_device_unmap_page (device, priv->r100c08);__free_page (priv->r100c08_page); }
drivers/gpu/drm/nouveau/core/subdev/fb/nvc0.c +3 -6
@@ -70,8 +70,7 @@ nvc0_fb_dtor(struct nouveau_object *object)struct nvc0_fb_priv *priv = (void *)object;if (priv->r100c10_page) { -pci_unmap_page (device->pdev, priv->r100c10,PAGE_SIZE , -PCI_DMA_BIDIRECTIONAL ); +nv_device_unmap_page (device, priv->r100c10);__free_page (priv->r100c10_page); }
@@ -94,10 +93,8 @@ nvc0_fb_ctor(struct nouveau_object *parent, struct nouveau_object *engine, priv->r100c10_page =alloc_page (GFP_KERNEL | __GFP_ZERO);if (priv->r100c10_page) { - priv->r100c10 =pci_map_page (device->pdev, priv->r100c10_page, -0 ,PAGE_SIZE , -PCI_DMA_BIDIRECTIONAL ); -if (pci_dma_mapping_error (device->pdev, priv->r100c10)) + priv->r100c10 =nv_device_map_page (device, priv->r100c10_page); +if (!priv->r100c10)return -EFAULT ; }
drivers/gpu/drm/nouveau/core/subdev/i2c/base.c +1 -1
@@ -111,7 +111,7 @@ nouveau_i2c_port_create_(struct nouveau_object *parent,snprintf (port->adapter.name,sizeof (port->adapter.name),"nouveau-%s-%d" , device->name, index); port->adapter.owner =THIS_MODULE ; - port->adapter.dev.parent = &device->pdev->dev; + port->adapter.dev.parent =nv_device_base (device); port->index = index; port->func = func;i2c_set_adapdata (&port->adapter, i2c);
drivers/gpu/drm/nouveau/core/subdev/instmem/nv40.c +3 -4
@@ -50,7 +50,6 @@ nv40_instmem_ctor(struct nouveau_object *parent, struct nouveau_object *engine, struct nouveau_object **pobject) {struct nouveau_device *device =nv_device (parent); -struct pci_dev *pdev = device->pdev;struct nv04_instmem_priv *priv;int ret, bar, vs;
@@ -60,13 +59,13 @@ nv40_instmem_ctor(struct nouveau_object *parent, struct nouveau_object *engine,return ret;/* map bar */ -if (pci_resource_len (pdev,2 )) +if (nv_device_resource_len (device,2 )) bar =2 ;else bar =3 ; - priv->iomem =ioremap (pci_resource_start (pdev, bar), -pci_resource_len (pdev, bar)); + priv->iomem =ioremap (nv_device_resource_start (device, bar), +nv_device_resource_len (device, bar));if (!priv->iomem) {nv_error (priv,"unable to map PRAMIN BAR\n" );return -EFAULT ;
drivers/gpu/drm/nouveau/core/subdev/mc/base.c +24 -15
@@ -93,8 +93,8 @@ _nouveau_mc_dtor(struct nouveau_object *object) {struct nouveau_device *device =nv_device (object);struct nouveau_mc *pmc = (void *)object; -free_irq (device->pdev->irq, pmc); -if (pmc->use_msi) +free_irq (pmc->irq, pmc); +if (nv_device_is_pci (device) && pmc->use_msi)pci_disable_msi (device->pdev);nouveau_subdev_destroy (&pmc->base); }
@@ -114,22 +114,25 @@ nouveau_mc_create_(struct nouveau_object *parent, struct nouveau_object *engine,if (ret)return ret; -switch (device->pdev->device &0x0ff0 ) { -case 0x00f0 : -case 0x02e0 : -/* BR02? NFI how these would be handled yet exactly */ -break ; -default : -switch (device->chipset) { -case 0xaa :break ;/* reported broken, nv also disable it */ -default : - pmc->use_msi = true; +if (nv_device_is_pci (device)) +switch (device->pdev->device &0x0ff0 ) { +case 0x00f0 : +case 0x02e0 : +/* BR02? NFI how these would be handled yet exactly */ break ; +default : +switch (device->chipset) { +case 0xaa : +/* reported broken, nv also disable it */ +break ; +default : + pmc->use_msi = true; +break ; } } pmc->use_msi =nouveau_boolopt (device->cfgopt,"NvMSI" , pmc->use_msi); -if (pmc->use_msi && oclass->msi_rearm) { +if (nv_device_is_pci (device) && pmc->use_msi && oclass->msi_rearm) { pmc->use_msi =pci_enable_msi (device->pdev) ==0 ;if (pmc->use_msi) {nv_info (pmc,"MSI interrupts enabled\n" );
@@ -139,8 +142,14 @@ nouveau_mc_create_(struct nouveau_object *parent, struct nouveau_object *engine, pmc->use_msi = false; } - ret =request_irq (device->pdev->irq, nouveau_mc_intr, -IRQF_SHARED ,"nouveau" , pmc); + ret =nv_device_get_irq (device, true); +if (ret <0 ) +return ret; + pmc->irq = ret; + + ret =request_irq (pmc->irq, nouveau_mc_intr,IRQF_SHARED ,"nouveau" , + pmc); +if (ret <0 )return ret;
drivers/gpu/drm/nouveau/core/subdev/mxm/base.c +1 -1
@@ -96,7 +96,7 @@ mxm_shadow_dsm(struct nouveau_mxm *mxm, u8 version)acpi_handle handle;int rev; - handle =ACPI_HANDLE (&device->pdev->dev); + handle =ACPI_HANDLE (nv_device_base (device));if (!handle)return false;
drivers/gpu/drm/nouveau/nouveau_abi16.c +11 -2
@@ -179,12 +179,21 @@ nouveau_abi16_ioctl_getparam(ABI16_IOCTL_ARGS) getparam->value = device->chipset;break ;case NOUVEAU_GETPARAM_PCI_VENDOR : - getparam->value = dev->pdev->vendor; +if (nv_device_is_pci (device)) + getparam->value = dev->pdev->vendor; +else + getparam->value =0 ;break ;case NOUVEAU_GETPARAM_PCI_DEVICE : - getparam->value = dev->pdev->device; +if (nv_device_is_pci (device)) + getparam->value = dev->pdev->device; +else + getparam->value =0 ;break ;case NOUVEAU_GETPARAM_BUS_TYPE : +if (!nv_device_is_pci (device)) + getparam->value =3 ; +else if (drm_pci_device_is_agp (dev)) getparam->value =0 ;else
drivers/gpu/drm/nouveau/nouveau_agp.c +1 -1
@@ -75,7 +75,7 @@ nouveau_agp_enabled(struct nouveau_drm *drm) {struct drm_device *dev = drm->dev; -if (!drm_pci_device_is_agp (dev) || !dev->agp) +if (!dev->pdev || !drm_pci_device_is_agp (dev) || !dev->agp)return false;if (drm->agp.stat ==UNKNOWN ) {
drivers/gpu/drm/nouveau/nouveau_bios.c +4 -0
@@ -2069,6 +2069,10 @@ nouveau_bios_init(struct drm_device *dev)struct nvbios *bios = &drm->vbios;int ret; +/* only relevant for PCI devices */ +if (!dev->pdev) +return 0 ; +if (!NVInitVBIOS (dev))return -ENODEV ;
drivers/gpu/drm/nouveau/nouveau_bo.c +12 -10
@@ -1255,7 +1255,7 @@ nouveau_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_mem_reg *mem)/* fallthrough, tiled memory */ case TTM_PL_VRAM : mem->bus.offset = mem->start <<PAGE_SHIFT ; - mem->bus.base =pci_resource_start (dev->pdev,1 ); + mem->bus.base =nv_device_resource_start (nouveau_dev (dev),1 ); mem->bus.is_iomem = true;if (nv_device (drm->device)->card_type >=NV_50 ) {struct nouveau_bar *bar =nouveau_bar (drm->device);
@@ -1293,7 +1293,7 @@ nouveau_ttm_fault_reserve_notify(struct ttm_buffer_object *bo)struct nouveau_drm *drm =nouveau_bdev (bo->bdev);struct nouveau_bo *nvbo =nouveau_bo (bo);struct nouveau_device *device =nv_device (drm->device); -u32 mappable =pci_resource_len (device->pdev,1 ) >>PAGE_SHIFT ; +u32 mappable =nv_device_resource_len (device,1 ) >>PAGE_SHIFT ;int ret;/* as long as the bo isn't in vram, and isn't tiled, we've got
@@ -1331,6 +1331,7 @@ nouveau_ttm_tt_populate(struct ttm_tt *ttm) {struct ttm_dma_tt *ttm_dma = (void *)ttm;struct nouveau_drm *drm; +struct nouveau_device *device;struct drm_device *dev;unsigned i;int r;
@@ -1348,6 +1349,7 @@ nouveau_ttm_tt_populate(struct ttm_tt *ttm) } drm =nouveau_bdev (ttm->bdev); + device =nv_device (drm->device); dev = drm->dev;#if __OS_HAS_AGP
@@ -1368,13 +1370,12 @@ nouveau_ttm_tt_populate(struct ttm_tt *ttm) }for (i =0 ; i < ttm->num_pages; i++) { - ttm_dma->dma_address[i] =pci_map_page (dev->pdev, ttm->pages[i], -0 ,PAGE_SIZE , -PCI_DMA_BIDIRECTIONAL ); -if (pci_dma_mapping_error (dev->pdev, ttm_dma->dma_address[i])) { + ttm_dma->dma_address[i] =nv_device_map_page (device, + ttm->pages[i]); +if (!ttm_dma->dma_address[i]) {while (--i) { -pci_unmap_page (dev->pdev, ttm_dma->dma_address[i], -PAGE_SIZE ,PCI_DMA_BIDIRECTIONAL ); +nv_device_unmap_page (device, + ttm_dma->dma_address[i]); ttm_dma->dma_address[i] =0 ; }ttm_pool_unpopulate (ttm);
@@ -1389,6 +1390,7 @@ nouveau_ttm_tt_unpopulate(struct ttm_tt *ttm) {struct ttm_dma_tt *ttm_dma = (void *)ttm;struct nouveau_drm *drm; +struct nouveau_device *device;struct drm_device *dev;unsigned i;bool slave = !!(ttm->page_flags &TTM_PAGE_FLAG_SG );
@@ -1397,6 +1399,7 @@ nouveau_ttm_tt_unpopulate(struct ttm_tt *ttm)return ; drm =nouveau_bdev (ttm->bdev); + device =nv_device (drm->device); dev = drm->dev;#if __OS_HAS_AGP
@@ -1415,8 +1418,7 @@ nouveau_ttm_tt_unpopulate(struct ttm_tt *ttm)for (i =0 ; i < ttm->num_pages; i++) {if (ttm_dma->dma_address[i]) { -pci_unmap_page (dev->pdev, ttm_dma->dma_address[i], -PAGE_SIZE ,PCI_DMA_BIDIRECTIONAL ); +nv_device_unmap_page (device, ttm_dma->dma_address[i]); } }
drivers/gpu/drm/nouveau/nouveau_chan.c +1 -1
@@ -154,7 +154,7 @@ nouveau_channel_prep(struct nouveau_drm *drm, struct nouveau_cli *cli,* nfi why this exists, it came from the -nv ddx. */ args.flags =NV_DMA_TARGET_PCI |NV_DMA_ACCESS_RDWR ; - args.start =pci_resource_start (device->pdev,1 ); + args.start =nv_device_resource_start (device,1 ); args.limit = args.start + limit; }else { args.flags =NV_DMA_TARGET_VRAM |NV_DMA_ACCESS_RDWR ;
drivers/gpu/drm/nouveau/nouveau_display.c +2 -1
@@ -339,6 +339,7 @@ int nouveau_display_create(struct drm_device *dev) {struct nouveau_drm *drm =nouveau_drm (dev); +struct nouveau_device *device =nouveau_dev (dev);struct nouveau_display *disp;int ret, gen;
@@ -379,7 +380,7 @@ nouveau_display_create(struct drm_device *dev) } dev->mode_config.funcs = &nouveau_mode_config_funcs; - dev->mode_config.fb_base =pci_resource_start (dev->pdev,1 ); + dev->mode_config.fb_base =nv_device_resource_start (device,1 ); dev->mode_config.min_width =0 ; dev->mode_config.min_height =0 ;
drivers/gpu/drm/nouveau/nouveau_drm.c +51 -8
120 lines not on this page · raw message
drivers/gpu/drm/nouveau/nouveau_sysfs.c +5 -3
@@ -30,7 +30,7 @@static inline struct drm_device *drm_device (struct device *d) { -return pci_get_drvdata (to_pci_dev (d)); +return dev_get_drvdata (d); } #define snappendf(p,r,f,a...) do { \
@@ -132,9 +132,10 @@ nouveau_sysfs_fini(struct drm_device *dev) {struct nouveau_sysfs *sysfs =nouveau_sysfs (dev);struct nouveau_drm *drm =nouveau_drm (dev); +struct nouveau_device *device =nv_device (drm->device);if (sysfs->ctrl) { -device_remove_file (&dev->pdev->dev, &dev_attr_pstate); +device_remove_file (nv_device_base (device), &dev_attr_pstate);nouveau_object_del (nv_object (drm),NVDRM_DEVICE ,NVDRM_CONTROL ); }
@@ -146,6 +147,7 @@ int nouveau_sysfs_init(struct drm_device *dev) {struct nouveau_drm *drm =nouveau_drm (dev); +struct nouveau_device *device =nv_device (drm->device);struct nouveau_sysfs *sysfs;int ret;
@@ -156,7 +158,7 @@ nouveau_sysfs_init(struct drm_device *dev) ret =nouveau_object_new (nv_object (drm),NVDRM_DEVICE ,NVDRM_CONTROL ,NV_CONTROL_CLASS ,NULL ,0 , &sysfs->ctrl);if (ret ==0 ) -device_create_file (&dev->pdev->dev, &dev_attr_pstate); +device_create_file (nv_device_base (device), &dev_attr_pstate);return 0 ; }
drivers/gpu/drm/nouveau/nouveau_ttm.c +18 -13
@@ -354,21 +354,26 @@ int nouveau_ttm_init(struct nouveau_drm *drm) {struct drm_device *dev = drm->dev; +struct nouveau_device *device =nv_device (drm->device);u32 bits;int ret; bits =nouveau_vmmgr (drm->device)->dma_bits; -if ( drm->agp.stat ==ENABLED || - !pci_dma_supported (dev->pdev,DMA_BIT_MASK (bits))) - bits =32 ; - - ret =pci_set_dma_mask (dev->pdev,DMA_BIT_MASK (bits)); -if (ret) -return ret; - - ret =pci_set_consistent_dma_mask (dev->pdev,DMA_BIT_MASK (bits)); -if (ret) -pci_set_consistent_dma_mask (dev->pdev,DMA_BIT_MASK (32 )); +if (nv_device_is_pci (device)) { +if (drm->agp.stat ==ENABLED || + !pci_dma_supported (dev->pdev,DMA_BIT_MASK (bits))) + bits =32 ; + + ret =pci_set_dma_mask (dev->pdev,DMA_BIT_MASK (bits)); +if (ret) +return ret; + + ret =pci_set_consistent_dma_mask (dev->pdev, +DMA_BIT_MASK (bits)); +if (ret) +pci_set_consistent_dma_mask (dev->pdev, +DMA_BIT_MASK (32 )); + } ret =nouveau_ttm_global_init (drm);if (ret)
@@ -394,8 +399,8 @@ nouveau_ttm_init(struct nouveau_drm *drm)return ret; } - drm->ttm.mtrr =arch_phys_wc_add (pci_resource_start (dev->pdev,1 ), -pci_resource_len (dev->pdev,1 )); + drm->ttm.mtrr =arch_phys_wc_add (nv_device_resource_start (device,1 ), +nv_device_resource_len (device,1 ));/* GART init */ if (drm->agp.stat !=ENABLED ) {
drivers/gpu/drm/nouveau/nouveau_vga.c +5 -0
@@ -82,6 +82,11 @@ nouveau_vga_init(struct nouveau_drm *drm) {struct drm_device *dev = drm->dev;bool runtime = false; + +/* only relevant for PCI devices */ +if (!dev->pdev) +return ; +vga_client_register (dev->pdev, dev,NULL , nouveau_vga_set_decode);if (nouveau_runtime_pm ==1 )
Signature · 1 line
1.8.5.4
Quoted 11 lines · Alexandre Courbot
Upcoming mobile Kepler GPUs (such as GK20A) use the platform bus instead of PCI to which Nouveau is tightly dependent. This patch allows Nouveau to handle platform devices by:
- abstracting PCI-dependent functions that were typically used for resource querying and page mapping,
- introducing anv_device_is_pci()function that allows to make PCI-dependent code conditional,
- providing anouveau_drm_platform_probe()function that takes a GPU platform device to be probed.
Quoted 5 lines
Core code as well as engine/subdev drivers are updated wherever possible to make use of these functions. Some older drivers are too dependent on PCI to be properly updated, but all newer code on which future chips may depend should at least be runnable with platform devices.
Hi Alexandre
I've tried really hard to find something wrong with this patch but it seems that you have it polished very nicely.
There is one quite minor nit in-line, but I'm not fussed either way.
Quoted 46 lines
Signed-off-by Alexandre Courbot <[email protected]>---
Changes since v1:
- Refactorednouveau_device_create_()to take an additional bus type argument instead of having two versions of it that duplicate code.
- Fixed a typo when substituting pci_resource_* with nv_device_resource_*
- Check whether devices are PCI in relevant functions instead ofnouveau_drm_load().drivers/gpu/drm/nouveau/core/engine/device/base.c | 83 ++++++++++++++++++++-- drivers/gpu/drm/nouveau/core/engine/falcon.c | 6 +- drivers/gpu/drm/nouveau/core/engine/fifo/base.c | 2 +- drivers/gpu/drm/nouveau/core/engine/graph/nv20.c | 2 +- drivers/gpu/drm/nouveau/core/engine/graph/nv40.c | 2 +- drivers/gpu/drm/nouveau/core/engine/graph/nvc0.c | 4 +- drivers/gpu/drm/nouveau/core/engine/xtensa.c | 2 +- drivers/gpu/drm/nouveau/core/include/core/device.h | 30 ++++++++ .../gpu/drm/nouveau/core/include/engine/device.h | 17 +++-- drivers/gpu/drm/nouveau/core/include/subdev/mc.h | 1 + drivers/gpu/drm/nouveau/core/os.h | 1 + drivers/gpu/drm/nouveau/core/subdev/bar/base.c | 4 +- drivers/gpu/drm/nouveau/core/subdev/bar/nv50.c | 4 +- drivers/gpu/drm/nouveau/core/subdev/bar/nvc0.c | 15 ++-- .../gpu/drm/nouveau/core/subdev/devinit/fbmem.h | 8 ++- drivers/gpu/drm/nouveau/core/subdev/devinit/nv04.c | 2 +- drivers/gpu/drm/nouveau/core/subdev/devinit/nv05.c | 2 +- drivers/gpu/drm/nouveau/core/subdev/devinit/nv10.c | 2 +- drivers/gpu/drm/nouveau/core/subdev/devinit/nv20.c | 2 +- drivers/gpu/drm/nouveau/core/subdev/fb/nv50.c | 9 +-- drivers/gpu/drm/nouveau/core/subdev/fb/nvc0.c | 9 +-- drivers/gpu/drm/nouveau/core/subdev/i2c/base.c | 2 +- drivers/gpu/drm/nouveau/core/subdev/instmem/nv40.c | 7 +- drivers/gpu/drm/nouveau/core/subdev/mc/base.c | 39 ++++++---- drivers/gpu/drm/nouveau/core/subdev/mxm/base.c | 2 +- drivers/gpu/drm/nouveau/nouveau_abi16.c | 13 +++- drivers/gpu/drm/nouveau/nouveau_agp.c | 2 +- drivers/gpu/drm/nouveau/nouveau_bios.c | 4 ++ drivers/gpu/drm/nouveau/nouveau_bo.c | 22 +++--- drivers/gpu/drm/nouveau/nouveau_chan.c | 2 +- drivers/gpu/drm/nouveau/nouveau_display.c | 3 +- drivers/gpu/drm/nouveau/nouveau_drm.c | 59 ++++++++++++--- drivers/gpu/drm/nouveau/nouveau_sysfs.c | 8 ++- drivers/gpu/drm/nouveau/nouveau_ttm.c | 31 ++++---- drivers/gpu/drm/nouveau/nouveau_vga.c | 5 ++ 35 files changed, 297 insertions(+), 109 deletions(-)
[snip]
drivers/gpu/drm/nouveau/core/subdev/mc/base.c _nouveau_mc_dtor(struct nouveau_object *object) · line 97
Quoted 12 lines
drivers/gpu/drm/nouveau/core/subdev/mc/base.c +2
-2@@ -93,8 +93,8 @@ _nouveau_mc_dtor(struct nouveau_object *object) {struct nouveau_device *device =nv_device (object);struct nouveau_mc *pmc = (void *)object; -free_irq (device->pdev->irq, pmc); -if (pmc->use_msi) +free_irq (pmc->irq, pmc); +if (nv_device_is_pci (device) && pmc->use_msi)
You should be able to keep the conditional as is.
Quoted 25 lines
drivers/gpu/drm/nouveau/core/subdev/mc/base.c +7
-10pci_disable_msi (device->pdev);nouveau_subdev_destroy (&pmc->base); }@@ -114,22 +114,25 @@ nouveau_mc_create_(struct nouveau_object *parent, struct nouveau_object *engine,if (ret)return ret; -switch (device->pdev->device &0x0ff0 ) { -case 0x00f0 : -case 0x02e0 : -/* BR02? NFI how these would be handled yet exactly */ -break ; -default : -switch (device->chipset) { -case 0xaa :break ;/* reported broken, nv also disable it */ -default : - pmc->use_msi = true; +if (nv_device_is_pci (device)) +switch (device->pdev->device &0x0ff0 ) { +case 0x00f0 : +case 0x02e0 : +/* BR02? NFI how these would be handled yet exactly */ break ; +default : +switch (device->chipset) {
drivers/gpu/drm/nouveau/core/subdev/mc/base.c nouveau_mc_create_(struct nouveau_object *parent, struct nouveau_object *engine, · line 134
Quoted 10 lines
drivers/gpu/drm/nouveau/core/subdev/mc/base.c +6
-0+case 0xaa : +/* reported broken, nv also disable it */ +break ; +default : + pmc->use_msi = true; +break ; } } pmc->use_msi =nouveau_boolopt (device->cfgopt,"NvMSI" , pmc->use_msi);
As you explicitly disable msi on platform devices you can move the option parsing within the if (nv_device_is_pci()) block.
This way you can drop the change in the following conditional and the similar one in _nouveau_mc_dtor.
drivers/gpu/drm/nouveau/core/subdev/mc/base.c nouveau_mc_create_(struct nouveau_object *parent, struct nouveau_object *engine, · line 135
Quoted 2 lines
drivers/gpu/drm/nouveau/core/subdev/mc/base.c +1
-1-if (pmc->use_msi && oclass->msi_rearm) { +if (nv_device_is_pci (device) && pmc->use_msi && oclass->msi_rearm) {
Many thanks, and again, welcome to nouveau :-)
-Emil
Hi Emil,
Quoted 17 lines · Emil Velikov
Quoted 11 lines · Alexandre Courbot
Upcoming mobile Kepler GPUs (such as GK20A) use the platform bus instead of PCI to which Nouveau is tightly dependent. This patch allows Nouveau to handle platform devices by:
- abstracting PCI-dependent functions that were typically used for resource querying and page mapping,
- introducing anv_device_is_pci()function that allows to make PCI-dependent code conditional,
- providing anouveau_drm_platform_probe()function that takes a GPU platform device to be probed.Quoted 5 lines
Core code as well as engine/subdev drivers are updated wherever possible to make use of these functions. Some older drivers are too dependent on PCI to be properly updated, but all newer code on which future chips may depend should at least be runnable with platform devices.
Quoted 4 lines
Hi Alexandre
I've tried really hard to find something wrong with this patch but it seems that you have it polished very nicely.
Great!
Quoted 97 lines
There is one quite minor nit in-line, but I'm not fussed either way.
Quoted 46 lines
Signed-off-by Alexandre Courbot <[email protected]>---
Changes since v1:
- Refactorednouveau_device_create_()to take an additional bus type argument instead of having two versions of it that duplicate code.
- Fixed a typo when substituting pci_resource_* with nv_device_resource_*
- Check whether devices are PCI in relevant functions instead ofnouveau_drm_load().drivers/gpu/drm/nouveau/core/engine/device/base.c | 83 ++++++++++++++++++++-- drivers/gpu/drm/nouveau/core/engine/falcon.c | 6 +- drivers/gpu/drm/nouveau/core/engine/fifo/base.c | 2 +- drivers/gpu/drm/nouveau/core/engine/graph/nv20.c | 2 +- drivers/gpu/drm/nouveau/core/engine/graph/nv40.c | 2 +- drivers/gpu/drm/nouveau/core/engine/graph/nvc0.c | 4 +- drivers/gpu/drm/nouveau/core/engine/xtensa.c | 2 +- drivers/gpu/drm/nouveau/core/include/core/device.h | 30 ++++++++ .../gpu/drm/nouveau/core/include/engine/device.h | 17 +++-- drivers/gpu/drm/nouveau/core/include/subdev/mc.h | 1 + drivers/gpu/drm/nouveau/core/os.h | 1 + drivers/gpu/drm/nouveau/core/subdev/bar/base.c | 4 +- drivers/gpu/drm/nouveau/core/subdev/bar/nv50.c | 4 +- drivers/gpu/drm/nouveau/core/subdev/bar/nvc0.c | 15 ++-- .../gpu/drm/nouveau/core/subdev/devinit/fbmem.h | 8 ++- drivers/gpu/drm/nouveau/core/subdev/devinit/nv04.c | 2 +- drivers/gpu/drm/nouveau/core/subdev/devinit/nv05.c | 2 +- drivers/gpu/drm/nouveau/core/subdev/devinit/nv10.c | 2 +- drivers/gpu/drm/nouveau/core/subdev/devinit/nv20.c | 2 +- drivers/gpu/drm/nouveau/core/subdev/fb/nv50.c | 9 +-- drivers/gpu/drm/nouveau/core/subdev/fb/nvc0.c | 9 +-- drivers/gpu/drm/nouveau/core/subdev/i2c/base.c | 2 +- drivers/gpu/drm/nouveau/core/subdev/instmem/nv40.c | 7 +- drivers/gpu/drm/nouveau/core/subdev/mc/base.c | 39 ++++++---- drivers/gpu/drm/nouveau/core/subdev/mxm/base.c | 2 +- drivers/gpu/drm/nouveau/nouveau_abi16.c | 13 +++- drivers/gpu/drm/nouveau/nouveau_agp.c | 2 +- drivers/gpu/drm/nouveau/nouveau_bios.c | 4 ++ drivers/gpu/drm/nouveau/nouveau_bo.c | 22 +++--- drivers/gpu/drm/nouveau/nouveau_chan.c | 2 +- drivers/gpu/drm/nouveau/nouveau_display.c | 3 +- drivers/gpu/drm/nouveau/nouveau_drm.c | 59 ++++++++++++--- drivers/gpu/drm/nouveau/nouveau_sysfs.c | 8 ++- drivers/gpu/drm/nouveau/nouveau_ttm.c | 31 ++++---- drivers/gpu/drm/nouveau/nouveau_vga.c | 5 ++ 35 files changed, 297 insertions(+), 109 deletions(-)[snip]
drivers/gpu/drm/nouveau/core/subdev/mc/base.c _nouveau_mc_dtor(struct nouveau_object *object) · line 97
Quoted 12 lines
drivers/gpu/drm/nouveau/core/subdev/mc/base.c +2
-2@@ -93,8 +93,8 @@ _nouveau_mc_dtor(struct nouveau_object *object) {struct nouveau_device *device =nv_device (object);struct nouveau_mc *pmc = (void *)object; -free_irq (device->pdev->irq, pmc); -if (pmc->use_msi) +free_irq (pmc->irq, pmc); +if (nv_device_is_pci (device) && pmc->use_msi)You should be able to keep the conditional as is.
Quoted 34 lines
drivers/gpu/drm/nouveau/core/subdev/mc/base.c +13
-10pci_disable_msi (device->pdev);nouveau_subdev_destroy (&pmc->base); }@@ -114,22 +114,25 @@ nouveau_mc_create_(struct nouveau_object *parent, struct nouveau_object *engine,if (ret)return ret; -switch (device->pdev->device &0x0ff0 ) { -case 0x00f0 : -case 0x02e0 : -/* BR02? NFI how these would be handled yet exactly */ -break ; -default : -switch (device->chipset) { -case 0xaa :break ;/* reported broken, nv also disable it */ -default : - pmc->use_msi = true; +if (nv_device_is_pci (device)) +switch (device->pdev->device &0x0ff0 ) { +case 0x00f0 : +case 0x02e0 : +/* BR02? NFI how these would be handled yet exactly */ break ; +default : +switch (device->chipset) { +case 0xaa : +/* reported broken, nv also disable it */ +break ; +default : + pmc->use_msi = true; +break ; } }
Quoted 3 lines
drivers/gpu/drm/nouveau/core/subdev/mc/base.c nouveau_mc_create_(struct nouveau_object *parent, struct nouveau_object *engine, · line 134
Quoted 1 line
drivers/gpu/drm/nouveau/core/subdev/mc/base.c +0
-0pmc->use_msi =nouveau_boolopt (device->cfgopt,"NvMSI" , pmc->use_msi);As you explicitly disable msi on platform devices you can move the option parsing within the if (
nv_device_is_pci()) block.
Yes, that's correct. Actually I think it would also make sense to move the next paragraph under the "if (nv_device_is_pci())" block as well, since it also deals with MSI.
Quoted 6 lines
This way you can drop the change in the following conditional and the similar one in
_nouveau_mc_dtor.drivers/gpu/drm/nouveau/core/subdev/mc/base.c nouveau_mc_create_(struct nouveau_object *parent, struct nouveau_object *engine, · line 135
Quoted 2 lines
drivers/gpu/drm/nouveau/core/subdev/mc/base.c +1
-1-if (pmc->use_msi && oclass->msi_rearm) { +if (nv_device_is_pci (device) && pmc->use_msi && oclass->msi_rearm) {
Will do that, rebase and post a v3.
Quoted 3 lines
Many thanks, and again, welcome to nouveau :-)
Thanks for the review and the welcome! :)
Alex.
PATCH v3 1/1 drm/nouveau: support for platform devices
Upcoming mobile Kepler GPUs (such as GK20A) use the platform bus instead of PCI to which Nouveau is tightly dependent. This patch allows Nouveau to handle platform devices by:
- abstracting PCI-dependent functions that were typically used for resource querying and page mapping,
- introducing a nv_device_is_pci() function that allows to make PCI-dependent code conditional,
- providing a nouveau_drm_platform_probe() function that takes a GPU platform device to be probed.
Core code as well as engine/subdev drivers are updated wherever possible to make use of these functions. Some older drivers are too dependent on PCI to be properly updated, but all newer code on which future chips may depend should at least be runnable with platform devices.
---
Changes since v2:
- Moved MSI code under PCI-conditioned blocks in mc/base.c, as suggested by Emil Velikov. This makes more sense with respect to how MSI is used and allows us to get rid of a couple extra conditional statements.
drivers/gpu/drm/nouveau/core/engine/device/base.c | 83 ++++++++++++++++++++-- drivers/gpu/drm/nouveau/core/engine/falcon.c | 6 +- drivers/gpu/drm/nouveau/core/engine/fifo/base.c | 2 +- drivers/gpu/drm/nouveau/core/engine/graph/nv20.c | 2 +- drivers/gpu/drm/nouveau/core/engine/graph/nv40.c | 2 +- drivers/gpu/drm/nouveau/core/engine/graph/nvc0.c | 4 +- drivers/gpu/drm/nouveau/core/engine/xtensa.c | 2 +- drivers/gpu/drm/nouveau/core/include/core/device.h | 30 ++++++++ .../gpu/drm/nouveau/core/include/engine/device.h | 17 +++-- drivers/gpu/drm/nouveau/core/include/subdev/mc.h | 1 + drivers/gpu/drm/nouveau/core/os.h | 1 + drivers/gpu/drm/nouveau/core/subdev/bar/base.c | 4 +- drivers/gpu/drm/nouveau/core/subdev/bar/nv50.c | 4 +- drivers/gpu/drm/nouveau/core/subdev/bar/nvc0.c | 15 ++-- .../gpu/drm/nouveau/core/subdev/devinit/fbmem.h | 8 ++- drivers/gpu/drm/nouveau/core/subdev/devinit/nv04.c | 2 +- drivers/gpu/drm/nouveau/core/subdev/devinit/nv05.c | 2 +- drivers/gpu/drm/nouveau/core/subdev/devinit/nv10.c | 2 +- drivers/gpu/drm/nouveau/core/subdev/devinit/nv20.c | 2 +- drivers/gpu/drm/nouveau/core/subdev/fb/nv50.c | 9 +-- drivers/gpu/drm/nouveau/core/subdev/fb/nvc0.c | 9 +-- drivers/gpu/drm/nouveau/core/subdev/i2c/base.c | 2 +- drivers/gpu/drm/nouveau/core/subdev/instmem/nv40.c | 7 +- drivers/gpu/drm/nouveau/core/subdev/mc/base.c | 55 ++++++++------ drivers/gpu/drm/nouveau/core/subdev/mxm/base.c | 2 +- drivers/gpu/drm/nouveau/nouveau_abi16.c | 13 +++- drivers/gpu/drm/nouveau/nouveau_agp.c | 2 +- drivers/gpu/drm/nouveau/nouveau_bios.c | 4 ++ drivers/gpu/drm/nouveau/nouveau_bo.c | 22 +++--- drivers/gpu/drm/nouveau/nouveau_chan.c | 2 +- drivers/gpu/drm/nouveau/nouveau_display.c | 3 +- drivers/gpu/drm/nouveau/nouveau_drm.c | 59 ++++++++++++--- drivers/gpu/drm/nouveau/nouveau_sysfs.c | 8 ++- drivers/gpu/drm/nouveau/nouveau_ttm.c | 31 ++++---- drivers/gpu/drm/nouveau/nouveau_vga.c | 5 ++ 35 files changed, 306 insertions(+), 116 deletions(-)
drivers/gpu/drm/nouveau/core/engine/device/base.c +78 -5
@@ -131,8 +131,8 @@ nouveau_devobj_ctor(struct nouveau_object *parent,if (ret)return ret; - mmio_base =pci_resource_start (device->pdev,0 ); - mmio_size =pci_resource_len (device->pdev,0 ); + mmio_base =nv_device_resource_start (device,0 ); + mmio_size =nv_device_resource_len (device,0 );/* translate api disable mask into internal mapping */ disable = args->debug0;
@@ -446,6 +446,72 @@ nouveau_device_dtor(struct nouveau_object *object)nouveau_engine_destroy (&device->base); } +resource_size_t +nv_device_resource_start (struct nouveau_device *device,unsigned int bar) +{ +if (nv_device_is_pci (device)) { +return pci_resource_start (device->pdev, bar); + }else { +struct resource *res; + res =platform_get_resource (device->platformdev, +IORESOURCE_MEM , bar); +if (!res) +return 0 ; +return res->start; + } +} + +resource_size_t +nv_device_resource_len (struct nouveau_device *device,unsigned int bar) +{ +if (nv_device_is_pci (device)) { +return pci_resource_len (device->pdev, bar); + }else { +struct resource *res; + res =platform_get_resource (device->platformdev, +IORESOURCE_MEM , bar); +if (!res) +return 0 ; +return resource_size (res); + } +} + +dma_addr_t +nv_device_map_page (struct nouveau_device *device,struct page *page) +{ +dma_addr_t ret; + +if (nv_device_is_pci (device)) { + ret =pci_map_page (device->pdev, page,0 ,PAGE_SIZE , +PCI_DMA_BIDIRECTIONAL ); +if (pci_dma_mapping_error (device->pdev, ret)) + ret =0 ; + }else { + ret =page_to_phys (page); + } + +return ret; +} + +void +nv_device_unmap_page (struct nouveau_device *device,dma_addr_t addr) +{ +if (nv_device_is_pci (device)) +pci_unmap_page (device->pdev, addr,PAGE_SIZE , +PCI_DMA_BIDIRECTIONAL ); +} + +int +nv_device_get_irq (struct nouveau_device *device,bool stall) +{ +if (nv_device_is_pci (device)) { +return device->pdev->irq; + }else { +return platform_get_irq_byname (device->platformdev, + stall ?"stall" :"nonstall" ); + } +} +static struct nouveau_oclass nouveau_device_oclass = { .handle =NV_ENGINE (DEVICE ,0x00 ),
@@ -457,8 +523,8 @@ nouveau_device_oclass = { };int -nouveau_device_create_ (struct pci_dev *pdev,u64 name,const char *sname, -const char *cfg,const char *dbg, +nouveau_device_create_ (void *dev,enum nv_bus_type type,u64 name, +const char *sname,const char *cfg,const char *dbg,int length,void **pobject) {struct nouveau_device *device;
@@ -476,7 +542,14 @@ nouveau_device_create_(struct pci_dev *pdev, u64 name, const char *sname,if (ret) goto done; - device->pdev = pdev; +switch (type) { +case NOUVEAU_BUS_PCI : + device->pdev = dev; +break ; +case NOUVEAU_BUS_PLATFORM : + device->platformdev = dev; +break ; + } device->handle = name; device->cfgopt = cfg; device->dbgopt = dbg;
drivers/gpu/drm/nouveau/core/engine/falcon.c +3 -3
@@ -119,7 +119,7 @@ _nouveau_falcon_init(struct nouveau_object *object)snprintf (name,sizeof (name),"nouveau/nv%02x_fuc%03x" , device->chipset, falcon->addr >>12 ); - ret =request_firmware (&fw, name, &device->pdev->dev); + ret =request_firmware (&fw, name,nv_device_base (device));if (ret ==0 ) { falcon->code.data =vmemdup (fw->data, fw->size); falcon->code.size = fw->size;
@@ -138,7 +138,7 @@ _nouveau_falcon_init(struct nouveau_object *object)snprintf (name,sizeof (name),"nouveau/nv%02x_fuc%03xd" , device->chipset, falcon->addr >>12 ); - ret =request_firmware (&fw, name, &device->pdev->dev); + ret =request_firmware (&fw, name,nv_device_base (device));if (ret) {nv_error (falcon,"unable to load firmware data\n" );return ret;
@@ -153,7 +153,7 @@ _nouveau_falcon_init(struct nouveau_object *object)snprintf (name,sizeof (name),"nouveau/nv%02x_fuc%03xc" , device->chipset, falcon->addr >>12 ); - ret =request_firmware (&fw, name, &device->pdev->dev); + ret =request_firmware (&fw, name,nv_device_base (device));if (ret) {nv_error (falcon,"unable to load firmware code\n" );return ret;
drivers/gpu/drm/nouveau/core/engine/fifo/base.c +1 -1
@@ -86,7 +86,7 @@ nouveau_fifo_channel_create_(struct nouveau_object *parent, }/* map fifo control registers */ - chan->user =ioremap (pci_resource_start (device->pdev, bar) + addr + + chan->user =ioremap (nv_device_resource_start (device, bar) + addr + (chan->chid * size), size);if (!chan->user)return -EFAULT ;
drivers/gpu/drm/nouveau/core/engine/graph/nv20.c +1 -1
@@ -349,7 +349,7 @@ nv20_graph_init(struct nouveau_object *object)nv_wr32 (priv,NV10_PGRAPH_SURFACE , tmp);/* begin RAM config */ - vramsz =pci_resource_len (nv_device (priv)->pdev,0 ) -1 ; + vramsz =nv_device_resource_len (nv_device (priv),0 ) -1 ;nv_wr32 (priv,0x4009A4 ,nv_rd32 (priv,0x100200 ));nv_wr32 (priv,0x4009A8 ,nv_rd32 (priv,0x100204 ));nv_wr32 (priv,NV10_PGRAPH_RDI_INDEX ,0x00EA0000 );
drivers/gpu/drm/nouveau/core/engine/graph/nv40.c +1 -1
@@ -484,7 +484,7 @@ nv40_graph_init(struct nouveau_object *object) engine->tile_prog (engine, i);/* begin RAM config */ - vramsz =pci_resource_len (nv_device (priv)->pdev,0 ) -1 ; + vramsz =nv_device_resource_len (nv_device (priv),0 ) -1 ;switch (nv_device (priv)->chipset) {case 0x40 :nv_wr32 (priv,0x4009A4 ,nv_rd32 (priv,0x100200 ));
drivers/gpu/drm/nouveau/core/engine/graph/nvc0.c +2 -2
@@ -1091,10 +1091,10 @@ nvc0_graph_ctor_fw(struct nvc0_graph_priv *priv, const char *fwname,int ret;snprintf (f,sizeof (f),"nouveau/nv%02x_%s" , device->chipset, fwname); - ret =request_firmware (&fw, f, &device->pdev->dev); + ret =request_firmware (&fw, f,nv_device_base (device));if (ret) {snprintf (f,sizeof (f),"nouveau/%s" , fwname); - ret =request_firmware (&fw, f, &device->pdev->dev); + ret =request_firmware (&fw, f,nv_device_base (device));if (ret) {nv_error (priv,"failed to load %s\n" , fwname);return ret;
drivers/gpu/drm/nouveau/core/engine/xtensa.c +1 -1
@@ -112,7 +112,7 @@ _nouveau_xtensa_init(struct nouveau_object *object)snprintf (name,sizeof (name),"nouveau/nv84_xuc%03x" , xtensa->addr >>12 ); - ret =request_firmware (&fw, name, &device->pdev->dev); + ret =request_firmware (&fw, name,nv_device_base (device));if (ret) {nv_warn (xtensa,"unable to load firmware %s\n" , name);return ret;
drivers/gpu/drm/nouveau/core/include/core/device.h +30 -0
@@ -65,6 +65,7 @@ struct nouveau_device {struct list_head head;struct pci_dev *pdev; +struct platform_device *platformdev;u64 handle;const char *cfgopt;
@@ -140,4 +141,33 @@ nv_device_match(struct nouveau_object *object, u16 dev, u16 ven, u16 sub) device->pdev->subsystem_device == sub; } +static inline bool +nv_device_is_pci (struct nouveau_device *device) +{ +return device->pdev !=NULL ; +} + +static inline struct device * +nv_device_base (struct nouveau_device *device) +{ +return nv_device_is_pci (device) ? &device->pdev->dev : + &device->platformdev->dev; +} + +resource_size_t +nv_device_resource_start (struct nouveau_device *device,unsigned int bar); + +resource_size_t +nv_device_resource_len (struct nouveau_device *device,unsigned int bar); + +dma_addr_t +nv_device_map_page (struct nouveau_device *device,struct page *page); + +void +nv_device_unmap_page (struct nouveau_device *device,dma_addr_t addr); + +int +nv_device_get_irq (struct nouveau_device *device,bool stall); +#endif +
drivers/gpu/drm/nouveau/core/include/engine/device.h +13 -4
@@ -3,11 +3,20 @@#include <core/device.h> -#define nouveau_device_create (p,n,s,c,d,u) \ - nouveau_device_create_((p), (n), (s), (c), (d), sizeof(**u), (void **)u) +struct platform_device ; -int nouveau_device_create_ (struct pci_dev *,u64 name,const char *sname, -const char *cfg,const char *dbg,int ,void **); +enum nv_bus_type { +NOUVEAU_BUS_PCI , +NOUVEAU_BUS_PLATFORM , +}; + +#define nouveau_device_create (p,t,n,s,c,d,u) \ + nouveau_device_create_((void *)(p), (t), (n), (s), (c), (d), \ + sizeof(**u), (void **)u) + +int nouveau_device_create_ (void *,enum nv_bus_type type,u64 name, +const char *sname,const char *cfg,const char *dbg, +int ,void **);int nv04_identify (struct nouveau_device *);int nv10_identify (struct nouveau_device *);
drivers/gpu/drm/nouveau/core/include/subdev/mc.h +1 -0
@@ -12,6 +12,7 @@ struct nouveau_mc_intr {struct nouveau_mc {struct nouveau_subdev base;bool use_msi; +unsigned int irq; }; static inline struct nouveau_mc *
drivers/gpu/drm/nouveau/core/os.h +1 -0
@@ -5,6 +5,7 @@#include <linux/slab.h> #include <linux/mutex.h> #include <linux/pci.h> +#include <linux/platform_device.h> #include <linux/printk.h> #include <linux/bitops.h> #include <linux/firmware.h>
drivers/gpu/drm/nouveau/core/subdev/bar/base.c +2 -2
@@ -118,8 +118,8 @@ nouveau_bar_create_(struct nouveau_object *parent,if (ret)return ret; - bar->iomem =ioremap (pci_resource_start (device->pdev,3 ), -pci_resource_len (device->pdev,3 )); + bar->iomem =ioremap (nv_device_resource_start (device,3 ), +nv_device_resource_len (device,3 ));return 0 ; }
drivers/gpu/drm/nouveau/core/subdev/bar/nv50.c +2 -2
@@ -139,7 +139,7 @@ nv50_bar_ctor(struct nouveau_object *parent, struct nouveau_object *engine,/* BAR3 */ start =0x0100000000ULL ; - limit = start +pci_resource_len (device->pdev,3 ); + limit = start +nv_device_resource_len (device,3 ); ret =nouveau_vm_new (device, start, limit, start, &vm);if (ret)
@@ -173,7 +173,7 @@ nv50_bar_ctor(struct nouveau_object *parent, struct nouveau_object *engine,/* BAR1 */ start =0x0000000000ULL ; - limit = start +pci_resource_len (device->pdev,1 ); + limit = start +nv_device_resource_len (device,1 ); ret =nouveau_vm_new (device, start, limit--, start, &vm);if (ret)
drivers/gpu/drm/nouveau/core/subdev/bar/nvc0.c +7 -8
@@ -84,7 +84,6 @@ nvc0_bar_ctor(struct nouveau_object *parent, struct nouveau_object *engine, struct nouveau_object **pobject) {struct nouveau_device *device =nv_device (parent); -struct pci_dev *pdev = device->pdev;struct nvc0_bar_priv *priv;struct nouveau_gpuobj *mem;struct nouveau_vm *vm;
@@ -107,14 +106,14 @@ nvc0_bar_ctor(struct nouveau_object *parent, struct nouveau_object *engine,if (ret)return ret; - ret =nouveau_vm_new (device,0 ,pci_resource_len (pdev,3 ),0 , &vm); + ret =nouveau_vm_new (device,0 ,nv_device_resource_len (device,3 ),0 , &vm);if (ret)return ret;atomic_inc (&vm->engref[NVDEV_SUBDEV_BAR ]); ret =nouveau_gpuobj_new (nv_object (priv),NULL , - (pci_resource_len (pdev,3 ) >>12 ) *8 , + (nv_device_resource_len (device,3 ) >>12 ) *8 ,0x1000 ,NVOBJ_FLAG_ZERO_ALLOC , &vm->pgt[0 ].obj[0 ]); vm->pgt[0 ].refcount[0 ] =1 ;
@@ -128,8 +127,8 @@ nvc0_bar_ctor(struct nouveau_object *parent, struct nouveau_object *engine,nv_wo32 (mem,0x0200 ,lower_32_bits (priv->bar[0 ].pgd->addr));nv_wo32 (mem,0x0204 ,upper_32_bits (priv->bar[0 ].pgd->addr)); -nv_wo32 (mem,0x0208 ,lower_32_bits (pci_resource_len (pdev,3 ) -1 )); -nv_wo32 (mem,0x020c ,upper_32_bits (pci_resource_len (pdev,3 ) -1 )); +nv_wo32 (mem,0x0208 ,lower_32_bits (nv_device_resource_len (device,3 ) -1 )); +nv_wo32 (mem,0x020c ,upper_32_bits (nv_device_resource_len (device,3 ) -1 ));/* BAR1 */ ret = nouveau_gpuobj_new(nv_object(priv), NULL, 0x1000, 0, 0,
@@ -143,7 +142,7 @@ nvc0_bar_ctor(struct nouveau_object *parent, struct nouveau_object *engine,if (ret)return ret; - ret =nouveau_vm_new (device,0 ,pci_resource_len (pdev,1 ),0 , &vm); + ret =nouveau_vm_new (device,0 ,nv_device_resource_len (device,1 ),0 , &vm);if (ret)return ret;
@@ -156,8 +155,8 @@ nvc0_bar_ctor(struct nouveau_object *parent, struct nouveau_object *engine,nv_wo32 (mem,0x0200 ,lower_32_bits (priv->bar[1 ].pgd->addr));nv_wo32 (mem,0x0204 ,upper_32_bits (priv->bar[1 ].pgd->addr)); -nv_wo32 (mem,0x0208 ,lower_32_bits (pci_resource_len (pdev,1 ) -1 )); -nv_wo32 (mem,0x020c ,upper_32_bits (pci_resource_len (pdev,1 ) -1 )); +nv_wo32 (mem,0x0208 ,lower_32_bits (nv_device_resource_len (device,1 ) -1 )); +nv_wo32 (mem,0x020c ,upper_32_bits (nv_device_resource_len (device,1 ) -1 )); priv->base.alloc = nouveau_bar_alloc; priv->base.kmap = nvc0_bar_kmap;
drivers/gpu/drm/nouveau/core/subdev/devinit/fbmem.h +5 -3
@@ -24,6 +24,8 @@* */ +#include <core/device.h> +#define NV04_PFB_BOOT_0 0x00100000# define NV04_PFB_BOOT_0_RAM_AMOUNT 0x00000003# define NV04_PFB_BOOT_0_RAM_AMOUNT_32MB 0x00000000
@@ -60,10 +62,10 @@# define NV10_PFB_REFCTRL_VALID_1 (1 << 31)static inline struct io_mapping * -fbmem_init (struct pci_dev *pdev) +fbmem_init (struct nouveau_device *dev) { -return io_mapping_create_wc (pci_resource_start (pdev,1 ), -pci_resource_len (pdev,1 )); +return io_mapping_create_wc (nv_device_resource_start (dev,1 ), +nv_device_resource_len (dev,1 )); } static inline void
drivers/gpu/drm/nouveau/core/subdev/devinit/nv04.c +1 -1
@@ -38,7 +38,7 @@ nv04_devinit_meminit(struct nouveau_devinit *devinit)int i;/* Map the framebuffer aperture */ - fb =fbmem_init (nv_device (priv)->pdev); + fb =fbmem_init (nv_device (priv));if (!fb) {nv_error (priv,"failed to map fb\n" );return ;
drivers/gpu/drm/nouveau/core/subdev/devinit/nv05.c +1 -1
@@ -53,7 +53,7 @@ nv05_devinit_meminit(struct nouveau_devinit *devinit)int i, v;/* Map the framebuffer aperture */ - fb =fbmem_init (nv_device (priv)->pdev); + fb =fbmem_init (nv_device (priv));if (!fb) {nv_error (priv,"failed to map fb\n" );return ;
drivers/gpu/drm/nouveau/core/subdev/devinit/nv10.c +1 -1
@@ -46,7 +46,7 @@ nv10_devinit_meminit(struct nouveau_devinit *devinit) mem_width_count =2 ;/* Map the framebuffer aperture */ - fb =fbmem_init (nv_device (priv)->pdev); + fb =fbmem_init (nv_device (priv));if (!fb) {nv_error (priv,"failed to map fb\n" );return ;
drivers/gpu/drm/nouveau/core/subdev/devinit/nv20.c +1 -1
@@ -37,7 +37,7 @@ nv20_devinit_meminit(struct nouveau_devinit *devinit)struct io_mapping *fb;/* Map the framebuffer aperture */ - fb =fbmem_init (nv_device (priv)->pdev); + fb =fbmem_init (nv_device (priv));if (!fb) {nv_error (priv,"failed to map fb\n" );return ;
drivers/gpu/drm/nouveau/core/subdev/fb/nv50.c +3 -6
@@ -250,10 +250,8 @@ nv50_fb_ctor(struct nouveau_object *parent, struct nouveau_object *engine, priv->r100c08_page =alloc_page (GFP_KERNEL | __GFP_ZERO);if (priv->r100c08_page) { - priv->r100c08 =pci_map_page (device->pdev, priv->r100c08_page, -0 ,PAGE_SIZE , -PCI_DMA_BIDIRECTIONAL ); -if (pci_dma_mapping_error (device->pdev, priv->r100c08)) + priv->r100c08 =nv_device_map_page (device, priv->r100c08_page); +if (!priv->r100c08)nv_warn (priv,"failed 0x100c08 page map\n" ); }else {nv_warn (priv,"failed 0x100c08 page alloc\n" );
@@ -270,8 +268,7 @@ nv50_fb_dtor(struct nouveau_object *object)struct nv50_fb_priv *priv = (void *)object;if (priv->r100c08_page) { -pci_unmap_page (device->pdev, priv->r100c08,PAGE_SIZE , -PCI_DMA_BIDIRECTIONAL ); +nv_device_unmap_page (device, priv->r100c08);__free_page (priv->r100c08_page); }
drivers/gpu/drm/nouveau/core/subdev/fb/nvc0.c +3 -6
@@ -70,8 +70,7 @@ nvc0_fb_dtor(struct nouveau_object *object)struct nvc0_fb_priv *priv = (void *)object;if (priv->r100c10_page) { -pci_unmap_page (device->pdev, priv->r100c10,PAGE_SIZE , -PCI_DMA_BIDIRECTIONAL ); +nv_device_unmap_page (device, priv->r100c10);__free_page (priv->r100c10_page); }
@@ -94,10 +93,8 @@ nvc0_fb_ctor(struct nouveau_object *parent, struct nouveau_object *engine, priv->r100c10_page =alloc_page (GFP_KERNEL | __GFP_ZERO);if (priv->r100c10_page) { - priv->r100c10 =pci_map_page (device->pdev, priv->r100c10_page, -0 ,PAGE_SIZE , -PCI_DMA_BIDIRECTIONAL ); -if (pci_dma_mapping_error (device->pdev, priv->r100c10)) + priv->r100c10 =nv_device_map_page (device, priv->r100c10_page); +if (!priv->r100c10)return -EFAULT ; }
drivers/gpu/drm/nouveau/core/subdev/i2c/base.c +1 -1
@@ -111,7 +111,7 @@ nouveau_i2c_port_create_(struct nouveau_object *parent,snprintf (port->adapter.name,sizeof (port->adapter.name),"nouveau-%s-%d" , device->name, index); port->adapter.owner =THIS_MODULE ; - port->adapter.dev.parent = &device->pdev->dev; + port->adapter.dev.parent =nv_device_base (device); port->index = index; port->func = func;i2c_set_adapdata (&port->adapter, i2c);
drivers/gpu/drm/nouveau/core/subdev/instmem/nv40.c +3 -4
@@ -50,7 +50,6 @@ nv40_instmem_ctor(struct nouveau_object *parent, struct nouveau_object *engine, struct nouveau_object **pobject) {struct nouveau_device *device =nv_device (parent); -struct pci_dev *pdev = device->pdev;struct nv04_instmem_priv *priv;int ret, bar, vs;
@@ -60,13 +59,13 @@ nv40_instmem_ctor(struct nouveau_object *parent, struct nouveau_object *engine,return ret;/* map bar */ -if (pci_resource_len (pdev,2 )) +if (nv_device_resource_len (device,2 )) bar =2 ;else bar =3 ; - priv->iomem =ioremap (pci_resource_start (pdev, bar), -pci_resource_len (pdev, bar)); + priv->iomem =ioremap (nv_device_resource_start (device, bar), +nv_device_resource_len (device, bar));if (!priv->iomem) {nv_error (priv,"unable to map PRAMIN BAR\n" );return -EFAULT ;
drivers/gpu/drm/nouveau/core/subdev/mc/base.c +33 -22
73 lines not on this page · raw message
drivers/gpu/drm/nouveau/core/subdev/mxm/base.c +1 -1
@@ -96,7 +96,7 @@ mxm_shadow_dsm(struct nouveau_mxm *mxm, u8 version)acpi_handle handle;int rev; - handle =ACPI_HANDLE (&device->pdev->dev); + handle =ACPI_HANDLE (nv_device_base (device));if (!handle)return false;
drivers/gpu/drm/nouveau/nouveau_abi16.c +11 -2
@@ -179,12 +179,21 @@ nouveau_abi16_ioctl_getparam(ABI16_IOCTL_ARGS) getparam->value = device->chipset;break ;case NOUVEAU_GETPARAM_PCI_VENDOR : - getparam->value = dev->pdev->vendor; +if (nv_device_is_pci (device)) + getparam->value = dev->pdev->vendor; +else + getparam->value =0 ;break ;case NOUVEAU_GETPARAM_PCI_DEVICE : - getparam->value = dev->pdev->device; +if (nv_device_is_pci (device)) + getparam->value = dev->pdev->device; +else + getparam->value =0 ;break ;case NOUVEAU_GETPARAM_BUS_TYPE : +if (!nv_device_is_pci (device)) + getparam->value =3 ; +else if (drm_pci_device_is_agp (dev)) getparam->value =0 ;else
drivers/gpu/drm/nouveau/nouveau_agp.c +1 -1
@@ -75,7 +75,7 @@ nouveau_agp_enabled(struct nouveau_drm *drm) {struct drm_device *dev = drm->dev; -if (!drm_pci_device_is_agp (dev) || !dev->agp) +if (!dev->pdev || !drm_pci_device_is_agp (dev) || !dev->agp)return false;if (drm->agp.stat ==UNKNOWN ) {
drivers/gpu/drm/nouveau/nouveau_bios.c +4 -0
@@ -2069,6 +2069,10 @@ nouveau_bios_init(struct drm_device *dev)struct nvbios *bios = &drm->vbios;int ret; +/* only relevant for PCI devices */ +if (!dev->pdev) +return 0 ; +if (!NVInitVBIOS (dev))return -ENODEV ;
drivers/gpu/drm/nouveau/nouveau_bo.c +12 -10
@@ -1255,7 +1255,7 @@ nouveau_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_mem_reg *mem)/* fallthrough, tiled memory */ case TTM_PL_VRAM : mem->bus.offset = mem->start <<PAGE_SHIFT ; - mem->bus.base =pci_resource_start (dev->pdev,1 ); + mem->bus.base =nv_device_resource_start (nouveau_dev (dev),1 ); mem->bus.is_iomem = true;if (nv_device (drm->device)->card_type >=NV_50 ) {struct nouveau_bar *bar =nouveau_bar (drm->device);
@@ -1293,7 +1293,7 @@ nouveau_ttm_fault_reserve_notify(struct ttm_buffer_object *bo)struct nouveau_drm *drm =nouveau_bdev (bo->bdev);struct nouveau_bo *nvbo =nouveau_bo (bo);struct nouveau_device *device =nv_device (drm->device); -u32 mappable =pci_resource_len (device->pdev,1 ) >>PAGE_SHIFT ; +u32 mappable =nv_device_resource_len (device,1 ) >>PAGE_SHIFT ;int ret;/* as long as the bo isn't in vram, and isn't tiled, we've got
@@ -1331,6 +1331,7 @@ nouveau_ttm_tt_populate(struct ttm_tt *ttm) {struct ttm_dma_tt *ttm_dma = (void *)ttm;struct nouveau_drm *drm; +struct nouveau_device *device;struct drm_device *dev;unsigned i;int r;
@@ -1348,6 +1349,7 @@ nouveau_ttm_tt_populate(struct ttm_tt *ttm) } drm =nouveau_bdev (ttm->bdev); + device =nv_device (drm->device); dev = drm->dev;#if __OS_HAS_AGP
@@ -1368,13 +1370,12 @@ nouveau_ttm_tt_populate(struct ttm_tt *ttm) }for (i =0 ; i < ttm->num_pages; i++) { - ttm_dma->dma_address[i] =pci_map_page (dev->pdev, ttm->pages[i], -0 ,PAGE_SIZE , -PCI_DMA_BIDIRECTIONAL ); -if (pci_dma_mapping_error (dev->pdev, ttm_dma->dma_address[i])) { + ttm_dma->dma_address[i] =nv_device_map_page (device, + ttm->pages[i]); +if (!ttm_dma->dma_address[i]) {while (--i) { -pci_unmap_page (dev->pdev, ttm_dma->dma_address[i], -PAGE_SIZE ,PCI_DMA_BIDIRECTIONAL ); +nv_device_unmap_page (device, + ttm_dma->dma_address[i]); ttm_dma->dma_address[i] =0 ; }ttm_pool_unpopulate (ttm);
@@ -1389,6 +1390,7 @@ nouveau_ttm_tt_unpopulate(struct ttm_tt *ttm) {struct ttm_dma_tt *ttm_dma = (void *)ttm;struct nouveau_drm *drm; +struct nouveau_device *device;struct drm_device *dev;unsigned i;bool slave = !!(ttm->page_flags &TTM_PAGE_FLAG_SG );
@@ -1397,6 +1399,7 @@ nouveau_ttm_tt_unpopulate(struct ttm_tt *ttm)return ; drm =nouveau_bdev (ttm->bdev); + device =nv_device (drm->device); dev = drm->dev;#if __OS_HAS_AGP
@@ -1415,8 +1418,7 @@ nouveau_ttm_tt_unpopulate(struct ttm_tt *ttm)for (i =0 ; i < ttm->num_pages; i++) {if (ttm_dma->dma_address[i]) { -pci_unmap_page (dev->pdev, ttm_dma->dma_address[i], -PAGE_SIZE ,PCI_DMA_BIDIRECTIONAL ); +nv_device_unmap_page (device, ttm_dma->dma_address[i]); } }
drivers/gpu/drm/nouveau/nouveau_chan.c +1 -1
@@ -154,7 +154,7 @@ nouveau_channel_prep(struct nouveau_drm *drm, struct nouveau_cli *cli,* nfi why this exists, it came from the -nv ddx. */ args.flags =NV_DMA_TARGET_PCI |NV_DMA_ACCESS_RDWR ; - args.start =pci_resource_start (device->pdev,1 ); + args.start =nv_device_resource_start (device,1 ); args.limit = args.start + limit; }else { args.flags =NV_DMA_TARGET_VRAM |NV_DMA_ACCESS_RDWR ;
drivers/gpu/drm/nouveau/nouveau_display.c +2 -1
@@ -339,6 +339,7 @@ int nouveau_display_create(struct drm_device *dev) {struct nouveau_drm *drm =nouveau_drm (dev); +struct nouveau_device *device =nouveau_dev (dev);struct nouveau_display *disp;int ret, gen;
@@ -379,7 +380,7 @@ nouveau_display_create(struct drm_device *dev) } dev->mode_config.funcs = &nouveau_mode_config_funcs; - dev->mode_config.fb_base =pci_resource_start (dev->pdev,1 ); + dev->mode_config.fb_base =nv_device_resource_start (device,1 ); dev->mode_config.min_width =0 ; dev->mode_config.min_height =0 ;
drivers/gpu/drm/nouveau/nouveau_drm.c +51 -8
120 lines not on this page · raw message
drivers/gpu/drm/nouveau/nouveau_sysfs.c +5 -3
@@ -30,7 +30,7 @@static inline struct drm_device *drm_device (struct device *d) { -return pci_get_drvdata (to_pci_dev (d)); +return dev_get_drvdata (d); } #define snappendf(p,r,f,a...) do { \
@@ -132,9 +132,10 @@ nouveau_sysfs_fini(struct drm_device *dev) {struct nouveau_sysfs *sysfs =nouveau_sysfs (dev);struct nouveau_drm *drm =nouveau_drm (dev); +struct nouveau_device *device =nv_device (drm->device);if (sysfs->ctrl) { -device_remove_file (&dev->pdev->dev, &dev_attr_pstate); +device_remove_file (nv_device_base (device), &dev_attr_pstate);nouveau_object_del (nv_object (drm),NVDRM_DEVICE ,NVDRM_CONTROL ); }
@@ -146,6 +147,7 @@ int nouveau_sysfs_init(struct drm_device *dev) {struct nouveau_drm *drm =nouveau_drm (dev); +struct nouveau_device *device =nv_device (drm->device);struct nouveau_sysfs *sysfs;int ret;
@@ -156,7 +158,7 @@ nouveau_sysfs_init(struct drm_device *dev) ret =nouveau_object_new (nv_object (drm),NVDRM_DEVICE ,NVDRM_CONTROL ,NV_CONTROL_CLASS ,NULL ,0 , &sysfs->ctrl);if (ret ==0 ) -device_create_file (&dev->pdev->dev, &dev_attr_pstate); +device_create_file (nv_device_base (device), &dev_attr_pstate);return 0 ; }
drivers/gpu/drm/nouveau/nouveau_ttm.c +18 -13
@@ -354,21 +354,26 @@ int nouveau_ttm_init(struct nouveau_drm *drm) {struct drm_device *dev = drm->dev; +struct nouveau_device *device =nv_device (drm->device);u32 bits;int ret; bits =nouveau_vmmgr (drm->device)->dma_bits; -if ( drm->agp.stat ==ENABLED || - !pci_dma_supported (dev->pdev,DMA_BIT_MASK (bits))) - bits =32 ; - - ret =pci_set_dma_mask (dev->pdev,DMA_BIT_MASK (bits)); -if (ret) -return ret; - - ret =pci_set_consistent_dma_mask (dev->pdev,DMA_BIT_MASK (bits)); -if (ret) -pci_set_consistent_dma_mask (dev->pdev,DMA_BIT_MASK (32 )); +if (nv_device_is_pci (device)) { +if (drm->agp.stat ==ENABLED || + !pci_dma_supported (dev->pdev,DMA_BIT_MASK (bits))) + bits =32 ; + + ret =pci_set_dma_mask (dev->pdev,DMA_BIT_MASK (bits)); +if (ret) +return ret; + + ret =pci_set_consistent_dma_mask (dev->pdev, +DMA_BIT_MASK (bits)); +if (ret) +pci_set_consistent_dma_mask (dev->pdev, +DMA_BIT_MASK (32 )); + } ret =nouveau_ttm_global_init (drm);if (ret)
@@ -394,8 +399,8 @@ nouveau_ttm_init(struct nouveau_drm *drm)return ret; } - drm->ttm.mtrr =arch_phys_wc_add (pci_resource_start (dev->pdev,1 ), -pci_resource_len (dev->pdev,1 )); + drm->ttm.mtrr =arch_phys_wc_add (nv_device_resource_start (device,1 ), +nv_device_resource_len (device,1 ));/* GART init */ if (drm->agp.stat !=ENABLED ) {
drivers/gpu/drm/nouveau/nouveau_vga.c +5 -0
@@ -82,6 +82,11 @@ nouveau_vga_init(struct nouveau_drm *drm) {struct drm_device *dev = drm->dev;bool runtime = false; + +/* only relevant for PCI devices */ +if (!dev->pdev) +return ; +vga_client_register (dev->pdev, dev,NULL , nouveau_vga_set_decode);if (nouveau_runtime_pm ==1 )
Signature · 1 line
1.9.0