Re: [Intel-gfx] [PATCH libdrm v3 1/2] intel: Add EXEC_OBJECT_SUPPORTS_48B_ADDRESS flag

2015-08-10 Thread Winiarski, Michal
On Fri, 2015-08-07 at 12:36 +0100, Michel Thierry wrote:
 Hi Michał,
 
 Ben suggested having the set/clear in emit reloc as this is the only 
 place mesa cares about these wa.
 
 But I see your point, this will be used not only by mesa, so we 
 should 
 have something that is good for all the other projects.
 
 -Michel

If there are no comments from anyone else then I'm fine with public API
from last version.
But comments about the error handling and implementation details could
still be addressed.

-Michał
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH libdrm v3 1/2] intel: Add EXEC_OBJECT_SUPPORTS_48B_ADDRESS flag

2015-08-07 Thread Michel Thierry

On 8/7/2015 11:56 AM, Michał Winiarski wrote:

On Fri, Aug 07, 2015 at 10:45:21AM +0100, Michel Thierry wrote:

Gen8+ supports 48-bit virtual addresses, but some objects must always be
allocated inside the 32-bit address range.

In specific, any resource used with flat/heapless (0x-0xf000)
General State Heap (GSH) or Instruction State Heap (ISH) must be in a
32-bit range, because the General State Offset and Instruction State Offset
are limited to 32-bits.

The i915 driver has been modified to provide a flag to set when the 4GB
limit is not necessary in a given bo (EXEC_OBJECT_SUPPORTS_48B_ADDRESS).
48-bit range will only be used when explicitly requested.

Calls to the new drm_intel_bo_emit_reloc_48bit function will have this flag
set automatically, while calls to drm_intel_bo_emit_reloc will clear it.

v2: Make set/clear functions nops on pre-gen8 platforms, and use them
 internally in emit_reloc functions (Ben)
 s/48BADDRESS/48B_ADDRESS/ (Dave)
v3: Keep set/clear functions internal, no-one needs to use them directly.

References: 
http://lists.freedesktop.org/archives/intel-gfx/2015-July/072612.html
Cc: Ben Widawsky b...@bwidawsk.net
Cc: Dave Gordon david.s.gor...@intel.com
Signed-off-by: Michel Thierry michel.thie...@intel.com
---
  include/drm/i915_drm.h|  3 ++-
  intel/intel_bufmgr.c  | 16 ++
  intel/intel_bufmgr.h  |  6 +-
  intel/intel_bufmgr_gem.c  | 54 +++
  intel/intel_bufmgr_priv.h | 11 ++
  5 files changed, 84 insertions(+), 6 deletions(-)

diff --git a/include/drm/i915_drm.h b/include/drm/i915_drm.h
index ded43b1..426b25c 100644
--- a/include/drm/i915_drm.h
+++ b/include/drm/i915_drm.h
@@ -680,7 +680,8 @@ struct drm_i915_gem_exec_object2 {
  #define EXEC_OBJECT_NEEDS_FENCE (10)
  #define EXEC_OBJECT_NEEDS_GTT (11)
  #define EXEC_OBJECT_WRITE (12)
-#define __EXEC_OBJECT_UNKNOWN_FLAGS -(EXEC_OBJECT_WRITE1)
+#define EXEC_OBJECT_SUPPORTS_48B_ADDRESS (13)
+#define __EXEC_OBJECT_UNKNOWN_FLAGS -(EXEC_OBJECT_SUPPORTS_48B_ADDRESS1)
__u64 flags;

__u64 rsvd1;
diff --git a/intel/intel_bufmgr.c b/intel/intel_bufmgr.c
index 14ea9f9..0bd5191 100644
--- a/intel/intel_bufmgr.c
+++ b/intel/intel_bufmgr.c
@@ -202,6 +202,22 @@ drm_intel_bo_emit_reloc(drm_intel_bo *bo, uint32_t offset,
drm_intel_bo *target_bo, uint32_t target_offset,
uint32_t read_domains, uint32_t write_domain)
  {
+   if (bo-bufmgr-bo_clear_supports_48b_address)
+   bo-bufmgr-bo_clear_supports_48b_address(target_bo);


This is always true - you assign func to this func pointer unconditionally.
Also - why not return some meaningful value if the user does not have
enable_ppgtt=3 set? You can get that from I915_PARAM_HAS_ALIASING_PPGTT right
now. Check for gen = 8 seems rather inadequate, and even then you're not
returning anything useful to the caller.


+
+   return bo-bufmgr-bo_emit_reloc(bo, offset,
+target_bo, target_offset,
+read_domains, write_domain);
+}
+


Using emit_reloc to set a BO flag seems confusing and can be error prone,
emit_reloc can be called many times and caller needs to be careful and call the
right function for each reloc.


+int
+drm_intel_bo_emit_reloc_48bit(drm_intel_bo *bo, uint32_t offset,
+   drm_intel_bo *target_bo, uint32_t target_offset,
+   uint32_t read_domains, uint32_t write_domain)
+{
+   if (bo-bufmgr-bo_set_supports_48b_address)
+   bo-bufmgr-bo_set_supports_48b_address(target_bo);


Same situation as with clear_supports_48b_address.


+
return bo-bufmgr-bo_emit_reloc(bo, offset,
 target_bo, target_offset,
 read_domains, write_domain);
diff --git a/intel/intel_bufmgr.h b/intel/intel_bufmgr.h
index 285919e..8f91ffe 100644
--- a/intel/intel_bufmgr.h
+++ b/intel/intel_bufmgr.h
@@ -87,7 +87,8 @@ struct _drm_intel_bo {
/**
 * Last seen card virtual address (offset from the beginning of the
 * aperture) for the object.  This should be used to fill relocation
-* entries when calling drm_intel_bo_emit_reloc()
+* entries when calling drm_intel_bo_emit_reloc() or
+* drm_intel_bo_emit_reloc_48bit()
 */
uint64_t offset64;
  };
@@ -147,6 +148,9 @@ int drm_intel_bufmgr_check_aperture_space(drm_intel_bo ** 
bo_array, int count);
  int drm_intel_bo_emit_reloc(drm_intel_bo *bo, uint32_t offset,
drm_intel_bo *target_bo, uint32_t target_offset,
uint32_t read_domains, uint32_t write_domain);
+int drm_intel_bo_emit_reloc_48bit(drm_intel_bo *bo, uint32_t offset,
+ drm_intel_bo *target_bo, uint32_t 
target_offset,
+ uint32_t read_domains, 

Re: [Intel-gfx] [PATCH libdrm v3 1/2] intel: Add EXEC_OBJECT_SUPPORTS_48B_ADDRESS flag

2015-08-07 Thread Michał Winiarski
On Fri, Aug 07, 2015 at 10:45:21AM +0100, Michel Thierry wrote:
 Gen8+ supports 48-bit virtual addresses, but some objects must always be
 allocated inside the 32-bit address range.
 
 In specific, any resource used with flat/heapless (0x-0xf000)
 General State Heap (GSH) or Instruction State Heap (ISH) must be in a
 32-bit range, because the General State Offset and Instruction State Offset
 are limited to 32-bits.
 
 The i915 driver has been modified to provide a flag to set when the 4GB
 limit is not necessary in a given bo (EXEC_OBJECT_SUPPORTS_48B_ADDRESS).
 48-bit range will only be used when explicitly requested.
 
 Calls to the new drm_intel_bo_emit_reloc_48bit function will have this flag
 set automatically, while calls to drm_intel_bo_emit_reloc will clear it.
 
 v2: Make set/clear functions nops on pre-gen8 platforms, and use them
 internally in emit_reloc functions (Ben)
 s/48BADDRESS/48B_ADDRESS/ (Dave)
 v3: Keep set/clear functions internal, no-one needs to use them directly.
 
 References: 
 http://lists.freedesktop.org/archives/intel-gfx/2015-July/072612.html
 Cc: Ben Widawsky b...@bwidawsk.net
 Cc: Dave Gordon david.s.gor...@intel.com
 Signed-off-by: Michel Thierry michel.thie...@intel.com
 ---
  include/drm/i915_drm.h|  3 ++-
  intel/intel_bufmgr.c  | 16 ++
  intel/intel_bufmgr.h  |  6 +-
  intel/intel_bufmgr_gem.c  | 54 
 +++
  intel/intel_bufmgr_priv.h | 11 ++
  5 files changed, 84 insertions(+), 6 deletions(-)
 
 diff --git a/include/drm/i915_drm.h b/include/drm/i915_drm.h
 index ded43b1..426b25c 100644
 --- a/include/drm/i915_drm.h
 +++ b/include/drm/i915_drm.h
 @@ -680,7 +680,8 @@ struct drm_i915_gem_exec_object2 {
  #define EXEC_OBJECT_NEEDS_FENCE (10)
  #define EXEC_OBJECT_NEEDS_GTT(11)
  #define EXEC_OBJECT_WRITE(12)
 -#define __EXEC_OBJECT_UNKNOWN_FLAGS -(EXEC_OBJECT_WRITE1)
 +#define EXEC_OBJECT_SUPPORTS_48B_ADDRESS (13)
 +#define __EXEC_OBJECT_UNKNOWN_FLAGS -(EXEC_OBJECT_SUPPORTS_48B_ADDRESS1)
   __u64 flags;
  
   __u64 rsvd1;
 diff --git a/intel/intel_bufmgr.c b/intel/intel_bufmgr.c
 index 14ea9f9..0bd5191 100644
 --- a/intel/intel_bufmgr.c
 +++ b/intel/intel_bufmgr.c
 @@ -202,6 +202,22 @@ drm_intel_bo_emit_reloc(drm_intel_bo *bo, uint32_t 
 offset,
   drm_intel_bo *target_bo, uint32_t target_offset,
   uint32_t read_domains, uint32_t write_domain)
  {
 + if (bo-bufmgr-bo_clear_supports_48b_address)
 + bo-bufmgr-bo_clear_supports_48b_address(target_bo);

This is always true - you assign func to this func pointer unconditionally.
Also - why not return some meaningful value if the user does not have
enable_ppgtt=3 set? You can get that from I915_PARAM_HAS_ALIASING_PPGTT right
now. Check for gen = 8 seems rather inadequate, and even then you're not
returning anything useful to the caller.

 +
 + return bo-bufmgr-bo_emit_reloc(bo, offset,
 +  target_bo, target_offset,
 +  read_domains, write_domain);
 +}
 +

Using emit_reloc to set a BO flag seems confusing and can be error prone,
emit_reloc can be called many times and caller needs to be careful and call the
right function for each reloc.

 +int
 +drm_intel_bo_emit_reloc_48bit(drm_intel_bo *bo, uint32_t offset,
 + drm_intel_bo *target_bo, uint32_t target_offset,
 + uint32_t read_domains, uint32_t write_domain)
 +{
 + if (bo-bufmgr-bo_set_supports_48b_address)
 + bo-bufmgr-bo_set_supports_48b_address(target_bo);

Same situation as with clear_supports_48b_address.

 +
   return bo-bufmgr-bo_emit_reloc(bo, offset,
target_bo, target_offset,
read_domains, write_domain);
 diff --git a/intel/intel_bufmgr.h b/intel/intel_bufmgr.h
 index 285919e..8f91ffe 100644
 --- a/intel/intel_bufmgr.h
 +++ b/intel/intel_bufmgr.h
 @@ -87,7 +87,8 @@ struct _drm_intel_bo {
   /**
* Last seen card virtual address (offset from the beginning of the
* aperture) for the object.  This should be used to fill relocation
 -  * entries when calling drm_intel_bo_emit_reloc()
 +  * entries when calling drm_intel_bo_emit_reloc() or
 +  * drm_intel_bo_emit_reloc_48bit()
*/
   uint64_t offset64;
  };
 @@ -147,6 +148,9 @@ int drm_intel_bufmgr_check_aperture_space(drm_intel_bo ** 
 bo_array, int count);
  int drm_intel_bo_emit_reloc(drm_intel_bo *bo, uint32_t offset,
   drm_intel_bo *target_bo, uint32_t target_offset,
   uint32_t read_domains, uint32_t write_domain);
 +int drm_intel_bo_emit_reloc_48bit(drm_intel_bo *bo, uint32_t offset,
 +   drm_intel_bo *target_bo, uint32_t 
 target_offset,
 +   uint32_t read_domains, uint32_t