drm/nouveau: change channel regs mapping to ioremap
Subsystems (3)
PATCH 1/3 drm/nouveau: change channel regs mapping to ioremap
Use ioremap() for mapping the channel user regs (that are never exposed to user space) instead of drm_addmap().
This removes the last use cases of drm_addmap/drm_rmmap from Nouveau.
--- drivers/gpu/drm/nouveau/nouveau_channel.c | 13 ++++++------- drivers/gpu/drm/nouveau/nouveau_drv.h | 9 +++------ drivers/gpu/drm/nouveau/nv50_display.c | 13 ++++++------- 3 files changed, 15 insertions(+), 20 deletions(-)
drivers/gpu/drm/nouveau/nouveau_channel.c +6 -7
@@ -167,13 +167,12 @@ nouveau_channel_alloc(struct drm_device *dev, struct nouveau_channel **chan_ret,else user =NV50_USER (channel); - ret =drm_addmap (dev,drm_get_resource_start (dev,0 ) + user, -PAGE_SIZE , _DRM_REGISTERS, _DRM_DRIVER | - _DRM_READ_ONLY, &chan->user); -if (ret) { -NV_ERROR (dev,"regs %d\n" , ret); + chan->user =ioremap (pci_resource_start (dev->pdev,0 ) + user, +PAGE_SIZE ); +if (!chan->user) { +NV_ERROR (dev,"ioremap of regs failed.\n" );nouveau_channel_free (chan); -return ret; +return -ENOMEM ; } chan->user_put =0x40 ; chan->user_get =0x44 ;
@@ -412,7 +411,7 @@ nouveau_channel_free(struct nouveau_channel *chan)nouveau_notifier_takedown_channel (chan);if (chan->user) -drm_rmmap (dev, chan->user); +iounmap (chan->user); dev_priv->fifos[chan->id] =NULL ; dev_priv->fifo_alloc_count--;
drivers/gpu/drm/nouveau/nouveau_drv.h +3 -6
@@ -169,7 +169,7 @@ struct nouveau_channel {struct drm_local_map *map;/* mapping of the regs controling the fifo */ -struct drm_local_map *user; +void __iomem *user;uint32_t user_get;uint32_t user_put;
@@ -1047,11 +1047,8 @@ extern int nouveau_gem_ioctl_info(struct drm_device *, void *,#endif /* !ioread32_native */ /* channel control reg access */ -#define nvchan_wr32 (reg, val) \ - iowrite32_native((val), \ - (void __force __iomem *)chan->user->handle + (reg)) -#define nvchan_rd32 (reg) \ - ioread32_native((void __force __iomem *)chan->user->handle + (reg)) +#define nvchan_wr32 (reg, val) iowrite32_native((val), chan->user + (reg)) +#define nvchan_rd32 (reg) ioread32_native(chan->user + (reg))/* register access */ static inline u32 nv_rd32 (struct drm_device *dev,unsigned reg)
drivers/gpu/drm/nouveau/nv50_display.c +6 -7
@@ -44,7 +44,7 @@ nv50_evo_channel_del(struct nouveau_channel **pchan)nouveau_bo_ref (NULL , &chan->pushbuf_bo);if (chan->user) -drm_rmmap (chan->dev, chan->user); +iounmap (chan->user);kfree (chan); }
@@ -166,13 +166,12 @@ nv50_evo_channel_new(struct drm_device *dev, struct nouveau_channel **pchan)return ret; } - ret =drm_addmap (dev,drm_get_resource_start (dev,0 ) + -NV50_PDISPLAY_USER (0 ),PAGE_SIZE , _DRM_REGISTERS, - _DRM_DRIVER | _DRM_READ_ONLY, &chan->user); -if (ret) { -NV_ERROR (dev,"Error mapping EVO control regs: %d\n" , ret); + chan->user =ioremap (pci_resource_start (dev->pdev,0 ) + +NV50_PDISPLAY_USER (0 ),PAGE_SIZE ); +if (!chan->user) { +NV_ERROR (dev,"Error mapping EVO control regs.\n" );nv50_evo_channel_del (pchan); -return ret; +return -ENOMEM ; }return 0 ;
Signature · 1 line
1.6.3.3
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 2/3 drm/nouveau: channel user reg accessors into functions
Change the channel user reg accessor macros into functions. This also gets rid of the implicit macro argument 'chan', which now has to be given explicitly.
--- drivers/gpu/drm/nouveau/nouveau_channel.c | 4 ++-- drivers/gpu/drm/nouveau/nouveau_dma.c | 2 +- drivers/gpu/drm/nouveau/nouveau_dma.h | 2 +- drivers/gpu/drm/nouveau/nouveau_drv.c | 4 ++-- drivers/gpu/drm/nouveau/nouveau_drv.h | 12 ++++++++++-- drivers/gpu/drm/nouveau/nouveau_fence.c | 2 +- 6 files changed, 17 insertions(+), 9 deletions(-)
drivers/gpu/drm/nouveau/nouveau_channel.c +2 -2
@@ -239,8 +239,8 @@ nouveau_channel_alloc(struct drm_device *dev, struct nouveau_channel **chan_ret, dev_priv->fifo_alloc_count == 1) {/* setup channel's default get/put values */ -nvchan_wr32 (chan->user_get, chan->pushbuf_base); -nvchan_wr32 (chan->user_put, chan->pushbuf_base); +nvchan_wr32 (chan, chan->user_get, chan->pushbuf_base); +nvchan_wr32 (chan, chan->user_put, chan->pushbuf_base); ret = engine->fifo.load_context (chan);if (ret) {
drivers/gpu/drm/nouveau/nouveau_dma.c +1 -1
@@ -111,7 +111,7 @@ READ_GET(struct nouveau_channel *chan, uint32_t *get) {uint32_t val; - val =nvchan_rd32 (chan->user_get); + val =nvchan_rd32 (chan, chan->user_get);if (val < chan->pushbuf_base || val >= chan->pushbuf_base + chan->pushbuf_bo->bo.mem.size) {/* meaningless to dma_wait() except to know whether the
drivers/gpu/drm/nouveau/nouveau_dma.h +1 -1
@@ -121,7 +121,7 @@ BEGIN_RING(struct nouveau_channel *chan, int subc, int mthd, int size)#define WRITE_PUT (val) do { \ DRM_MEMORYBARRIER(); \ nouveau_bo_rd32(chan->pushbuf_bo, 0); \ - nvchan_wr32(chan->user_put, ((val) << 2) + chan->pushbuf_base); \ + nvchan_wr32(chan, chan->user_put, ((val) << 2) + chan->pushbuf_base); \ } while (0) static inline void
drivers/gpu/drm/nouveau/nouveau_drv.c +2 -2
@@ -290,8 +290,8 @@ nouveau_pci_resume(struct pci_dev *pdev)struct nouveau_channel *chan = dev_priv->channel;int ptr = chan->pushbuf_base + (chan->dma.cur <<2 ); -nvchan_wr32 (chan->user_get, ptr); -nvchan_wr32 (chan->user_put, ptr); +nvchan_wr32 (chan, chan->user_get, ptr); +nvchan_wr32 (chan, chan->user_put, ptr); engine->fifo.load_context (chan); engine->graph.load_context (chan);
drivers/gpu/drm/nouveau/nouveau_drv.h +10 -2
@@ -1047,8 +1047,16 @@ extern int nouveau_gem_ioctl_info(struct drm_device *, void *,#endif /* !ioread32_native */ /* channel control reg access */ -#define nvchan_wr32 (reg, val) iowrite32_native((val), chan->user + (reg)) -#define nvchan_rd32 (reg) ioread32_native(chan->user + (reg)) +static inline u32 nvchan_rd32 (struct nouveau_channel *chan,unsigned reg) +{ +return ioread32_native (chan->user + reg); +} + +static inline void nvchan_wr32 (struct nouveau_channel *chan, +unsigned reg,u32 val) +{ +iowrite32_native (val, chan->user + reg); +}/* register access */ static inline u32 nv_rd32 (struct drm_device *dev,unsigned reg)
drivers/gpu/drm/nouveau/nouveau_fence.c +1 -1
@@ -65,7 +65,7 @@ nouveau_fence_update(struct nouveau_channel *chan)uint32_t sequence;if (USE_REFCNT ) - sequence =nvchan_rd32 (0x48 ); + sequence =nvchan_rd32 (chan,0x48 );else sequence = chan->fence.last_sequence_irq;
Signature · 1 line
1.6.3.3
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 3/3 drm: revert Nouveau's changes to generic DRM code
Revert changes to drm_bufs.c and drmP.h to bring the Nouveau kernel tree in sync with drm-next.
The old changes are not necessary for Nouveau because:
- nothing calls drm_find_matching_map()
- nothing calls drm_addmap() or drm_rmmap()
- nothing calls the drm ADD_MAP ioctl
--- drivers/gpu/drm/drm_bufs.c | 28 +++++++++++++++++++++------- include/drm/drmP.h | 2 -- 2 files changed, 21 insertions(+), 9 deletions(-)
drivers/gpu/drm/drm_bufs.c +21 -7
@@ -51,24 +51,38 @@ resource_size_t drm_get_resource_len(struct drm_device *dev, unsigned int resourEXPORT_SYMBOL (drm_get_resource_len); -struct drm_map_list *drm_find_matching_map (struct drm_device *dev, -struct drm_local_map *map) +static struct drm_map_list *drm_find_matching_map (struct drm_device *dev, +struct drm_local_map *map) {struct drm_map_list *entry;list_for_each_entry (entry, &dev->maplist, head) { +/* +* Because the kernel-userspace ABI is fixed at a 32-bit offset +* while PCI resources may live above that, we ignore the map +* offset for maps of type _DRM_FRAMEBUFFER or _DRM_REGISTERS. +* It is assumed that each driver will have only one resource of +* each type. +*/ if (!entry->map || map->type != entry->map->type || entry->master != dev->primary->master)continue ; - -if (entry->map->offset == map->offset || - (map->type == _DRM_SHM && map->flags & _DRM_CONTAINS_LOCK)) +switch (map->type) { +case _DRM_SHM: +if (map->flags != _DRM_CONTAINS_LOCK) +break ; +case _DRM_REGISTERS: +case _DRM_FRAME_BUFFER: +return entry; +default :/* Make gcc happy */ + ; + } +if (entry->map->offset == map->offset)return entry; }return NULL ; } -EXPORT_SYMBOL (drm_find_matching_map);static int drm_map_handle (struct drm_device *dev,struct drm_hash_item *hash,unsigned long user_token,int hashed_handle,int shm)
@@ -343,7 +357,7 @@ static int drm_addmap_core(struct drm_device * dev, resource_size_t offset,/* We do it here so that dev->struct_mutex protects the increment */ user_token = (map->type == _DRM_SHM) ? (unsigned long )map->handle : map->offset; - ret =drm_map_handle (dev, &list->hash, user_token,1 , + ret =drm_map_handle (dev, &list->hash, user_token,0 , (map->type == _DRM_SHM));if (ret) {if (map->type == _DRM_REGISTERS)
include/drm/drmP.h +0 -2
@@ -1240,8 +1240,6 @@ extern void drm_idlelock_release(struct drm_lock_data *lock_data);extern int drm_i_have_hw_lock (struct drm_device *dev,struct drm_file *file_priv);/* Buffer management support (drm_bufs.h) */ -extern struct drm_map_list *drm_find_matching_map (struct drm_device *dev, -drm_local_map_t *map);extern int drm_addbufs_agp (struct drm_device *dev,struct drm_buf_desc * request);extern int drm_addbufs_pci (struct drm_device *dev,struct drm_buf_desc * request); extern int drm_addmap(struct drm_device *dev, resource_size_t offset,
Signature · 1 line
1.6.3.3