Merge branch 'etnaviv/next' of https://git.pengutronix.de/git/lst/linux into drm...
authorDave Airlie <airlied@redhat.com>
Fri, 11 Jun 2021 02:50:47 +0000 (12:50 +1000)
committerDave Airlie <airlied@redhat.com>
Fri, 11 Jun 2021 03:00:58 +0000 (13:00 +1000)
- remove redundant NULL checks by various people
- fix sparse checker warnings from Marc
- expose more GPU ID values to userspace from Christian
- add HWDB entry for GPU found on i.MX8MP from Sascha
- rework of the linear window calculation to better deal with
  systems with large regions of reserved RAM

Signed-off-by: Dave Airlie <airlied@redhat.com>
From: Lucas Stach <l.stach@pengutronix.de>
Link: https://patchwork.freedesktop.org/patch/msgid/f27e1ec2c2fea310bfb6fe6c99174a54e9dfba83.camel@pengutronix.de
drivers/gpu/drm/etnaviv/etnaviv_dump.c
drivers/gpu/drm/etnaviv/etnaviv_gem_prime.c
drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c
drivers/gpu/drm/etnaviv/etnaviv_gpu.c
drivers/gpu/drm/etnaviv/etnaviv_hwdb.c
include/uapi/drm/etnaviv_drm.h

index 706af0304ca4c85655b55c7194e445fc48cb8559..f418e0b75772e25ef4deda04e78be837218303b2 100644 (file)
@@ -75,7 +75,7 @@ static void etnaviv_core_dump_header(struct core_dump_iterator *iter,
        hdr->file_size = cpu_to_le32(data_end - iter->data);
 
        iter->hdr++;
-       iter->data += hdr->file_size;
+       iter->data += le32_to_cpu(hdr->file_size);
 }
 
 static void etnaviv_core_dump_registers(struct core_dump_iterator *iter,
@@ -85,8 +85,8 @@ static void etnaviv_core_dump_registers(struct core_dump_iterator *iter,
        unsigned int i;
 
        for (i = 0; i < ARRAY_SIZE(etnaviv_dump_registers); i++, reg++) {
-               reg->reg = etnaviv_dump_registers[i];
-               reg->value = gpu_read(gpu, etnaviv_dump_registers[i]);
+               reg->reg = cpu_to_le32(etnaviv_dump_registers[i]);
+               reg->value = cpu_to_le32(gpu_read(gpu, etnaviv_dump_registers[i]));
        }
 
        etnaviv_core_dump_header(iter, ETDUMP_BUF_REG, reg);
@@ -207,7 +207,7 @@ void etnaviv_core_dump(struct etnaviv_gem_submit *submit)
                if (!IS_ERR(pages)) {
                        int j;
 
-                       iter.hdr->data[0] = bomap - bomap_start;
+                       iter.hdr->data[0] = cpu_to_le32((bomap - bomap_start));
 
                        for (j = 0; j < obj->base.size >> PAGE_SHIFT; j++)
                                *bomap++ = cpu_to_le64(page_to_phys(*pages++));
index b390dd4d60b76d929fc2847484f1a8067126d2b9..d741b1d735f72e31ccc836880b08ecf984ac0cf8 100644 (file)
@@ -80,8 +80,7 @@ static void etnaviv_gem_prime_release(struct etnaviv_gem_object *etnaviv_obj)
        /* Don't drop the pages for imported dmabuf, as they are not
         * ours, just free the array we allocated:
         */
-       if (etnaviv_obj->pages)
-               kvfree(etnaviv_obj->pages);
+       kvfree(etnaviv_obj->pages);
 
        drm_prime_gem_destroy(&etnaviv_obj->base, etnaviv_obj->sgt);
 }
index d53856d7a747b2191a06fb1983d47ad2850d9721..4dd7d9d541c0903c1e66fbe074af9d846e396c6b 100644 (file)
@@ -612,14 +612,10 @@ err_submit_ww_acquire:
 err_submit_cmds:
        if (ret && (out_fence_fd >= 0))
                put_unused_fd(out_fence_fd);
-       if (stream)
-               kvfree(stream);
-       if (bos)
-               kvfree(bos);
-       if (relocs)
-               kvfree(relocs);
-       if (pmrs)
-               kvfree(pmrs);
+       kvfree(stream);
+       kvfree(bos);
+       kvfree(relocs);
+       kvfree(pmrs);
 
        return ret;
 }
index c6404b8d067f10279221dad7eb925a1650ae7534..4102bcea334133128f31ebaed745ddbd27923853 100644 (file)
 #include "state_hi.xml.h"
 #include "cmdstream.xml.h"
 
-#ifndef PHYS_OFFSET
-#define PHYS_OFFSET 0
-#endif
-
 static const struct platform_device_id gpu_ids[] = {
        { .name = "etnaviv-gpu,2d" },
        { },
@@ -156,6 +152,18 @@ int etnaviv_gpu_get_param(struct etnaviv_gpu *gpu, u32 param, u64 *value)
                        *value = ~0ULL;
                break;
 
+       case ETNAVIV_PARAM_GPU_PRODUCT_ID:
+               *value = gpu->identity.product_id;
+               break;
+
+       case ETNAVIV_PARAM_GPU_CUSTOMER_ID:
+               *value = gpu->identity.customer_id;
+               break;
+
+       case ETNAVIV_PARAM_GPU_ECO_ID:
+               *value = gpu->identity.eco_id;
+               break;
+
        default:
                DBG("%s: invalid param: %u", dev_name(gpu->dev), param);
                return -EINVAL;
@@ -724,6 +732,7 @@ static void etnaviv_gpu_hw_init(struct etnaviv_gpu *gpu)
 int etnaviv_gpu_init(struct etnaviv_gpu *gpu)
 {
        struct etnaviv_drm_private *priv = gpu->drm->dev_private;
+       dma_addr_t cmdbuf_paddr;
        int ret, i;
 
        ret = pm_runtime_get_sync(gpu->dev);
@@ -766,28 +775,6 @@ int etnaviv_gpu_init(struct etnaviv_gpu *gpu)
        if (ret)
                goto fail;
 
-       /*
-        * Set the GPU linear window to be at the end of the DMA window, where
-        * the CMA area is likely to reside. This ensures that we are able to
-        * map the command buffers while having the linear window overlap as
-        * much RAM as possible, so we can optimize mappings for other buffers.
-        *
-        * For 3D cores only do this if MC2.0 is present, as with MC1.0 it leads
-        * to different views of the memory on the individual engines.
-        */
-       if (!(gpu->identity.features & chipFeatures_PIPE_3D) ||
-           (gpu->identity.minor_features0 & chipMinorFeatures0_MC20)) {
-               u32 dma_mask = (u32)dma_get_required_mask(gpu->dev);
-               if (dma_mask < PHYS_OFFSET + SZ_2G)
-                       priv->mmu_global->memory_base = PHYS_OFFSET;
-               else
-                       priv->mmu_global->memory_base = dma_mask - SZ_2G + 1;
-       } else if (PHYS_OFFSET >= SZ_2G) {
-               dev_info(gpu->dev, "Need to move linear window on MC1.0, disabling TS\n");
-               priv->mmu_global->memory_base = PHYS_OFFSET;
-               gpu->identity.features &= ~chipFeatures_FAST_CLEAR;
-       }
-
        /*
         * If the GPU is part of a system with DMA addressing limitations,
         * request pages for our SHM backend buffers from the DMA32 zone to
@@ -804,6 +791,31 @@ int etnaviv_gpu_init(struct etnaviv_gpu *gpu)
                goto fail;
        }
 
+       /*
+        * Set the GPU linear window to cover the cmdbuf region, as the GPU
+        * won't be able to start execution otherwise. The alignment to 128M is
+        * chosen arbitrarily but helps in debugging, as the MMU offset
+        * calculations are much more straight forward this way.
+        *
+        * On MC1.0 cores the linear window offset is ignored by the TS engine,
+        * leading to inconsistent memory views. Avoid using the offset on those
+        * cores if possible, otherwise disable the TS feature.
+        */
+       cmdbuf_paddr = ALIGN_DOWN(etnaviv_cmdbuf_get_pa(&gpu->buffer), SZ_128M);
+
+       if (!(gpu->identity.features & chipFeatures_PIPE_3D) ||
+           (gpu->identity.minor_features0 & chipMinorFeatures0_MC20)) {
+               if (cmdbuf_paddr >= SZ_2G)
+                       priv->mmu_global->memory_base = SZ_2G;
+               else
+                       priv->mmu_global->memory_base = cmdbuf_paddr;
+       } else if (cmdbuf_paddr + SZ_128M >= SZ_2G) {
+               dev_info(gpu->dev,
+                        "Need to move linear window on MC1.0, disabling TS\n");
+               gpu->identity.features &= ~chipFeatures_FAST_CLEAR;
+               priv->mmu_global->memory_base = SZ_2G;
+       }
+
        /* Setup event management */
        spin_lock_init(&gpu->event_spinlock);
        init_completion(&gpu->event_free);
@@ -1771,10 +1783,8 @@ static int etnaviv_gpu_platform_probe(struct platform_device *pdev)
 
        /* Get Interrupt: */
        gpu->irq = platform_get_irq(pdev, 0);
-       if (gpu->irq < 0) {
-               dev_err(dev, "failed to get irq: %d\n", gpu->irq);
+       if (gpu->irq < 0)
                return gpu->irq;
-       }
 
        err = devm_request_irq(&pdev->dev, gpu->irq, irq_handler, 0,
                               dev_name(gpu->dev), gpu);
index 167971a09be79ce0973fb8e50314c5a061a5d39c..dfc0f536b3b9d4ef01252d703900ce41dd2636c4 100644 (file)
@@ -37,6 +37,37 @@ static const struct etnaviv_chip_identity etnaviv_chip_identities[] = {
                .minor_features10 = 0x0,
                .minor_features11 = 0x0,
        },
+       {
+               .model = 0x7000,
+               .revision = 0x6204,
+               .product_id = ~0U,
+               .customer_id = ~0U,
+               .eco_id = 0,
+               .stream_count = 16,
+               .register_max = 64,
+               .thread_count = 512,
+               .shader_core_count = 2,
+               .vertex_cache_size = 16,
+               .vertex_output_buffer_size = 1024,
+               .pixel_pipes = 1,
+               .instruction_count = 512,
+               .num_constants = 320,
+               .buffer_size = 0,
+               .varyings_count = 16,
+               .features = 0xe0287c8d,
+               .minor_features0 = 0xc1589eff,
+               .minor_features1 = 0xfefbfad9,
+               .minor_features2 = 0xeb9d4fbf,
+               .minor_features3 = 0xedfffced,
+               .minor_features4 = 0xdb0dafc7,
+               .minor_features5 = 0x3b5ac333,
+               .minor_features6 = 0xfcce6000,
+               .minor_features7 = 0xfffbfa6f,
+               .minor_features8 = 0x00e10ef3,
+               .minor_features9 = 0x04c8003c,
+               .minor_features10 = 0x00004060,
+               .minor_features11 = 0x00000024,
+       },
        {
                .model = 0x7000,
                .revision = 0x6214,
index 09d0df8b71c5dd5a6347aeafffdafcc554d322fb..af024d90453ddc5376892b13efd8e6c51043e97e 100644 (file)
@@ -74,6 +74,9 @@ struct drm_etnaviv_timespec {
 #define ETNAVIV_PARAM_GPU_NUM_CONSTANTS             0x19
 #define ETNAVIV_PARAM_GPU_NUM_VARYINGS              0x1a
 #define ETNAVIV_PARAM_SOFTPIN_START_ADDR            0x1b
+#define ETNAVIV_PARAM_GPU_PRODUCT_ID                0x1c
+#define ETNAVIV_PARAM_GPU_CUSTOMER_ID               0x1d
+#define ETNAVIV_PARAM_GPU_ECO_ID                    0x1e
 
 #define ETNA_MAX_PIPES 4