Skip to content

Commit de04744

Browse files
committed
Merge tag 'drm-misc-next-fixes-2021-09-03' of git://anongit.freedesktop.org/drm/drm-misc into drm-next
drm-misc-next-fixes for v5.15: - Fix ttm_bo_move_memcpy() when ttm_resource is subclassed. - Small fixes to panfrost, mgag200, vc4. - Small ttm compilation fixes. Signed-off-by: Dave Airlie <[email protected]> From: Maarten Lankhorst <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2 parents 06b224d + efcefc7 commit de04744

File tree

8 files changed

+21
-28
lines changed

8 files changed

+21
-28
lines changed

Documentation/gpu/drm-mm.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ TTM initialization
3737
This section is outdated.
3838

3939
Drivers wishing to support TTM must pass a filled :c:type:`ttm_bo_driver
40-
<ttm_bo_driver>` structure to ttm_bo_device_init, together with an
40+
<ttm_bo_driver>` structure to ttm_device_init, together with an
4141
initialized global reference to the memory manager. The ttm_bo_driver
4242
structure contains several fields with function pointers for
4343
initializing the TTM, allocating and freeing memory, waiting for command

drivers/gpu/drm/mgag200/mgag200_pll.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ static int mgag200_pixpll_compute_g200se_00(struct mgag200_pll *pixpll, long clo
124124
unsigned int computed;
125125

126126
m = n = p = s = 0;
127+
delta = 0xffffffff;
127128
permitteddelta = clock * 5 / 1000;
128129

129130
for (testp = 8; testp > 0; testp /= 2) {

drivers/gpu/drm/panfrost/panfrost_mmu.c

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -58,25 +58,16 @@ static int write_cmd(struct panfrost_device *pfdev, u32 as_nr, u32 cmd)
5858
}
5959

6060
static void lock_region(struct panfrost_device *pfdev, u32 as_nr,
61-
u64 iova, size_t size)
61+
u64 iova, u64 size)
6262
{
6363
u8 region_width;
6464
u64 region = iova & PAGE_MASK;
65-
/*
66-
* fls returns:
67-
* 1 .. 32
68-
*
69-
* 10 + fls(num_pages)
70-
* results in the range (11 .. 42)
71-
*/
72-
73-
size = round_up(size, PAGE_SIZE);
7465

75-
region_width = 10 + fls(size >> PAGE_SHIFT);
76-
if ((size >> PAGE_SHIFT) != (1ul << (region_width - 11))) {
77-
/* not pow2, so must go up to the next pow2 */
78-
region_width += 1;
79-
}
66+
/* The size is encoded as ceil(log2) minus(1), which may be calculated
67+
* with fls. The size must be clamped to hardware bounds.
68+
*/
69+
size = max_t(u64, size, AS_LOCK_REGION_MIN_SIZE);
70+
region_width = fls64(size - 1) - 1;
8071
region |= region_width;
8172

8273
/* Lock the region that needs to be updated */
@@ -87,7 +78,7 @@ static void lock_region(struct panfrost_device *pfdev, u32 as_nr,
8778

8879

8980
static int mmu_hw_do_operation_locked(struct panfrost_device *pfdev, int as_nr,
90-
u64 iova, size_t size, u32 op)
81+
u64 iova, u64 size, u32 op)
9182
{
9283
if (as_nr < 0)
9384
return 0;
@@ -104,7 +95,7 @@ static int mmu_hw_do_operation_locked(struct panfrost_device *pfdev, int as_nr,
10495

10596
static int mmu_hw_do_operation(struct panfrost_device *pfdev,
10697
struct panfrost_mmu *mmu,
107-
u64 iova, size_t size, u32 op)
98+
u64 iova, u64 size, u32 op)
10899
{
109100
int ret;
110101

@@ -121,7 +112,7 @@ static void panfrost_mmu_enable(struct panfrost_device *pfdev, struct panfrost_m
121112
u64 transtab = cfg->arm_mali_lpae_cfg.transtab;
122113
u64 memattr = cfg->arm_mali_lpae_cfg.memattr;
123114

124-
mmu_hw_do_operation_locked(pfdev, as_nr, 0, ~0UL, AS_COMMAND_FLUSH_MEM);
115+
mmu_hw_do_operation_locked(pfdev, as_nr, 0, ~0ULL, AS_COMMAND_FLUSH_MEM);
125116

126117
mmu_write(pfdev, AS_TRANSTAB_LO(as_nr), transtab & 0xffffffffUL);
127118
mmu_write(pfdev, AS_TRANSTAB_HI(as_nr), transtab >> 32);
@@ -137,7 +128,7 @@ static void panfrost_mmu_enable(struct panfrost_device *pfdev, struct panfrost_m
137128

138129
static void panfrost_mmu_disable(struct panfrost_device *pfdev, u32 as_nr)
139130
{
140-
mmu_hw_do_operation_locked(pfdev, as_nr, 0, ~0UL, AS_COMMAND_FLUSH_MEM);
131+
mmu_hw_do_operation_locked(pfdev, as_nr, 0, ~0ULL, AS_COMMAND_FLUSH_MEM);
141132

142133
mmu_write(pfdev, AS_TRANSTAB_LO(as_nr), 0);
143134
mmu_write(pfdev, AS_TRANSTAB_HI(as_nr), 0);
@@ -251,7 +242,7 @@ static size_t get_pgsize(u64 addr, size_t size)
251242

252243
static void panfrost_mmu_flush_range(struct panfrost_device *pfdev,
253244
struct panfrost_mmu *mmu,
254-
u64 iova, size_t size)
245+
u64 iova, u64 size)
255246
{
256247
if (mmu->as < 0)
257248
return;

drivers/gpu/drm/panfrost/panfrost_regs.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,8 @@
316316
#define AS_FAULTSTATUS_ACCESS_TYPE_READ (0x2 << 8)
317317
#define AS_FAULTSTATUS_ACCESS_TYPE_WRITE (0x3 << 8)
318318

319+
#define AS_LOCK_REGION_MIN_SIZE (1ULL << 15)
320+
319321
#define gpu_write(dev, reg, data) writel(data, dev->iomem + reg)
320322
#define gpu_read(dev, reg) readl(dev->iomem + reg)
321323

drivers/gpu/drm/ttm/ttm_bo_util.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,6 @@ int ttm_bo_move_memcpy(struct ttm_buffer_object *bo,
143143
struct ttm_resource *src_mem = bo->resource;
144144
struct ttm_resource_manager *src_man =
145145
ttm_manager_type(bdev, src_mem->mem_type);
146-
struct ttm_resource src_copy = *src_mem;
147146
union {
148147
struct ttm_kmap_iter_tt tt;
149148
struct ttm_kmap_iter_linear_io io;
@@ -173,11 +172,11 @@ int ttm_bo_move_memcpy(struct ttm_buffer_object *bo,
173172
}
174173

175174
ttm_move_memcpy(bo, dst_mem->num_pages, dst_iter, src_iter);
176-
src_copy = *src_mem;
177-
ttm_bo_move_sync_cleanup(bo, dst_mem);
178175

179176
if (!src_iter->ops->maps_tt)
180-
ttm_kmap_iter_linear_io_fini(&_src_iter.io, bdev, &src_copy);
177+
ttm_kmap_iter_linear_io_fini(&_src_iter.io, bdev, src_mem);
178+
ttm_bo_move_sync_cleanup(bo, dst_mem);
179+
181180
out_src_iter:
182181
if (!dst_iter->ops->maps_tt)
183182
ttm_kmap_iter_linear_io_fini(&_dst_iter.io, bdev, dst_mem);

drivers/gpu/drm/ttm/ttm_tt.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
#define pr_fmt(fmt) "[TTM] " fmt
3333

3434
#include <linux/sched.h>
35-
#include <linux/pagemap.h>
3635
#include <linux/shmem_fs.h>
3736
#include <linux/file.h>
3837
#include <drm/drm_cache.h>

drivers/gpu/drm/vc4/vc4_hdmi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1462,7 +1462,7 @@ static const struct hdmi_codec_ops vc4_hdmi_codec_ops = {
14621462
.audio_startup = vc4_hdmi_audio_startup,
14631463
};
14641464

1465-
struct hdmi_codec_pdata vc4_hdmi_codec_pdata = {
1465+
static struct hdmi_codec_pdata vc4_hdmi_codec_pdata = {
14661466
.ops = &vc4_hdmi_codec_ops,
14671467
.max_i2s_channels = 8,
14681468
.i2s = 1,

include/drm/ttm/ttm_tt.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,12 @@
2727
#ifndef _TTM_TT_H_
2828
#define _TTM_TT_H_
2929

30+
#include <linux/pagemap.h>
3031
#include <linux/types.h>
3132
#include <drm/ttm/ttm_caching.h>
3233
#include <drm/ttm/ttm_kmap_iter.h>
3334

34-
struct ttm_bo_device;
35+
struct ttm_device;
3536
struct ttm_tt;
3637
struct ttm_resource;
3738
struct ttm_buffer_object;

0 commit comments

Comments
 (0)