[Intel-gfx] [PATCH i-g-t v3 07/11] lib/intel_bufops: update mmap_{read, write} for discrete

Matthew Auld
2021-07-30T08:54:13Z

On discrete we can no longer call get_caching or set_domain, and the
mmap mode must be FIXED.

Signed-off-by: Matthew Auld <matthew.auld@intel.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Ashutosh Dixit <ashutosh.dixit@intel.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Ramalingam C <ramalingam.c@intel.com>
---
lib/intel_bufops.c | 25 +++++++++++++++++++++++--
1 file changed, 23 insertions(+), 2 deletions(-)

diff --git a/lib/intel_bufops.c b/lib/intel_bufops.c
index 3ce68663..faca4406 100644
--- a/lib/intel_bufops.c
+++ b/lib/intel_bufops.c
@@ -424,7 +424,18 @@ static void *mmap_write(int fd, struct intel_buf *buf)
{
void *map = NULL;

- if (is_cache_coherent(fd, buf->handle)) {
+ if (gem_has_lmem(fd)) {
+ /*
+ * set/get_caching and set_domain are no longer supported on
+ * discrete, also the only mmap mode supportd is FIXED.
+ */
+ map = gem_mmap_offset__fixed(fd, buf->handle, 0,
+ buf->surface[0].size,
+ PROT_READ | PROT_WRITE);
+ igt_assert_eq(gem_wait(fd, buf->handle, 0), 0);
+ }
+
+ if (!map && is_cache_coherent(fd, buf->handle)) {
map = __gem_mmap_offset__cpu(fd, buf->handle, 0, buf->surface[0].size,
PROT_READ | PROT_WRITE);
if (!map)
@@ -455,7 +466,17 @@ static void *mmap_read(int fd, struct intel_buf *buf)
{
void *map = NULL;

- if (gem_has_llc(fd) || is_cache_coherent(fd, buf->handle)) {
+ if (gem_has_lmem(fd)) {
+ /*
+ * set/get_caching and set_domain are no longer supported on
+ * discrete, also the only supported mmap mode is FIXED.
+ */
+ map = gem_mmap_offset__fixed(fd, buf->handle, 0,
+ buf->surface[0].size, PROT_READ);
+ igt_assert_eq(gem_wait(fd, buf->handle, 0), 0);
+ }
+
+ if (!map && (gem_has_llc(fd) || is_cache_coherent(fd, buf->handle))) {
map = __gem_mmap_offset__cpu(fd, buf->handle, 0,
buf->surface[0].size, PROT_READ);
if (!map)