drm/i915/gvt: treat intel_gvt_mpt as const in gvt code
authorJulian Stecklina <julian.stecklina@cyberus-technology.de>
Wed, 11 Nov 2020 17:28:11 +0000 (18:28 +0100)
committerZhenyu Wang <zhenyuw@linux.intel.com>
Mon, 23 Nov 2020 09:14:20 +0000 (17:14 +0800)
The current interface of intel_gvt_register_hypervisor() expects a
non-const pointer to struct intel_gvt_mpt, even though the mediator
never modifies (or should modifiy) the content of this struct.

Change the function signature and relevant struct members to const to
properly express the API's intent and allow instances of intel_gvt_mpt
to be allocated as const.

While I was here, I also made KVM's instance of this struct const to
reduce the number of writable function pointers in the kernel.

Cc: Zhenyu Wang <zhenyuw@linux.intel.com>
Cc: intel-gvt-dev@lists.freedesktop.org
Reviewed-by: Zhenyu Wang <zhenyuw@linux.intel.com>
Signed-off-by: Julian Stecklina <julian.stecklina@cyberus-technology.de>
Signed-off-by: Zhenyu Wang <zhenyuw@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20201111172811.558443-1-julian.stecklina@cyberus-technology.de
drivers/gpu/drm/i915/gvt/gvt.c
drivers/gpu/drm/i915/gvt/gvt.h
drivers/gpu/drm/i915/gvt/kvmgt.c
drivers/gpu/drm/i915/gvt/mpt.h

index 0262a6fa3a6c68af58d8678932f51b7da6b8a05c..d1d8ee4a5f16a3862d20506224edc7676a778884 100644 (file)
@@ -415,7 +415,7 @@ intel_gvt_pm_resume(struct intel_gvt *gvt)
 }
 
 int
-intel_gvt_register_hypervisor(struct intel_gvt_mpt *m)
+intel_gvt_register_hypervisor(const struct intel_gvt_mpt *m)
 {
        int ret;
        void *gvt;
index b3d6355dd797dd2d35f5546dfadba146133c28d4..cf3578e3f4ddae8a8439de15833c5fa202d08365 100644 (file)
@@ -56,7 +56,7 @@ struct intel_gvt_host {
        struct device *dev;
        bool initialized;
        int hypervisor_type;
-       struct intel_gvt_mpt *mpt;
+       const struct intel_gvt_mpt *mpt;
 };
 
 extern struct intel_gvt_host intel_gvt_host;
index ad8a9df49f295f1dd7e94fc50303fa1e2e83e8c3..d830b6c6528400d5865b03c80efca6298e7cbf1a 100644 (file)
@@ -2099,7 +2099,7 @@ static bool kvmgt_is_valid_gfn(unsigned long handle, unsigned long gfn)
        return ret;
 }
 
-static struct intel_gvt_mpt kvmgt_mpt = {
+static const struct intel_gvt_mpt kvmgt_mpt = {
        .type = INTEL_GVT_HYPERVISOR_KVM,
        .host_init = kvmgt_host_init,
        .host_exit = kvmgt_host_exit,
index 9ad224df9c68bb2aedbb58fbc0c4d4387a95eada..6f92cde71971ea7aac72fe838f08e5b70009b5c9 100644 (file)
@@ -392,7 +392,7 @@ static inline bool intel_gvt_hypervisor_is_valid_gfn(
        return intel_gvt_host.mpt->is_valid_gfn(vgpu->handle, gfn);
 }
 
-int intel_gvt_register_hypervisor(struct intel_gvt_mpt *);
+int intel_gvt_register_hypervisor(const struct intel_gvt_mpt *);
 void intel_gvt_unregister_hypervisor(void);
 
 #endif /* _GVT_MPT_H_ */