mirror of
https://github.com/torvalds/linux.git
synced 2026-05-31 02:24:24 +02:00
drm/i915/dpt: pass opaque struct intel_dpt around instead of i915_address_space
struct i915_address_space is used in an opaque fashion in the display parent interface, but it's just one include away from being non-opaque. And anyway the name is rather specific. Switch to using the struct intel_dpt instead, which embeds struct i915_address_space anyway. With the definition hidden in i915_dpt.c, this can't be accidentally made non-opaque, and the type seems rather more generic anyway. We do have to add a new helper i915_dpt_to_vm(), as there's one case in intel_fb_pin_to_dpt() that requires direct access to struct i915_address_space. But this just underlines the point about opacity. Reviewed-by: Juha-Pekka Heikkila <juhapekka.heikkila@gmail.com> Link: https://patch.msgid.link/daa39178c0b0305b010564952d691f06e3cd63ca.1772030909.git.jani.nikula@intel.com Signed-off-by: Jani Nikula <jani.nikula@intel.com>
This commit is contained in:
parent
a8ea895d34
commit
4226479f91
|
|
@ -145,7 +145,7 @@ struct intel_framebuffer {
|
|||
struct intel_fb_view remapped_view;
|
||||
};
|
||||
|
||||
struct i915_address_space *dpt_vm;
|
||||
struct intel_dpt *dpt;
|
||||
|
||||
unsigned int min_alignment;
|
||||
unsigned int vtd_guard;
|
||||
|
|
|
|||
|
|
@ -57,8 +57,8 @@ void intel_dpt_suspend(struct intel_display *display)
|
|||
drm_for_each_fb(drm_fb, display->drm) {
|
||||
struct intel_framebuffer *fb = to_intel_framebuffer(drm_fb);
|
||||
|
||||
if (fb->dpt_vm)
|
||||
intel_parent_dpt_suspend(display, fb->dpt_vm);
|
||||
if (fb->dpt)
|
||||
intel_parent_dpt_suspend(display, fb->dpt);
|
||||
}
|
||||
|
||||
mutex_unlock(&display->drm->mode_config.fb_lock);
|
||||
|
|
@ -87,8 +87,8 @@ void intel_dpt_resume(struct intel_display *display)
|
|||
drm_for_each_fb(drm_fb, display->drm) {
|
||||
struct intel_framebuffer *fb = to_intel_framebuffer(drm_fb);
|
||||
|
||||
if (fb->dpt_vm)
|
||||
intel_parent_dpt_resume(display, fb->dpt_vm);
|
||||
if (fb->dpt)
|
||||
intel_parent_dpt_resume(display, fb->dpt);
|
||||
}
|
||||
mutex_unlock(&display->drm->mode_config.fb_lock);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2109,7 +2109,7 @@ static void intel_user_framebuffer_destroy(struct drm_framebuffer *fb)
|
|||
drm_framebuffer_cleanup(fb);
|
||||
|
||||
if (intel_fb_uses_dpt(fb))
|
||||
intel_parent_dpt_destroy(display, intel_fb->dpt_vm);
|
||||
intel_parent_dpt_destroy(display, intel_fb->dpt);
|
||||
|
||||
intel_fb_bo_framebuffer_fini(intel_fb_bo(fb));
|
||||
|
||||
|
|
@ -2305,20 +2305,20 @@ int intel_framebuffer_init(struct intel_framebuffer *intel_fb,
|
|||
|
||||
if (intel_fb_uses_dpt(fb)) {
|
||||
struct drm_gem_object *obj = intel_fb_bo(&intel_fb->base);
|
||||
struct i915_address_space *vm;
|
||||
struct intel_dpt *dpt;
|
||||
size_t size = 0;
|
||||
|
||||
if (intel_fb_needs_pot_stride_remap(intel_fb))
|
||||
size = intel_remapped_info_size(&intel_fb->remapped_view.gtt.remapped);
|
||||
|
||||
vm = intel_parent_dpt_create(display, obj, size);
|
||||
if (IS_ERR(vm)) {
|
||||
dpt = intel_parent_dpt_create(display, obj, size);
|
||||
if (IS_ERR(dpt)) {
|
||||
drm_dbg_kms(display->drm, "failed to create DPT\n");
|
||||
ret = PTR_ERR(vm);
|
||||
ret = PTR_ERR(dpt);
|
||||
goto err_frontbuffer_put;
|
||||
}
|
||||
|
||||
intel_fb->dpt_vm = vm;
|
||||
intel_fb->dpt = dpt;
|
||||
}
|
||||
|
||||
ret = drm_framebuffer_init(display->drm, fb, &intel_fb_funcs);
|
||||
|
|
@ -2331,7 +2331,7 @@ int intel_framebuffer_init(struct intel_framebuffer *intel_fb,
|
|||
|
||||
err_free_dpt:
|
||||
if (intel_fb_uses_dpt(fb))
|
||||
intel_parent_dpt_destroy(display, intel_fb->dpt_vm);
|
||||
intel_parent_dpt_destroy(display, intel_fb->dpt);
|
||||
err_bo_framebuffer_fini:
|
||||
intel_fb_bo_framebuffer_fini(obj);
|
||||
err_frontbuffer_put:
|
||||
|
|
|
|||
|
|
@ -27,13 +27,14 @@ intel_fb_pin_to_dpt(const struct drm_framebuffer *fb,
|
|||
const struct i915_gtt_view *view,
|
||||
unsigned int alignment,
|
||||
unsigned long *out_flags,
|
||||
struct i915_address_space *vm)
|
||||
struct intel_dpt *dpt)
|
||||
{
|
||||
struct drm_device *dev = fb->dev;
|
||||
struct intel_display *display = to_intel_display(dev);
|
||||
struct drm_i915_private *dev_priv = to_i915(dev);
|
||||
struct drm_gem_object *_obj = intel_fb_bo(fb);
|
||||
struct drm_i915_gem_object *obj = to_intel_bo(_obj);
|
||||
struct i915_address_space *vm = i915_dpt_to_vm(dpt);
|
||||
struct i915_gem_ww_ctx ww;
|
||||
struct i915_vma *vma;
|
||||
int ret;
|
||||
|
|
@ -284,7 +285,7 @@ int intel_plane_pin_fb(struct intel_plane_state *plane_state,
|
|||
} else {
|
||||
unsigned int alignment = intel_plane_fb_min_alignment(plane_state);
|
||||
|
||||
vma = i915_dpt_pin_to_ggtt(fb->dpt_vm, alignment / 512);
|
||||
vma = i915_dpt_pin_to_ggtt(fb->dpt, alignment / 512);
|
||||
if (IS_ERR(vma))
|
||||
return PTR_ERR(vma);
|
||||
|
||||
|
|
@ -292,9 +293,9 @@ int intel_plane_pin_fb(struct intel_plane_state *plane_state,
|
|||
|
||||
vma = intel_fb_pin_to_dpt(&fb->base, &plane_state->view.gtt,
|
||||
alignment, &plane_state->flags,
|
||||
fb->dpt_vm);
|
||||
fb->dpt);
|
||||
if (IS_ERR(vma)) {
|
||||
i915_dpt_unpin_from_ggtt(fb->dpt_vm);
|
||||
i915_dpt_unpin_from_ggtt(fb->dpt);
|
||||
plane_state->ggtt_vma = NULL;
|
||||
return PTR_ERR(vma);
|
||||
}
|
||||
|
|
@ -346,7 +347,7 @@ void intel_plane_unpin_fb(struct intel_plane_state *old_plane_state)
|
|||
|
||||
vma = fetch_and_zero(&old_plane_state->ggtt_vma);
|
||||
if (vma)
|
||||
i915_dpt_unpin_from_ggtt(fb->dpt_vm);
|
||||
i915_dpt_unpin_from_ggtt(fb->dpt);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,9 +24,8 @@
|
|||
#include "intel_parent.h"
|
||||
|
||||
/* dpt */
|
||||
struct i915_address_space *intel_parent_dpt_create(struct intel_display *display,
|
||||
struct drm_gem_object *obj,
|
||||
size_t size)
|
||||
struct intel_dpt *intel_parent_dpt_create(struct intel_display *display,
|
||||
struct drm_gem_object *obj, size_t size)
|
||||
{
|
||||
if (display->parent->dpt)
|
||||
return display->parent->dpt->create(obj, size);
|
||||
|
|
@ -34,22 +33,22 @@ struct i915_address_space *intel_parent_dpt_create(struct intel_display *display
|
|||
return NULL;
|
||||
}
|
||||
|
||||
void intel_parent_dpt_destroy(struct intel_display *display, struct i915_address_space *vm)
|
||||
void intel_parent_dpt_destroy(struct intel_display *display, struct intel_dpt *dpt)
|
||||
{
|
||||
if (display->parent->dpt)
|
||||
display->parent->dpt->destroy(vm);
|
||||
display->parent->dpt->destroy(dpt);
|
||||
}
|
||||
|
||||
void intel_parent_dpt_suspend(struct intel_display *display, struct i915_address_space *vm)
|
||||
void intel_parent_dpt_suspend(struct intel_display *display, struct intel_dpt *dpt)
|
||||
{
|
||||
if (display->parent->dpt)
|
||||
display->parent->dpt->suspend(vm);
|
||||
display->parent->dpt->suspend(dpt);
|
||||
}
|
||||
|
||||
void intel_parent_dpt_resume(struct intel_display *display, struct i915_address_space *vm)
|
||||
void intel_parent_dpt_resume(struct intel_display *display, struct intel_dpt *dpt)
|
||||
{
|
||||
if (display->parent->dpt)
|
||||
display->parent->dpt->resume(vm);
|
||||
display->parent->dpt->resume(dpt);
|
||||
}
|
||||
|
||||
/* hdcp */
|
||||
|
|
|
|||
|
|
@ -9,19 +9,18 @@
|
|||
struct dma_fence;
|
||||
struct drm_gem_object;
|
||||
struct drm_scanout_buffer;
|
||||
struct i915_address_space;
|
||||
struct intel_display;
|
||||
struct intel_dpt;
|
||||
struct intel_hdcp_gsc_context;
|
||||
struct intel_panic;
|
||||
struct intel_stolen_node;
|
||||
|
||||
/* dpt */
|
||||
struct i915_address_space *intel_parent_dpt_create(struct intel_display *display,
|
||||
struct drm_gem_object *obj,
|
||||
size_t size);
|
||||
void intel_parent_dpt_destroy(struct intel_display *display, struct i915_address_space *vm);
|
||||
void intel_parent_dpt_suspend(struct intel_display *display, struct i915_address_space *vm);
|
||||
void intel_parent_dpt_resume(struct intel_display *display, struct i915_address_space *vm);
|
||||
struct intel_dpt *intel_parent_dpt_create(struct intel_display *display,
|
||||
struct drm_gem_object *obj, size_t size);
|
||||
void intel_parent_dpt_destroy(struct intel_display *display, struct intel_dpt *dpt);
|
||||
void intel_parent_dpt_suspend(struct intel_display *display, struct intel_dpt *dpt);
|
||||
void intel_parent_dpt_resume(struct intel_display *display, struct intel_dpt *dpt);
|
||||
|
||||
/* hdcp */
|
||||
ssize_t intel_parent_hdcp_gsc_msg_send(struct intel_display *display,
|
||||
|
|
|
|||
|
|
@ -33,6 +33,11 @@ i915_vm_to_dpt(struct i915_address_space *vm)
|
|||
return container_of(vm, struct intel_dpt, vm);
|
||||
}
|
||||
|
||||
struct i915_address_space *i915_dpt_to_vm(struct intel_dpt *dpt)
|
||||
{
|
||||
return &dpt->vm;
|
||||
}
|
||||
|
||||
static void gen8_set_pte(void __iomem *addr, gen8_pte_t pte)
|
||||
{
|
||||
writeq(pte, addr);
|
||||
|
|
@ -121,11 +126,10 @@ static void dpt_cleanup(struct i915_address_space *vm)
|
|||
i915_gem_object_put(dpt->obj);
|
||||
}
|
||||
|
||||
struct i915_vma *i915_dpt_pin_to_ggtt(struct i915_address_space *vm, unsigned int alignment)
|
||||
struct i915_vma *i915_dpt_pin_to_ggtt(struct intel_dpt *dpt, unsigned int alignment)
|
||||
{
|
||||
struct drm_i915_private *i915 = vm->i915;
|
||||
struct drm_i915_private *i915 = dpt->vm.i915;
|
||||
struct intel_display *display = i915->display;
|
||||
struct intel_dpt *dpt = i915_vm_to_dpt(vm);
|
||||
struct ref_tracker *wakeref;
|
||||
struct i915_vma *vma;
|
||||
void __iomem *iomem;
|
||||
|
|
@ -173,15 +177,13 @@ struct i915_vma *i915_dpt_pin_to_ggtt(struct i915_address_space *vm, unsigned in
|
|||
return err ? ERR_PTR(err) : vma;
|
||||
}
|
||||
|
||||
void i915_dpt_unpin_from_ggtt(struct i915_address_space *vm)
|
||||
void i915_dpt_unpin_from_ggtt(struct intel_dpt *dpt)
|
||||
{
|
||||
struct intel_dpt *dpt = i915_vm_to_dpt(vm);
|
||||
|
||||
i915_vma_unpin_iomap(dpt->vma);
|
||||
i915_vma_put(dpt->vma);
|
||||
}
|
||||
|
||||
static struct i915_address_space *i915_dpt_create(struct drm_gem_object *obj, size_t size)
|
||||
static struct intel_dpt *i915_dpt_create(struct drm_gem_object *obj, size_t size)
|
||||
{
|
||||
struct drm_i915_private *i915 = to_i915(obj->dev);
|
||||
struct drm_i915_gem_object *dpt_obj;
|
||||
|
|
@ -243,25 +245,23 @@ static struct i915_address_space *i915_dpt_create(struct drm_gem_object *obj, si
|
|||
dpt->obj = dpt_obj;
|
||||
dpt->obj->is_dpt = true;
|
||||
|
||||
return &dpt->vm;
|
||||
return dpt;
|
||||
}
|
||||
|
||||
static void i915_dpt_destroy(struct i915_address_space *vm)
|
||||
static void i915_dpt_destroy(struct intel_dpt *dpt)
|
||||
{
|
||||
struct intel_dpt *dpt = i915_vm_to_dpt(vm);
|
||||
|
||||
dpt->obj->is_dpt = false;
|
||||
i915_vm_put(&dpt->vm);
|
||||
}
|
||||
|
||||
static void i915_dpt_suspend(struct i915_address_space *vm)
|
||||
static void i915_dpt_suspend(struct intel_dpt *dpt)
|
||||
{
|
||||
i915_ggtt_suspend_vm(vm, true);
|
||||
i915_ggtt_suspend_vm(&dpt->vm, true);
|
||||
}
|
||||
|
||||
static void i915_dpt_resume(struct i915_address_space *vm)
|
||||
static void i915_dpt_resume(struct intel_dpt *dpt)
|
||||
{
|
||||
i915_ggtt_resume_vm(vm, true);
|
||||
i915_ggtt_resume_vm(&dpt->vm, true);
|
||||
}
|
||||
|
||||
u64 i915_dpt_offset(struct i915_vma *dpt_vma)
|
||||
|
|
|
|||
|
|
@ -8,9 +8,11 @@
|
|||
|
||||
struct i915_address_space;
|
||||
struct i915_vma;
|
||||
struct intel_dpt;
|
||||
|
||||
struct i915_vma *i915_dpt_pin_to_ggtt(struct i915_address_space *vm, unsigned int alignment);
|
||||
void i915_dpt_unpin_from_ggtt(struct i915_address_space *vm);
|
||||
struct i915_address_space *i915_dpt_to_vm(struct intel_dpt *dpt);
|
||||
struct i915_vma *i915_dpt_pin_to_ggtt(struct intel_dpt *dpt, unsigned int alignment);
|
||||
void i915_dpt_unpin_from_ggtt(struct intel_dpt *dpt);
|
||||
u64 i915_dpt_offset(struct i915_vma *dpt_vma);
|
||||
|
||||
extern const struct intel_display_dpt_interface i915_display_dpt_interface;
|
||||
|
|
|
|||
|
|
@ -13,8 +13,8 @@ struct drm_framebuffer;
|
|||
struct drm_gem_object;
|
||||
struct drm_plane_state;
|
||||
struct drm_scanout_buffer;
|
||||
struct i915_address_space;
|
||||
struct i915_vma;
|
||||
struct intel_dpt;
|
||||
struct intel_dsb_buffer;
|
||||
struct intel_hdcp_gsc_context;
|
||||
struct intel_initial_plane_config;
|
||||
|
|
@ -25,10 +25,10 @@ struct ref_tracker;
|
|||
/* Keep struct definitions sorted */
|
||||
|
||||
struct intel_display_dpt_interface {
|
||||
struct i915_address_space *(*create)(struct drm_gem_object *obj, size_t size);
|
||||
void (*destroy)(struct i915_address_space *vm);
|
||||
void (*suspend)(struct i915_address_space *vm);
|
||||
void (*resume)(struct i915_address_space *vm);
|
||||
struct intel_dpt *(*create)(struct drm_gem_object *obj, size_t size);
|
||||
void (*destroy)(struct intel_dpt *dpt);
|
||||
void (*suspend)(struct intel_dpt *dpt);
|
||||
void (*resume)(struct intel_dpt *dpt);
|
||||
};
|
||||
|
||||
struct intel_display_dsb_interface {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user