drm/vmwgfx: switch from ioremap_cache to memremap
Subsystems (3)
PATCH 1/1 drm/vmwgfx: switch from ioremap_cache to memremap
Per commit 2e586a7e017a "drm/vmwgfx: Map the fifo as cached" the driver expects the fifo registers to be cacheable. In preparation for deprecating ioremap_cache() convert its usage in vmwgfx to memremap().
---
This is part of the tree-wide conversion of ioremap_cache() to memremap() targeted for v4.4 [1]
As noted in that cover letter feel free to apply or ack. These individual conversions can go in independently given the base memremap() implementation is already upstream in v4.3-rc1.
This passes a clean run of sparse, but I have not tried to run the result.
[1]: https://lkml.org/lkml/2015/10/9/699
drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 8 +-- drivers/gpu/drm/vmwgfx/vmwgfx_drv.h | 2 - drivers/gpu/drm/vmwgfx/vmwgfx_fence.c | 23 ++++--- drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c | 102 ++++++++++++++++----------------- drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c | 9 +-- drivers/gpu/drm/vmwgfx/vmwgfx_irq.c | 8 +-- drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 24 ++++---- 7 files changed, 84 insertions(+), 92 deletions(-)
drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +4 -4
@@ -752,8 +752,8 @@ static int vmw_driver_load(struct drm_device *dev, unsigned long chipset)ttm_lock_set_kill (&dev_priv->fbdev_master.lock, false,SIGTERM ); dev_priv->active_master = &dev_priv->fbdev_master; - dev_priv->mmio_virt =ioremap_cache (dev_priv->mmio_start, - dev_priv->mmio_size); + dev_priv->mmio_virt =memremap (dev_priv->mmio_start, + dev_priv->mmio_size,MEMREMAP_WB );if (unlikely (dev_priv->mmio_virt ==NULL )) { ret = -ENOMEM ;
@@ -907,7 +907,7 @@ out_no_irq: out_no_device:ttm_object_device_release (&dev_priv->tdev); out_err4: -iounmap (dev_priv->mmio_virt); +memunmap (dev_priv->mmio_virt); out_err3:vmw_ttm_global_release (dev_priv); out_err0:
@@ -958,7 +958,7 @@ static int vmw_driver_unload(struct drm_device *dev)pci_release_regions (dev->pdev);ttm_object_device_release (&dev_priv->tdev); -iounmap (dev_priv->mmio_virt); +memunmap (dev_priv->mmio_virt);if (dev_priv->ctx.staged_bindings)vmw_binding_state_free (dev_priv->ctx.staged_bindings);vmw_ttm_global_release (dev_priv);
drivers/gpu/drm/vmwgfx/vmwgfx_drv.h +1 -1
@@ -375,7 +375,7 @@ struct vmw_private {uint32_t stdu_max_height;uint32_t initial_width;uint32_t initial_height; -u32 __iomem *mmio_virt; +u32 *mmio_virt;uint32_t capabilities;uint32_t max_gmr_ids;uint32_t max_gmr_pages;
drivers/gpu/drm/vmwgfx/vmwgfx_fence.c +11 -12
@@ -141,9 +141,9 @@ static bool vmw_fence_enable_signaling(struct fence *f)struct vmw_fence_manager *fman =fman_from_fence (fence);struct vmw_private *dev_priv = fman->dev_priv; +u32 *fifo_mem = dev_priv->mmio_virt; +u32 seqno = *(fifo_mem +SVGA_FIFO_FENCE ); -u32 __iomem *fifo_mem = dev_priv->mmio_virt; -u32 seqno =ioread32 (fifo_mem +SVGA_FIFO_FENCE );if (seqno - fence->base.seqno <VMW_FENCE_WRAP )return false;
@@ -386,14 +386,14 @@ static bool vmw_fence_goal_new_locked(struct vmw_fence_manager *fman, u32 passed_seqno) {u32 goal_seqno; -u32 __iomem *fifo_mem; +u32 *fifo_mem;struct vmw_fence_obj *fence;if (likely (!fman->seqno_valid))return false; fifo_mem = fman->dev_priv->mmio_virt; - goal_seqno =ioread32 (fifo_mem +SVGA_FIFO_FENCE_GOAL ); + goal_seqno = *(fifo_mem +SVGA_FIFO_FENCE_GOAL );if (likely (passed_seqno - goal_seqno >=VMW_FENCE_WRAP ))return false;
@@ -401,8 +401,7 @@ static bool vmw_fence_goal_new_locked(struct vmw_fence_manager *fman,list_for_each_entry (fence, &fman->fence_list, head) {if (!list_empty (&fence->seq_passed_actions)) { fman->seqno_valid = true; -iowrite32 (fence->base.seqno, - fifo_mem +SVGA_FIFO_FENCE_GOAL ); + *(fifo_mem +SVGA_FIFO_FENCE_GOAL ) = fence->base.seqno;break ; } }
@@ -430,18 +429,18 @@ static bool vmw_fence_goal_check_locked(struct vmw_fence_obj *fence) {struct vmw_fence_manager *fman =fman_from_fence (fence);u32 goal_seqno; -u32 __iomem *fifo_mem; +u32 *fifo_mem;if (fence_is_signaled_locked (&fence->base))return false; fifo_mem = fman->dev_priv->mmio_virt; - goal_seqno =ioread32 (fifo_mem +SVGA_FIFO_FENCE_GOAL ); + goal_seqno = *(fifo_mem +SVGA_FIFO_FENCE_GOAL );if (likely (fman->seqno_valid && goal_seqno - fence->base.seqno <VMW_FENCE_WRAP ))return false; -iowrite32 (fence->base.seqno, fifo_mem +SVGA_FIFO_FENCE_GOAL ); + *(fifo_mem +SVGA_FIFO_FENCE_GOAL ) = fence->base.seqno; fman->seqno_valid = true;return true;
@@ -453,9 +452,9 @@ static void __vmw_fences_update(struct vmw_fence_manager *fman)struct list_head action_list;bool needs_rerun;uint32_t seqno, new_seqno; -u32 __iomem *fifo_mem = fman->dev_priv->mmio_virt; +u32 *fifo_mem = fman->dev_priv->mmio_virt; - seqno =ioread32 (fifo_mem +SVGA_FIFO_FENCE ); + seqno = *(fifo_mem +SVGA_FIFO_FENCE ); rerun:list_for_each_entry_safe (fence, next_fence, &fman->fence_list, head) {if (seqno - fence->base.seqno <VMW_FENCE_WRAP ) {
@@ -477,7 +476,7 @@ rerun: needs_rerun =vmw_fence_goal_new_locked (fman, seqno);if (unlikely (needs_rerun)) { - new_seqno =ioread32 (fifo_mem +SVGA_FIFO_FENCE ); + new_seqno = *(fifo_mem +SVGA_FIFO_FENCE );if (new_seqno != seqno) { seqno = new_seqno; goto rerun;
drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c +49 -53
247 lines not on this page · raw message
drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c +4 -5
@@ -64,7 +64,7 @@ int vmw_getparam_ioctl(struct drm_device *dev, void *data,break ;case DRM_VMW_PARAM_FIFO_HW_VERSION : { -u32 __iomem *fifo_mem = dev_priv->mmio_virt; +u32 *fifo_mem = dev_priv->mmio_virt;const struct vmw_fifo_state *fifo = &dev_priv->fifo;if ((dev_priv->capabilities &SVGA_CAP_GBOBJECTS )) {
@@ -72,8 +72,7 @@ int vmw_getparam_ioctl(struct drm_device *dev, void *data,break ; } - param->value = - ioread32(fifo_mem + + param->value = *(fifo_mem + ((fifo->capabilities & SVGA_FIFO_CAP_3D_HWVERSION_REVISED) ? SVGA_FIFO_3D_HWVERSION_REVISED :
@@ -162,7 +161,7 @@ int vmw_get_cap_3d_ioctl(struct drm_device *dev, void *data, (struct drm_vmw_get_3d_cap_arg *) data;struct vmw_private *dev_priv =vmw_priv (dev);uint32_t size; -u32 __iomem *fifo_mem; +u32 *fifo_mem;void __user *buffer = (void __user *)((unsigned long )(arg->buffer));void *bounce;int ret;
@@ -211,7 +210,7 @@ int vmw_get_cap_3d_ioctl(struct drm_device *dev, void *data, goto out_err; }else { fifo_mem = dev_priv->mmio_virt; -memcpy_fromio (bounce, &fifo_mem[SVGA_FIFO_3D_CAPS ], size); +memcpy (bounce, &fifo_mem[SVGA_FIFO_3D_CAPS ], size); } ret =copy_to_user (buffer, bounce, size);
drivers/gpu/drm/vmwgfx/vmwgfx_irq.c +4 -4
@@ -72,8 +72,8 @@ static bool vmw_fifo_idle(struct vmw_private *dev_priv, uint32_t seqno)void vmw_update_seqno (struct vmw_private *dev_priv,struct vmw_fifo_state *fifo_state) { -u32 __iomem *fifo_mem = dev_priv->mmio_virt; -uint32_t seqno =ioread32 (fifo_mem +SVGA_FIFO_FENCE ); +u32 *fifo_mem = dev_priv->mmio_virt; +uint32_t seqno = *(fifo_mem +SVGA_FIFO_FENCE );if (dev_priv->last_read_seqno != seqno) { dev_priv->last_read_seqno = seqno;
@@ -178,8 +178,8 @@ int vmw_fallback_wait(struct vmw_private *dev_priv, }finish_wait (&dev_priv->fence_queue, &__wait);if (ret ==0 && fifo_idle) { -u32 __iomem *fifo_mem = dev_priv->mmio_virt; -iowrite32 (signal_seq, fifo_mem +SVGA_FIFO_FENCE ); +u32 *fifo_mem = dev_priv->mmio_virt; + *(fifo_mem +SVGA_FIFO_FENCE ) = signal_seq; }wake_up_all (&dev_priv->fence_queue); out_err:
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +11 -13
@@ -123,14 +123,12 @@ err_unreserve:void vmw_cursor_update_position (struct vmw_private *dev_priv,bool show,int x,int y) { -u32 __iomem *fifo_mem = dev_priv->mmio_virt; -uint32_t count; - -iowrite32 (show ?1 :0 , fifo_mem +SVGA_FIFO_CURSOR_ON ); -iowrite32 (x, fifo_mem +SVGA_FIFO_CURSOR_X ); -iowrite32 (y, fifo_mem +SVGA_FIFO_CURSOR_Y ); - count =ioread32 (fifo_mem +SVGA_FIFO_CURSOR_COUNT ); -iowrite32 (++count, fifo_mem +SVGA_FIFO_CURSOR_COUNT ); +u32 *fifo_mem = dev_priv->mmio_virt; + + *(fifo_mem +SVGA_FIFO_CURSOR_ON ) = show ?1 :0 ; + *(fifo_mem +SVGA_FIFO_CURSOR_X ) = x; + *(fifo_mem +SVGA_FIFO_CURSOR_Y ) = y; + *(fifo_mem +SVGA_FIFO_CURSOR_COUNT ) +=1 ; } int vmw_du_crtc_cursor_set(struct drm_crtc *crtc, struct drm_file *file_priv,
@@ -1155,7 +1153,7 @@ int vmw_kms_write_svga(struct vmw_private *vmw_priv,if (vmw_priv->capabilities &SVGA_CAP_PITCHLOCK )vmw_write (vmw_priv,SVGA_REG_PITCHLOCK , pitch);else if (vmw_fifo_have_pitchlock (vmw_priv)) -iowrite32 (pitch, vmw_priv->mmio_virt +SVGA_FIFO_PITCHLOCK ); + *(vmw_priv->mmio_virt +SVGA_FIFO_PITCHLOCK ) = pitch;vmw_write (vmw_priv,SVGA_REG_WIDTH , width);vmw_write (vmw_priv,SVGA_REG_HEIGHT , height);vmw_write (vmw_priv,SVGA_REG_BITS_PER_PIXEL , bpp);
@@ -1181,8 +1179,8 @@ int vmw_kms_save_vga(struct vmw_private *vmw_priv) vmw_priv->vga_pitchlock =vmw_read (vmw_priv,SVGA_REG_PITCHLOCK ); else if (vmw_fifo_have_pitchlock(vmw_priv)) - vmw_priv->vga_pitchlock = ioread32(vmw_priv->mmio_virt + -SVGA_FIFO_PITCHLOCK ); + vmw_priv->vga_pitchlock = *(vmw_priv->mmio_virt + +SVGA_FIFO_PITCHLOCK );if (!(vmw_priv->capabilities &SVGA_CAP_DISPLAY_TOPOLOGY ))return 0 ;
@@ -1230,8 +1228,8 @@ int vmw_kms_restore_vga(struct vmw_private *vmw_priv)vmw_write (vmw_priv,SVGA_REG_PITCHLOCK , vmw_priv->vga_pitchlock); else if (vmw_fifo_have_pitchlock(vmw_priv)) - iowrite32(vmw_priv->vga_pitchlock, - vmw_priv->mmio_virt + SVGA_FIFO_PITCHLOCK); + *(vmw_priv->mmio_virt +SVGA_FIFO_PITCHLOCK ) = + vmw_priv->vga_pitchlock;if (!(vmw_priv->capabilities &SVGA_CAP_DISPLAY_TOPOLOGY ))return 0 ;
Hi!
Quoted 9 lines · Dan Williams
Per commit
2e586a7e017a"drm/vmwgfx: Map the fifo as cached" the driver expects the fifo registers to be cacheable. In preparation for deprecatingioremap_cache()convert its usage in vmwgfx tomemremap().Cc David Airlie <[email protected]>Cc Thomas Hellstrom <[email protected]>Cc Sinclair Yeh <[email protected]>Signed-off-by Dan Williams <[email protected]>
While I have nothing against the conversion, what's stopping the compiler from reordering writes on a generic architecture and caching and reordering reads on x86 in particular? At the very least it looks to me like the memory accesses of the memremap'd memory needs to be encapsulated within READ_ONCE and WRITE_ONCE.
How is this handled in the other conversions?
Thanks,
Thomas
Quoted 76 lines
---
This is part of the tree-wide conversion of
ioremap_cache()tomemremap()targeted for v4.4 [1]As noted in that cover letter feel free to apply or ack. These individual conversions can go in independently given the base
memremap()implementation is already upstream in v4.3-rc1.This passes a clean run of sparse, but I have not tried to run the result.
drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 8 +-- drivers/gpu/drm/vmwgfx/vmwgfx_drv.h | 2 - drivers/gpu/drm/vmwgfx/vmwgfx_fence.c | 23 ++++--- drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c | 102 ++++++++++++++++----------------- drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c | 9 +-- drivers/gpu/drm/vmwgfx/vmwgfx_irq.c | 8 +-- drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 24 ++++---- 7 files changed, 84 insertions(+), 92 deletions(-)drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +4
-4@@ -752,8 +752,8 @@ static int vmw_driver_load(struct drm_device *dev, unsigned long chipset)ttm_lock_set_kill (&dev_priv->fbdev_master.lock, false,SIGTERM ); dev_priv->active_master = &dev_priv->fbdev_master; - dev_priv->mmio_virt =ioremap_cache (dev_priv->mmio_start, - dev_priv->mmio_size); + dev_priv->mmio_virt =memremap (dev_priv->mmio_start, + dev_priv->mmio_size,MEMREMAP_WB );if (unlikely (dev_priv->mmio_virt ==NULL )) { ret = -ENOMEM ;@@ -907,7 +907,7 @@ out_no_irq: out_no_device:ttm_object_device_release (&dev_priv->tdev); out_err4: -iounmap (dev_priv->mmio_virt); +memunmap (dev_priv->mmio_virt); out_err3:vmw_ttm_global_release (dev_priv); out_err0:@@ -958,7 +958,7 @@ static int vmw_driver_unload(struct drm_device *dev)pci_release_regions (dev->pdev);ttm_object_device_release (&dev_priv->tdev); -iounmap (dev_priv->mmio_virt); +memunmap (dev_priv->mmio_virt);if (dev_priv->ctx.staged_bindings)vmw_binding_state_free (dev_priv->ctx.staged_bindings);vmw_ttm_global_release (dev_priv);drivers/gpu/drm/vmwgfx/vmwgfx_drv.h +1
-1@@ -375,7 +375,7 @@ struct vmw_private {uint32_t stdu_max_height;uint32_t initial_width;uint32_t initial_height; -u32 __iomem *mmio_virt; +u32 *mmio_virt;uint32_t capabilities;uint32_t max_gmr_ids;uint32_t max_gmr_pages;drivers/gpu/drm/vmwgfx/vmwgfx_fence.c +0
-0@@ -141,9 +141,9 @@ static bool vmw_fence_enable_signaling(struct fence *f)
drivers/gpu/drm/vmwgfx/vmwgfx_fence.c static bool vmw_fence_enable_signaling(struct fence *f) · line 149
Quoted 10 lines
drivers/gpu/drm/vmwgfx/vmwgfx_fence.c +2
-2struct vmw_fence_manager *fman =fman_from_fence (fence);struct vmw_private *dev_priv = fman->dev_priv; +u32 *fifo_mem = dev_priv->mmio_virt; +u32 seqno = *(fifo_mem +SVGA_FIFO_FENCE ); -u32 __iomem *fifo_mem = dev_priv->mmio_virt; -u32 seqno =ioread32 (fifo_mem +SVGA_FIFO_FENCE );if (seqno - fence->base.seqno <VMW_FENCE_WRAP )return false;
Here, for example.
/Thomas
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 13 lines · Thomas Hellstrom
Hi!
Quoted 9 lines · Dan Williams
Per commit
2e586a7e017a"drm/vmwgfx: Map the fifo as cached" the driver expects the fifo registers to be cacheable. In preparation for deprecatingioremap_cache()convert its usage in vmwgfx tomemremap().Cc David Airlie <[email protected]>Cc Thomas Hellstrom <[email protected]>Cc Sinclair Yeh <[email protected]>Signed-off-by Dan Williams <[email protected]>
Quoted 5 lines
While I have nothing against the conversion, what's stopping the compiler from reordering writes on a generic architecture and caching and reordering reads on x86 in particular? At the very least it looks to me like the memory accesses of the memremap'd memory needs to be encapsulated within
READ_ONCEandWRITE_ONCE.
Hmm, currently the code is using ioread32/iowrite32 which only do volatile accesses, whereas READ_ONCE / WRITE_ONCE have a memory clobber on entry and exit. So, I'm assuming all you need is the guarantee of "no compiler re-ordering" and not the stronger READ_ONCE/WRITE_ONCE guarantees, but that still seems broken compared to explicit fencing where it matters.
If the ordering needs to be guaranteed with respect to the agent on the other side of the fifo that can only be asserted via real barriers (mb(), wmb()) which the driver already seems to have in places. ioread32 and iowrite32 as is don't help with that case.
Quoted 1 line
How is this handled in the other conversions?
As far as I can see, the vmwgfx conversion is unique in implementing a device fifo in cached memory.
Quoted 19 lines · Dan Williams
Quoted 12 lines · Thomas Hellstrom
Hi!
Quoted 9 lines · Dan Williams
Per commit
2e586a7e017a"drm/vmwgfx: Map the fifo as cached" the driver expects the fifo registers to be cacheable. In preparation for deprecatingioremap_cache()convert its usage in vmwgfx tomemremap().Cc David Airlie <[email protected]>Cc Thomas Hellstrom <[email protected]>Cc Sinclair Yeh <[email protected]>Signed-off-by Dan Williams <[email protected]>Quoted 5 lines
While I have nothing against the conversion, what's stopping the compiler from reordering writes on a generic architecture and caching and reordering reads on x86 in particular? At the very least it looks to me like the memory accesses of the memremap'd memory needs to be encapsulated within
READ_ONCEandWRITE_ONCE.
Quoted 6 lines
Hmm, currently the code is using ioread32/iowrite32 which only do volatile accesses, whereas
READ_ONCE/WRITE_ONCEhave a memory clobber on entry and exit. So, I'm assuming all you need is the guarantee of "no compiler re-ordering" and not the stronger READ_ONCE/WRITE_ONCE guarantees, but that still seems broken compared to explicit fencing where it matters.
I'm not quite sure I follow you here, it looks to me like READ_ONCE() and WRITE_ONCE() are implemented as
volatile accesses,
http://lxr.free-electrons.com/source/include/linux/compiler.h#L215
just like ioread32 and iowrite32
http://lxr.free-electrons.com/source/include/asm-generic/io.h#L54
which would minimize any potential impact of this change. IMO optimizing the memory accesses can be done as a later step.
/Thomas
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 27 lines · Thomas Hellstrom
Quoted 19 lines · Dan Williams
Quoted 12 lines · Thomas Hellstrom
Hi!
Quoted 9 lines · Dan Williams
Per commit
2e586a7e017a"drm/vmwgfx: Map the fifo as cached" the driver expects the fifo registers to be cacheable. In preparation for deprecatingioremap_cache()convert its usage in vmwgfx tomemremap().Cc David Airlie <[email protected]>Cc Thomas Hellstrom <[email protected]>Cc Sinclair Yeh <[email protected]>Signed-off-by Dan Williams <[email protected]>Quoted 5 lines
While I have nothing against the conversion, what's stopping the compiler from reordering writes on a generic architecture and caching and reordering reads on x86 in particular? At the very least it looks to me like the memory accesses of the memremap'd memory needs to be encapsulated within
READ_ONCEandWRITE_ONCE.Quoted 6 lines
Hmm, currently the code is using ioread32/iowrite32 which only do volatile accesses, whereas
READ_ONCE/WRITE_ONCEhave a memory clobber on entry and exit. So, I'm assuming all you need is the guarantee of "no compiler re-ordering" and not the stronger READ_ONCE/WRITE_ONCE guarantees, but that still seems broken compared to explicit fencing where it matters.
Quoted 3 lines
I'm not quite sure I follow you here, it looks to me like
READ_ONCE()andWRITE_ONCE()are implemented as
volatile accesses,
Ah, sorry, I was looking at the default case...
Quoted 10 lines
http://lxr.free-electrons.com/source/include/linux/compiler.h#L215
just like ioread32 and iowrite32
http://lxr.free-electrons.com/source/include/asm-generic/io.h#L54
which would minimize any potential impact of this change. IMO optimizing the memory accesses can be done as a later step.
Ok, I'll make local read_fifo() and write_fifo() macros to make this explicit. Are these names ok with you?
Quoted 37 lines · Dan Williams
Quoted 26 lines · Thomas Hellstrom
Quoted 19 lines · Dan Williams
Quoted 12 lines · Thomas Hellstrom
Hi!
Quoted 9 lines · Dan Williams
Per commit
2e586a7e017a"drm/vmwgfx: Map the fifo as cached" the driver expects the fifo registers to be cacheable. In preparation for deprecatingioremap_cache()convert its usage in vmwgfx tomemremap().Cc David Airlie <[email protected]>Cc Thomas Hellstrom <[email protected]>Cc Sinclair Yeh <[email protected]>Signed-off-by Dan Williams <[email protected]>Quoted 5 lines
While I have nothing against the conversion, what's stopping the compiler from reordering writes on a generic architecture and caching and reordering reads on x86 in particular? At the very least it looks to me like the memory accesses of the memremap'd memory needs to be encapsulated within
READ_ONCEandWRITE_ONCE.Quoted 6 lines
Hmm, currently the code is using ioread32/iowrite32 which only do volatile accesses, whereas
READ_ONCE/WRITE_ONCEhave a memory clobber on entry and exit. So, I'm assuming all you need is the guarantee of "no compiler re-ordering" and not the stronger READ_ONCE/WRITE_ONCE guarantees, but that still seems broken compared to explicit fencing where it matters.Quoted 3 lines
I'm not quite sure I follow you here, it looks to me like
READ_ONCE()andWRITE_ONCE()are implemented as
volatile accesses,Ah, sorry, I was looking at the default case...
Quoted 4 lines
just like ioread32 and iowrite32
Quoted 7 lines
Quoted 5 lines
which would minimize any potential impact of this change. IMO optimizing the memory accesses can be done as a later step.
Ok, I'll make local
read_fifo()andwrite_fifo()macros to make this explicit. Are these names ok with you?
Sure.
Thanks,
Thomas
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 5 lines · Thomas Hellstrom
Quoted 2 lines
Ok, I'll make local
read_fifo()andwrite_fifo()macros to make this explicit. Are these names ok with you?Sure.
So I ended up just leaving the __iomem annotation on mmio_virt for now until the implementation can be converted to use explicit barriers where necessary.
8<-----
Subject: drm/vmwgfx: switch from ioremap_cache to memremap
From: Dan Williams <[email protected]>
Per commit 2e586a7e017a "drm/vmwgfx: Map the fifo as cached" the driver expects the fifo registers to be cacheable. In preparation for deprecating ioremap_cache() convert its usage in vmwgfx to memremap().
--- drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +10 -4
@@ -752,8 +752,14 @@ static int vmw_driver_load(struct drm_device *dev, unsigned long chipset)ttm_lock_set_kill (&dev_priv->fbdev_master.lock, false,SIGTERM ); dev_priv->active_master = &dev_priv->fbdev_master; - dev_priv->mmio_virt =ioremap_cache (dev_priv->mmio_start, - dev_priv->mmio_size); +/* +* Force __iomem for this mapping until the implied compiler +* barriers and {READ|WRITE}_ONCE semantics from the +* io{read|write}32() accessors can be replaced with explicit +* barriers. +*/ + dev_priv->mmio_virt = (void __iomem *)memremap (dev_priv->mmio_start, + dev_priv->mmio_size,MEMREMAP_WB );if (unlikely (dev_priv->mmio_virt ==NULL )) { ret = -ENOMEM ;
@@ -907,7 +913,7 @@ out_no_irq: out_no_device:ttm_object_device_release (&dev_priv->tdev); out_err4: -iounmap (dev_priv->mmio_virt); +memunmap ((void __force *) dev_priv->mmio_virt); out_err3:vmw_ttm_global_release (dev_priv); out_err0:
@@ -958,7 +964,7 @@ static int vmw_driver_unload(struct drm_device *dev)pci_release_regions (dev->pdev);ttm_object_device_release (&dev_priv->tdev); -iounmap (dev_priv->mmio_virt); +memunmap ((void __force *) dev_priv->mmio_virt);if (dev_priv->ctx.staged_bindings)vmw_binding_state_free (dev_priv->ctx.staged_bindings);vmw_ttm_global_release (dev_priv);
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Thomas Hellstrom
Reviewed-byDan,
Quoted 8 lines · Dan J
Quoted 4 lines · Thomas Hellstrom
Quoted 2 lines
Ok, I'll make local
read_fifo()andwrite_fifo()macros to make this explicit. Are these names ok with you?Sure.
So I ended up just leaving the
__iomemannotation onmmio_virtfor now until the implementation can be converted to use explicit barriers where necessary.
Thanks, I'll queue this on vmwgfx-next for 4.4 and carry on from there.
Quoted 59 lines
8<-----
Subject: drm/vmwgfx: switch fromioremap_cacheto memremapFrom: Dan Williams <[email protected]>
Per commit
2e586a7e017a"drm/vmwgfx: Map the fifo as cached" the driver expects the fifo registers to be cacheable. In preparation for deprecatingioremap_cache()convert its usage in vmwgfx tomemremap().Cc David Airlie <[email protected]>Cc Thomas Hellstrom <[email protected]>Cc Sinclair Yeh <[email protected]>Signed-off-by Dan Williams <[email protected]>--- drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +10
-4@@ -752,8 +752,14 @@ static int vmw_driver_load(struct drm_device *dev, unsigned long chipset)ttm_lock_set_kill (&dev_priv->fbdev_master.lock, false,SIGTERM ); dev_priv->active_master = &dev_priv->fbdev_master; - dev_priv->mmio_virt =ioremap_cache (dev_priv->mmio_start, - dev_priv->mmio_size); +/* +* Force __iomem for this mapping until the implied compiler +* barriers and {READ|WRITE}_ONCE semantics from the +* io{read|write}32() accessors can be replaced with explicit +* barriers. +*/ + dev_priv->mmio_virt = (void __iomem *)memremap (dev_priv->mmio_start, + dev_priv->mmio_size,MEMREMAP_WB );if (unlikely (dev_priv->mmio_virt ==NULL )) { ret = -ENOMEM ;@@ -907,7 +913,7 @@ out_no_irq: out_no_device:ttm_object_device_release (&dev_priv->tdev); out_err4: -iounmap (dev_priv->mmio_virt); +memunmap ((void __force *) dev_priv->mmio_virt); out_err3:vmw_ttm_global_release (dev_priv); out_err0:@@ -958,7 +964,7 @@ static int vmw_driver_unload(struct drm_device *dev)pci_release_regions (dev->pdev);ttm_object_device_release (&dev_priv->tdev); -iounmap (dev_priv->mmio_virt); +memunmap ((void __force *) dev_priv->mmio_virt);if (dev_priv->ctx.staged_bindings)vmw_binding_state_free (dev_priv->ctx.staged_bindings);vmw_ttm_global_release (dev_priv);