Commit de04744d authored by Dave Airlie's avatar Dave Airlie

Merge tag 'drm-misc-next-fixes-2021-09-03' of...

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: default avatarDave Airlie <airlied@redhat.com>

From: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/41ff5e54-0837-2226-a182-97ffd11ef01e@linux.intel.com
parents 06b224d5 efcefc71
...@@ -37,7 +37,7 @@ TTM initialization ...@@ -37,7 +37,7 @@ TTM initialization
This section is outdated. This section is outdated.
Drivers wishing to support TTM must pass a filled :c:type:`ttm_bo_driver Drivers wishing to support TTM must pass a filled :c:type:`ttm_bo_driver
<ttm_bo_driver>` structure to ttm_bo_device_init, together with an <ttm_bo_driver>` structure to ttm_device_init, together with an
initialized global reference to the memory manager. The ttm_bo_driver initialized global reference to the memory manager. The ttm_bo_driver
structure contains several fields with function pointers for structure contains several fields with function pointers for
initializing the TTM, allocating and freeing memory, waiting for command initializing the TTM, allocating and freeing memory, waiting for command
......
...@@ -124,6 +124,7 @@ static int mgag200_pixpll_compute_g200se_00(struct mgag200_pll *pixpll, long clo ...@@ -124,6 +124,7 @@ static int mgag200_pixpll_compute_g200se_00(struct mgag200_pll *pixpll, long clo
unsigned int computed; unsigned int computed;
m = n = p = s = 0; m = n = p = s = 0;
delta = 0xffffffff;
permitteddelta = clock * 5 / 1000; permitteddelta = clock * 5 / 1000;
for (testp = 8; testp > 0; testp /= 2) { for (testp = 8; testp > 0; testp /= 2) {
......
...@@ -58,25 +58,16 @@ static int write_cmd(struct panfrost_device *pfdev, u32 as_nr, u32 cmd) ...@@ -58,25 +58,16 @@ static int write_cmd(struct panfrost_device *pfdev, u32 as_nr, u32 cmd)
} }
static void lock_region(struct panfrost_device *pfdev, u32 as_nr, static void lock_region(struct panfrost_device *pfdev, u32 as_nr,
u64 iova, size_t size) u64 iova, u64 size)
{ {
u8 region_width; u8 region_width;
u64 region = iova & PAGE_MASK; u64 region = iova & PAGE_MASK;
/*
* fls returns:
* 1 .. 32
*
* 10 + fls(num_pages)
* results in the range (11 .. 42)
*/
size = round_up(size, PAGE_SIZE);
region_width = 10 + fls(size >> PAGE_SHIFT); /* The size is encoded as ceil(log2) minus(1), which may be calculated
if ((size >> PAGE_SHIFT) != (1ul << (region_width - 11))) { * with fls. The size must be clamped to hardware bounds.
/* not pow2, so must go up to the next pow2 */ */
region_width += 1; size = max_t(u64, size, AS_LOCK_REGION_MIN_SIZE);
} region_width = fls64(size - 1) - 1;
region |= region_width; region |= region_width;
/* Lock the region that needs to be updated */ /* Lock the region that needs to be updated */
...@@ -87,7 +78,7 @@ static void lock_region(struct panfrost_device *pfdev, u32 as_nr, ...@@ -87,7 +78,7 @@ static void lock_region(struct panfrost_device *pfdev, u32 as_nr,
static int mmu_hw_do_operation_locked(struct panfrost_device *pfdev, int as_nr, static int mmu_hw_do_operation_locked(struct panfrost_device *pfdev, int as_nr,
u64 iova, size_t size, u32 op) u64 iova, u64 size, u32 op)
{ {
if (as_nr < 0) if (as_nr < 0)
return 0; return 0;
...@@ -104,7 +95,7 @@ static int mmu_hw_do_operation_locked(struct panfrost_device *pfdev, int as_nr, ...@@ -104,7 +95,7 @@ static int mmu_hw_do_operation_locked(struct panfrost_device *pfdev, int as_nr,
static int mmu_hw_do_operation(struct panfrost_device *pfdev, static int mmu_hw_do_operation(struct panfrost_device *pfdev,
struct panfrost_mmu *mmu, struct panfrost_mmu *mmu,
u64 iova, size_t size, u32 op) u64 iova, u64 size, u32 op)
{ {
int ret; int ret;
...@@ -121,7 +112,7 @@ static void panfrost_mmu_enable(struct panfrost_device *pfdev, struct panfrost_m ...@@ -121,7 +112,7 @@ static void panfrost_mmu_enable(struct panfrost_device *pfdev, struct panfrost_m
u64 transtab = cfg->arm_mali_lpae_cfg.transtab; u64 transtab = cfg->arm_mali_lpae_cfg.transtab;
u64 memattr = cfg->arm_mali_lpae_cfg.memattr; u64 memattr = cfg->arm_mali_lpae_cfg.memattr;
mmu_hw_do_operation_locked(pfdev, as_nr, 0, ~0UL, AS_COMMAND_FLUSH_MEM); mmu_hw_do_operation_locked(pfdev, as_nr, 0, ~0ULL, AS_COMMAND_FLUSH_MEM);
mmu_write(pfdev, AS_TRANSTAB_LO(as_nr), transtab & 0xffffffffUL); mmu_write(pfdev, AS_TRANSTAB_LO(as_nr), transtab & 0xffffffffUL);
mmu_write(pfdev, AS_TRANSTAB_HI(as_nr), transtab >> 32); 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 ...@@ -137,7 +128,7 @@ static void panfrost_mmu_enable(struct panfrost_device *pfdev, struct panfrost_m
static void panfrost_mmu_disable(struct panfrost_device *pfdev, u32 as_nr) static void panfrost_mmu_disable(struct panfrost_device *pfdev, u32 as_nr)
{ {
mmu_hw_do_operation_locked(pfdev, as_nr, 0, ~0UL, AS_COMMAND_FLUSH_MEM); mmu_hw_do_operation_locked(pfdev, as_nr, 0, ~0ULL, AS_COMMAND_FLUSH_MEM);
mmu_write(pfdev, AS_TRANSTAB_LO(as_nr), 0); mmu_write(pfdev, AS_TRANSTAB_LO(as_nr), 0);
mmu_write(pfdev, AS_TRANSTAB_HI(as_nr), 0); mmu_write(pfdev, AS_TRANSTAB_HI(as_nr), 0);
...@@ -251,7 +242,7 @@ static size_t get_pgsize(u64 addr, size_t size) ...@@ -251,7 +242,7 @@ static size_t get_pgsize(u64 addr, size_t size)
static void panfrost_mmu_flush_range(struct panfrost_device *pfdev, static void panfrost_mmu_flush_range(struct panfrost_device *pfdev,
struct panfrost_mmu *mmu, struct panfrost_mmu *mmu,
u64 iova, size_t size) u64 iova, u64 size)
{ {
if (mmu->as < 0) if (mmu->as < 0)
return; return;
......
...@@ -316,6 +316,8 @@ ...@@ -316,6 +316,8 @@
#define AS_FAULTSTATUS_ACCESS_TYPE_READ (0x2 << 8) #define AS_FAULTSTATUS_ACCESS_TYPE_READ (0x2 << 8)
#define AS_FAULTSTATUS_ACCESS_TYPE_WRITE (0x3 << 8) #define AS_FAULTSTATUS_ACCESS_TYPE_WRITE (0x3 << 8)
#define AS_LOCK_REGION_MIN_SIZE (1ULL << 15)
#define gpu_write(dev, reg, data) writel(data, dev->iomem + reg) #define gpu_write(dev, reg, data) writel(data, dev->iomem + reg)
#define gpu_read(dev, reg) readl(dev->iomem + reg) #define gpu_read(dev, reg) readl(dev->iomem + reg)
......
...@@ -143,7 +143,6 @@ int ttm_bo_move_memcpy(struct ttm_buffer_object *bo, ...@@ -143,7 +143,6 @@ int ttm_bo_move_memcpy(struct ttm_buffer_object *bo,
struct ttm_resource *src_mem = bo->resource; struct ttm_resource *src_mem = bo->resource;
struct ttm_resource_manager *src_man = struct ttm_resource_manager *src_man =
ttm_manager_type(bdev, src_mem->mem_type); ttm_manager_type(bdev, src_mem->mem_type);
struct ttm_resource src_copy = *src_mem;
union { union {
struct ttm_kmap_iter_tt tt; struct ttm_kmap_iter_tt tt;
struct ttm_kmap_iter_linear_io io; struct ttm_kmap_iter_linear_io io;
...@@ -173,11 +172,11 @@ int ttm_bo_move_memcpy(struct ttm_buffer_object *bo, ...@@ -173,11 +172,11 @@ int ttm_bo_move_memcpy(struct ttm_buffer_object *bo,
} }
ttm_move_memcpy(bo, dst_mem->num_pages, dst_iter, src_iter); ttm_move_memcpy(bo, dst_mem->num_pages, dst_iter, src_iter);
src_copy = *src_mem;
ttm_bo_move_sync_cleanup(bo, dst_mem);
if (!src_iter->ops->maps_tt) if (!src_iter->ops->maps_tt)
ttm_kmap_iter_linear_io_fini(&_src_iter.io, bdev, &src_copy); ttm_kmap_iter_linear_io_fini(&_src_iter.io, bdev, src_mem);
ttm_bo_move_sync_cleanup(bo, dst_mem);
out_src_iter: out_src_iter:
if (!dst_iter->ops->maps_tt) if (!dst_iter->ops->maps_tt)
ttm_kmap_iter_linear_io_fini(&_dst_iter.io, bdev, dst_mem); ttm_kmap_iter_linear_io_fini(&_dst_iter.io, bdev, dst_mem);
......
...@@ -32,7 +32,6 @@ ...@@ -32,7 +32,6 @@
#define pr_fmt(fmt) "[TTM] " fmt #define pr_fmt(fmt) "[TTM] " fmt
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/pagemap.h>
#include <linux/shmem_fs.h> #include <linux/shmem_fs.h>
#include <linux/file.h> #include <linux/file.h>
#include <drm/drm_cache.h> #include <drm/drm_cache.h>
......
...@@ -1462,7 +1462,7 @@ static const struct hdmi_codec_ops vc4_hdmi_codec_ops = { ...@@ -1462,7 +1462,7 @@ static const struct hdmi_codec_ops vc4_hdmi_codec_ops = {
.audio_startup = vc4_hdmi_audio_startup, .audio_startup = vc4_hdmi_audio_startup,
}; };
struct hdmi_codec_pdata vc4_hdmi_codec_pdata = { static struct hdmi_codec_pdata vc4_hdmi_codec_pdata = {
.ops = &vc4_hdmi_codec_ops, .ops = &vc4_hdmi_codec_ops,
.max_i2s_channels = 8, .max_i2s_channels = 8,
.i2s = 1, .i2s = 1,
......
...@@ -27,11 +27,12 @@ ...@@ -27,11 +27,12 @@
#ifndef _TTM_TT_H_ #ifndef _TTM_TT_H_
#define _TTM_TT_H_ #define _TTM_TT_H_
#include <linux/pagemap.h>
#include <linux/types.h> #include <linux/types.h>
#include <drm/ttm/ttm_caching.h> #include <drm/ttm/ttm_caching.h>
#include <drm/ttm/ttm_kmap_iter.h> #include <drm/ttm/ttm_kmap_iter.h>
struct ttm_bo_device; struct ttm_device;
struct ttm_tt; struct ttm_tt;
struct ttm_resource; struct ttm_resource;
struct ttm_buffer_object; struct ttm_buffer_object;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment