Commit 63db15fe authored by Jani Nikula's avatar Jani Nikula
Browse files

drm/i915/display: add intel_bo_read_from_page() and use it



Add an interface based on struct drm_gem_object, and use it. Move the xe
implementation to the intel_bo abstraction layer.

Reviewed-by: default avatarMaarten Lankhorst <maarten.lankhorst@linux.intel.com>
Acked-by: default avatarRodrigo Vivi <rodrigo.vivi@intel.com>
Signed-off-by: default avatarJani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/45fcd209221a7b2ada5a243d95b8953237471e52.1726589119.git.jani.nikula@intel.com
parent 4b4836d2
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -34,3 +34,8 @@ int intel_bo_fb_mmap(struct drm_gem_object *obj, struct vm_area_struct *vma)
{
	return i915_gem_fb_mmap(to_intel_bo(obj), vma);
}

int intel_bo_read_from_page(struct drm_gem_object *obj, u64 offset, void *dst, int size)
{
	return i915_gem_object_read_from_page(to_intel_bo(obj), offset, dst, size);
}
+1 −0
Original line number Diff line number Diff line
@@ -15,5 +15,6 @@ bool intel_bo_is_shmem(struct drm_gem_object *obj);
bool intel_bo_is_protected(struct drm_gem_object *obj);
void intel_bo_flush_if_display(struct drm_gem_object *obj);
int intel_bo_fb_mmap(struct drm_gem_object *obj, struct vm_area_struct *vma);
int intel_bo_read_from_page(struct drm_gem_object *obj, u64 offset, void *dst, int size);

#endif /* __INTEL_BO__ */
+5 −7
Original line number Diff line number Diff line
@@ -45,9 +45,6 @@
#include <drm/drm_rect.h>
#include <drm/drm_vblank.h>

#include "gem/i915_gem_lmem.h"
#include "gem/i915_gem_object.h"

#include "g4x_dp.h"
#include "g4x_hdmi.h"
#include "hsw_ips.h"
@@ -61,6 +58,7 @@
#include "intel_atomic.h"
#include "intel_atomic_plane.h"
#include "intel_audio.h"
#include "intel_bo.h"
#include "intel_bw.h"
#include "intel_cdclk.h"
#include "intel_clock_gating.h"
@@ -7375,7 +7373,7 @@ static void intel_atomic_prepare_plane_clear_colors(struct intel_atomic_state *s
		 * caller made sure that the object is synced wrt. the related color clear value
		 * GPU write on it.
		 */
		ret = i915_gem_object_read_from_page(intel_fb_obj(fb),
		ret = intel_bo_read_from_page(intel_fb_bo(fb),
					      fb->offsets[cc_plane] + 16,
					      &plane_state->ccval,
					      sizeof(plane_state->ccval));
+0 −30
Original line number Diff line number Diff line
@@ -31,34 +31,4 @@ static inline bool i915_gem_object_is_userptr(const struct xe_bo *bo)
	return false;
}

static inline int i915_gem_object_read_from_page(struct xe_bo *bo,
					  u32 ofs, u64 *ptr, u32 size)
{
	struct ttm_bo_kmap_obj map;
	void *src;
	bool is_iomem;
	int ret;

	ret = xe_bo_lock(bo, true);
	if (ret)
		return ret;

	ret = ttm_bo_kmap(&bo->ttm, ofs >> PAGE_SHIFT, 1, &map);
	if (ret)
		goto out_unlock;

	ofs &= ~PAGE_MASK;
	src = ttm_kmap_obj_virtual(&map, &is_iomem);
	src += ofs;
	if (is_iomem)
		memcpy_fromio(ptr, (void __iomem *)src, size);
	else
		memcpy(ptr, src, size);

	ttm_bo_kunmap(&map);
out_unlock:
	xe_bo_unlock(bo);
	return ret;
}

#endif
+30 −0
Original line number Diff line number Diff line
@@ -36,3 +36,33 @@ int intel_bo_fb_mmap(struct drm_gem_object *obj, struct vm_area_struct *vma)
{
	return drm_gem_prime_mmap(obj, vma);
}

int intel_bo_read_from_page(struct drm_gem_object *obj, u64 offset, void *dst, int size)
{
	struct xe_bo *bo = gem_to_xe_bo(obj);
	struct ttm_bo_kmap_obj map;
	void *src;
	bool is_iomem;
	int ret;

	ret = xe_bo_lock(bo, true);
	if (ret)
		return ret;

	ret = ttm_bo_kmap(&bo->ttm, offset >> PAGE_SHIFT, 1, &map);
	if (ret)
		goto out_unlock;

	offset &= ~PAGE_MASK;
	src = ttm_kmap_obj_virtual(&map, &is_iomem);
	src += offset;
	if (is_iomem)
		memcpy_fromio(dst, (void __iomem *)src, size);
	else
		memcpy(dst, src, size);

	ttm_bo_kunmap(&map);
out_unlock:
	xe_bo_unlock(bo);
	return ret;
}