diff options
| author | Dave Airlie <airlied@redhat.com> | 2018-05-21 20:37:07 -0400 |
|---|---|---|
| committer | Dave Airlie <airlied@redhat.com> | 2018-05-21 20:43:27 -0400 |
| commit | ca6444f3417a1dec045a7413041312b1e45e55b2 (patch) | |
| tree | f4965f423873a4e3e423f92b27bf7709c5cd6026 /drivers/gpu/drm | |
| parent | 1dd6eb88af7a511b090fa847ed826bf3accf3bce (diff) | |
| parent | f6ffbd4fc1a1caafe2ab840993b917fba5324598 (diff) | |
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
Diffstat (limited to 'drivers/gpu/drm')
24 files changed, 143 insertions, 469 deletions
diff --git a/drivers/gpu/drm/etnaviv/Kconfig b/drivers/gpu/drm/etnaviv/Kconfig index e5bfeca361bd..041a77e400d4 100644 --- a/drivers/gpu/drm/etnaviv/Kconfig +++ b/drivers/gpu/drm/etnaviv/Kconfig | |||
| @@ -22,11 +22,3 @@ config DRM_ETNAVIV_THERMAL | |||
| 22 | help | 22 | help |
| 23 | Compile in support for thermal throttling. | 23 | Compile in support for thermal throttling. |
| 24 | Say Y unless you want to risk burning your SoC. | 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. | ||
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_buffer.c b/drivers/gpu/drm/etnaviv/etnaviv_buffer.c index bfc6d4aa3b7c..7fea74861a87 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_buffer.c +++ b/drivers/gpu/drm/etnaviv/etnaviv_buffer.c | |||
| @@ -1,18 +1,6 @@ | |||
| 1 | // SPDX-License-Identifier: GPL-2.0 | ||
| 1 | /* | 2 | /* |
| 2 | * Copyright (C) 2014 Etnaviv Project | 3 | * Copyright (C) 2014-2018 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/>. | ||
| 16 | */ | 4 | */ |
| 17 | 5 | ||
| 18 | #include "etnaviv_cmdbuf.h" | 6 | #include "etnaviv_cmdbuf.h" |
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_cmd_parser.c b/drivers/gpu/drm/etnaviv/etnaviv_cmd_parser.c index 68e6d3772ad8..b106e8b288ad 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_cmd_parser.c +++ b/drivers/gpu/drm/etnaviv/etnaviv_cmd_parser.c | |||
| @@ -1,17 +1,6 @@ | |||
| 1 | // SPDX-License-Identifier: GPL-2.0 | ||
| 1 | /* | 2 | /* |
| 2 | * Copyright (C) 2015 Etnaviv Project | 3 | * Copyright (C) 2015-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 | #include <linux/kernel.h> | 6 | #include <linux/kernel.h> |
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_cmdbuf.c b/drivers/gpu/drm/etnaviv/etnaviv_cmdbuf.c index 3746827f45eb..a3c44f145c1d 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_cmdbuf.c +++ b/drivers/gpu/drm/etnaviv/etnaviv_cmdbuf.c | |||
| @@ -1,17 +1,6 @@ | |||
| 1 | // SPDX-License-Identifier: GPL-2.0 | ||
| 1 | /* | 2 | /* |
| 2 | * Copyright (C) 2017 Etnaviv Project | 3 | * Copyright (C) 2017-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 | #include <drm/drm_mm.h> | 6 | #include <drm/drm_mm.h> |
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_cmdbuf.h b/drivers/gpu/drm/etnaviv/etnaviv_cmdbuf.h index ddc3f7ea169c..acb68c698363 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_cmdbuf.h +++ b/drivers/gpu/drm/etnaviv/etnaviv_cmdbuf.h | |||
| @@ -1,17 +1,6 @@ | |||
| 1 | /* SPDX-License-Identifier: GPL-2.0 */ | ||
| 1 | /* | 2 | /* |
| 2 | * Copyright (C) 2017 Etnaviv Project | 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 | #ifndef __ETNAVIV_CMDBUF_H__ | 6 | #ifndef __ETNAVIV_CMDBUF_H__ |
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_drv.c b/drivers/gpu/drm/etnaviv/etnaviv_drv.c index 23e73c2a19f4..e5013a999147 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_drv.c +++ b/drivers/gpu/drm/etnaviv/etnaviv_drv.c | |||
| @@ -1,17 +1,6 @@ | |||
| 1 | // SPDX-License-Identifier: GPL-2.0 | ||
| 1 | /* | 2 | /* |
| 2 | * Copyright (C) 2015 Etnaviv Project | 3 | * Copyright (C) 2015-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 | #include <linux/component.h> | 6 | #include <linux/component.h> |
| @@ -25,57 +14,6 @@ | |||
| 25 | #include "etnaviv_mmu.h" | 14 | #include "etnaviv_mmu.h" |
| 26 | #include "etnaviv_perfmon.h" | 15 | #include "etnaviv_perfmon.h" |
| 27 | 16 | ||
| 28 | #ifdef CONFIG_DRM_ETNAVIV_REGISTER_LOGGING | ||
| 29 | static bool reglog; | ||
| 30 | MODULE_PARM_DESC(reglog, "Enable register read/write logging"); | ||
| 31 | module_param(reglog, bool, 0600); | ||
| 32 | #else | ||
| 33 | #define reglog 0 | ||
| 34 | #endif | ||
| 35 | |||
| 36 | void __iomem *etnaviv_ioremap(struct platform_device *pdev, const char *name, | ||
| 37 | const char *dbgname) | ||
| 38 | { | ||
| 39 | struct resource *res; | ||
| 40 | void __iomem *ptr; | ||
| 41 | |||
| 42 | if (name) | ||
| 43 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM, name); | ||
| 44 | else | ||
| 45 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
| 46 | |||
| 47 | ptr = devm_ioremap_resource(&pdev->dev, res); | ||
| 48 | if (IS_ERR(ptr)) { | ||
| 49 | dev_err(&pdev->dev, "failed to ioremap %s: %ld\n", name, | ||
| 50 | PTR_ERR(ptr)); | ||
| 51 | return ptr; | ||
| 52 | } | ||
| 53 | |||
| 54 | if (reglog) | ||
| 55 | dev_printk(KERN_DEBUG, &pdev->dev, "IO:region %s 0x%p %08zx\n", | ||
| 56 | dbgname, ptr, (size_t)resource_size(res)); | ||
| 57 | |||
| 58 | return ptr; | ||
| 59 | } | ||
| 60 | |||
| 61 | void etnaviv_writel(u32 data, void __iomem *addr) | ||
| 62 | { | ||
| 63 | if (reglog) | ||
| 64 | printk(KERN_DEBUG "IO:W %p %08x\n", addr, data); | ||
| 65 | |||
| 66 | writel(data, addr); | ||
| 67 | } | ||
| 68 | |||
| 69 | u32 etnaviv_readl(const void __iomem *addr) | ||
| 70 | { | ||
| 71 | u32 val = readl(addr); | ||
| 72 | |||
| 73 | if (reglog) | ||
| 74 | printk(KERN_DEBUG "IO:R %p %08x\n", addr, val); | ||
| 75 | |||
| 76 | return val; | ||
| 77 | } | ||
| 78 | |||
| 79 | /* | 17 | /* |
| 80 | * DRM operations: | 18 | * DRM operations: |
| 81 | */ | 19 | */ |
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_drv.h b/drivers/gpu/drm/etnaviv/etnaviv_drv.h index ddb17ee565e9..d36c7bbe66db 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_drv.h +++ b/drivers/gpu/drm/etnaviv/etnaviv_drv.h | |||
| @@ -1,17 +1,6 @@ | |||
| 1 | /* SPDX-License-Identifier: GPL-2.0 */ | ||
| 1 | /* | 2 | /* |
| 2 | * Copyright (C) 2015 Etnaviv Project | 3 | * Copyright (C) 2015-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 | #ifndef __ETNAVIV_DRV_H__ | 6 | #ifndef __ETNAVIV_DRV_H__ |
| @@ -26,6 +15,7 @@ | |||
| 26 | #include <linux/pm_runtime.h> | 15 | #include <linux/pm_runtime.h> |
| 27 | #include <linux/slab.h> | 16 | #include <linux/slab.h> |
| 28 | #include <linux/list.h> | 17 | #include <linux/list.h> |
| 18 | #include <linux/time64.h> | ||
| 29 | #include <linux/types.h> | 19 | #include <linux/types.h> |
| 30 | #include <linux/sizes.h> | 20 | #include <linux/sizes.h> |
| 31 | 21 | ||
| @@ -101,11 +91,6 @@ void etnaviv_gem_describe_objects(struct etnaviv_drm_private *priv, | |||
| 101 | struct seq_file *m); | 91 | struct seq_file *m); |
| 102 | #endif | 92 | #endif |
| 103 | 93 | ||
| 104 | void __iomem *etnaviv_ioremap(struct platform_device *pdev, const char *name, | ||
| 105 | const char *dbgname); | ||
| 106 | void etnaviv_writel(u32 data, void __iomem *addr); | ||
| 107 | u32 etnaviv_readl(const void __iomem *addr); | ||
| 108 | |||
| 109 | #define DBG(fmt, ...) DRM_DEBUG(fmt"\n", ##__VA_ARGS__) | 94 | #define DBG(fmt, ...) DRM_DEBUG(fmt"\n", ##__VA_ARGS__) |
| 110 | #define VERB(fmt, ...) if (0) DRM_DEBUG(fmt"\n", ##__VA_ARGS__) | 95 | #define VERB(fmt, ...) if (0) DRM_DEBUG(fmt"\n", ##__VA_ARGS__) |
| 111 | 96 | ||
| @@ -132,19 +117,27 @@ static inline bool fence_after_eq(u32 a, u32 b) | |||
| 132 | return (s32)(a - b) >= 0; | 117 | return (s32)(a - b) >= 0; |
| 133 | } | 118 | } |
| 134 | 119 | ||
| 120 | /* | ||
| 121 | * Etnaviv timeouts are specified wrt CLOCK_MONOTONIC, not jiffies. | ||
| 122 | * We need to calculate the timeout in terms of number of jiffies | ||
| 123 | * between the specified timeout and the current CLOCK_MONOTONIC time. | ||
| 124 | */ | ||
| 135 | static inline unsigned long etnaviv_timeout_to_jiffies( | 125 | static inline unsigned long etnaviv_timeout_to_jiffies( |
| 136 | const struct timespec *timeout) | 126 | const struct timespec *timeout) |
| 137 | { | 127 | { |
| 138 | unsigned long timeout_jiffies = timespec_to_jiffies(timeout); | 128 | struct timespec64 ts, to; |
| 139 | unsigned long start_jiffies = jiffies; | 129 | |
| 140 | unsigned long remaining_jiffies; | 130 | to = timespec_to_timespec64(*timeout); |
| 131 | |||
| 132 | ktime_get_ts64(&ts); | ||
| 133 | |||
| 134 | /* timeouts before "now" have already expired */ | ||
| 135 | if (timespec64_compare(&to, &ts) <= 0) | ||
| 136 | return 0; | ||
| 141 | 137 | ||
| 142 | if (time_after(start_jiffies, timeout_jiffies)) | 138 | ts = timespec64_sub(to, ts); |
| 143 | remaining_jiffies = 0; | ||
| 144 | else | ||
| 145 | remaining_jiffies = timeout_jiffies - start_jiffies; | ||
| 146 | 139 | ||
| 147 | return remaining_jiffies; | 140 | return timespec64_to_jiffies(&ts); |
| 148 | } | 141 | } |
| 149 | 142 | ||
| 150 | #endif /* __ETNAVIV_DRV_H__ */ | 143 | #endif /* __ETNAVIV_DRV_H__ */ |
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_dump.c b/drivers/gpu/drm/etnaviv/etnaviv_dump.c index 48aef6cf6a42..9146e30e24a6 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_dump.c +++ b/drivers/gpu/drm/etnaviv/etnaviv_dump.c | |||
| @@ -1,17 +1,6 @@ | |||
| 1 | // SPDX-License-Identifier: GPL-2.0 | ||
| 1 | /* | 2 | /* |
| 2 | * Copyright (C) 2015 Etnaviv Project | 3 | * Copyright (C) 2015-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 | #include <linux/devcoredump.h> | 6 | #include <linux/devcoredump.h> |
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_dump.h b/drivers/gpu/drm/etnaviv/etnaviv_dump.h index 97f2f8db9133..2d916c2667ee 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_dump.h +++ b/drivers/gpu/drm/etnaviv/etnaviv_dump.h | |||
| @@ -1,20 +1,8 @@ | |||
| 1 | /* SPDX-License-Identifier: GPL-2.0 */ | ||
| 1 | /* | 2 | /* |
| 2 | * Copyright (C) 2015 Etnaviv Project | 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 | #ifndef ETNAVIV_DUMP_H | 6 | #ifndef ETNAVIV_DUMP_H |
| 19 | #define ETNAVIV_DUMP_H | 7 | #define ETNAVIV_DUMP_H |
| 20 | 8 | ||
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem.c b/drivers/gpu/drm/etnaviv/etnaviv_gem.c index fcc969fa0e69..209ef1274b80 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_gem.c +++ b/drivers/gpu/drm/etnaviv/etnaviv_gem.c | |||
| @@ -1,17 +1,6 @@ | |||
| 1 | // SPDX-License-Identifier: GPL-2.0 | ||
| 1 | /* | 2 | /* |
| 2 | * Copyright (C) 2015 Etnaviv Project | 3 | * Copyright (C) 2015-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 | #include <linux/spinlock.h> | 6 | #include <linux/spinlock.h> |
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem.h b/drivers/gpu/drm/etnaviv/etnaviv_gem.h index 93e696fcc14f..76079c2291f8 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_gem.h +++ b/drivers/gpu/drm/etnaviv/etnaviv_gem.h | |||
| @@ -1,17 +1,6 @@ | |||
| 1 | /* SPDX-License-Identifier: GPL-2.0 */ | ||
| 1 | /* | 2 | /* |
| 2 | * Copyright (C) 2015 Etnaviv Project | 3 | * Copyright (C) 2015-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 | #ifndef __ETNAVIV_GEM_H__ | 6 | #ifndef __ETNAVIV_GEM_H__ |
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem_prime.c b/drivers/gpu/drm/etnaviv/etnaviv_gem_prime.c index 5704305d41e6..0566171f8df2 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_gem_prime.c +++ b/drivers/gpu/drm/etnaviv/etnaviv_gem_prime.c | |||
| @@ -1,18 +1,6 @@ | |||
| 1 | // SPDX-License-Identifier: GPL-2.0 | ||
| 1 | /* | 2 | /* |
| 2 | * Copyright (C) 2013 Red Hat | 3 | * Copyright (C) 2014-2018 Etnaviv Project |
| 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/>. | ||
| 16 | */ | 4 | */ |
| 17 | 5 | ||
| 18 | #include <linux/dma-buf.h> | 6 | #include <linux/dma-buf.h> |
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c index 8a88799bf79b..686f6552db48 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c +++ b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c | |||
| @@ -1,17 +1,6 @@ | |||
| 1 | // SPDX-License-Identifier: GPL-2.0 | ||
| 1 | /* | 2 | /* |
| 2 | * Copyright (C) 2015 Etnaviv Project | 3 | * Copyright (C) 2015-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 | #include <linux/component.h> | 6 | #include <linux/component.h> |
| @@ -1735,6 +1724,7 @@ static int etnaviv_gpu_platform_probe(struct platform_device *pdev) | |||
| 1735 | { | 1724 | { |
| 1736 | struct device *dev = &pdev->dev; | 1725 | struct device *dev = &pdev->dev; |
| 1737 | struct etnaviv_gpu *gpu; | 1726 | struct etnaviv_gpu *gpu; |
| 1727 | struct resource *res; | ||
| 1738 | int err; | 1728 | int err; |
| 1739 | 1729 | ||
| 1740 | gpu = devm_kzalloc(dev, sizeof(*gpu), GFP_KERNEL); | 1730 | gpu = devm_kzalloc(dev, sizeof(*gpu), GFP_KERNEL); |
| @@ -1746,7 +1736,8 @@ static int etnaviv_gpu_platform_probe(struct platform_device *pdev) | |||
| 1746 | mutex_init(&gpu->fence_idr_lock); | 1736 | mutex_init(&gpu->fence_idr_lock); |
| 1747 | 1737 | ||
| 1748 | /* Map registers: */ | 1738 | /* Map registers: */ |
| 1749 | gpu->mmio = etnaviv_ioremap(pdev, NULL, dev_name(gpu->dev)); | 1739 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
| 1740 | gpu->mmio = devm_ioremap_resource(&pdev->dev, res); | ||
| 1750 | if (IS_ERR(gpu->mmio)) | 1741 | if (IS_ERR(gpu->mmio)) |
| 1751 | return PTR_ERR(gpu->mmio); | 1742 | return PTR_ERR(gpu->mmio); |
| 1752 | 1743 | ||
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gpu.h b/drivers/gpu/drm/etnaviv/etnaviv_gpu.h index 3c3005501846..dd430f0f8ff5 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_gpu.h +++ b/drivers/gpu/drm/etnaviv/etnaviv_gpu.h | |||
| @@ -1,17 +1,6 @@ | |||
| 1 | /* SPDX-License-Identifier: GPL-2.0 */ | ||
| 1 | /* | 2 | /* |
| 2 | * Copyright (C) 2015 Etnaviv Project | 3 | * Copyright (C) 2015-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 | #ifndef __ETNAVIV_GPU_H__ | 6 | #ifndef __ETNAVIV_GPU_H__ |
| @@ -161,12 +150,12 @@ struct etnaviv_gpu { | |||
| 161 | 150 | ||
| 162 | static inline void gpu_write(struct etnaviv_gpu *gpu, u32 reg, u32 data) | 151 | static inline void gpu_write(struct etnaviv_gpu *gpu, u32 reg, u32 data) |
| 163 | { | 152 | { |
| 164 | etnaviv_writel(data, gpu->mmio + reg); | 153 | writel(data, gpu->mmio + reg); |
| 165 | } | 154 | } |
| 166 | 155 | ||
| 167 | static inline u32 gpu_read(struct etnaviv_gpu *gpu, u32 reg) | 156 | static inline u32 gpu_read(struct etnaviv_gpu *gpu, u32 reg) |
| 168 | { | 157 | { |
| 169 | return etnaviv_readl(gpu->mmio + reg); | 158 | return readl(gpu->mmio + reg); |
| 170 | } | 159 | } |
| 171 | 160 | ||
| 172 | static inline bool fence_completed(struct etnaviv_gpu *gpu, u32 fence) | 161 | static inline bool fence_completed(struct etnaviv_gpu *gpu, u32 fence) |
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_hwdb.c b/drivers/gpu/drm/etnaviv/etnaviv_hwdb.c index ea08bb38caaf..39b463db76c9 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_hwdb.c +++ b/drivers/gpu/drm/etnaviv/etnaviv_hwdb.c | |||
| @@ -1,17 +1,6 @@ | |||
| 1 | // SPDX-License-Identifier: GPL-2.0 | ||
| 1 | /* | 2 | /* |
| 2 | * Copyright (C) 2018 Etnaviv Project | 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 | #include "etnaviv_gpu.h" | 6 | #include "etnaviv_gpu.h" |
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_iommu.c b/drivers/gpu/drm/etnaviv/etnaviv_iommu.c index 4b9b11ca6f03..b163bdbcb880 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_iommu.c +++ b/drivers/gpu/drm/etnaviv/etnaviv_iommu.c | |||
| @@ -1,17 +1,6 @@ | |||
| 1 | // SPDX-License-Identifier: GPL-2.0 | ||
| 1 | /* | 2 | /* |
| 2 | * Copyright (C) 2014 Christian Gmeiner <christian.gmeiner@gmail.com> | 3 | * Copyright (C) 2014-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 | #include <linux/platform_device.h> | 6 | #include <linux/platform_device.h> |
| @@ -47,11 +36,10 @@ static int __etnaviv_iommu_init(struct etnaviv_iommuv1_domain *etnaviv_domain) | |||
| 47 | u32 *p; | 36 | u32 *p; |
| 48 | int i; | 37 | int i; |
| 49 | 38 | ||
| 50 | etnaviv_domain->base.bad_page_cpu = dma_alloc_coherent( | 39 | etnaviv_domain->base.bad_page_cpu = |
| 51 | etnaviv_domain->base.dev, | 40 | dma_alloc_wc(etnaviv_domain->base.dev, SZ_4K, |
| 52 | SZ_4K, | 41 | &etnaviv_domain->base.bad_page_dma, |
| 53 | &etnaviv_domain->base.bad_page_dma, | 42 | GFP_KERNEL); |
| 54 | GFP_KERNEL); | ||
| 55 | if (!etnaviv_domain->base.bad_page_cpu) | 43 | if (!etnaviv_domain->base.bad_page_cpu) |
| 56 | return -ENOMEM; | 44 | return -ENOMEM; |
| 57 | 45 | ||
| @@ -59,14 +47,14 @@ static int __etnaviv_iommu_init(struct etnaviv_iommuv1_domain *etnaviv_domain) | |||
| 59 | for (i = 0; i < SZ_4K / 4; i++) | 47 | for (i = 0; i < SZ_4K / 4; i++) |
| 60 | *p++ = 0xdead55aa; | 48 | *p++ = 0xdead55aa; |
| 61 | 49 | ||
| 62 | etnaviv_domain->pgtable_cpu = | 50 | etnaviv_domain->pgtable_cpu = dma_alloc_wc(etnaviv_domain->base.dev, |
| 63 | dma_alloc_coherent(etnaviv_domain->base.dev, PT_SIZE, | 51 | PT_SIZE, |
| 64 | &etnaviv_domain->pgtable_dma, | 52 | &etnaviv_domain->pgtable_dma, |
| 65 | GFP_KERNEL); | 53 | GFP_KERNEL); |
| 66 | if (!etnaviv_domain->pgtable_cpu) { | 54 | if (!etnaviv_domain->pgtable_cpu) { |
| 67 | dma_free_coherent(etnaviv_domain->base.dev, SZ_4K, | 55 | dma_free_wc(etnaviv_domain->base.dev, SZ_4K, |
| 68 | etnaviv_domain->base.bad_page_cpu, | 56 | etnaviv_domain->base.bad_page_cpu, |
| 69 | etnaviv_domain->base.bad_page_dma); | 57 | etnaviv_domain->base.bad_page_dma); |
| 70 | return -ENOMEM; | 58 | return -ENOMEM; |
| 71 | } | 59 | } |
| 72 | 60 | ||
| @@ -81,13 +69,12 @@ static void etnaviv_iommuv1_domain_free(struct etnaviv_iommu_domain *domain) | |||
| 81 | struct etnaviv_iommuv1_domain *etnaviv_domain = | 69 | struct etnaviv_iommuv1_domain *etnaviv_domain = |
| 82 | to_etnaviv_domain(domain); | 70 | to_etnaviv_domain(domain); |
| 83 | 71 | ||
| 84 | dma_free_coherent(etnaviv_domain->base.dev, PT_SIZE, | 72 | dma_free_wc(etnaviv_domain->base.dev, PT_SIZE, |
| 85 | etnaviv_domain->pgtable_cpu, | 73 | etnaviv_domain->pgtable_cpu, etnaviv_domain->pgtable_dma); |
| 86 | etnaviv_domain->pgtable_dma); | ||
| 87 | 74 | ||
| 88 | dma_free_coherent(etnaviv_domain->base.dev, SZ_4K, | 75 | dma_free_wc(etnaviv_domain->base.dev, SZ_4K, |
| 89 | etnaviv_domain->base.bad_page_cpu, | 76 | etnaviv_domain->base.bad_page_cpu, |
| 90 | etnaviv_domain->base.bad_page_dma); | 77 | etnaviv_domain->base.bad_page_dma); |
| 91 | 78 | ||
| 92 | kfree(etnaviv_domain); | 79 | kfree(etnaviv_domain); |
| 93 | } | 80 | } |
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_iommu.h b/drivers/gpu/drm/etnaviv/etnaviv_iommu.h index 01d59bf70d78..b279404ce91a 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_iommu.h +++ b/drivers/gpu/drm/etnaviv/etnaviv_iommu.h | |||
| @@ -1,17 +1,6 @@ | |||
| 1 | /* SPDX-License-Identifier: GPL-2.0 */ | ||
| 1 | /* | 2 | /* |
| 2 | * Copyright (C) 2014 Christian Gmeiner <christian.gmeiner@gmail.com> | 3 | * Copyright (C) 2014-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 | #ifndef __ETNAVIV_IOMMU_H__ | 6 | #ifndef __ETNAVIV_IOMMU_H__ |
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_iommu_v2.c b/drivers/gpu/drm/etnaviv/etnaviv_iommu_v2.c index 9752dbd5d28b..71fbc1f96cb6 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_iommu_v2.c +++ b/drivers/gpu/drm/etnaviv/etnaviv_iommu_v2.c | |||
| @@ -1,17 +1,6 @@ | |||
| 1 | // SPDX-License-Identifier: GPL-2.0 | ||
| 1 | /* | 2 | /* |
| 2 | * Copyright (C) 2016 Etnaviv Project | 3 | * Copyright (C) 2016-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 | #include <linux/platform_device.h> | 6 | #include <linux/platform_device.h> |
| @@ -47,8 +36,8 @@ struct etnaviv_iommuv2_domain { | |||
| 47 | u32 *mtlb_cpu; | 36 | u32 *mtlb_cpu; |
| 48 | dma_addr_t mtlb_dma; | 37 | dma_addr_t mtlb_dma; |
| 49 | /* S(lave) TLB aka second level pagetable */ | 38 | /* S(lave) TLB aka second level pagetable */ |
| 50 | u32 *stlb_cpu[1024]; | 39 | u32 *stlb_cpu[MMUv2_MAX_STLB_ENTRIES]; |
| 51 | dma_addr_t stlb_dma[1024]; | 40 | dma_addr_t stlb_dma[MMUv2_MAX_STLB_ENTRIES]; |
| 52 | }; | 41 | }; |
| 53 | 42 | ||
| 54 | static struct etnaviv_iommuv2_domain * | 43 | static struct etnaviv_iommuv2_domain * |
| @@ -57,24 +46,54 @@ to_etnaviv_domain(struct etnaviv_iommu_domain *domain) | |||
| 57 | return container_of(domain, struct etnaviv_iommuv2_domain, base); | 46 | return container_of(domain, struct etnaviv_iommuv2_domain, base); |
| 58 | } | 47 | } |
| 59 | 48 | ||
| 49 | static int | ||
| 50 | etnaviv_iommuv2_ensure_stlb(struct etnaviv_iommuv2_domain *etnaviv_domain, | ||
| 51 | int stlb) | ||
| 52 | { | ||
| 53 | if (etnaviv_domain->stlb_cpu[stlb]) | ||
| 54 | return 0; | ||
| 55 | |||
| 56 | etnaviv_domain->stlb_cpu[stlb] = | ||
| 57 | dma_alloc_wc(etnaviv_domain->base.dev, SZ_4K, | ||
| 58 | &etnaviv_domain->stlb_dma[stlb], | ||
| 59 | GFP_KERNEL); | ||
| 60 | |||
| 61 | if (!etnaviv_domain->stlb_cpu[stlb]) | ||
| 62 | return -ENOMEM; | ||
| 63 | |||
| 64 | memset32(etnaviv_domain->stlb_cpu[stlb], MMUv2_PTE_EXCEPTION, | ||
| 65 | SZ_4K / sizeof(u32)); | ||
| 66 | |||
| 67 | etnaviv_domain->mtlb_cpu[stlb] = etnaviv_domain->stlb_dma[stlb] | | ||
| 68 | MMUv2_PTE_PRESENT; | ||
| 69 | return 0; | ||
| 70 | } | ||
| 71 | |||
| 60 | static int etnaviv_iommuv2_map(struct etnaviv_iommu_domain *domain, | 72 | static int etnaviv_iommuv2_map(struct etnaviv_iommu_domain *domain, |
| 61 | unsigned long iova, phys_addr_t paddr, | 73 | unsigned long iova, phys_addr_t paddr, |
| 62 | size_t size, int prot) | 74 | size_t size, int prot) |
| 63 | { | 75 | { |
| 64 | struct etnaviv_iommuv2_domain *etnaviv_domain = | 76 | struct etnaviv_iommuv2_domain *etnaviv_domain = |
| 65 | to_etnaviv_domain(domain); | 77 | to_etnaviv_domain(domain); |
| 66 | int mtlb_entry, stlb_entry; | 78 | int mtlb_entry, stlb_entry, ret; |
| 67 | u32 entry = (u32)paddr | MMUv2_PTE_PRESENT; | 79 | u32 entry = lower_32_bits(paddr) | MMUv2_PTE_PRESENT; |
| 68 | 80 | ||
| 69 | if (size != SZ_4K) | 81 | if (size != SZ_4K) |
| 70 | return -EINVAL; | 82 | return -EINVAL; |
| 71 | 83 | ||
| 84 | if (IS_ENABLED(CONFIG_PHYS_ADDR_T_64BIT)) | ||
| 85 | entry |= (upper_32_bits(paddr) & 0xff) << 4; | ||
| 86 | |||
| 72 | if (prot & ETNAVIV_PROT_WRITE) | 87 | if (prot & ETNAVIV_PROT_WRITE) |
| 73 | entry |= MMUv2_PTE_WRITEABLE; | 88 | entry |= MMUv2_PTE_WRITEABLE; |
| 74 | 89 | ||
| 75 | mtlb_entry = (iova & MMUv2_MTLB_MASK) >> MMUv2_MTLB_SHIFT; | 90 | mtlb_entry = (iova & MMUv2_MTLB_MASK) >> MMUv2_MTLB_SHIFT; |
| 76 | stlb_entry = (iova & MMUv2_STLB_MASK) >> MMUv2_STLB_SHIFT; | 91 | stlb_entry = (iova & MMUv2_STLB_MASK) >> MMUv2_STLB_SHIFT; |
| 77 | 92 | ||
| 93 | ret = etnaviv_iommuv2_ensure_stlb(etnaviv_domain, mtlb_entry); | ||
| 94 | if (ret) | ||
| 95 | return ret; | ||
| 96 | |||
| 78 | etnaviv_domain->stlb_cpu[mtlb_entry][stlb_entry] = entry; | 97 | etnaviv_domain->stlb_cpu[mtlb_entry][stlb_entry] = entry; |
| 79 | 98 | ||
| 80 | return 0; | 99 | return 0; |
| @@ -101,14 +120,13 @@ static size_t etnaviv_iommuv2_unmap(struct etnaviv_iommu_domain *domain, | |||
| 101 | static int etnaviv_iommuv2_init(struct etnaviv_iommuv2_domain *etnaviv_domain) | 120 | static int etnaviv_iommuv2_init(struct etnaviv_iommuv2_domain *etnaviv_domain) |
| 102 | { | 121 | { |
| 103 | u32 *p; | 122 | u32 *p; |
| 104 | int ret, i, j; | 123 | int ret, i; |
| 105 | 124 | ||
| 106 | /* allocate scratch page */ | 125 | /* allocate scratch page */ |
| 107 | etnaviv_domain->base.bad_page_cpu = dma_alloc_coherent( | 126 | etnaviv_domain->base.bad_page_cpu = |
| 108 | etnaviv_domain->base.dev, | 127 | dma_alloc_wc(etnaviv_domain->base.dev, SZ_4K, |
| 109 | SZ_4K, | 128 | &etnaviv_domain->base.bad_page_dma, |
| 110 | &etnaviv_domain->base.bad_page_dma, | 129 | GFP_KERNEL); |
| 111 | GFP_KERNEL); | ||
| 112 | if (!etnaviv_domain->base.bad_page_cpu) { | 130 | if (!etnaviv_domain->base.bad_page_cpu) { |
| 113 | ret = -ENOMEM; | 131 | ret = -ENOMEM; |
| 114 | goto fail_mem; | 132 | goto fail_mem; |
| @@ -117,67 +135,40 @@ static int etnaviv_iommuv2_init(struct etnaviv_iommuv2_domain *etnaviv_domain) | |||
| 117 | for (i = 0; i < SZ_4K / 4; i++) | 135 | for (i = 0; i < SZ_4K / 4; i++) |
| 118 | *p++ = 0xdead55aa; | 136 | *p++ = 0xdead55aa; |
| 119 | 137 | ||
| 120 | etnaviv_domain->pta_cpu = dma_alloc_coherent(etnaviv_domain->base.dev, | 138 | etnaviv_domain->pta_cpu = dma_alloc_wc(etnaviv_domain->base.dev, |
| 121 | SZ_4K, | 139 | SZ_4K, &etnaviv_domain->pta_dma, |
| 122 | &etnaviv_domain->pta_dma, | 140 | GFP_KERNEL); |
| 123 | GFP_KERNEL); | ||
| 124 | if (!etnaviv_domain->pta_cpu) { | 141 | if (!etnaviv_domain->pta_cpu) { |
| 125 | ret = -ENOMEM; | 142 | ret = -ENOMEM; |
| 126 | goto fail_mem; | 143 | goto fail_mem; |
| 127 | } | 144 | } |
| 128 | 145 | ||
| 129 | etnaviv_domain->mtlb_cpu = dma_alloc_coherent(etnaviv_domain->base.dev, | 146 | etnaviv_domain->mtlb_cpu = dma_alloc_wc(etnaviv_domain->base.dev, |
| 130 | SZ_4K, | 147 | SZ_4K, &etnaviv_domain->mtlb_dma, |
| 131 | &etnaviv_domain->mtlb_dma, | 148 | GFP_KERNEL); |
| 132 | GFP_KERNEL); | ||
| 133 | if (!etnaviv_domain->mtlb_cpu) { | 149 | if (!etnaviv_domain->mtlb_cpu) { |
| 134 | ret = -ENOMEM; | 150 | ret = -ENOMEM; |
| 135 | goto fail_mem; | 151 | goto fail_mem; |
| 136 | } | 152 | } |
| 137 | 153 | ||
| 138 | /* pre-populate STLB pages (may want to switch to on-demand later) */ | 154 | memset32(etnaviv_domain->mtlb_cpu, MMUv2_PTE_EXCEPTION, |
| 139 | for (i = 0; i < MMUv2_MAX_STLB_ENTRIES; i++) { | 155 | MMUv2_MAX_STLB_ENTRIES); |
| 140 | etnaviv_domain->stlb_cpu[i] = | ||
| 141 | dma_alloc_coherent(etnaviv_domain->base.dev, | ||
| 142 | SZ_4K, | ||
| 143 | &etnaviv_domain->stlb_dma[i], | ||
| 144 | GFP_KERNEL); | ||
| 145 | if (!etnaviv_domain->stlb_cpu[i]) { | ||
| 146 | ret = -ENOMEM; | ||
| 147 | goto fail_mem; | ||
| 148 | } | ||
| 149 | p = etnaviv_domain->stlb_cpu[i]; | ||
| 150 | for (j = 0; j < SZ_4K / 4; j++) | ||
| 151 | *p++ = MMUv2_PTE_EXCEPTION; | ||
| 152 | |||
| 153 | etnaviv_domain->mtlb_cpu[i] = etnaviv_domain->stlb_dma[i] | | ||
| 154 | MMUv2_PTE_PRESENT; | ||
| 155 | } | ||
| 156 | 156 | ||
| 157 | return 0; | 157 | return 0; |
| 158 | 158 | ||
| 159 | fail_mem: | 159 | fail_mem: |
| 160 | if (etnaviv_domain->base.bad_page_cpu) | 160 | if (etnaviv_domain->base.bad_page_cpu) |
| 161 | dma_free_coherent(etnaviv_domain->base.dev, SZ_4K, | 161 | dma_free_wc(etnaviv_domain->base.dev, SZ_4K, |
| 162 | etnaviv_domain->base.bad_page_cpu, | 162 | etnaviv_domain->base.bad_page_cpu, |
| 163 | etnaviv_domain->base.bad_page_dma); | 163 | etnaviv_domain->base.bad_page_dma); |
| 164 | 164 | ||
| 165 | if (etnaviv_domain->pta_cpu) | 165 | if (etnaviv_domain->pta_cpu) |
| 166 | dma_free_coherent(etnaviv_domain->base.dev, SZ_4K, | 166 | dma_free_wc(etnaviv_domain->base.dev, SZ_4K, |
| 167 | etnaviv_domain->pta_cpu, | 167 | etnaviv_domain->pta_cpu, etnaviv_domain->pta_dma); |
| 168 | etnaviv_domain->pta_dma); | ||
| 169 | 168 | ||
| 170 | if (etnaviv_domain->mtlb_cpu) | 169 | if (etnaviv_domain->mtlb_cpu) |
| 171 | dma_free_coherent(etnaviv_domain->base.dev, SZ_4K, | 170 | dma_free_wc(etnaviv_domain->base.dev, SZ_4K, |
| 172 | etnaviv_domain->mtlb_cpu, | 171 | etnaviv_domain->mtlb_cpu, etnaviv_domain->mtlb_dma); |
| 173 | etnaviv_domain->mtlb_dma); | ||
| 174 | |||
| 175 | for (i = 0; i < MMUv2_MAX_STLB_ENTRIES; i++) { | ||
| 176 | if (etnaviv_domain->stlb_cpu[i]) | ||
| 177 | dma_free_coherent(etnaviv_domain->base.dev, SZ_4K, | ||
| 178 | etnaviv_domain->stlb_cpu[i], | ||
| 179 | etnaviv_domain->stlb_dma[i]); | ||
| 180 | } | ||
| 181 | 172 | ||
| 182 | return ret; | 173 | return ret; |
| 183 | } | 174 | } |
| @@ -188,23 +179,21 @@ static void etnaviv_iommuv2_domain_free(struct etnaviv_iommu_domain *domain) | |||
| 188 | to_etnaviv_domain(domain); | 179 | to_etnaviv_domain(domain); |
| 189 | int i; | 180 | int i; |
| 190 | 181 | ||
| 191 | dma_free_coherent(etnaviv_domain->base.dev, SZ_4K, | 182 | dma_free_wc(etnaviv_domain->base.dev, SZ_4K, |
| 192 | etnaviv_domain->base.bad_page_cpu, | 183 | etnaviv_domain->base.bad_page_cpu, |
| 193 | etnaviv_domain->base.bad_page_dma); | 184 | etnaviv_domain->base.bad_page_dma); |
| 194 | 185 | ||
| 195 | dma_free_coherent(etnaviv_domain->base.dev, SZ_4K, | 186 | dma_free_wc(etnaviv_domain->base.dev, SZ_4K, |
| 196 | etnaviv_domain->pta_cpu, | 187 | etnaviv_domain->pta_cpu, etnaviv_domain->pta_dma); |
| 197 | etnaviv_domain->pta_dma); | ||
| 198 | 188 | ||
| 199 | dma_free_coherent(etnaviv_domain->base.dev, SZ_4K, | 189 | dma_free_wc(etnaviv_domain->base.dev, SZ_4K, |
| 200 | etnaviv_domain->mtlb_cpu, | 190 | etnaviv_domain->mtlb_cpu, etnaviv_domain->mtlb_dma); |
| 201 | etnaviv_domain->mtlb_dma); | ||
| 202 | 191 | ||
| 203 | for (i = 0; i < MMUv2_MAX_STLB_ENTRIES; i++) { | 192 | for (i = 0; i < MMUv2_MAX_STLB_ENTRIES; i++) { |
| 204 | if (etnaviv_domain->stlb_cpu[i]) | 193 | if (etnaviv_domain->stlb_cpu[i]) |
| 205 | dma_free_coherent(etnaviv_domain->base.dev, SZ_4K, | 194 | dma_free_wc(etnaviv_domain->base.dev, SZ_4K, |
| 206 | etnaviv_domain->stlb_cpu[i], | 195 | etnaviv_domain->stlb_cpu[i], |
| 207 | etnaviv_domain->stlb_dma[i]); | 196 | etnaviv_domain->stlb_dma[i]); |
| 208 | } | 197 | } |
| 209 | 198 | ||
| 210 | vfree(etnaviv_domain); | 199 | vfree(etnaviv_domain); |
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_mmu.c b/drivers/gpu/drm/etnaviv/etnaviv_mmu.c index 49e049713a52..8069f9f36a2e 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_mmu.c +++ b/drivers/gpu/drm/etnaviv/etnaviv_mmu.c | |||
| @@ -1,17 +1,6 @@ | |||
| 1 | // SPDX-License-Identifier: GPL-2.0 | ||
| 1 | /* | 2 | /* |
| 2 | * Copyright (C) 2015 Etnaviv Project | 3 | * Copyright (C) 2015-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 | #include "common.xml.h" | 6 | #include "common.xml.h" |
| @@ -162,22 +151,10 @@ static int etnaviv_iommu_find_iova(struct etnaviv_iommu *mmu, | |||
| 162 | bool found; | 151 | bool found; |
| 163 | 152 | ||
| 164 | ret = drm_mm_insert_node_in_range(&mmu->mm, node, | 153 | ret = drm_mm_insert_node_in_range(&mmu->mm, node, |
| 165 | size, 0, 0, | 154 | size, 0, 0, 0, U64_MAX, mode); |
| 166 | mmu->last_iova, U64_MAX, | ||
| 167 | mode); | ||
| 168 | if (ret != -ENOSPC) | 155 | if (ret != -ENOSPC) |
| 169 | break; | 156 | break; |
| 170 | 157 | ||
| 171 | /* | ||
| 172 | * If we did not search from the start of the MMU region, | ||
| 173 | * try again in case there are free slots. | ||
| 174 | */ | ||
| 175 | if (mmu->last_iova) { | ||
| 176 | mmu->last_iova = 0; | ||
| 177 | mmu->need_flush = true; | ||
| 178 | continue; | ||
| 179 | } | ||
| 180 | |||
| 181 | /* Try to retire some entries */ | 158 | /* Try to retire some entries */ |
| 182 | drm_mm_scan_init(&scan, &mmu->mm, size, 0, 0, mode); | 159 | drm_mm_scan_init(&scan, &mmu->mm, size, 0, 0, mode); |
| 183 | 160 | ||
| @@ -274,7 +251,6 @@ int etnaviv_iommu_map_gem(struct etnaviv_iommu *mmu, | |||
| 274 | if (ret < 0) | 251 | if (ret < 0) |
| 275 | goto unlock; | 252 | goto unlock; |
| 276 | 253 | ||
| 277 | mmu->last_iova = node->start + etnaviv_obj->base.size; | ||
| 278 | mapping->iova = node->start; | 254 | mapping->iova = node->start; |
| 279 | ret = etnaviv_iommu_map(mmu, node->start, sgt, etnaviv_obj->base.size, | 255 | ret = etnaviv_iommu_map(mmu, node->start, sgt, etnaviv_obj->base.size, |
| 280 | ETNAVIV_PROT_READ | ETNAVIV_PROT_WRITE); | 256 | ETNAVIV_PROT_READ | ETNAVIV_PROT_WRITE); |
| @@ -381,7 +357,6 @@ int etnaviv_iommu_get_suballoc_va(struct etnaviv_gpu *gpu, dma_addr_t paddr, | |||
| 381 | mutex_unlock(&mmu->lock); | 357 | mutex_unlock(&mmu->lock); |
| 382 | return ret; | 358 | return ret; |
| 383 | } | 359 | } |
| 384 | mmu->last_iova = vram_node->start + size; | ||
| 385 | gpu->mmu->need_flush = true; | 360 | gpu->mmu->need_flush = true; |
| 386 | mutex_unlock(&mmu->lock); | 361 | mutex_unlock(&mmu->lock); |
| 387 | 362 | ||
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_mmu.h b/drivers/gpu/drm/etnaviv/etnaviv_mmu.h index ab603f5166b1..a0db17ffb686 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_mmu.h +++ b/drivers/gpu/drm/etnaviv/etnaviv_mmu.h | |||
| @@ -1,17 +1,6 @@ | |||
| 1 | /* SPDX-License-Identifier: GPL-2.0 */ | ||
| 1 | /* | 2 | /* |
| 2 | * Copyright (C) 2015 Etnaviv Project | 3 | * Copyright (C) 2015-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 | #ifndef __ETNAVIV_MMU_H__ | 6 | #ifndef __ETNAVIV_MMU_H__ |
| @@ -59,7 +48,6 @@ struct etnaviv_iommu { | |||
| 59 | struct mutex lock; | 48 | struct mutex lock; |
| 60 | struct list_head mappings; | 49 | struct list_head mappings; |
| 61 | struct drm_mm mm; | 50 | struct drm_mm mm; |
| 62 | u32 last_iova; | ||
| 63 | bool need_flush; | 51 | bool need_flush; |
| 64 | }; | 52 | }; |
| 65 | 53 | ||
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_perfmon.c b/drivers/gpu/drm/etnaviv/etnaviv_perfmon.c index 26dddfc41aac..9980d81a26e3 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_perfmon.c +++ b/drivers/gpu/drm/etnaviv/etnaviv_perfmon.c | |||
| @@ -1,18 +1,7 @@ | |||
| 1 | // SPDX-License-Identifier: GPL-2.0 | ||
| 1 | /* | 2 | /* |
| 2 | * Copyright (C) 2017 Etnaviv Project | 3 | * Copyright (C) 2017 Etnaviv Project |
| 3 | * Copyright (C) 2017 Zodiac Inflight Innovations | 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 | #include "etnaviv_gpu.h" | 7 | #include "etnaviv_gpu.h" |
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_perfmon.h b/drivers/gpu/drm/etnaviv/etnaviv_perfmon.h index c1653c64ab6b..4a9d508f6e10 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_perfmon.h +++ b/drivers/gpu/drm/etnaviv/etnaviv_perfmon.h | |||
| @@ -1,18 +1,7 @@ | |||
| 1 | /* SPDX-License-Identifier: GPL-2.0 */ | ||
| 1 | /* | 2 | /* |
| 2 | * Copyright (C) 2017 Etnaviv Project | 3 | * Copyright (C) 2017 Etnaviv Project |
| 3 | * Copyright (C) 2017 Zodiac Inflight Innovations | 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 | #ifndef __ETNAVIV_PERFMON_H__ | 7 | #ifndef __ETNAVIV_PERFMON_H__ |
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_sched.c b/drivers/gpu/drm/etnaviv/etnaviv_sched.c index 6cf0775dbcd7..a74eb57af15b 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_sched.c +++ b/drivers/gpu/drm/etnaviv/etnaviv_sched.c | |||
| @@ -1,17 +1,6 @@ | |||
| 1 | // SPDX-License-Identifier: GPL-2.0 | ||
| 1 | /* | 2 | /* |
| 2 | * Copyright (C) 2017 Etnaviv Project | 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 | #include <linux/kthread.h> | 6 | #include <linux/kthread.h> |
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_sched.h b/drivers/gpu/drm/etnaviv/etnaviv_sched.h index 097635fa78ae..c0a6796e22c9 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_sched.h +++ b/drivers/gpu/drm/etnaviv/etnaviv_sched.h | |||
| @@ -1,17 +1,6 @@ | |||
| 1 | /* SPDX-License-Identifier: GPL-2.0 */ | ||
| 1 | /* | 2 | /* |
| 2 | * Copyright (C) 2017 Etnaviv Project | 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 | #ifndef __ETNAVIV_SCHED_H__ | 6 | #ifndef __ETNAVIV_SCHED_H__ |
