Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'etnaviv/next' of https://git.pengutronix.de/git/lst/linux into drm-next

- 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

+82 -43
+4 -4
drivers/gpu/drm/etnaviv/etnaviv_dump.c
··· 75 75 hdr->file_size = cpu_to_le32(data_end - iter->data); 76 76 77 77 iter->hdr++; 78 - iter->data += hdr->file_size; 78 + iter->data += le32_to_cpu(hdr->file_size); 79 79 } 80 80 81 81 static void etnaviv_core_dump_registers(struct core_dump_iterator *iter, ··· 85 85 unsigned int i; 86 86 87 87 for (i = 0; i < ARRAY_SIZE(etnaviv_dump_registers); i++, reg++) { 88 - reg->reg = etnaviv_dump_registers[i]; 89 - reg->value = gpu_read(gpu, etnaviv_dump_registers[i]); 88 + reg->reg = cpu_to_le32(etnaviv_dump_registers[i]); 89 + reg->value = cpu_to_le32(gpu_read(gpu, etnaviv_dump_registers[i])); 90 90 } 91 91 92 92 etnaviv_core_dump_header(iter, ETDUMP_BUF_REG, reg); ··· 207 207 if (!IS_ERR(pages)) { 208 208 int j; 209 209 210 - iter.hdr->data[0] = bomap - bomap_start; 210 + iter.hdr->data[0] = cpu_to_le32((bomap - bomap_start)); 211 211 212 212 for (j = 0; j < obj->base.size >> PAGE_SHIFT; j++) 213 213 *bomap++ = cpu_to_le64(page_to_phys(*pages++));
+1 -2
drivers/gpu/drm/etnaviv/etnaviv_gem_prime.c
··· 80 80 /* Don't drop the pages for imported dmabuf, as they are not 81 81 * ours, just free the array we allocated: 82 82 */ 83 - if (etnaviv_obj->pages) 84 - kvfree(etnaviv_obj->pages); 83 + kvfree(etnaviv_obj->pages); 85 84 86 85 drm_prime_gem_destroy(&etnaviv_obj->base, etnaviv_obj->sgt); 87 86 }
+4 -8
drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c
··· 612 612 err_submit_cmds: 613 613 if (ret && (out_fence_fd >= 0)) 614 614 put_unused_fd(out_fence_fd); 615 - if (stream) 616 - kvfree(stream); 617 - if (bos) 618 - kvfree(bos); 619 - if (relocs) 620 - kvfree(relocs); 621 - if (pmrs) 622 - kvfree(pmrs); 615 + kvfree(stream); 616 + kvfree(bos); 617 + kvfree(relocs); 618 + kvfree(pmrs); 623 619 624 620 return ret; 625 621 }
+39 -29
drivers/gpu/drm/etnaviv/etnaviv_gpu.c
··· 27 27 #include "state_hi.xml.h" 28 28 #include "cmdstream.xml.h" 29 29 30 - #ifndef PHYS_OFFSET 31 - #define PHYS_OFFSET 0 32 - #endif 33 - 34 30 static const struct platform_device_id gpu_ids[] = { 35 31 { .name = "etnaviv-gpu,2d" }, 36 32 { }, ··· 150 154 *value = ETNAVIV_SOFTPIN_START_ADDRESS; 151 155 else 152 156 *value = ~0ULL; 157 + break; 158 + 159 + case ETNAVIV_PARAM_GPU_PRODUCT_ID: 160 + *value = gpu->identity.product_id; 161 + break; 162 + 163 + case ETNAVIV_PARAM_GPU_CUSTOMER_ID: 164 + *value = gpu->identity.customer_id; 165 + break; 166 + 167 + case ETNAVIV_PARAM_GPU_ECO_ID: 168 + *value = gpu->identity.eco_id; 153 169 break; 154 170 155 171 default: ··· 732 724 int etnaviv_gpu_init(struct etnaviv_gpu *gpu) 733 725 { 734 726 struct etnaviv_drm_private *priv = gpu->drm->dev_private; 727 + dma_addr_t cmdbuf_paddr; 735 728 int ret, i; 736 729 737 730 ret = pm_runtime_get_sync(gpu->dev); ··· 776 767 goto fail; 777 768 778 769 /* 779 - * Set the GPU linear window to be at the end of the DMA window, where 780 - * the CMA area is likely to reside. This ensures that we are able to 781 - * map the command buffers while having the linear window overlap as 782 - * much RAM as possible, so we can optimize mappings for other buffers. 783 - * 784 - * For 3D cores only do this if MC2.0 is present, as with MC1.0 it leads 785 - * to different views of the memory on the individual engines. 786 - */ 787 - if (!(gpu->identity.features & chipFeatures_PIPE_3D) || 788 - (gpu->identity.minor_features0 & chipMinorFeatures0_MC20)) { 789 - u32 dma_mask = (u32)dma_get_required_mask(gpu->dev); 790 - if (dma_mask < PHYS_OFFSET + SZ_2G) 791 - priv->mmu_global->memory_base = PHYS_OFFSET; 792 - else 793 - priv->mmu_global->memory_base = dma_mask - SZ_2G + 1; 794 - } else if (PHYS_OFFSET >= SZ_2G) { 795 - dev_info(gpu->dev, "Need to move linear window on MC1.0, disabling TS\n"); 796 - priv->mmu_global->memory_base = PHYS_OFFSET; 797 - gpu->identity.features &= ~chipFeatures_FAST_CLEAR; 798 - } 799 - 800 - /* 801 770 * If the GPU is part of a system with DMA addressing limitations, 802 771 * request pages for our SHM backend buffers from the DMA32 zone to 803 772 * hopefully avoid performance killing SWIOTLB bounce buffering. ··· 789 802 if (ret) { 790 803 dev_err(gpu->dev, "could not create command buffer\n"); 791 804 goto fail; 805 + } 806 + 807 + /* 808 + * Set the GPU linear window to cover the cmdbuf region, as the GPU 809 + * won't be able to start execution otherwise. The alignment to 128M is 810 + * chosen arbitrarily but helps in debugging, as the MMU offset 811 + * calculations are much more straight forward this way. 812 + * 813 + * On MC1.0 cores the linear window offset is ignored by the TS engine, 814 + * leading to inconsistent memory views. Avoid using the offset on those 815 + * cores if possible, otherwise disable the TS feature. 816 + */ 817 + cmdbuf_paddr = ALIGN_DOWN(etnaviv_cmdbuf_get_pa(&gpu->buffer), SZ_128M); 818 + 819 + if (!(gpu->identity.features & chipFeatures_PIPE_3D) || 820 + (gpu->identity.minor_features0 & chipMinorFeatures0_MC20)) { 821 + if (cmdbuf_paddr >= SZ_2G) 822 + priv->mmu_global->memory_base = SZ_2G; 823 + else 824 + priv->mmu_global->memory_base = cmdbuf_paddr; 825 + } else if (cmdbuf_paddr + SZ_128M >= SZ_2G) { 826 + dev_info(gpu->dev, 827 + "Need to move linear window on MC1.0, disabling TS\n"); 828 + gpu->identity.features &= ~chipFeatures_FAST_CLEAR; 829 + priv->mmu_global->memory_base = SZ_2G; 792 830 } 793 831 794 832 /* Setup event management */ ··· 1783 1771 1784 1772 /* Get Interrupt: */ 1785 1773 gpu->irq = platform_get_irq(pdev, 0); 1786 - if (gpu->irq < 0) { 1787 - dev_err(dev, "failed to get irq: %d\n", gpu->irq); 1774 + if (gpu->irq < 0) 1788 1775 return gpu->irq; 1789 - } 1790 1776 1791 1777 err = devm_request_irq(&pdev->dev, gpu->irq, irq_handler, 0, 1792 1778 dev_name(gpu->dev), gpu);
+31
drivers/gpu/drm/etnaviv/etnaviv_hwdb.c
··· 39 39 }, 40 40 { 41 41 .model = 0x7000, 42 + .revision = 0x6204, 43 + .product_id = ~0U, 44 + .customer_id = ~0U, 45 + .eco_id = 0, 46 + .stream_count = 16, 47 + .register_max = 64, 48 + .thread_count = 512, 49 + .shader_core_count = 2, 50 + .vertex_cache_size = 16, 51 + .vertex_output_buffer_size = 1024, 52 + .pixel_pipes = 1, 53 + .instruction_count = 512, 54 + .num_constants = 320, 55 + .buffer_size = 0, 56 + .varyings_count = 16, 57 + .features = 0xe0287c8d, 58 + .minor_features0 = 0xc1589eff, 59 + .minor_features1 = 0xfefbfad9, 60 + .minor_features2 = 0xeb9d4fbf, 61 + .minor_features3 = 0xedfffced, 62 + .minor_features4 = 0xdb0dafc7, 63 + .minor_features5 = 0x3b5ac333, 64 + .minor_features6 = 0xfcce6000, 65 + .minor_features7 = 0xfffbfa6f, 66 + .minor_features8 = 0x00e10ef3, 67 + .minor_features9 = 0x04c8003c, 68 + .minor_features10 = 0x00004060, 69 + .minor_features11 = 0x00000024, 70 + }, 71 + { 72 + .model = 0x7000, 42 73 .revision = 0x6214, 43 74 .product_id = ~0U, 44 75 .customer_id = ~0U,
+3
include/uapi/drm/etnaviv_drm.h
··· 74 74 #define ETNAVIV_PARAM_GPU_NUM_CONSTANTS 0x19 75 75 #define ETNAVIV_PARAM_GPU_NUM_VARYINGS 0x1a 76 76 #define ETNAVIV_PARAM_SOFTPIN_START_ADDR 0x1b 77 + #define ETNAVIV_PARAM_GPU_PRODUCT_ID 0x1c 78 + #define ETNAVIV_PARAM_GPU_CUSTOMER_ID 0x1d 79 + #define ETNAVIV_PARAM_GPU_ECO_ID 0x1e 77 80 78 81 #define ETNA_MAX_PIPES 4 79 82