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

So what we have for this cycle is a bit of spring cleaning with removal
of unused register logging code and getting rid of the license text in
favor of SPDX, a few smaller MMU handling improvements and a timeout
calculation change, fixing premature fence wait timeouts after 50 days
of uptime.

Signed-off-by: Dave Airlie <airlied@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/1526652437.28565.2.camel@pengutronix.de

+143 -469
-8
drivers/gpu/drm/etnaviv/Kconfig
··· 22 22 help 23 23 Compile in support for thermal throttling. 24 24 Say Y unless you want to risk burning your SoC. 25 - 26 - config DRM_ETNAVIV_REGISTER_LOGGING 27 - bool "enable ETNAVIV register logging" 28 - depends on DRM_ETNAVIV 29 - help 30 - Compile in support for logging register reads/writes in a format 31 - that can be parsed by envytools demsm tool. If enabled, register 32 - logging can be switched on via etnaviv.reglog=y module param.
+2 -14
drivers/gpu/drm/etnaviv/etnaviv_buffer.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 - * Copyright (C) 2014 Etnaviv Project 3 - * Author: Christian Gmeiner <christian.gmeiner@gmail.com> 4 - * 5 - * This program is free software; you can redistribute it and/or modify it 6 - * under the terms of the GNU General Public License version 2 as published by 7 - * the Free Software Foundation. 8 - * 9 - * This program is distributed in the hope that it will be useful, but WITHOUT 10 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12 - * more details. 13 - * 14 - * You should have received a copy of the GNU General Public License along with 15 - * this program. If not, see <http://www.gnu.org/licenses/>. 3 + * Copyright (C) 2014-2018 Etnaviv Project 16 4 */ 17 5 18 6 #include "etnaviv_cmdbuf.h"
+2 -13
drivers/gpu/drm/etnaviv/etnaviv_cmd_parser.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 - * Copyright (C) 2015 Etnaviv Project 3 - * 4 - * This program is free software; you can redistribute it and/or modify it 5 - * under the terms of the GNU General Public License version 2 as published by 6 - * the Free Software Foundation. 7 - * 8 - * This program is distributed in the hope that it will be useful, but WITHOUT 9 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 11 - * more details. 12 - * 13 - * You should have received a copy of the GNU General Public License along with 14 - * this program. If not, see <http://www.gnu.org/licenses/>. 3 + * Copyright (C) 2015-2018 Etnaviv Project 15 4 */ 16 5 17 6 #include <linux/kernel.h>
+2 -13
drivers/gpu/drm/etnaviv/etnaviv_cmdbuf.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 - * Copyright (C) 2017 Etnaviv Project 3 - * 4 - * This program is free software; you can redistribute it and/or modify it 5 - * under the terms of the GNU General Public License version 2 as published by 6 - * the Free Software Foundation. 7 - * 8 - * This program is distributed in the hope that it will be useful, but WITHOUT 9 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 11 - * more details. 12 - * 13 - * You should have received a copy of the GNU General Public License along with 14 - * this program. If not, see <http://www.gnu.org/licenses/>. 3 + * Copyright (C) 2017-2018 Etnaviv Project 15 4 */ 16 5 17 6 #include <drm/drm_mm.h>
+1 -12
drivers/gpu/drm/etnaviv/etnaviv_cmdbuf.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 1 2 /* 2 3 * Copyright (C) 2017 Etnaviv Project 3 - * 4 - * This program is free software; you can redistribute it and/or modify it 5 - * under the terms of the GNU General Public License version 2 as published by 6 - * the Free Software Foundation. 7 - * 8 - * This program is distributed in the hope that it will be useful, but WITHOUT 9 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 11 - * more details. 12 - * 13 - * You should have received a copy of the GNU General Public License along with 14 - * this program. If not, see <http://www.gnu.org/licenses/>. 15 4 */ 16 5 17 6 #ifndef __ETNAVIV_CMDBUF_H__
+2 -64
drivers/gpu/drm/etnaviv/etnaviv_drv.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 - * Copyright (C) 2015 Etnaviv Project 3 - * 4 - * This program is free software; you can redistribute it and/or modify it 5 - * under the terms of the GNU General Public License version 2 as published by 6 - * the Free Software Foundation. 7 - * 8 - * This program is distributed in the hope that it will be useful, but WITHOUT 9 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 11 - * more details. 12 - * 13 - * You should have received a copy of the GNU General Public License along with 14 - * this program. If not, see <http://www.gnu.org/licenses/>. 3 + * Copyright (C) 2015-2018 Etnaviv Project 15 4 */ 16 5 17 6 #include <linux/component.h> ··· 13 24 #include "etnaviv_gem.h" 14 25 #include "etnaviv_mmu.h" 15 26 #include "etnaviv_perfmon.h" 16 - 17 - #ifdef CONFIG_DRM_ETNAVIV_REGISTER_LOGGING 18 - static bool reglog; 19 - MODULE_PARM_DESC(reglog, "Enable register read/write logging"); 20 - module_param(reglog, bool, 0600); 21 - #else 22 - #define reglog 0 23 - #endif 24 - 25 - void __iomem *etnaviv_ioremap(struct platform_device *pdev, const char *name, 26 - const char *dbgname) 27 - { 28 - struct resource *res; 29 - void __iomem *ptr; 30 - 31 - if (name) 32 - res = platform_get_resource_byname(pdev, IORESOURCE_MEM, name); 33 - else 34 - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 35 - 36 - ptr = devm_ioremap_resource(&pdev->dev, res); 37 - if (IS_ERR(ptr)) { 38 - dev_err(&pdev->dev, "failed to ioremap %s: %ld\n", name, 39 - PTR_ERR(ptr)); 40 - return ptr; 41 - } 42 - 43 - if (reglog) 44 - dev_printk(KERN_DEBUG, &pdev->dev, "IO:region %s 0x%p %08zx\n", 45 - dbgname, ptr, (size_t)resource_size(res)); 46 - 47 - return ptr; 48 - } 49 - 50 - void etnaviv_writel(u32 data, void __iomem *addr) 51 - { 52 - if (reglog) 53 - printk(KERN_DEBUG "IO:W %p %08x\n", addr, data); 54 - 55 - writel(data, addr); 56 - } 57 - 58 - u32 etnaviv_readl(const void __iomem *addr) 59 - { 60 - u32 val = readl(addr); 61 - 62 - if (reglog) 63 - printk(KERN_DEBUG "IO:R %p %08x\n", addr, val); 64 - 65 - return val; 66 - } 67 27 68 28 /* 69 29 * DRM operations:
+19 -26
drivers/gpu/drm/etnaviv/etnaviv_drv.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 1 2 /* 2 - * Copyright (C) 2015 Etnaviv Project 3 - * 4 - * This program is free software; you can redistribute it and/or modify it 5 - * under the terms of the GNU General Public License version 2 as published by 6 - * the Free Software Foundation. 7 - * 8 - * This program is distributed in the hope that it will be useful, but WITHOUT 9 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 11 - * more details. 12 - * 13 - * You should have received a copy of the GNU General Public License along with 14 - * this program. If not, see <http://www.gnu.org/licenses/>. 3 + * Copyright (C) 2015-2018 Etnaviv Project 15 4 */ 16 5 17 6 #ifndef __ETNAVIV_DRV_H__ ··· 15 26 #include <linux/pm_runtime.h> 16 27 #include <linux/slab.h> 17 28 #include <linux/list.h> 29 + #include <linux/time64.h> 18 30 #include <linux/types.h> 19 31 #include <linux/sizes.h> 20 32 ··· 91 101 struct seq_file *m); 92 102 #endif 93 103 94 - void __iomem *etnaviv_ioremap(struct platform_device *pdev, const char *name, 95 - const char *dbgname); 96 - void etnaviv_writel(u32 data, void __iomem *addr); 97 - u32 etnaviv_readl(const void __iomem *addr); 98 - 99 104 #define DBG(fmt, ...) DRM_DEBUG(fmt"\n", ##__VA_ARGS__) 100 105 #define VERB(fmt, ...) if (0) DRM_DEBUG(fmt"\n", ##__VA_ARGS__) 101 106 ··· 117 132 return (s32)(a - b) >= 0; 118 133 } 119 134 135 + /* 136 + * Etnaviv timeouts are specified wrt CLOCK_MONOTONIC, not jiffies. 137 + * We need to calculate the timeout in terms of number of jiffies 138 + * between the specified timeout and the current CLOCK_MONOTONIC time. 139 + */ 120 140 static inline unsigned long etnaviv_timeout_to_jiffies( 121 141 const struct timespec *timeout) 122 142 { 123 - unsigned long timeout_jiffies = timespec_to_jiffies(timeout); 124 - unsigned long start_jiffies = jiffies; 125 - unsigned long remaining_jiffies; 143 + struct timespec64 ts, to; 126 144 127 - if (time_after(start_jiffies, timeout_jiffies)) 128 - remaining_jiffies = 0; 129 - else 130 - remaining_jiffies = timeout_jiffies - start_jiffies; 145 + to = timespec_to_timespec64(*timeout); 131 146 132 - return remaining_jiffies; 147 + ktime_get_ts64(&ts); 148 + 149 + /* timeouts before "now" have already expired */ 150 + if (timespec64_compare(&to, &ts) <= 0) 151 + return 0; 152 + 153 + ts = timespec64_sub(to, ts); 154 + 155 + return timespec64_to_jiffies(&ts); 133 156 } 134 157 135 158 #endif /* __ETNAVIV_DRV_H__ */
+2 -13
drivers/gpu/drm/etnaviv/etnaviv_dump.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 - * Copyright (C) 2015 Etnaviv Project 3 - * 4 - * This program is free software; you can redistribute it and/or modify it 5 - * under the terms of the GNU General Public License version 2 as published by 6 - * the Free Software Foundation. 7 - * 8 - * This program is distributed in the hope that it will be useful, but WITHOUT 9 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 11 - * more details. 12 - * 13 - * You should have received a copy of the GNU General Public License along with 14 - * this program. If not, see <http://www.gnu.org/licenses/>. 3 + * Copyright (C) 2015-2018 Etnaviv Project 15 4 */ 16 5 17 6 #include <linux/devcoredump.h>
+2 -14
drivers/gpu/drm/etnaviv/etnaviv_dump.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 1 2 /* 2 3 * Copyright (C) 2015 Etnaviv Project 3 - * 4 - * This program is free software; you can redistribute it and/or modify it 5 - * under the terms of the GNU General Public License version 2 as published by 6 - * the Free Software Foundation. 7 - * 8 - * This program is distributed in the hope that it will be useful, but WITHOUT 9 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 11 - * more details. 12 - * 13 - * You should have received a copy of the GNU General Public License along with 14 - * this program. If not, see <http://www.gnu.org/licenses/>. 15 - * 16 - * Etnaviv devcoredump file definitions 17 4 */ 5 + 18 6 #ifndef ETNAVIV_DUMP_H 19 7 #define ETNAVIV_DUMP_H 20 8
+2 -13
drivers/gpu/drm/etnaviv/etnaviv_gem.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 - * Copyright (C) 2015 Etnaviv Project 3 - * 4 - * This program is free software; you can redistribute it and/or modify it 5 - * under the terms of the GNU General Public License version 2 as published by 6 - * the Free Software Foundation. 7 - * 8 - * This program is distributed in the hope that it will be useful, but WITHOUT 9 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 11 - * more details. 12 - * 13 - * You should have received a copy of the GNU General Public License along with 14 - * this program. If not, see <http://www.gnu.org/licenses/>. 3 + * Copyright (C) 2015-2018 Etnaviv Project 15 4 */ 16 5 17 6 #include <linux/spinlock.h>
+2 -13
drivers/gpu/drm/etnaviv/etnaviv_gem.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 1 2 /* 2 - * Copyright (C) 2015 Etnaviv Project 3 - * 4 - * This program is free software; you can redistribute it and/or modify it 5 - * under the terms of the GNU General Public License version 2 as published by 6 - * the Free Software Foundation. 7 - * 8 - * This program is distributed in the hope that it will be useful, but WITHOUT 9 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 11 - * more details. 12 - * 13 - * You should have received a copy of the GNU General Public License along with 14 - * this program. If not, see <http://www.gnu.org/licenses/>. 3 + * Copyright (C) 2015-2018 Etnaviv Project 15 4 */ 16 5 17 6 #ifndef __ETNAVIV_GEM_H__
+2 -14
drivers/gpu/drm/etnaviv/etnaviv_gem_prime.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 - * Copyright (C) 2013 Red Hat 3 - * Author: Rob Clark <robdclark@gmail.com> 4 - * 5 - * This program is free software; you can redistribute it and/or modify it 6 - * under the terms of the GNU General Public License version 2 as published by 7 - * the Free Software Foundation. 8 - * 9 - * This program is distributed in the hope that it will be useful, but WITHOUT 10 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12 - * more details. 13 - * 14 - * You should have received a copy of the GNU General Public License along with 15 - * this program. If not, see <http://www.gnu.org/licenses/>. 3 + * Copyright (C) 2014-2018 Etnaviv Project 16 4 */ 17 5 18 6 #include <linux/dma-buf.h>
+5 -14
drivers/gpu/drm/etnaviv/etnaviv_gpu.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 - * Copyright (C) 2015 Etnaviv Project 3 - * 4 - * This program is free software; you can redistribute it and/or modify it 5 - * under the terms of the GNU General Public License version 2 as published by 6 - * the Free Software Foundation. 7 - * 8 - * This program is distributed in the hope that it will be useful, but WITHOUT 9 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 11 - * more details. 12 - * 13 - * You should have received a copy of the GNU General Public License along with 14 - * this program. If not, see <http://www.gnu.org/licenses/>. 3 + * Copyright (C) 2015-2018 Etnaviv Project 15 4 */ 16 5 17 6 #include <linux/component.h> ··· 1724 1735 { 1725 1736 struct device *dev = &pdev->dev; 1726 1737 struct etnaviv_gpu *gpu; 1738 + struct resource *res; 1727 1739 int err; 1728 1740 1729 1741 gpu = devm_kzalloc(dev, sizeof(*gpu), GFP_KERNEL); ··· 1736 1746 mutex_init(&gpu->fence_idr_lock); 1737 1747 1738 1748 /* Map registers: */ 1739 - gpu->mmio = etnaviv_ioremap(pdev, NULL, dev_name(gpu->dev)); 1749 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1750 + gpu->mmio = devm_ioremap_resource(&pdev->dev, res); 1740 1751 if (IS_ERR(gpu->mmio)) 1741 1752 return PTR_ERR(gpu->mmio); 1742 1753
+4 -15
drivers/gpu/drm/etnaviv/etnaviv_gpu.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 1 2 /* 2 - * Copyright (C) 2015 Etnaviv Project 3 - * 4 - * This program is free software; you can redistribute it and/or modify it 5 - * under the terms of the GNU General Public License version 2 as published by 6 - * the Free Software Foundation. 7 - * 8 - * This program is distributed in the hope that it will be useful, but WITHOUT 9 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 11 - * more details. 12 - * 13 - * You should have received a copy of the GNU General Public License along with 14 - * this program. If not, see <http://www.gnu.org/licenses/>. 3 + * Copyright (C) 2015-2018 Etnaviv Project 15 4 */ 16 5 17 6 #ifndef __ETNAVIV_GPU_H__ ··· 150 161 151 162 static inline void gpu_write(struct etnaviv_gpu *gpu, u32 reg, u32 data) 152 163 { 153 - etnaviv_writel(data, gpu->mmio + reg); 164 + writel(data, gpu->mmio + reg); 154 165 } 155 166 156 167 static inline u32 gpu_read(struct etnaviv_gpu *gpu, u32 reg) 157 168 { 158 - return etnaviv_readl(gpu->mmio + reg); 169 + return readl(gpu->mmio + reg); 159 170 } 160 171 161 172 static inline bool fence_completed(struct etnaviv_gpu *gpu, u32 fence)
+1 -12
drivers/gpu/drm/etnaviv/etnaviv_hwdb.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * Copyright (C) 2018 Etnaviv Project 3 - * 4 - * This program is free software; you can redistribute it and/or modify it 5 - * under the terms of the GNU General Public License version 2 as published by 6 - * the Free Software Foundation. 7 - * 8 - * This program is distributed in the hope that it will be useful, but WITHOUT 9 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 11 - * more details. 12 - * 13 - * You should have received a copy of the GNU General Public License along with 14 - * this program. If not, see <http://www.gnu.org/licenses/>. 15 4 */ 16 5 17 6 #include "etnaviv_gpu.h"
+18 -31
drivers/gpu/drm/etnaviv/etnaviv_iommu.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 - * Copyright (C) 2014 Christian Gmeiner <christian.gmeiner@gmail.com> 3 - * 4 - * This program is free software; you can redistribute it and/or modify it 5 - * under the terms of the GNU General Public License version 2 as published by 6 - * the Free Software Foundation. 7 - * 8 - * This program is distributed in the hope that it will be useful, but WITHOUT 9 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 11 - * more details. 12 - * 13 - * You should have received a copy of the GNU General Public License along with 14 - * this program. If not, see <http://www.gnu.org/licenses/>. 3 + * Copyright (C) 2014-2018 Etnaviv Project 15 4 */ 16 5 17 6 #include <linux/platform_device.h> ··· 36 47 u32 *p; 37 48 int i; 38 49 39 - etnaviv_domain->base.bad_page_cpu = dma_alloc_coherent( 40 - etnaviv_domain->base.dev, 41 - SZ_4K, 42 - &etnaviv_domain->base.bad_page_dma, 43 - GFP_KERNEL); 50 + etnaviv_domain->base.bad_page_cpu = 51 + dma_alloc_wc(etnaviv_domain->base.dev, SZ_4K, 52 + &etnaviv_domain->base.bad_page_dma, 53 + GFP_KERNEL); 44 54 if (!etnaviv_domain->base.bad_page_cpu) 45 55 return -ENOMEM; 46 56 ··· 47 59 for (i = 0; i < SZ_4K / 4; i++) 48 60 *p++ = 0xdead55aa; 49 61 50 - etnaviv_domain->pgtable_cpu = 51 - dma_alloc_coherent(etnaviv_domain->base.dev, PT_SIZE, 52 - &etnaviv_domain->pgtable_dma, 53 - GFP_KERNEL); 62 + etnaviv_domain->pgtable_cpu = dma_alloc_wc(etnaviv_domain->base.dev, 63 + PT_SIZE, 64 + &etnaviv_domain->pgtable_dma, 65 + GFP_KERNEL); 54 66 if (!etnaviv_domain->pgtable_cpu) { 55 - dma_free_coherent(etnaviv_domain->base.dev, SZ_4K, 56 - etnaviv_domain->base.bad_page_cpu, 57 - etnaviv_domain->base.bad_page_dma); 67 + dma_free_wc(etnaviv_domain->base.dev, SZ_4K, 68 + etnaviv_domain->base.bad_page_cpu, 69 + etnaviv_domain->base.bad_page_dma); 58 70 return -ENOMEM; 59 71 } 60 72 ··· 69 81 struct etnaviv_iommuv1_domain *etnaviv_domain = 70 82 to_etnaviv_domain(domain); 71 83 72 - dma_free_coherent(etnaviv_domain->base.dev, PT_SIZE, 73 - etnaviv_domain->pgtable_cpu, 74 - etnaviv_domain->pgtable_dma); 84 + dma_free_wc(etnaviv_domain->base.dev, PT_SIZE, 85 + etnaviv_domain->pgtable_cpu, etnaviv_domain->pgtable_dma); 75 86 76 - dma_free_coherent(etnaviv_domain->base.dev, SZ_4K, 77 - etnaviv_domain->base.bad_page_cpu, 78 - etnaviv_domain->base.bad_page_dma); 87 + dma_free_wc(etnaviv_domain->base.dev, SZ_4K, 88 + etnaviv_domain->base.bad_page_cpu, 89 + etnaviv_domain->base.bad_page_dma); 79 90 80 91 kfree(etnaviv_domain); 81 92 }
+2 -13
drivers/gpu/drm/etnaviv/etnaviv_iommu.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 1 2 /* 2 - * Copyright (C) 2014 Christian Gmeiner <christian.gmeiner@gmail.com> 3 - * 4 - * This program is free software; you can redistribute it and/or modify it 5 - * under the terms of the GNU General Public License version 2 as published by 6 - * the Free Software Foundation. 7 - * 8 - * This program is distributed in the hope that it will be useful, but WITHOUT 9 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 11 - * more details. 12 - * 13 - * You should have received a copy of the GNU General Public License along with 14 - * this program. If not, see <http://www.gnu.org/licenses/>. 3 + * Copyright (C) 2014-2018 Etnaviv Project 15 4 */ 16 5 17 6 #ifndef __ETNAVIV_IOMMU_H__
+66 -77
drivers/gpu/drm/etnaviv/etnaviv_iommu_v2.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 - * Copyright (C) 2016 Etnaviv Project 3 - * 4 - * This program is free software; you can redistribute it and/or modify it 5 - * under the terms of the GNU General Public License version 2 as published by 6 - * the Free Software Foundation. 7 - * 8 - * This program is distributed in the hope that it will be useful, but WITHOUT 9 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 11 - * more details. 12 - * 13 - * You should have received a copy of the GNU General Public License along with 14 - * this program. If not, see <http://www.gnu.org/licenses/>. 3 + * Copyright (C) 2016-2018 Etnaviv Project 15 4 */ 16 5 17 6 #include <linux/platform_device.h> ··· 36 47 u32 *mtlb_cpu; 37 48 dma_addr_t mtlb_dma; 38 49 /* S(lave) TLB aka second level pagetable */ 39 - u32 *stlb_cpu[1024]; 40 - dma_addr_t stlb_dma[1024]; 50 + u32 *stlb_cpu[MMUv2_MAX_STLB_ENTRIES]; 51 + dma_addr_t stlb_dma[MMUv2_MAX_STLB_ENTRIES]; 41 52 }; 42 53 43 54 static struct etnaviv_iommuv2_domain * ··· 46 57 return container_of(domain, struct etnaviv_iommuv2_domain, base); 47 58 } 48 59 60 + static int 61 + etnaviv_iommuv2_ensure_stlb(struct etnaviv_iommuv2_domain *etnaviv_domain, 62 + int stlb) 63 + { 64 + if (etnaviv_domain->stlb_cpu[stlb]) 65 + return 0; 66 + 67 + etnaviv_domain->stlb_cpu[stlb] = 68 + dma_alloc_wc(etnaviv_domain->base.dev, SZ_4K, 69 + &etnaviv_domain->stlb_dma[stlb], 70 + GFP_KERNEL); 71 + 72 + if (!etnaviv_domain->stlb_cpu[stlb]) 73 + return -ENOMEM; 74 + 75 + memset32(etnaviv_domain->stlb_cpu[stlb], MMUv2_PTE_EXCEPTION, 76 + SZ_4K / sizeof(u32)); 77 + 78 + etnaviv_domain->mtlb_cpu[stlb] = etnaviv_domain->stlb_dma[stlb] | 79 + MMUv2_PTE_PRESENT; 80 + return 0; 81 + } 82 + 49 83 static int etnaviv_iommuv2_map(struct etnaviv_iommu_domain *domain, 50 84 unsigned long iova, phys_addr_t paddr, 51 85 size_t size, int prot) 52 86 { 53 87 struct etnaviv_iommuv2_domain *etnaviv_domain = 54 88 to_etnaviv_domain(domain); 55 - int mtlb_entry, stlb_entry; 56 - u32 entry = (u32)paddr | MMUv2_PTE_PRESENT; 89 + int mtlb_entry, stlb_entry, ret; 90 + u32 entry = lower_32_bits(paddr) | MMUv2_PTE_PRESENT; 57 91 58 92 if (size != SZ_4K) 59 93 return -EINVAL; 94 + 95 + if (IS_ENABLED(CONFIG_PHYS_ADDR_T_64BIT)) 96 + entry |= (upper_32_bits(paddr) & 0xff) << 4; 60 97 61 98 if (prot & ETNAVIV_PROT_WRITE) 62 99 entry |= MMUv2_PTE_WRITEABLE; 63 100 64 101 mtlb_entry = (iova & MMUv2_MTLB_MASK) >> MMUv2_MTLB_SHIFT; 65 102 stlb_entry = (iova & MMUv2_STLB_MASK) >> MMUv2_STLB_SHIFT; 103 + 104 + ret = etnaviv_iommuv2_ensure_stlb(etnaviv_domain, mtlb_entry); 105 + if (ret) 106 + return ret; 66 107 67 108 etnaviv_domain->stlb_cpu[mtlb_entry][stlb_entry] = entry; 68 109 ··· 120 101 static int etnaviv_iommuv2_init(struct etnaviv_iommuv2_domain *etnaviv_domain) 121 102 { 122 103 u32 *p; 123 - int ret, i, j; 104 + int ret, i; 124 105 125 106 /* allocate scratch page */ 126 - etnaviv_domain->base.bad_page_cpu = dma_alloc_coherent( 127 - etnaviv_domain->base.dev, 128 - SZ_4K, 129 - &etnaviv_domain->base.bad_page_dma, 130 - GFP_KERNEL); 107 + etnaviv_domain->base.bad_page_cpu = 108 + dma_alloc_wc(etnaviv_domain->base.dev, SZ_4K, 109 + &etnaviv_domain->base.bad_page_dma, 110 + GFP_KERNEL); 131 111 if (!etnaviv_domain->base.bad_page_cpu) { 132 112 ret = -ENOMEM; 133 113 goto fail_mem; ··· 135 117 for (i = 0; i < SZ_4K / 4; i++) 136 118 *p++ = 0xdead55aa; 137 119 138 - etnaviv_domain->pta_cpu = dma_alloc_coherent(etnaviv_domain->base.dev, 139 - SZ_4K, 140 - &etnaviv_domain->pta_dma, 141 - GFP_KERNEL); 120 + etnaviv_domain->pta_cpu = dma_alloc_wc(etnaviv_domain->base.dev, 121 + SZ_4K, &etnaviv_domain->pta_dma, 122 + GFP_KERNEL); 142 123 if (!etnaviv_domain->pta_cpu) { 143 124 ret = -ENOMEM; 144 125 goto fail_mem; 145 126 } 146 127 147 - etnaviv_domain->mtlb_cpu = dma_alloc_coherent(etnaviv_domain->base.dev, 148 - SZ_4K, 149 - &etnaviv_domain->mtlb_dma, 150 - GFP_KERNEL); 128 + etnaviv_domain->mtlb_cpu = dma_alloc_wc(etnaviv_domain->base.dev, 129 + SZ_4K, &etnaviv_domain->mtlb_dma, 130 + GFP_KERNEL); 151 131 if (!etnaviv_domain->mtlb_cpu) { 152 132 ret = -ENOMEM; 153 133 goto fail_mem; 154 134 } 155 135 156 - /* pre-populate STLB pages (may want to switch to on-demand later) */ 157 - for (i = 0; i < MMUv2_MAX_STLB_ENTRIES; i++) { 158 - etnaviv_domain->stlb_cpu[i] = 159 - dma_alloc_coherent(etnaviv_domain->base.dev, 160 - SZ_4K, 161 - &etnaviv_domain->stlb_dma[i], 162 - GFP_KERNEL); 163 - if (!etnaviv_domain->stlb_cpu[i]) { 164 - ret = -ENOMEM; 165 - goto fail_mem; 166 - } 167 - p = etnaviv_domain->stlb_cpu[i]; 168 - for (j = 0; j < SZ_4K / 4; j++) 169 - *p++ = MMUv2_PTE_EXCEPTION; 170 - 171 - etnaviv_domain->mtlb_cpu[i] = etnaviv_domain->stlb_dma[i] | 172 - MMUv2_PTE_PRESENT; 173 - } 136 + memset32(etnaviv_domain->mtlb_cpu, MMUv2_PTE_EXCEPTION, 137 + MMUv2_MAX_STLB_ENTRIES); 174 138 175 139 return 0; 176 140 177 141 fail_mem: 178 142 if (etnaviv_domain->base.bad_page_cpu) 179 - dma_free_coherent(etnaviv_domain->base.dev, SZ_4K, 180 - etnaviv_domain->base.bad_page_cpu, 181 - etnaviv_domain->base.bad_page_dma); 143 + dma_free_wc(etnaviv_domain->base.dev, SZ_4K, 144 + etnaviv_domain->base.bad_page_cpu, 145 + etnaviv_domain->base.bad_page_dma); 182 146 183 147 if (etnaviv_domain->pta_cpu) 184 - dma_free_coherent(etnaviv_domain->base.dev, SZ_4K, 185 - etnaviv_domain->pta_cpu, 186 - etnaviv_domain->pta_dma); 148 + dma_free_wc(etnaviv_domain->base.dev, SZ_4K, 149 + etnaviv_domain->pta_cpu, etnaviv_domain->pta_dma); 187 150 188 151 if (etnaviv_domain->mtlb_cpu) 189 - dma_free_coherent(etnaviv_domain->base.dev, SZ_4K, 190 - etnaviv_domain->mtlb_cpu, 191 - etnaviv_domain->mtlb_dma); 192 - 193 - for (i = 0; i < MMUv2_MAX_STLB_ENTRIES; i++) { 194 - if (etnaviv_domain->stlb_cpu[i]) 195 - dma_free_coherent(etnaviv_domain->base.dev, SZ_4K, 196 - etnaviv_domain->stlb_cpu[i], 197 - etnaviv_domain->stlb_dma[i]); 198 - } 152 + dma_free_wc(etnaviv_domain->base.dev, SZ_4K, 153 + etnaviv_domain->mtlb_cpu, etnaviv_domain->mtlb_dma); 199 154 200 155 return ret; 201 156 } ··· 179 188 to_etnaviv_domain(domain); 180 189 int i; 181 190 182 - dma_free_coherent(etnaviv_domain->base.dev, SZ_4K, 183 - etnaviv_domain->base.bad_page_cpu, 184 - etnaviv_domain->base.bad_page_dma); 191 + dma_free_wc(etnaviv_domain->base.dev, SZ_4K, 192 + etnaviv_domain->base.bad_page_cpu, 193 + etnaviv_domain->base.bad_page_dma); 185 194 186 - dma_free_coherent(etnaviv_domain->base.dev, SZ_4K, 187 - etnaviv_domain->pta_cpu, 188 - etnaviv_domain->pta_dma); 195 + dma_free_wc(etnaviv_domain->base.dev, SZ_4K, 196 + etnaviv_domain->pta_cpu, etnaviv_domain->pta_dma); 189 197 190 - dma_free_coherent(etnaviv_domain->base.dev, SZ_4K, 191 - etnaviv_domain->mtlb_cpu, 192 - etnaviv_domain->mtlb_dma); 198 + dma_free_wc(etnaviv_domain->base.dev, SZ_4K, 199 + etnaviv_domain->mtlb_cpu, etnaviv_domain->mtlb_dma); 193 200 194 201 for (i = 0; i < MMUv2_MAX_STLB_ENTRIES; i++) { 195 202 if (etnaviv_domain->stlb_cpu[i]) 196 - dma_free_coherent(etnaviv_domain->base.dev, SZ_4K, 197 - etnaviv_domain->stlb_cpu[i], 198 - etnaviv_domain->stlb_dma[i]); 203 + dma_free_wc(etnaviv_domain->base.dev, SZ_4K, 204 + etnaviv_domain->stlb_cpu[i], 205 + etnaviv_domain->stlb_dma[i]); 199 206 } 200 207 201 208 vfree(etnaviv_domain);
+3 -28
drivers/gpu/drm/etnaviv/etnaviv_mmu.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 - * Copyright (C) 2015 Etnaviv Project 3 - * 4 - * This program is free software; you can redistribute it and/or modify it 5 - * under the terms of the GNU General Public License version 2 as published by 6 - * the Free Software Foundation. 7 - * 8 - * This program is distributed in the hope that it will be useful, but WITHOUT 9 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 11 - * more details. 12 - * 13 - * You should have received a copy of the GNU General Public License along with 14 - * this program. If not, see <http://www.gnu.org/licenses/>. 3 + * Copyright (C) 2015-2018 Etnaviv Project 15 4 */ 16 5 17 6 #include "common.xml.h" ··· 151 162 bool found; 152 163 153 164 ret = drm_mm_insert_node_in_range(&mmu->mm, node, 154 - size, 0, 0, 155 - mmu->last_iova, U64_MAX, 156 - mode); 165 + size, 0, 0, 0, U64_MAX, mode); 157 166 if (ret != -ENOSPC) 158 167 break; 159 - 160 - /* 161 - * If we did not search from the start of the MMU region, 162 - * try again in case there are free slots. 163 - */ 164 - if (mmu->last_iova) { 165 - mmu->last_iova = 0; 166 - mmu->need_flush = true; 167 - continue; 168 - } 169 168 170 169 /* Try to retire some entries */ 171 170 drm_mm_scan_init(&scan, &mmu->mm, size, 0, 0, mode); ··· 251 274 if (ret < 0) 252 275 goto unlock; 253 276 254 - mmu->last_iova = node->start + etnaviv_obj->base.size; 255 277 mapping->iova = node->start; 256 278 ret = etnaviv_iommu_map(mmu, node->start, sgt, etnaviv_obj->base.size, 257 279 ETNAVIV_PROT_READ | ETNAVIV_PROT_WRITE); ··· 357 381 mutex_unlock(&mmu->lock); 358 382 return ret; 359 383 } 360 - mmu->last_iova = vram_node->start + size; 361 384 gpu->mmu->need_flush = true; 362 385 mutex_unlock(&mmu->lock); 363 386
+2 -14
drivers/gpu/drm/etnaviv/etnaviv_mmu.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 1 2 /* 2 - * Copyright (C) 2015 Etnaviv Project 3 - * 4 - * This program is free software; you can redistribute it and/or modify it 5 - * under the terms of the GNU General Public License version 2 as published by 6 - * the Free Software Foundation. 7 - * 8 - * This program is distributed in the hope that it will be useful, but WITHOUT 9 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 11 - * more details. 12 - * 13 - * You should have received a copy of the GNU General Public License along with 14 - * this program. If not, see <http://www.gnu.org/licenses/>. 3 + * Copyright (C) 2015-2018 Etnaviv Project 15 4 */ 16 5 17 6 #ifndef __ETNAVIV_MMU_H__ ··· 48 59 struct mutex lock; 49 60 struct list_head mappings; 50 61 struct drm_mm mm; 51 - u32 last_iova; 52 62 bool need_flush; 53 63 }; 54 64
+1 -12
drivers/gpu/drm/etnaviv/etnaviv_perfmon.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * Copyright (C) 2017 Etnaviv Project 3 4 * Copyright (C) 2017 Zodiac Inflight Innovations 4 - * 5 - * This program is free software; you can redistribute it and/or modify it 6 - * under the terms of the GNU General Public License version 2 as published by 7 - * the Free Software Foundation. 8 - * 9 - * This program is distributed in the hope that it will be useful, but WITHOUT 10 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12 - * more details. 13 - * 14 - * You should have received a copy of the GNU General Public License along with 15 - * this program. If not, see <http://www.gnu.org/licenses/>. 16 5 */ 17 6 18 7 #include "etnaviv_gpu.h"
+1 -12
drivers/gpu/drm/etnaviv/etnaviv_perfmon.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 1 2 /* 2 3 * Copyright (C) 2017 Etnaviv Project 3 4 * Copyright (C) 2017 Zodiac Inflight Innovations 4 - * 5 - * This program is free software; you can redistribute it and/or modify it 6 - * under the terms of the GNU General Public License version 2 as published by 7 - * the Free Software Foundation. 8 - * 9 - * This program is distributed in the hope that it will be useful, but WITHOUT 10 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12 - * more details. 13 - * 14 - * You should have received a copy of the GNU General Public License along with 15 - * this program. If not, see <http://www.gnu.org/licenses/>. 16 5 */ 17 6 18 7 #ifndef __ETNAVIV_PERFMON_H__
+1 -12
drivers/gpu/drm/etnaviv/etnaviv_sched.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * Copyright (C) 2017 Etnaviv Project 3 - * 4 - * This program is free software; you can redistribute it and/or modify it 5 - * under the terms of the GNU General Public License version 2 as published by 6 - * the Free Software Foundation. 7 - * 8 - * This program is distributed in the hope that it will be useful, but WITHOUT 9 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 11 - * more details. 12 - * 13 - * You should have received a copy of the GNU General Public License along with 14 - * this program. If not, see <http://www.gnu.org/licenses/>. 15 4 */ 16 5 17 6 #include <linux/kthread.h>
+1 -12
drivers/gpu/drm/etnaviv/etnaviv_sched.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 1 2 /* 2 3 * Copyright (C) 2017 Etnaviv Project 3 - * 4 - * This program is free software; you can redistribute it and/or modify it 5 - * under the terms of the GNU General Public License version 2 as published by 6 - * the Free Software Foundation. 7 - * 8 - * This program is distributed in the hope that it will be useful, but WITHOUT 9 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 11 - * more details. 12 - * 13 - * You should have received a copy of the GNU General Public License along with 14 - * this program. If not, see <http://www.gnu.org/licenses/>. 15 4 */ 16 5 17 6 #ifndef __ETNAVIV_SCHED_H__