Merge tag 'drm-intel-gt-next-2022-08-24' of git://anongit.freedesktop.org/drm/drm...
authorDave Airlie <airlied@redhat.com>
Fri, 26 Aug 2022 00:01:44 +0000 (10:01 +1000)
committerDave Airlie <airlied@redhat.com>
Fri, 26 Aug 2022 00:03:43 +0000 (10:03 +1000)
UAPI Changes:

- Create gt/gtN/.defaults/ for per gt sysfs defaults

  Create a gt/gtN/.defaults/ directory (similar to
  engine/<engine-name>/.defaults/) to expose default parameter values for
  each gt in sysfs. This allows userspace to restore default parameter values
  after they have changed.

Driver Changes:

- Support GuC v69 in parallel to v70 (Daniele)
- Improve TLB invalidation to limit performance regression (Chris, Mauro)
- Expose per-gt RPS defaults in sysfs (Ashutosh)
- Suppress OOM warning for shmemfs object allocation failure (Chris, Nirmoy)
- Disable PCI resize on 32-bit machines (Nirmoy)
- Update DG2 to GuC v70.4.1 (John)
- Fix CCS data copying on DG2 during swapping (Matt A)
- Add DG2 performance tuning setting recommended by spec (Matt R)
- Add GuC <-> kernel time stamp translation information to error logs (John)
- Record GuC CTB info in error logs (John)

- Route semaphores to GuC for Gen12+ when enabled (Michal Wi, John)
- Improve resilency to bug #3575: Handle reset timeouts under unrelated kernel hangs (Chris, Ashutosh)
- Avoid system freeze by removing shared locking on freeing objects (Chris, Nirmoy)
- Demote GuC error "No response for request" into debug when expected (Zhanjun)
- Fix GuC capture size warning and bump the size (John)
- Use streaming loads to speed up dumping the GuC log (Chris, John)
- Don't abort on CTB_UNUSED status from GuC (John)
- Don't send spurious policy update for GuC child contexts (Daniele)
- Don't leak the CCS state (Matt A)

- Prefer drm_err over pr_err (John)
- Eliminate unused calc_ctrl_surf_instr_size (Matt A)
- Add dedicated function for non-ctx register tuning settings (Matt R)
- Style and typo fixes, documentation improvements (Jason Wang, Mauro)
- Selftest improvements (Matt B, Rahul, John)

Signed-off-by: Dave Airlie <airlied@redhat.com>
From: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/YwYTCjA/Rhpd1n4A@jlahtine-mobl.ger.corp.intel.com
1  2 
drivers/gpu/drm/i915/gem/i915_gem_shmem.c
drivers/gpu/drm/i915/gt/uc/intel_guc_log.c

index 4eed3dd90ba8bc75aaa030ae752d2b7403593090,6a80ad8097bb40e08f0a580b30b76a2081f8e7e9..f42ca1179f3732e9aeb9158c2e295fda30ae1eea
@@@ -75,7 -75,7 +75,7 @@@ int shmem_sg_alloc_table(struct drm_i91
        if (size > resource_size(&mr->region))
                return -ENOMEM;
  
-       if (sg_alloc_table(st, page_count, GFP_KERNEL))
+       if (sg_alloc_table(st, page_count, GFP_KERNEL | __GFP_NOWARN))
                return -ENOMEM;
  
        /*
                                 * trigger the out-of-memory killer and for
                                 * this we want __GFP_RETRY_MAYFAIL.
                                 */
-                               gfp |= __GFP_RETRY_MAYFAIL;
+                               gfp |= __GFP_RETRY_MAYFAIL | __GFP_NOWARN;
                        }
                } while (1);
  
@@@ -209,7 -209,7 +209,7 @@@ static int shmem_get_pages(struct drm_i
        GEM_BUG_ON(obj->write_domain & I915_GEM_GPU_DOMAINS);
  
  rebuild_st:
-       st = kmalloc(sizeof(*st), GFP_KERNEL);
+       st = kmalloc(sizeof(*st), GFP_KERNEL | __GFP_NOWARN);
        if (!st)
                return -ENOMEM;
  
@@@ -409,7 -409,6 +409,7 @@@ shmem_pwrite(struct drm_i915_gem_objec
             const struct drm_i915_gem_pwrite *arg)
  {
        struct address_space *mapping = obj->base.filp->f_mapping;
 +      const struct address_space_operations *aops = mapping->a_ops;
        char __user *user_data = u64_to_user_ptr(arg->data_ptr);
        u64 remain, offset;
        unsigned int pg;
                if (err)
                        return err;
  
 -              err = pagecache_write_begin(obj->base.filp, mapping,
 -                                          offset, len, 0,
 -                                          &page, &data);
 +              err = aops->write_begin(obj->base.filp, mapping, offset, len,
 +                                      &page, &data);
                if (err < 0)
                        return err;
  
                                                      len);
                kunmap_atomic(vaddr);
  
 -              err = pagecache_write_end(obj->base.filp, mapping,
 -                                        offset, len, len - unwritten,
 -                                        page, data);
 +              err = aops->write_end(obj->base.filp, mapping, offset, len,
 +                                    len - unwritten, page, data);
                if (err < 0)
                        return err;
  
@@@ -623,7 -624,6 +623,7 @@@ i915_gem_object_create_shmem_from_data(
  {
        struct drm_i915_gem_object *obj;
        struct file *file;
 +      const struct address_space_operations *aops;
        resource_size_t offset;
        int err;
  
        GEM_BUG_ON(obj->write_domain != I915_GEM_DOMAIN_CPU);
  
        file = obj->base.filp;
 +      aops = file->f_mapping->a_ops;
        offset = 0;
        do {
                unsigned int len = min_t(typeof(size), size, PAGE_SIZE);
                struct page *page;
                void *pgdata, *vaddr;
  
 -              err = pagecache_write_begin(file, file->f_mapping,
 -                                          offset, len, 0,
 -                                          &page, &pgdata);
 +              err = aops->write_begin(file, file->f_mapping, offset, len,
 +                                      &page, &pgdata);
                if (err < 0)
                        goto fail;
  
                memcpy(vaddr, data, len);
                kunmap(page);
  
 -              err = pagecache_write_end(file, file->f_mapping,
 -                                        offset, len, len,
 -                                        page, pgdata);
 +              err = aops->write_end(file, file->f_mapping, offset, len, len,
 +                                    page, pgdata);
                if (err < 0)
                        goto fail;
  
index 25b2d7ce6640d8c3fa0e5dceee924c4091d32f19,44e6e6853b38453dc2ccd623c30c80d4abbbdc73..4722d4b18ed196c86c46da79b428d0eb5162aeab
  
  static void guc_log_copy_debuglogs_for_relay(struct intel_guc_log *log);
  
+ static u32 intel_guc_log_size(struct intel_guc_log *log)
+ {
+       /*
+        *  GuC Log buffer Layout:
+        *
+        *  NB: Ordering must follow "enum guc_log_buffer_type".
+        *
+        *  +===============================+ 00B
+        *  |      Debug state header       |
+        *  +-------------------------------+ 32B
+        *  |    Crash dump state header    |
+        *  +-------------------------------+ 64B
+        *  |     Capture state header      |
+        *  +-------------------------------+ 96B
+        *  |                               |
+        *  +===============================+ PAGE_SIZE (4KB)
+        *  |          Debug logs           |
+        *  +===============================+ + DEBUG_SIZE
+        *  |        Crash Dump logs        |
+        *  +===============================+ + CRASH_SIZE
+        *  |         Capture logs          |
+        *  +===============================+ + CAPTURE_SIZE
+        */
+       return PAGE_SIZE + CRASH_BUFFER_SIZE + DEBUG_BUFFER_SIZE + CAPTURE_BUFFER_SIZE;
+ }
  /**
   * DOC: GuC firmware log
   *
@@@ -461,32 -487,7 +487,7 @@@ int intel_guc_log_create(struct intel_g
  
        GEM_BUG_ON(log->vma);
  
-       /*
-        *  GuC Log buffer Layout
-        * (this ordering must follow "enum guc_log_buffer_type" definition)
-        *
-        *  +===============================+ 00B
-        *  |      Debug state header       |
-        *  +-------------------------------+ 32B
-        *  |    Crash dump state header    |
-        *  +-------------------------------+ 64B
-        *  |     Capture state header      |
-        *  +-------------------------------+ 96B
-        *  |                               |
-        *  +===============================+ PAGE_SIZE (4KB)
-        *  |          Debug logs           |
-        *  +===============================+ + DEBUG_SIZE
-        *  |        Crash Dump logs        |
-        *  +===============================+ + CRASH_SIZE
-        *  |         Capture logs          |
-        *  +===============================+ + CAPTURE_SIZE
-        */
-       if (intel_guc_capture_output_min_size_est(guc) > CAPTURE_BUFFER_SIZE)
-               DRM_WARN("GuC log buffer for state_capture maybe too small. %d < %d\n",
-                        CAPTURE_BUFFER_SIZE, intel_guc_capture_output_min_size_est(guc));
-       guc_log_size = PAGE_SIZE + CRASH_BUFFER_SIZE + DEBUG_BUFFER_SIZE +
-                      CAPTURE_BUFFER_SIZE;
+       guc_log_size = intel_guc_log_size(log);
  
        vma = intel_guc_allocate_vma(guc, guc_log_size);
        if (IS_ERR(vma)) {
@@@ -588,7 -589,7 +589,7 @@@ int intel_guc_log_relay_open(struct int
        /*
         * We require SSE 4.1 for fast reads from the GuC log buffer and
         * it should be present on the chipsets supporting GuC based
 -       * submisssions.
 +       * submissions.
         */
        if (!i915_has_memcpy_from_wc()) {
                ret = -ENXIO;
@@@ -749,8 -750,9 +750,9 @@@ int intel_guc_log_dump(struct intel_guc
        struct intel_guc *guc = log_to_guc(log);
        struct intel_uc *uc = container_of(guc, struct intel_uc, guc);
        struct drm_i915_gem_object *obj = NULL;
-       u32 *map;
-       int i = 0;
+       void *map;
+       u32 *page;
+       int i, j;
  
        if (!intel_guc_is_supported(guc))
                return -ENODEV;
        if (!obj)
                return 0;
  
+       page = (u32 *)__get_free_page(GFP_KERNEL);
+       if (!page)
+               return -ENOMEM;
+       intel_guc_dump_time_info(guc, p);
        map = i915_gem_object_pin_map_unlocked(obj, I915_MAP_WC);
        if (IS_ERR(map)) {
                DRM_DEBUG("Failed to pin object\n");
                drm_puts(p, "(log data unaccessible)\n");
+               free_page((unsigned long)page);
                return PTR_ERR(map);
        }
  
-       for (i = 0; i < obj->base.size / sizeof(u32); i += 4)
-               drm_printf(p, "0x%08x 0x%08x 0x%08x 0x%08x\n",
-                          *(map + i), *(map + i + 1),
-                          *(map + i + 2), *(map + i + 3));
+       for (i = 0; i < obj->base.size; i += PAGE_SIZE) {
+               if (!i915_memcpy_from_wc(page, map + i, PAGE_SIZE))
+                       memcpy(page, map + i, PAGE_SIZE);
+               for (j = 0; j < PAGE_SIZE / sizeof(u32); j += 4)
+                       drm_printf(p, "0x%08x 0x%08x 0x%08x 0x%08x\n",
+                                  *(page + j + 0), *(page + j + 1),
+                                  *(page + j + 2), *(page + j + 3));
+       }
  
        drm_puts(p, "\n");
  
        i915_gem_object_unpin_map(obj);
+       free_page((unsigned long)page);
  
        return 0;
  }