drm/i915/gvt: Constify static structs
cover drm/i915/gvt: Constify static structs
Constify a number of static structs that are never modified to allow the compiler to put them in read-only memory. In order to do this, constify a number of local variables and pointers in structs.
This is most important for structs that contain function pointers, and the patches for those structs are placed first in the series.
Rikard Falkeborn (9):
drm/i915/gvt: Constify intel_gvt_gtt_pte_ops drm/i915/gvt: Constify intel_gvt_gtt_pte_ops drm/i915/gvt: Constify intel_gvt_irq_ops drm/i915/gvt: Constify intel_gvt_sched_policy_ops drm/i915/gvt: Constify gvt_mmio_block drm/i915/gvt: Constify cmd_interrupt_events drm/i915/gvt: Constify formats drm/i915/gvt: Constify gtt_type_table_entry drm/i915/gvt: Constify vgpu_types
drivers/gpu/drm/i915/gvt/cmd_parser.c | 2 +- drivers/gpu/drm/i915/gvt/fb_decoder.c | 24 ++++----- drivers/gpu/drm/i915/gvt/gtt.c | 68 ++++++++++++------------- drivers/gpu/drm/i915/gvt/gtt.h | 4 +- drivers/gpu/drm/i915/gvt/gvt.h | 2 +- drivers/gpu/drm/i915/gvt/handlers.c | 12 ++--- drivers/gpu/drm/i915/gvt/interrupt.c | 10 ++-- drivers/gpu/drm/i915/gvt/interrupt.h | 2 +- drivers/gpu/drm/i915/gvt/sched_policy.c | 2 +- drivers/gpu/drm/i915/gvt/scheduler.h | 2 +- drivers/gpu/drm/i915/gvt/vgpu.c | 4 +- 11 files changed, 66 insertions(+), 66 deletions(-)
Signature · 1 line
2.34.1
PATCH 1/9 drm/i915/gvt: Constify intel_gvt_gtt_pte_ops
These are never modified, so make them const to allow the compiler to put them in read-only memory.
--- drivers/gpu/drm/i915/gvt/gtt.c | 4 ++-- drivers/gpu/drm/i915/gvt/gtt.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/gvt/gtt.c +2 -2
@@ -516,7 +516,7 @@ static struct intel_gvt_gtt_pte_ops gen8_gtt_pte_ops = { .set_pfn = gen8_gtt_set_pfn, }; -static struct intel_gvt_gtt_gma_ops gen8_gtt_gma_ops = { +static const struct intel_gvt_gtt_gma_ops gen8_gtt_gma_ops = { .gma_to_ggtt_pte_index = gma_to_ggtt_pte_index, .gma_to_pte_index = gen8_gma_to_pte_index, .gma_to_pde_index = gen8_gma_to_pde_index,
@@ -2097,7 +2097,7 @@ unsigned long intel_vgpu_gma_to_gpa(struct intel_vgpu_mm *mm, unsigned long gma)struct intel_vgpu *vgpu = mm->vgpu;struct intel_gvt *gvt = vgpu->gvt;struct intel_gvt_gtt_pte_ops *pte_ops = gvt->gtt.pte_ops; -struct intel_gvt_gtt_gma_ops *gma_ops = gvt->gtt.gma_ops; +const struct intel_gvt_gtt_gma_ops *gma_ops = gvt->gtt.gma_ops;unsigned long gpa =INTEL_GVT_INVALID_ADDR ;unsigned long gma_index[4 ];struct intel_gvt_gtt_entry e;
drivers/gpu/drm/i915/gvt/gtt.h +1 -1
@@ -92,7 +92,7 @@ struct intel_gvt_gtt_gma_ops {struct intel_gvt_gtt {struct intel_gvt_gtt_pte_ops *pte_ops; -struct intel_gvt_gtt_gma_ops *gma_ops; +const struct intel_gvt_gtt_gma_ops *gma_ops;int (*mm_alloc_page_table)(struct intel_vgpu_mm *mm);void (*mm_free_page_table)(struct intel_vgpu_mm *mm);struct list_head oos_page_use_list_head;
Signature · 1 line
2.34.1
Re: [PATCH 1/9] drm/i915/gvt: Constify intel_gvt_gtt_pte_ops
Quoted 36 lines · Rikard Falkeborn
These are never modified, so make them const to allow the compiler to put them in read-only memory.
Signed-off-by Rikard Falkeborn <[email protected]>--- drivers/gpu/drm/i915/gvt/gtt.c | 4 ++-- drivers/gpu/drm/i915/gvt/gtt.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)drivers/gpu/drm/i915/gvt/gtt.c +2
-2@@ -516,7 +516,7 @@ static struct intel_gvt_gtt_pte_ops gen8_gtt_pte_ops = { .set_pfn = gen8_gtt_set_pfn, }; -static struct intel_gvt_gtt_gma_ops gen8_gtt_gma_ops = { +static const struct intel_gvt_gtt_gma_ops gen8_gtt_gma_ops = { .gma_to_ggtt_pte_index = gma_to_ggtt_pte_index, .gma_to_pte_index = gen8_gma_to_pte_index, .gma_to_pde_index = gen8_gma_to_pde_index,@@ -2097,7 +2097,7 @@ unsigned long intel_vgpu_gma_to_gpa(struct intel_vgpu_mm *mm, unsigned long gma)struct intel_vgpu *vgpu = mm->vgpu;struct intel_gvt *gvt = vgpu->gvt;struct intel_gvt_gtt_pte_ops *pte_ops = gvt->gtt.pte_ops; -struct intel_gvt_gtt_gma_ops *gma_ops = gvt->gtt.gma_ops; +const struct intel_gvt_gtt_gma_ops *gma_ops = gvt->gtt.gma_ops;unsigned long gpa =INTEL_GVT_INVALID_ADDR ;unsigned long gma_index[4 ];struct intel_gvt_gtt_entry e;drivers/gpu/drm/i915/gvt/gtt.h +0
-0
drivers/gpu/drm/i915/gvt/gtt.h struct intel_gvt_gtt_gma_ops { · line 98
Quoted 8 lines
drivers/gpu/drm/i915/gvt/gtt.h +1
-1@@ -92,7 +92,7 @@ struct intel_gvt_gtt_gma_ops {struct intel_gvt_gtt {struct intel_gvt_gtt_pte_ops *pte_ops; -struct intel_gvt_gtt_gma_ops *gma_ops; +const struct intel_gvt_gtt_gma_ops *gma_ops;int (*mm_alloc_page_table)(struct intel_vgpu_mm *mm);void (*mm_free_page_table)(struct intel_vgpu_mm *mm);struct list_head oos_page_use_list_head;
It seems like the tittle doesn't match with the modification. I guess it should be Constify intel_gvt_gtt_gma_ops. I can fix that for you when applied.
PATCH 2/9 drm/i915/gvt: Constify intel_gvt_gtt_pte_ops
In reply to Rikard FalkebornThese are never modified, so make them const to allow the compiler to put them in read-only memory.
--- drivers/gpu/drm/i915/gvt/gtt.c | 62 +++++++++++++++++----------------- drivers/gpu/drm/i915/gvt/gtt.h | 2 +- 2 files changed, 32 insertions(+), 32 deletions(-)
drivers/gpu/drm/i915/gvt/gtt.c +31 -31
@@ -499,7 +499,7 @@ DEFINE_PPGTT_GMA_TO_INDEX(gen8, l3_pdp, (gma >> 30 & 0x3));DEFINE_PPGTT_GMA_TO_INDEX (gen8, l4_pdp, (gma >>30 &0x1ff ));DEFINE_PPGTT_GMA_TO_INDEX (gen8, pml4, (gma >>39 &0x1ff )); -static struct intel_gvt_gtt_pte_ops gen8_gtt_pte_ops = { +static const struct intel_gvt_gtt_pte_ops gen8_gtt_pte_ops = { .get_entry = gtt_get_entry64, .set_entry = gtt_set_entry64, .clear_present = gtt_entry_clear_present,
@@ -526,7 +526,7 @@ static const struct intel_gvt_gtt_gma_ops gen8_gtt_gma_ops = { };/* Update entry type per pse and ips bit. */ -static void update_entry_type_for_real (struct intel_gvt_gtt_pte_ops *pte_ops, +static void update_entry_type_for_real (const struct intel_gvt_gtt_pte_ops *pte_ops,struct intel_gvt_gtt_entry *entry,bool ips) {switch (entry->type) {
@@ -553,7 +553,7 @@ static void _ppgtt_get_root_entry(struct intel_vgpu_mm *mm, struct intel_gvt_gtt_entry *entry, unsigned long index, bool guest) { - struct intel_gvt_gtt_pte_ops *pte_ops = mm->vgpu->gvt->gtt.pte_ops; +const struct intel_gvt_gtt_pte_ops *pte_ops = mm->vgpu->gvt->gtt.pte_ops;GEM_BUG_ON (mm->type !=INTEL_GVT_MM_PPGTT );
@@ -580,7 +580,7 @@ static void _ppgtt_set_root_entry(struct intel_vgpu_mm *mm, struct intel_gvt_gtt_entry *entry, unsigned long index, bool guest) { - struct intel_gvt_gtt_pte_ops *pte_ops = mm->vgpu->gvt->gtt.pte_ops; +const struct intel_gvt_gtt_pte_ops *pte_ops = mm->vgpu->gvt->gtt.pte_ops; pte_ops->set_entry(guest ? mm->ppgtt_mm.guest_pdps : mm->ppgtt_mm.shadow_pdps,
@@ -596,7 +596,7 @@ static inline void ppgtt_set_shadow_root_entry(struct intel_vgpu_mm *mm,static void ggtt_get_guest_entry (struct intel_vgpu_mm *mm,struct intel_gvt_gtt_entry *entry,unsigned long index) { -struct intel_gvt_gtt_pte_ops *pte_ops = mm->vgpu->gvt->gtt.pte_ops; +const struct intel_gvt_gtt_pte_ops *pte_ops = mm->vgpu->gvt->gtt.pte_ops;GEM_BUG_ON (mm->type !=INTEL_GVT_MM_GGTT );
@@ -608,7 +608,7 @@ static void ggtt_get_guest_entry(struct intel_vgpu_mm *mm,static void ggtt_set_guest_entry (struct intel_vgpu_mm *mm,struct intel_gvt_gtt_entry *entry,unsigned long index) { -struct intel_gvt_gtt_pte_ops *pte_ops = mm->vgpu->gvt->gtt.pte_ops; +const struct intel_gvt_gtt_pte_ops *pte_ops = mm->vgpu->gvt->gtt.pte_ops;GEM_BUG_ON (mm->type !=INTEL_GVT_MM_GGTT );
@@ -619,7 +619,7 @@ static void ggtt_set_guest_entry(struct intel_vgpu_mm *mm,static void ggtt_get_host_entry (struct intel_vgpu_mm *mm,struct intel_gvt_gtt_entry *entry,unsigned long index) { -struct intel_gvt_gtt_pte_ops *pte_ops = mm->vgpu->gvt->gtt.pte_ops; +const struct intel_gvt_gtt_pte_ops *pte_ops = mm->vgpu->gvt->gtt.pte_ops;GEM_BUG_ON (mm->type !=INTEL_GVT_MM_GGTT );
@@ -629,7 +629,7 @@ static void ggtt_get_host_entry(struct intel_vgpu_mm *mm,static void ggtt_set_host_entry (struct intel_vgpu_mm *mm,struct intel_gvt_gtt_entry *entry,unsigned long index) { -struct intel_gvt_gtt_pte_ops *pte_ops = mm->vgpu->gvt->gtt.pte_ops; +const struct intel_gvt_gtt_pte_ops *pte_ops = mm->vgpu->gvt->gtt.pte_ops;unsigned long offset = index;GEM_BUG_ON (mm->type !=INTEL_GVT_MM_GGTT );
@@ -655,7 +655,7 @@ static inline int ppgtt_spt_get_entry( bool guest) {struct intel_gvt *gvt = spt->vgpu->gvt; -struct intel_gvt_gtt_pte_ops *ops = gvt->gtt.pte_ops; +const struct intel_gvt_gtt_pte_ops *ops = gvt->gtt.pte_ops;int ret; e->type =get_entry_type (type);
@@ -684,7 +684,7 @@ static inline int ppgtt_spt_set_entry( bool guest) {struct intel_gvt *gvt = spt->vgpu->gvt; -struct intel_gvt_gtt_pte_ops *ops = gvt->gtt.pte_ops; +const struct intel_gvt_gtt_pte_ops *ops = gvt->gtt.pte_ops;if (WARN (!gtt_type_is_entry (e->type),"invalid entry type\n" ))return -EINVAL ;
@@ -947,7 +947,7 @@ static int ppgtt_invalidate_spt_by_shadow_entry(struct intel_vgpu *vgpu, struct intel_gvt_gtt_entry *e) {struct drm_i915_private *i915 = vgpu->gvt->gt->i915; -struct intel_gvt_gtt_pte_ops *ops = vgpu->gvt->gtt.pte_ops; +const struct intel_gvt_gtt_pte_ops *ops = vgpu->gvt->gtt.pte_ops;struct intel_vgpu_ppgtt_spt *s;enum intel_gvt_gtt_type cur_pt_type;
@@ -984,7 +984,7 @@ static inline void ppgtt_invalidate_pte(struct intel_vgpu_ppgtt_spt *spt, struct intel_gvt_gtt_entry *entry) {struct intel_vgpu *vgpu = spt->vgpu; -struct intel_gvt_gtt_pte_ops *ops = vgpu->gvt->gtt.pte_ops; +const struct intel_gvt_gtt_pte_ops *ops = vgpu->gvt->gtt.pte_ops;unsigned long pfn;int type;
@@ -1072,7 +1072,7 @@ static int ppgtt_populate_spt(struct intel_vgpu_ppgtt_spt *spt);static struct intel_vgpu_ppgtt_spt *ppgtt_populate_spt_by_guest_entry (struct intel_vgpu *vgpu,struct intel_gvt_gtt_entry *we) { -struct intel_gvt_gtt_pte_ops *ops = vgpu->gvt->gtt.pte_ops; +const struct intel_gvt_gtt_pte_ops *ops = vgpu->gvt->gtt.pte_ops;struct intel_vgpu_ppgtt_spt *spt =NULL ;bool ips = false;int ret;
@@ -1136,7 +1136,7 @@ static struct intel_vgpu_ppgtt_spt *ppgtt_populate_spt_by_guest_entry(static inline void ppgtt_generate_shadow_entry (struct intel_gvt_gtt_entry *se,struct intel_vgpu_ppgtt_spt *s,struct intel_gvt_gtt_entry *ge) { -struct intel_gvt_gtt_pte_ops *ops = s->vgpu->gvt->gtt.pte_ops; +const struct intel_gvt_gtt_pte_ops *ops = s->vgpu->gvt->gtt.pte_ops; se->type = ge->type; se->val64 = ge->val64;
@@ -1159,7 +1159,7 @@ static inline void ppgtt_generate_shadow_entry(struct intel_gvt_gtt_entry *se,static int is_2MB_gtt_possible (struct intel_vgpu *vgpu,struct intel_gvt_gtt_entry *entry) { -struct intel_gvt_gtt_pte_ops *ops = vgpu->gvt->gtt.pte_ops; +const struct intel_gvt_gtt_pte_ops *ops = vgpu->gvt->gtt.pte_ops;unsigned long pfn;if (!HAS_PAGE_SIZES (vgpu->gvt->gt->i915,I915_GTT_PAGE_SIZE_2M ))
@@ -1176,7 +1176,7 @@ static int split_2MB_gtt_entry(struct intel_vgpu *vgpu, struct intel_vgpu_ppgtt_spt *spt, unsigned long index, struct intel_gvt_gtt_entry *se) { - struct intel_gvt_gtt_pte_ops *ops = vgpu->gvt->gtt.pte_ops; + const struct intel_gvt_gtt_pte_ops *ops = vgpu->gvt->gtt.pte_ops;struct intel_vgpu_ppgtt_spt *sub_spt;struct intel_gvt_gtt_entry sub_se;unsigned long start_gfn;
@@ -1223,7 +1223,7 @@ static int split_64KB_gtt_entry(struct intel_vgpu *vgpu, struct intel_vgpu_ppgtt_spt *spt, unsigned long index, struct intel_gvt_gtt_entry *se) { - struct intel_gvt_gtt_pte_ops *ops = vgpu->gvt->gtt.pte_ops; + const struct intel_gvt_gtt_pte_ops *ops = vgpu->gvt->gtt.pte_ops;struct intel_gvt_gtt_entry entry = *se;unsigned long start_gfn;dma_addr_t dma_addr;
@@ -1254,7 +1254,7 @@ static int ppgtt_populate_shadow_entry(struct intel_vgpu *vgpu, struct intel_vgpu_ppgtt_spt *spt, unsigned long index, struct intel_gvt_gtt_entry *ge) { - struct intel_gvt_gtt_pte_ops *pte_ops = vgpu->gvt->gtt.pte_ops; + const struct intel_gvt_gtt_pte_ops *pte_ops = vgpu->gvt->gtt.pte_ops;struct intel_gvt_gtt_entry se = *ge;unsigned long gfn, page_size =PAGE_SIZE ;dma_addr_t dma_addr;
@@ -1308,7 +1308,7 @@ static int ppgtt_populate_spt(struct intel_vgpu_ppgtt_spt *spt) {struct intel_vgpu *vgpu = spt->vgpu;struct intel_gvt *gvt = vgpu->gvt; -struct intel_gvt_gtt_pte_ops *ops = gvt->gtt.pte_ops; +const struct intel_gvt_gtt_pte_ops *ops = gvt->gtt.pte_ops;struct intel_vgpu_ppgtt_spt *s;struct intel_gvt_gtt_entry se, ge;unsigned long gfn, i;
@@ -1351,7 +1351,7 @@ static int ppgtt_handle_guest_entry_removal(struct intel_vgpu_ppgtt_spt *spt, struct intel_gvt_gtt_entry *se, unsigned long index) {struct intel_vgpu *vgpu = spt->vgpu; -struct intel_gvt_gtt_pte_ops *ops = vgpu->gvt->gtt.pte_ops; +const struct intel_gvt_gtt_pte_ops *ops = vgpu->gvt->gtt.pte_ops;int ret; trace_spt_guest_change(spt->vgpu->id, "remove", spt,
@@ -1432,7 +1432,7 @@ static int sync_oos_page(struct intel_vgpu *vgpu, {const struct intel_gvt_device_info *info = &vgpu->gvt->device_info;struct intel_gvt *gvt = vgpu->gvt; -struct intel_gvt_gtt_pte_ops *ops = gvt->gtt.pte_ops; +const struct intel_gvt_gtt_pte_ops *ops = gvt->gtt.pte_ops;struct intel_vgpu_ppgtt_spt *spt = oos_page->spt;struct intel_gvt_gtt_entry old, new;int index;
@@ -1603,7 +1603,7 @@ static int ppgtt_handle_guest_write_page_table( {struct intel_vgpu *vgpu = spt->vgpu;int type = spt->shadow_page.type; -struct intel_gvt_gtt_pte_ops *ops = vgpu->gvt->gtt.pte_ops; +const struct intel_gvt_gtt_pte_ops *ops = vgpu->gvt->gtt.pte_ops;struct intel_gvt_gtt_entry old_se;int new_present;int i, ret;
@@ -1720,7 +1720,7 @@ static int ppgtt_handle_guest_write_page_table_bytes( u64 pa, void *p_data, int bytes) { struct intel_vgpu *vgpu = spt->vgpu; -struct intel_gvt_gtt_pte_ops *ops = vgpu->gvt->gtt.pte_ops; +const struct intel_gvt_gtt_pte_ops *ops = vgpu->gvt->gtt.pte_ops;const struct intel_gvt_device_info *info = &vgpu->gvt->device_info;struct intel_gvt_gtt_entry we, se;unsigned long index;
@@ -1785,7 +1785,7 @@ static void invalidate_ppgtt_mm(struct intel_vgpu_mm *mm)struct intel_vgpu *vgpu = mm->vgpu;struct intel_gvt *gvt = vgpu->gvt;struct intel_gvt_gtt *gtt = &gvt->gtt; -struct intel_gvt_gtt_pte_ops *ops = gtt->pte_ops; +const struct intel_gvt_gtt_pte_ops *ops = gtt->pte_ops;struct intel_gvt_gtt_entry se;int index;
@@ -1815,7 +1815,7 @@ static int shadow_ppgtt_mm(struct intel_vgpu_mm *mm)struct intel_vgpu *vgpu = mm->vgpu;struct intel_gvt *gvt = vgpu->gvt;struct intel_gvt_gtt *gtt = &gvt->gtt; -struct intel_gvt_gtt_pte_ops *ops = gtt->pte_ops; +const struct intel_gvt_gtt_pte_ops *ops = gtt->pte_ops;struct intel_vgpu_ppgtt_spt *spt;struct intel_gvt_gtt_entry ge, se;int index, ret;
@@ -2067,7 +2067,7 @@ static inline int ppgtt_get_next_level_entry(struct intel_vgpu_mm *mm, struct intel_gvt_gtt_entry *e, unsigned long index, bool guest) { struct intel_vgpu *vgpu = mm->vgpu; -struct intel_gvt_gtt_pte_ops *ops = vgpu->gvt->gtt.pte_ops; +const struct intel_gvt_gtt_pte_ops *ops = vgpu->gvt->gtt.pte_ops;struct intel_vgpu_ppgtt_spt *s; s =intel_vgpu_find_spt_by_mfn (vgpu, ops->get_pfn (e));
@@ -2096,7 +2096,7 @@ unsigned long intel_vgpu_gma_to_gpa(struct intel_vgpu_mm *mm, unsigned long gma) {struct intel_vgpu *vgpu = mm->vgpu;struct intel_gvt *gvt = vgpu->gvt; -struct intel_gvt_gtt_pte_ops *pte_ops = gvt->gtt.pte_ops; +const struct intel_gvt_gtt_pte_ops *pte_ops = gvt->gtt.pte_ops;const struct intel_gvt_gtt_gma_ops *gma_ops = gvt->gtt.gma_ops;unsigned long gpa =INTEL_GVT_INVALID_ADDR ;unsigned long gma_index[4 ];
@@ -2221,7 +2221,7 @@ int intel_vgpu_emulate_ggtt_mmio_read(struct intel_vgpu *vgpu, unsigned int off,static void ggtt_invalidate_pte (struct intel_vgpu *vgpu,struct intel_gvt_gtt_entry *entry) { -struct intel_gvt_gtt_pte_ops *pte_ops = vgpu->gvt->gtt.pte_ops; +const struct intel_gvt_gtt_pte_ops *pte_ops = vgpu->gvt->gtt.pte_ops;unsigned long pfn; pfn = pte_ops->get_pfn (entry);
@@ -2236,7 +2236,7 @@ static int emulate_ggtt_mmio_write(struct intel_vgpu *vgpu, unsigned int off,struct intel_gvt *gvt = vgpu->gvt;const struct intel_gvt_device_info *info = &gvt->device_info;struct intel_vgpu_mm *ggtt_mm = vgpu->gtt.ggtt_mm; -struct intel_gvt_gtt_pte_ops *ops = gvt->gtt.pte_ops; +const struct intel_gvt_gtt_pte_ops *ops = gvt->gtt.pte_ops;unsigned long g_gtt_index = off >> info->gtt_entry_size_shift;unsigned long gma, gfn;struct intel_gvt_gtt_entry e = {.val64 =0 , .type =GTT_TYPE_GGTT_PTE };
@@ -2391,7 +2391,7 @@ static int alloc_scratch_pages(struct intel_vgpu *vgpu, {struct drm_i915_private *i915 = vgpu->gvt->gt->i915;struct intel_vgpu_gtt *gtt = &vgpu->gtt; -struct intel_gvt_gtt_pte_ops *ops = vgpu->gvt->gtt.pte_ops; +const struct intel_gvt_gtt_pte_ops *ops = vgpu->gvt->gtt.pte_ops;int page_entry_num =I915_GTT_PAGE_SIZE >> vgpu->gvt->device_info.gtt_entry_size_shift;void *scratch_pt;
@@ -2822,7 +2822,7 @@ void intel_vgpu_invalidate_ppgtt(struct intel_vgpu *vgpu)void intel_vgpu_reset_ggtt (struct intel_vgpu *vgpu,bool invalidate_old) {struct intel_gvt *gvt = vgpu->gvt; -struct intel_gvt_gtt_pte_ops *pte_ops = vgpu->gvt->gtt.pte_ops; +const struct intel_gvt_gtt_pte_ops *pte_ops = vgpu->gvt->gtt.pte_ops;struct intel_gvt_gtt_entry entry = {.type =GTT_TYPE_GGTT_PTE };struct intel_gvt_gtt_entry old_entry;u32 index;
drivers/gpu/drm/i915/gvt/gtt.h +1 -1
@@ -91,7 +91,7 @@ struct intel_gvt_gtt_gma_ops { };struct intel_gvt_gtt { -struct intel_gvt_gtt_pte_ops *pte_ops; +const struct intel_gvt_gtt_pte_ops *pte_ops;const struct intel_gvt_gtt_gma_ops *gma_ops;int (*mm_alloc_page_table)(struct intel_vgpu_mm *mm);void (*mm_free_page_table)(struct intel_vgpu_mm *mm);
Signature · 1 line
2.34.1
Re: [PATCH 2/9] drm/i915/gvt: Constify intel_gvt_gtt_pte_ops
Quoted 297 lines · Rikard Falkeborn
These are never modified, so make them const to allow the compiler to put them in read-only memory.
Signed-off-by Rikard Falkeborn <[email protected]>--- drivers/gpu/drm/i915/gvt/gtt.c | 62 +++++++++++++++++----------------- drivers/gpu/drm/i915/gvt/gtt.h | 2 +- 2 files changed, 32 insertions(+), 32 deletions(-)drivers/gpu/drm/i915/gvt/gtt.c +31
-31@@ -499,7 +499,7 @@ DEFINE_PPGTT_GMA_TO_INDEX(gen8, l3_pdp, (gma >> 30 & 0x3));DEFINE_PPGTT_GMA_TO_INDEX (gen8, l4_pdp, (gma >>30 &0x1ff ));DEFINE_PPGTT_GMA_TO_INDEX (gen8, pml4, (gma >>39 &0x1ff )); -static struct intel_gvt_gtt_pte_ops gen8_gtt_pte_ops = { +static const struct intel_gvt_gtt_pte_ops gen8_gtt_pte_ops = { .get_entry = gtt_get_entry64, .set_entry = gtt_set_entry64, .clear_present = gtt_entry_clear_present,@@ -526,7 +526,7 @@ static const struct intel_gvt_gtt_gma_ops gen8_gtt_gma_ops = { };/* Update entry type per pse and ips bit. */ -static void update_entry_type_for_real (struct intel_gvt_gtt_pte_ops *pte_ops, +static void update_entry_type_for_real (const struct intel_gvt_gtt_pte_ops *pte_ops,struct intel_gvt_gtt_entry *entry,bool ips) {switch (entry->type) {@@ -553,7 +553,7 @@ static void _ppgtt_get_root_entry(struct intel_vgpu_mm *mm, struct intel_gvt_gtt_entry *entry, unsigned long index, bool guest) { - struct intel_gvt_gtt_pte_ops *pte_ops = mm->vgpu->gvt->gtt.pte_ops; +const struct intel_gvt_gtt_pte_ops *pte_ops = mm->vgpu->gvt->gtt.pte_ops;GEM_BUG_ON (mm->type !=INTEL_GVT_MM_PPGTT );@@ -580,7 +580,7 @@ static void _ppgtt_set_root_entry(struct intel_vgpu_mm *mm, struct intel_gvt_gtt_entry *entry, unsigned long index, bool guest) { - struct intel_gvt_gtt_pte_ops *pte_ops = mm->vgpu->gvt->gtt.pte_ops; +const struct intel_gvt_gtt_pte_ops *pte_ops = mm->vgpu->gvt->gtt.pte_ops; pte_ops->set_entry(guest ? mm->ppgtt_mm.guest_pdps : mm->ppgtt_mm.shadow_pdps,@@ -596,7 +596,7 @@ static inline void ppgtt_set_shadow_root_entry(struct intel_vgpu_mm *mm,static void ggtt_get_guest_entry (struct intel_vgpu_mm *mm,struct intel_gvt_gtt_entry *entry,unsigned long index) { -struct intel_gvt_gtt_pte_ops *pte_ops = mm->vgpu->gvt->gtt.pte_ops; +const struct intel_gvt_gtt_pte_ops *pte_ops = mm->vgpu->gvt->gtt.pte_ops;GEM_BUG_ON (mm->type !=INTEL_GVT_MM_GGTT );@@ -608,7 +608,7 @@ static void ggtt_get_guest_entry(struct intel_vgpu_mm *mm,static void ggtt_set_guest_entry (struct intel_vgpu_mm *mm,struct intel_gvt_gtt_entry *entry,unsigned long index) { -struct intel_gvt_gtt_pte_ops *pte_ops = mm->vgpu->gvt->gtt.pte_ops; +const struct intel_gvt_gtt_pte_ops *pte_ops = mm->vgpu->gvt->gtt.pte_ops;GEM_BUG_ON (mm->type !=INTEL_GVT_MM_GGTT );@@ -619,7 +619,7 @@ static void ggtt_set_guest_entry(struct intel_vgpu_mm *mm,static void ggtt_get_host_entry (struct intel_vgpu_mm *mm,struct intel_gvt_gtt_entry *entry,unsigned long index) { -struct intel_gvt_gtt_pte_ops *pte_ops = mm->vgpu->gvt->gtt.pte_ops; +const struct intel_gvt_gtt_pte_ops *pte_ops = mm->vgpu->gvt->gtt.pte_ops;GEM_BUG_ON (mm->type !=INTEL_GVT_MM_GGTT );@@ -629,7 +629,7 @@ static void ggtt_get_host_entry(struct intel_vgpu_mm *mm,static void ggtt_set_host_entry (struct intel_vgpu_mm *mm,struct intel_gvt_gtt_entry *entry,unsigned long index) { -struct intel_gvt_gtt_pte_ops *pte_ops = mm->vgpu->gvt->gtt.pte_ops; +const struct intel_gvt_gtt_pte_ops *pte_ops = mm->vgpu->gvt->gtt.pte_ops;unsigned long offset = index;GEM_BUG_ON (mm->type !=INTEL_GVT_MM_GGTT );@@ -655,7 +655,7 @@ static inline int ppgtt_spt_get_entry( bool guest) {struct intel_gvt *gvt = spt->vgpu->gvt; -struct intel_gvt_gtt_pte_ops *ops = gvt->gtt.pte_ops; +const struct intel_gvt_gtt_pte_ops *ops = gvt->gtt.pte_ops;int ret; e->type =get_entry_type (type);@@ -684,7 +684,7 @@ static inline int ppgtt_spt_set_entry( bool guest) {struct intel_gvt *gvt = spt->vgpu->gvt; -struct intel_gvt_gtt_pte_ops *ops = gvt->gtt.pte_ops; +const struct intel_gvt_gtt_pte_ops *ops = gvt->gtt.pte_ops;if (WARN (!gtt_type_is_entry (e->type),"invalid entry type\n" ))return -EINVAL ;@@ -947,7 +947,7 @@ static int ppgtt_invalidate_spt_by_shadow_entry(struct intel_vgpu *vgpu, struct intel_gvt_gtt_entry *e) {struct drm_i915_private *i915 = vgpu->gvt->gt->i915; -struct intel_gvt_gtt_pte_ops *ops = vgpu->gvt->gtt.pte_ops; +const struct intel_gvt_gtt_pte_ops *ops = vgpu->gvt->gtt.pte_ops;struct intel_vgpu_ppgtt_spt *s;enum intel_gvt_gtt_type cur_pt_type;@@ -984,7 +984,7 @@ static inline void ppgtt_invalidate_pte(struct intel_vgpu_ppgtt_spt *spt, struct intel_gvt_gtt_entry *entry) {struct intel_vgpu *vgpu = spt->vgpu; -struct intel_gvt_gtt_pte_ops *ops = vgpu->gvt->gtt.pte_ops; +const struct intel_gvt_gtt_pte_ops *ops = vgpu->gvt->gtt.pte_ops;unsigned long pfn;int type;@@ -1072,7 +1072,7 @@ static int ppgtt_populate_spt(struct intel_vgpu_ppgtt_spt *spt);static struct intel_vgpu_ppgtt_spt *ppgtt_populate_spt_by_guest_entry (struct intel_vgpu *vgpu,struct intel_gvt_gtt_entry *we) { -struct intel_gvt_gtt_pte_ops *ops = vgpu->gvt->gtt.pte_ops; +const struct intel_gvt_gtt_pte_ops *ops = vgpu->gvt->gtt.pte_ops;struct intel_vgpu_ppgtt_spt *spt =NULL ;bool ips = false;int ret;@@ -1136,7 +1136,7 @@ static struct intel_vgpu_ppgtt_spt *ppgtt_populate_spt_by_guest_entry(static inline void ppgtt_generate_shadow_entry (struct intel_gvt_gtt_entry *se,struct intel_vgpu_ppgtt_spt *s,struct intel_gvt_gtt_entry *ge) { -struct intel_gvt_gtt_pte_ops *ops = s->vgpu->gvt->gtt.pte_ops; +const struct intel_gvt_gtt_pte_ops *ops = s->vgpu->gvt->gtt.pte_ops; se->type = ge->type; se->val64 = ge->val64;@@ -1159,7 +1159,7 @@ static inline void ppgtt_generate_shadow_entry(struct intel_gvt_gtt_entry *se,static int is_2MB_gtt_possible (struct intel_vgpu *vgpu,struct intel_gvt_gtt_entry *entry) { -struct intel_gvt_gtt_pte_ops *ops = vgpu->gvt->gtt.pte_ops; +const struct intel_gvt_gtt_pte_ops *ops = vgpu->gvt->gtt.pte_ops;unsigned long pfn;if (!HAS_PAGE_SIZES (vgpu->gvt->gt->i915,I915_GTT_PAGE_SIZE_2M ))@@ -1176,7 +1176,7 @@ static int split_2MB_gtt_entry(struct intel_vgpu *vgpu, struct intel_vgpu_ppgtt_spt *spt, unsigned long index, struct intel_gvt_gtt_entry *se) { - struct intel_gvt_gtt_pte_ops *ops = vgpu->gvt->gtt.pte_ops; + const struct intel_gvt_gtt_pte_ops *ops = vgpu->gvt->gtt.pte_ops;struct intel_vgpu_ppgtt_spt *sub_spt;struct intel_gvt_gtt_entry sub_se;unsigned long start_gfn;@@ -1223,7 +1223,7 @@ static int split_64KB_gtt_entry(struct intel_vgpu *vgpu, struct intel_vgpu_ppgtt_spt *spt, unsigned long index, struct intel_gvt_gtt_entry *se) { - struct intel_gvt_gtt_pte_ops *ops = vgpu->gvt->gtt.pte_ops; + const struct intel_gvt_gtt_pte_ops *ops = vgpu->gvt->gtt.pte_ops;struct intel_gvt_gtt_entry entry = *se;unsigned long start_gfn;dma_addr_t dma_addr;@@ -1254,7 +1254,7 @@ static int ppgtt_populate_shadow_entry(struct intel_vgpu *vgpu, struct intel_vgpu_ppgtt_spt *spt, unsigned long index, struct intel_gvt_gtt_entry *ge) { - struct intel_gvt_gtt_pte_ops *pte_ops = vgpu->gvt->gtt.pte_ops; + const struct intel_gvt_gtt_pte_ops *pte_ops = vgpu->gvt->gtt.pte_ops;struct intel_gvt_gtt_entry se = *ge;unsigned long gfn, page_size =PAGE_SIZE ;dma_addr_t dma_addr;@@ -1308,7 +1308,7 @@ static int ppgtt_populate_spt(struct intel_vgpu_ppgtt_spt *spt) {struct intel_vgpu *vgpu = spt->vgpu;struct intel_gvt *gvt = vgpu->gvt; -struct intel_gvt_gtt_pte_ops *ops = gvt->gtt.pte_ops; +const struct intel_gvt_gtt_pte_ops *ops = gvt->gtt.pte_ops;struct intel_vgpu_ppgtt_spt *s;struct intel_gvt_gtt_entry se, ge;unsigned long gfn, i;@@ -1351,7 +1351,7 @@ static int ppgtt_handle_guest_entry_removal(struct intel_vgpu_ppgtt_spt *spt, struct intel_gvt_gtt_entry *se, unsigned long index) {struct intel_vgpu *vgpu = spt->vgpu; -struct intel_gvt_gtt_pte_ops *ops = vgpu->gvt->gtt.pte_ops; +const struct intel_gvt_gtt_pte_ops *ops = vgpu->gvt->gtt.pte_ops;int ret; trace_spt_guest_change(spt->vgpu->id, "remove", spt,@@ -1432,7 +1432,7 @@ static int sync_oos_page(struct intel_vgpu *vgpu, {const struct intel_gvt_device_info *info = &vgpu->gvt->device_info;struct intel_gvt *gvt = vgpu->gvt; -struct intel_gvt_gtt_pte_ops *ops = gvt->gtt.pte_ops; +const struct intel_gvt_gtt_pte_ops *ops = gvt->gtt.pte_ops;struct intel_vgpu_ppgtt_spt *spt = oos_page->spt;struct intel_gvt_gtt_entry old, new;int index;@@ -1603,7 +1603,7 @@ static int ppgtt_handle_guest_write_page_table( {struct intel_vgpu *vgpu = spt->vgpu;int type = spt->shadow_page.type; -struct intel_gvt_gtt_pte_ops *ops = vgpu->gvt->gtt.pte_ops; +const struct intel_gvt_gtt_pte_ops *ops = vgpu->gvt->gtt.pte_ops;struct intel_gvt_gtt_entry old_se;int new_present;int i, ret;@@ -1720,7 +1720,7 @@ static int ppgtt_handle_guest_write_page_table_bytes( u64 pa, void *p_data, int bytes) { struct intel_vgpu *vgpu = spt->vgpu; -struct intel_gvt_gtt_pte_ops *ops = vgpu->gvt->gtt.pte_ops; +const struct intel_gvt_gtt_pte_ops *ops = vgpu->gvt->gtt.pte_ops;const struct intel_gvt_device_info *info = &vgpu->gvt->device_info;struct intel_gvt_gtt_entry we, se;unsigned long index;@@ -1785,7 +1785,7 @@ static void invalidate_ppgtt_mm(struct intel_vgpu_mm *mm)struct intel_vgpu *vgpu = mm->vgpu;struct intel_gvt *gvt = vgpu->gvt;struct intel_gvt_gtt *gtt = &gvt->gtt; -struct intel_gvt_gtt_pte_ops *ops = gtt->pte_ops; +const struct intel_gvt_gtt_pte_ops *ops = gtt->pte_ops;struct intel_gvt_gtt_entry se;int index;@@ -1815,7 +1815,7 @@ static int shadow_ppgtt_mm(struct intel_vgpu_mm *mm)struct intel_vgpu *vgpu = mm->vgpu;struct intel_gvt *gvt = vgpu->gvt;struct intel_gvt_gtt *gtt = &gvt->gtt; -struct intel_gvt_gtt_pte_ops *ops = gtt->pte_ops; +const struct intel_gvt_gtt_pte_ops *ops = gtt->pte_ops;struct intel_vgpu_ppgtt_spt *spt;struct intel_gvt_gtt_entry ge, se;int index, ret;@@ -2067,7 +2067,7 @@ static inline int ppgtt_get_next_level_entry(struct intel_vgpu_mm *mm, struct intel_gvt_gtt_entry *e, unsigned long index, bool guest) { struct intel_vgpu *vgpu = mm->vgpu; -struct intel_gvt_gtt_pte_ops *ops = vgpu->gvt->gtt.pte_ops; +const struct intel_gvt_gtt_pte_ops *ops = vgpu->gvt->gtt.pte_ops;struct intel_vgpu_ppgtt_spt *s; s =intel_vgpu_find_spt_by_mfn (vgpu, ops->get_pfn (e));@@ -2096,7 +2096,7 @@ unsigned long intel_vgpu_gma_to_gpa(struct intel_vgpu_mm *mm, unsigned long gma) {struct intel_vgpu *vgpu = mm->vgpu;struct intel_gvt *gvt = vgpu->gvt; -struct intel_gvt_gtt_pte_ops *pte_ops = gvt->gtt.pte_ops; +const struct intel_gvt_gtt_pte_ops *pte_ops = gvt->gtt.pte_ops;const struct intel_gvt_gtt_gma_ops *gma_ops = gvt->gtt.gma_ops;unsigned long gpa =INTEL_GVT_INVALID_ADDR ;unsigned long gma_index[4 ];@@ -2221,7 +2221,7 @@ int intel_vgpu_emulate_ggtt_mmio_read(struct intel_vgpu *vgpu, unsigned int off,static void ggtt_invalidate_pte (struct intel_vgpu *vgpu,struct intel_gvt_gtt_entry *entry) { -struct intel_gvt_gtt_pte_ops *pte_ops = vgpu->gvt->gtt.pte_ops; +const struct intel_gvt_gtt_pte_ops *pte_ops = vgpu->gvt->gtt.pte_ops;unsigned long pfn; pfn = pte_ops->get_pfn (entry);@@ -2236,7 +2236,7 @@ static int emulate_ggtt_mmio_write(struct intel_vgpu *vgpu, unsigned int off,struct intel_gvt *gvt = vgpu->gvt;const struct intel_gvt_device_info *info = &gvt->device_info;struct intel_vgpu_mm *ggtt_mm = vgpu->gtt.ggtt_mm; -struct intel_gvt_gtt_pte_ops *ops = gvt->gtt.pte_ops; +const struct intel_gvt_gtt_pte_ops *ops = gvt->gtt.pte_ops;unsigned long g_gtt_index = off >> info->gtt_entry_size_shift;unsigned long gma, gfn;struct intel_gvt_gtt_entry e = {.val64 =0 , .type =GTT_TYPE_GGTT_PTE };@@ -2391,7 +2391,7 @@ static int alloc_scratch_pages(struct intel_vgpu *vgpu, {struct drm_i915_private *i915 = vgpu->gvt->gt->i915;struct intel_vgpu_gtt *gtt = &vgpu->gtt; -struct intel_gvt_gtt_pte_ops *ops = vgpu->gvt->gtt.pte_ops; +const struct intel_gvt_gtt_pte_ops *ops = vgpu->gvt->gtt.pte_ops;int page_entry_num =I915_GTT_PAGE_SIZE >> vgpu->gvt->device_info.gtt_entry_size_shift;void *scratch_pt;@@ -2822,7 +2822,7 @@ void intel_vgpu_invalidate_ppgtt(struct intel_vgpu *vgpu)void intel_vgpu_reset_ggtt (struct intel_vgpu *vgpu,bool invalidate_old) {struct intel_gvt *gvt = vgpu->gvt; -struct intel_gvt_gtt_pte_ops *pte_ops = vgpu->gvt->gtt.pte_ops; +const struct intel_gvt_gtt_pte_ops *pte_ops = vgpu->gvt->gtt.pte_ops;struct intel_gvt_gtt_entry entry = {.type =GTT_TYPE_GGTT_PTE };struct intel_gvt_gtt_entry old_entry;u32 index;drivers/gpu/drm/i915/gvt/gtt.h +0
-0
drivers/gpu/drm/i915/gvt/gtt.h struct intel_gvt_gtt_gma_ops { · line 97
Quoted 8 lines
drivers/gpu/drm/i915/gvt/gtt.h +1
-1@@ -91,7 +91,7 @@ struct intel_gvt_gtt_gma_ops { };struct intel_gvt_gtt { -struct intel_gvt_gtt_pte_ops *pte_ops; +const struct intel_gvt_gtt_pte_ops *pte_ops;const struct intel_gvt_gtt_gma_ops *gma_ops;int (*mm_alloc_page_table)(struct intel_vgpu_mm *mm);void (*mm_free_page_table)(struct intel_vgpu_mm *mm);
PATCH 3/9 drm/i915/gvt: Constify intel_gvt_irq_ops
In reply to Rikard FalkebornThese are never modified, so make them const to allow the compiler to put them in read-only memory.
--- drivers/gpu/drm/i915/gvt/interrupt.c | 10 +++++----- drivers/gpu/drm/i915/gvt/interrupt.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/gvt/interrupt.c +5 -5
@@ -176,7 +176,7 @@ int intel_vgpu_reg_imr_handler(struct intel_vgpu *vgpu, unsigned int reg, void *p_data, unsigned int bytes) { struct intel_gvt *gvt = vgpu->gvt; -struct intel_gvt_irq_ops *ops = gvt->irq.ops; +const struct intel_gvt_irq_ops *ops = gvt->irq.ops;u32 imr = *(u32 *)p_data; trace_write_ir(vgpu->id, "IMR", reg, imr, vgpu_vreg(vgpu, reg),
@@ -206,7 +206,7 @@ int intel_vgpu_reg_master_irq_handler(struct intel_vgpu *vgpu, unsigned int reg, void *p_data, unsigned int bytes) { struct intel_gvt *gvt = vgpu->gvt; -struct intel_gvt_irq_ops *ops = gvt->irq.ops; +const struct intel_gvt_irq_ops *ops = gvt->irq.ops;u32 ier = *(u32 *)p_data;u32 virtual_ier =vgpu_vreg (vgpu, reg);
@@ -246,7 +246,7 @@ int intel_vgpu_reg_ier_handler(struct intel_vgpu *vgpu, {struct intel_gvt *gvt = vgpu->gvt;struct drm_i915_private *i915 = gvt->gt->i915; -struct intel_gvt_irq_ops *ops = gvt->irq.ops; +const struct intel_gvt_irq_ops *ops = gvt->irq.ops;struct intel_gvt_irq_info *info;u32 ier = *(u32 *)p_data;
@@ -604,7 +604,7 @@ static void gen8_init_irq(SET_BIT_INFO (irq,25 ,PCU_PCODE2DRIVER_MAILBOX ,INTEL_GVT_IRQ_INFO_PCU ); } -static struct intel_gvt_irq_ops gen8_irq_ops = { +static const struct intel_gvt_irq_ops gen8_irq_ops = { .init_irq = gen8_init_irq, .check_pending_irq = gen8_check_pending_irq, };
@@ -626,7 +626,7 @@ void intel_vgpu_trigger_virtual_event(struct intel_vgpu *vgpu,struct intel_gvt *gvt = vgpu->gvt;struct intel_gvt_irq *irq = &gvt->irq;gvt_event_virt_handler_t handler; -struct intel_gvt_irq_ops *ops = gvt->irq.ops; +const struct intel_gvt_irq_ops *ops = gvt->irq.ops; handler =get_event_virt_handler (irq, event);drm_WARN_ON (&i915->drm, !handler);
drivers/gpu/drm/i915/gvt/interrupt.h +1 -1
@@ -203,7 +203,7 @@ struct intel_gvt_irq_map {/* structure containing device specific IRQ state */ struct intel_gvt_irq { -struct intel_gvt_irq_ops *ops; +const struct intel_gvt_irq_ops *ops;struct intel_gvt_irq_info *info[INTEL_GVT_IRQ_INFO_MAX ]; DECLARE_BITMAP(irq_info_bitmap, INTEL_GVT_IRQ_INFO_MAX);struct intel_gvt_event_info events[INTEL_GVT_EVENT_MAX ];
Signature · 1 line
2.34.1
Re: [PATCH 3/9] drm/i915/gvt: Constify intel_gvt_irq_ops
Quoted 63 lines · Rikard Falkeborn
These are never modified, so make them const to allow the compiler to put them in read-only memory.
Signed-off-by Rikard Falkeborn <[email protected]>--- drivers/gpu/drm/i915/gvt/interrupt.c | 10 +++++----- drivers/gpu/drm/i915/gvt/interrupt.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-)drivers/gpu/drm/i915/gvt/interrupt.c +5
-5@@ -176,7 +176,7 @@ int intel_vgpu_reg_imr_handler(struct intel_vgpu *vgpu, unsigned int reg, void *p_data, unsigned int bytes) { struct intel_gvt *gvt = vgpu->gvt; -struct intel_gvt_irq_ops *ops = gvt->irq.ops; +const struct intel_gvt_irq_ops *ops = gvt->irq.ops;u32 imr = *(u32 *)p_data; trace_write_ir(vgpu->id, "IMR", reg, imr, vgpu_vreg(vgpu, reg),@@ -206,7 +206,7 @@ int intel_vgpu_reg_master_irq_handler(struct intel_vgpu *vgpu, unsigned int reg, void *p_data, unsigned int bytes) { struct intel_gvt *gvt = vgpu->gvt; -struct intel_gvt_irq_ops *ops = gvt->irq.ops; +const struct intel_gvt_irq_ops *ops = gvt->irq.ops;u32 ier = *(u32 *)p_data;u32 virtual_ier =vgpu_vreg (vgpu, reg);@@ -246,7 +246,7 @@ int intel_vgpu_reg_ier_handler(struct intel_vgpu *vgpu, {struct intel_gvt *gvt = vgpu->gvt;struct drm_i915_private *i915 = gvt->gt->i915; -struct intel_gvt_irq_ops *ops = gvt->irq.ops; +const struct intel_gvt_irq_ops *ops = gvt->irq.ops;struct intel_gvt_irq_info *info;u32 ier = *(u32 *)p_data;@@ -604,7 +604,7 @@ static void gen8_init_irq(SET_BIT_INFO (irq,25 ,PCU_PCODE2DRIVER_MAILBOX ,INTEL_GVT_IRQ_INFO_PCU ); } -static struct intel_gvt_irq_ops gen8_irq_ops = { +static const struct intel_gvt_irq_ops gen8_irq_ops = { .init_irq = gen8_init_irq, .check_pending_irq = gen8_check_pending_irq, };@@ -626,7 +626,7 @@ void intel_vgpu_trigger_virtual_event(struct intel_vgpu *vgpu,struct intel_gvt *gvt = vgpu->gvt;struct intel_gvt_irq *irq = &gvt->irq;gvt_event_virt_handler_t handler; -struct intel_gvt_irq_ops *ops = gvt->irq.ops; +const struct intel_gvt_irq_ops *ops = gvt->irq.ops; handler =get_event_virt_handler (irq, event);drm_WARN_ON (&i915->drm, !handler);drivers/gpu/drm/i915/gvt/interrupt.h +0
-0
drivers/gpu/drm/i915/gvt/interrupt.h struct intel_gvt_irq_map { · line 209
Quoted 8 lines
drivers/gpu/drm/i915/gvt/interrupt.h +1
-1@@ -203,7 +203,7 @@ struct intel_gvt_irq_map {/* structure containing device specific IRQ state */ struct intel_gvt_irq { -struct intel_gvt_irq_ops *ops; +const struct intel_gvt_irq_ops *ops;struct intel_gvt_irq_info *info[INTEL_GVT_IRQ_INFO_MAX ]; DECLARE_BITMAP(irq_info_bitmap, INTEL_GVT_IRQ_INFO_MAX);struct intel_gvt_event_info events[INTEL_GVT_EVENT_MAX ];
PATCH 4/9 drm/i915/gvt: Constify intel_gvt_sched_policy_ops
In reply to Rikard FalkebornThese are never modified, so make them const to allow the compiler to put them in read-only memory.
--- drivers/gpu/drm/i915/gvt/sched_policy.c | 2 +- drivers/gpu/drm/i915/gvt/scheduler.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/gvt/sched_policy.c +1 -1
@@ -368,7 +368,7 @@ static void tbs_sched_stop_schedule(struct intel_vgpu *vgpu) vgpu_data->active = false; } -static struct intel_gvt_sched_policy_ops tbs_schedule_ops = { +static const struct intel_gvt_sched_policy_ops tbs_schedule_ops = { .init = tbs_sched_init, .clean = tbs_sched_clean, .init_vgpu = tbs_sched_init_vgpu,
drivers/gpu/drm/i915/gvt/scheduler.h +1 -1
@@ -56,7 +56,7 @@ struct intel_gvt_workload_scheduler {wait_queue_head_t waitq[I915_NUM_ENGINES ];void *sched_data; -struct intel_gvt_sched_policy_ops *sched_ops; +const struct intel_gvt_sched_policy_ops *sched_ops; };#define INDIRECT_CTX_ADDR_MASK 0xffffffc0
Signature · 1 line
2.34.1
Re: [PATCH 4/9] drm/i915/gvt: Constify intel_gvt_sched_policy_ops
Quoted 27 lines · Rikard Falkeborn
These are never modified, so make them const to allow the compiler to put them in read-only memory.
Signed-off-by Rikard Falkeborn <[email protected]>--- drivers/gpu/drm/i915/gvt/sched_policy.c | 2 +- drivers/gpu/drm/i915/gvt/scheduler.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)drivers/gpu/drm/i915/gvt/sched_policy.c +1
-1@@ -368,7 +368,7 @@ static void tbs_sched_stop_schedule(struct intel_vgpu *vgpu) vgpu_data->active = false; } -static struct intel_gvt_sched_policy_ops tbs_schedule_ops = { +static const struct intel_gvt_sched_policy_ops tbs_schedule_ops = { .init = tbs_sched_init, .clean = tbs_sched_clean, .init_vgpu = tbs_sched_init_vgpu,drivers/gpu/drm/i915/gvt/scheduler.h +0
-0
drivers/gpu/drm/i915/gvt/scheduler.h struct intel_gvt_workload_scheduler { · line 62
Quoted 8 lines
drivers/gpu/drm/i915/gvt/scheduler.h +1
-1@@ -56,7 +56,7 @@ struct intel_gvt_workload_scheduler {wait_queue_head_t waitq[I915_NUM_ENGINES ];void *sched_data; -struct intel_gvt_sched_policy_ops *sched_ops; +const struct intel_gvt_sched_policy_ops *sched_ops; };#define INDIRECT_CTX_ADDR_MASK 0xffffffc0
PATCH 5/9 drm/i915/gvt: Constify gvt_mmio_block
In reply to Rikard FalkebornThese are never modified, so make them const to allow the compiler to put it in read-only memory.
--- drivers/gpu/drm/i915/gvt/gvt.h | 2 +- drivers/gpu/drm/i915/gvt/handlers.c | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-)
drivers/gpu/drm/i915/gvt/gvt.h +1 -1
@@ -272,7 +272,7 @@ struct intel_gvt_mmio {/* Value of command write of this reg needs to be patched */ #define F_CMD_WRITE_PATCH (1 << 8) -struct gvt_mmio_block *mmio_block; +const struct gvt_mmio_block *mmio_block;unsigned int num_mmio_block;DECLARE_HASHTABLE (mmio_info_table,INTEL_GVT_MMIO_HASH_BITS );
drivers/gpu/drm/i915/gvt/handlers.c +6 -6
@@ -3627,11 +3627,11 @@ static int init_bxt_mmio_info(struct intel_gvt *gvt)return 0 ; } -static struct gvt_mmio_block *find_mmio_block (struct intel_gvt *gvt, -unsigned int offset) +static const struct gvt_mmio_block *find_mmio_block (struct intel_gvt *gvt, +unsigned int offset) {unsigned long device =intel_gvt_get_device_type (gvt); -struct gvt_mmio_block *block = gvt->mmio.mmio_block; +const struct gvt_mmio_block *block = gvt->mmio.mmio_block;int num = gvt->mmio.num_mmio_block;int i;
@@ -3670,7 +3670,7 @@ void intel_gvt_clean_mmio_info(struct intel_gvt *gvt)* accessible (should have no F_CMD_ACCESS flag). * otherwise, need to update cmd_reg_handler in cmd_parser.c */ -static struct gvt_mmio_block mmio_blocks[] = { +static const struct gvt_mmio_block mmio_blocks[] = { {D_SKL_PLUS ,_MMIO (DMC_MMIO_START_RANGE ),0x3000 ,NULL ,NULL }, {D_ALL ,_MMIO (MCHBAR_MIRROR_BASE_SNB ),0x40000 ,NULL ,NULL }, {D_ALL ,_MMIO (VGT_PVINFO_PAGE ),VGT_PVINFO_SIZE ,
@@ -3753,7 +3753,7 @@ int intel_gvt_for_each_tracked_mmio(struct intel_gvt *gvt,int (*handler)(struct intel_gvt *gvt,u32 offset,void *data), void *data) { - struct gvt_mmio_block *block = gvt->mmio.mmio_block; + const struct gvt_mmio_block *block = gvt->mmio.mmio_block;struct intel_gvt_mmio_info *e;int i, j, ret;
@@ -3871,7 +3871,7 @@ int intel_vgpu_mmio_reg_rw(struct intel_vgpu *vgpu, unsigned int offset,struct drm_i915_private *i915 = vgpu->gvt->gt->i915;struct intel_gvt *gvt = vgpu->gvt;struct intel_gvt_mmio_info *mmio_info; -struct gvt_mmio_block *mmio_block; +const struct gvt_mmio_block *mmio_block;gvt_mmio_func func;int ret;
Signature · 1 line
2.34.1
Re: [PATCH 5/9] drm/i915/gvt: Constify gvt_mmio_block
Quoted 60 lines · Rikard Falkeborn
These are never modified, so make them const to allow the compiler to put it in read-only memory.
Signed-off-by Rikard Falkeborn <[email protected]>--- drivers/gpu/drm/i915/gvt/gvt.h | 2 +- drivers/gpu/drm/i915/gvt/handlers.c | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-)drivers/gpu/drm/i915/gvt/gvt.h +1
-1@@ -272,7 +272,7 @@ struct intel_gvt_mmio {/* Value of command write of this reg needs to be patched */ #define F_CMD_WRITE_PATCH (1 << 8) -struct gvt_mmio_block *mmio_block; +const struct gvt_mmio_block *mmio_block;unsigned int num_mmio_block;DECLARE_HASHTABLE (mmio_info_table,INTEL_GVT_MMIO_HASH_BITS );drivers/gpu/drm/i915/gvt/handlers.c +5
-5@@ -3627,11 +3627,11 @@ static int init_bxt_mmio_info(struct intel_gvt *gvt)return 0 ; } -static struct gvt_mmio_block *find_mmio_block (struct intel_gvt *gvt, -unsigned int offset) +static const struct gvt_mmio_block *find_mmio_block (struct intel_gvt *gvt, +unsigned int offset) {unsigned long device =intel_gvt_get_device_type (gvt); -struct gvt_mmio_block *block = gvt->mmio.mmio_block; +const struct gvt_mmio_block *block = gvt->mmio.mmio_block;int num = gvt->mmio.num_mmio_block;int i;@@ -3670,7 +3670,7 @@ void intel_gvt_clean_mmio_info(struct intel_gvt *gvt)* accessible (should have no F_CMD_ACCESS flag). * otherwise, need to update cmd_reg_handler in cmd_parser.c */ -static struct gvt_mmio_block mmio_blocks[] = { +static const struct gvt_mmio_block mmio_blocks[] = { {D_SKL_PLUS ,_MMIO (DMC_MMIO_START_RANGE ),0x3000 ,NULL ,NULL }, {D_ALL ,_MMIO (MCHBAR_MIRROR_BASE_SNB ),0x40000 ,NULL ,NULL }, {D_ALL ,_MMIO (VGT_PVINFO_PAGE ),VGT_PVINFO_SIZE ,@@ -3753,7 +3753,7 @@ int intel_gvt_for_each_tracked_mmio(struct intel_gvt *gvt,int (*handler)(struct intel_gvt *gvt,u32 offset,void *data), void *data) { - struct gvt_mmio_block *block = gvt->mmio.mmio_block; + const struct gvt_mmio_block *block = gvt->mmio.mmio_block;struct intel_gvt_mmio_info *e;int i, j, ret;
drivers/gpu/drm/i915/gvt/handlers.c int intel_vgpu_mmio_reg_rw(struct intel_vgpu *vgpu, unsigned int offset, · line 3877
Quoted 8 lines
drivers/gpu/drm/i915/gvt/handlers.c +1
-1@@ -3871,7 +3871,7 @@ int intel_vgpu_mmio_reg_rw(struct intel_vgpu *vgpu, unsigned int offset,struct drm_i915_private *i915 = vgpu->gvt->gt->i915;struct intel_gvt *gvt = vgpu->gvt;struct intel_gvt_mmio_info *mmio_info; -struct gvt_mmio_block *mmio_block; +const struct gvt_mmio_block *mmio_block;gvt_mmio_func func;int ret;
PATCH 6/9 drm/i915/gvt: Constify cmd_interrupt_events
In reply to Rikard FalkebornIt is never modified, so make it const to allow the compiler to put it in read-only memory.
--- drivers/gpu/drm/i915/gvt/cmd_parser.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/i915/gvt/cmd_parser.c +1 -1
@@ -1144,7 +1144,7 @@ struct cmd_interrupt_event {int mi_user_interrupt; }; -static struct cmd_interrupt_event cmd_interrupt_events[] = { +static const struct cmd_interrupt_event cmd_interrupt_events[] = { [RCS0 ] = { .pipe_control_notify =RCS_PIPE_CONTROL , .mi_flush_dw =INTEL_GVT_EVENT_RESERVED ,
Signature · 1 line
2.34.1
Re: [PATCH 6/9] drm/i915/gvt: Constify cmd_interrupt_events
Quoted 13 lines · Rikard Falkeborn
It is never modified, so make it const to allow the compiler to put it in read-only memory.
Signed-off-by Rikard Falkeborn <[email protected]>--- drivers/gpu/drm/i915/gvt/cmd_parser.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/i915/gvt/cmd_parser.c +0
-0
drivers/gpu/drm/i915/gvt/cmd_parser.c struct cmd_interrupt_event { · line 1150
Quoted 8 lines
drivers/gpu/drm/i915/gvt/cmd_parser.c +1
-1@@ -1144,7 +1144,7 @@ struct cmd_interrupt_event {int mi_user_interrupt; }; -static struct cmd_interrupt_event cmd_interrupt_events[] = { +static const struct cmd_interrupt_event cmd_interrupt_events[] = { [RCS0 ] = { .pipe_control_notify =RCS_PIPE_CONTROL , .mi_flush_dw =INTEL_GVT_EVENT_RESERVED ,
PATCH 7/9 drm/i915/gvt: Constify formats
In reply to Rikard FalkebornThese are never modified, so make them const to allow the compiler to put them in read-only memory. WHile at it, make the description const char* since it is never modified.
--- drivers/gpu/drm/i915/gvt/fb_decoder.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)
drivers/gpu/drm/i915/gvt/fb_decoder.c +12 -12
@@ -40,12 +40,12 @@#define PRIMARY_FORMAT_NUM 16struct pixel_format { -int drm_format;/* Pixel format in DRM definition */ -int bpp;/* Bits per pixel, 0 indicates invalid */ -char *desc;/* The description */ +int drm_format;/* Pixel format in DRM definition */ +int bpp;/* Bits per pixel, 0 indicates invalid */ +const char *desc;/* The description */ }; -static struct pixel_format bdw_pixel_formats[] = { +static const struct pixel_format bdw_pixel_formats[] = { {DRM_FORMAT_C8 ,8 ,"8-bit Indexed" }, {DRM_FORMAT_RGB565 ,16 ,"16-bit BGRX (5:6:5 MSB-R:G:B)" }, {DRM_FORMAT_XRGB8888 ,32 ,"32-bit BGRX (8:8:8:8 MSB-X:R:G:B)" },
@@ -58,7 +58,7 @@ static struct pixel_format bdw_pixel_formats[] = { {0, 0, NULL}, }; -static struct pixel_format skl_pixel_formats[] = { +static const struct pixel_format skl_pixel_formats[] = { {DRM_FORMAT_YUYV ,16 ,"16-bit packed YUYV (8:8:8:8 MSB-V:Y2:U:Y1)" }, {DRM_FORMAT_UYVY ,16 ,"16-bit packed UYVY (8:8:8:8 MSB-Y2:V:Y1:U)" }, {DRM_FORMAT_YVYU, 16, "16-bit packed YVYU (8:8:8:8 MSB-U:Y2:V:Y1)"},
@@ -278,14 +278,14 @@ int intel_vgpu_decode_primary_plane(struct intel_vgpu *vgpu,#define CURSOR_FORMAT_NUM (1 << 6)struct cursor_mode_format { -int drm_format;/* Pixel format in DRM definition */ -u8 bpp;/* Bits per pixel; 0 indicates invalid */ -u32 width;/* In pixel */ -u32 height;/* In lines */ -char *desc;/* The description */ +int drm_format;/* Pixel format in DRM definition */ +u8 bpp;/* Bits per pixel; 0 indicates invalid */ +u32 width;/* In pixel */ +u32 height;/* In lines */ +const char *desc;/* The description */ }; -static struct cursor_mode_format cursor_pixel_formats[] = { +static const struct cursor_mode_format cursor_pixel_formats[] = { {DRM_FORMAT_ARGB8888 ,32 ,128 ,128 ,"128x128 32bpp ARGB" }, {DRM_FORMAT_ARGB8888 ,32 ,256 ,256 ,"256x256 32bpp ARGB" }, {DRM_FORMAT_ARGB8888 ,32 ,64 ,64 ,"64x64 32bpp ARGB" },
@@ -391,7 +391,7 @@ int intel_vgpu_decode_cursor_plane(struct intel_vgpu *vgpu,#define SPRITE_FORMAT_NUM (1 << 3) -static struct pixel_format sprite_pixel_formats[SPRITE_FORMAT_NUM ] = { +static const struct pixel_format sprite_pixel_formats[SPRITE_FORMAT_NUM ] = { [0x0 ] = {DRM_FORMAT_YUV422 ,16 ,"YUV 16-bit 4:2:2 packed" }, [0x1 ] = {DRM_FORMAT_XRGB2101010 ,32 ,"RGB 32-bit 2:10:10:10" }, [0x2 ] = {DRM_FORMAT_XRGB8888 ,32 ,"RGB 32-bit 8:8:8:8" },
Signature · 1 line
2.34.1
Re: [PATCH 7/9] drm/i915/gvt: Constify formats
Quoted 14 lines · Rikard Falkeborn
These are never modified, so make them const to allow the compiler to put them in read-only memory. WHile at it, make the description const char* since it is never modified.
Signed-off-by Rikard Falkeborn <[email protected]>--- drivers/gpu/drm/i915/gvt/fb_decoder.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)drivers/gpu/drm/i915/gvt/fb_decoder.c +0
-0
drivers/gpu/drm/i915/gvt/fb_decoder.c line 46
Quoted 10 lines
drivers/gpu/drm/i915/gvt/fb_decoder.c +3
-3@@ -40,12 +40,12 @@#define PRIMARY_FORMAT_NUM 16struct pixel_format { -int drm_format;/* Pixel format in DRM definition */ -int bpp;/* Bits per pixel, 0 indicates invalid */ -char *desc;/* The description */ +int drm_format;/* Pixel format in DRM definition */ +int bpp;/* Bits per pixel, 0 indicates invalid */ +const char *desc;/* The description */ };
Thanks so much for this. According to the code of i915, we prefer using one space as seperator.
Quoted 20 lines
drivers/gpu/drm/i915/gvt/fb_decoder.c +2
-3-static struct pixel_format bdw_pixel_formats[] = { +static const struct pixel_format bdw_pixel_formats[] = { {DRM_FORMAT_C8 ,8 ,"8-bit Indexed" }, {DRM_FORMAT_RGB565 ,16 ,"16-bit BGRX (5:6:5 MSB-R:G:B)" }, {DRM_FORMAT_XRGB8888 ,32 ,"32-bit BGRX (8:8:8:8 MSB-X:R:G:B)" },@@ -58,7 +58,7 @@ static struct pixel_format bdw_pixel_formats[] = { {0, 0, NULL}, }; -static struct pixel_format skl_pixel_formats[] = { +static const struct pixel_format skl_pixel_formats[] = { {DRM_FORMAT_YUYV ,16 ,"16-bit packed YUYV (8:8:8:8 MSB-V:Y2:U:Y1)" }, {DRM_FORMAT_UYVY ,16 ,"16-bit packed UYVY (8:8:8:8 MSB-Y2:V:Y1:U)" }, {DRM_FORMAT_YVYU, 16, "16-bit packed YVYU (8:8:8:8 MSB-U:Y2:V:Y1)"},@@ -278,14 +278,14 @@ int intel_vgpu_decode_primary_plane(struct intel_vgpu *vgpu,#define CURSOR_FORMAT_NUM (1 << 6)struct cursor_mode_format { -int drm_format;/* Pixel format in DRM definition */
drivers/gpu/drm/i915/gvt/fb_decoder.c int intel_vgpu_decode_primary_plane(struct intel_vgpu *vgpu, · line 286
Quoted 10 lines
drivers/gpu/drm/i915/gvt/fb_decoder.c +5
-4-u8 bpp;/* Bits per pixel; 0 indicates invalid */ -u32 width;/* In pixel */ -u32 height;/* In lines */ -char *desc;/* The description */ +int drm_format;/* Pixel format in DRM definition */ +u8 bpp;/* Bits per pixel; 0 indicates invalid */ +u32 width;/* In pixel */ +u32 height;/* In lines */ +const char *desc;/* The description */ };
The same comment as above.
Quoted 6 lines
drivers/gpu/drm/i915/gvt/fb_decoder.c +1
-1-static struct cursor_mode_format cursor_pixel_formats[] = { +static const struct cursor_mode_format cursor_pixel_formats[] = { {DRM_FORMAT_ARGB8888 ,32 ,128 ,128 ,"128x128 32bpp ARGB" }, {DRM_FORMAT_ARGB8888 ,32 ,256 ,256 ,"256x256 32bpp ARGB" }, {DRM_FORMAT_ARGB8888 ,32 ,64 ,64 ,"64x64 32bpp ARGB" },
drivers/gpu/drm/i915/gvt/fb_decoder.c int intel_vgpu_decode_cursor_plane(struct intel_vgpu *vgpu, · line 397
Quoted 8 lines
drivers/gpu/drm/i915/gvt/fb_decoder.c +1
-1@@ -391,7 +391,7 @@ int intel_vgpu_decode_cursor_plane(struct intel_vgpu *vgpu,#define SPRITE_FORMAT_NUM (1 << 3) -static struct pixel_format sprite_pixel_formats[SPRITE_FORMAT_NUM ] = { +static const struct pixel_format sprite_pixel_formats[SPRITE_FORMAT_NUM ] = { [0x0 ] = {DRM_FORMAT_YUV422 ,16 ,"YUV 16-bit 4:2:2 packed" }, [0x1 ] = {DRM_FORMAT_XRGB2101010 ,32 ,"RGB 32-bit 2:10:10:10" }, [0x2 ] = {DRM_FORMAT_XRGB8888 ,32 ,"RGB 32-bit 8:8:8:8" },
The rest of the patch looks good to me.
Re: [PATCH 7/9] drm/i915/gvt: Constify formats
Quoted 16 lines · Zhi A
Quoted 15 lines · Rikard Falkeborn
These are never modified, so make them const to allow the compiler to put them in read-only memory. WHile at it, make the description const char* since it is never modified.
Signed-off-by Rikard Falkeborn <[email protected]>--- drivers/gpu/drm/i915/gvt/fb_decoder.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)drivers/gpu/drm/i915/gvt/fb_decoder.c +0
-0@@ -40,12 +40,12 @@
Quoted 12 lines
drivers/gpu/drm/i915/gvt/fb_decoder.c line 46
Quoted 9 lines
drivers/gpu/drm/i915/gvt/fb_decoder.c +3
-3#define PRIMARY_FORMAT_NUM 16struct pixel_format { -int drm_format;/* Pixel format in DRM definition */ -int bpp;/* Bits per pixel, 0 indicates invalid */ -char *desc;/* The description */ +int drm_format;/* Pixel format in DRM definition */ +int bpp;/* Bits per pixel, 0 indicates invalid */ +const char *desc;/* The description */ };Thanks so much for this. According to the code of i915, we prefer using one space as seperator.
Quoted 1 line
Thanks for reviewing. Just to clarify, is this how you want it to look:
struct pixel_format {
int drm_format; /* Pixel format in DRM definition */ int bpp; /* Bits per pixel, 0 indicates invalid */ char *desc; /* The description */
};
Rikard
PATCH 8/9 drm/i915/gvt: Constify gtt_type_table_entry
In reply to Rikard FalkebornIt is never modified, so make it const to allow the compiler to put it in read-only memory.
--- drivers/gpu/drm/i915/gvt/gtt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/i915/gvt/gtt.c +1 -1
@@ -185,7 +185,7 @@ struct gtt_type_table_entry { .pse_entry_type = pse_type, \ } -static struct gtt_type_table_entry gtt_type_table[] = { +static const struct gtt_type_table_entry gtt_type_table[] = { GTT_TYPE_TABLE_ENTRY(GTT_TYPE_PPGTT_ROOT_L4_ENTRY, GTT_TYPE_PPGTT_ROOT_L4_ENTRY, GTT_TYPE_INVALID,
Signature · 1 line
2.34.1
Re: [PATCH 8/9] drm/i915/gvt: Constify gtt_type_table_entry
Quoted 13 lines · Rikard Falkeborn
It is never modified, so make it const to allow the compiler to put it in read-only memory.
Signed-off-by Rikard Falkeborn <[email protected]>--- drivers/gpu/drm/i915/gvt/gtt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/i915/gvt/gtt.c +0
-0
drivers/gpu/drm/i915/gvt/gtt.c struct gtt_type_table_entry { · line 191
Quoted 8 lines
drivers/gpu/drm/i915/gvt/gtt.c +1
-1@@ -185,7 +185,7 @@ struct gtt_type_table_entry { .pse_entry_type = pse_type, \ } -static struct gtt_type_table_entry gtt_type_table[] = { +static const struct gtt_type_table_entry gtt_type_table[] = { GTT_TYPE_TABLE_ENTRY(GTT_TYPE_PPGTT_ROOT_L4_ENTRY, GTT_TYPE_PPGTT_ROOT_L4_ENTRY, GTT_TYPE_INVALID,
PATCH 9/9 drm/i915/gvt: Constify vgpu_types
In reply to Rikard FalkebornIt is never modified, so make it const to allow the compiler to put it in read-only memory. While at it, make name a const char*.
--- drivers/gpu/drm/i915/gvt/vgpu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/gvt/vgpu.c +2 -2
@@ -77,7 +77,7 @@ void populate_pvinfo_page(struct intel_vgpu *vgpu)#define VGPU_WEIGHT (vgpu_num) \ (VGPU_MAX_WEIGHT / (vgpu_num)) -static struct { +static const struct { unsigned int low_mm; unsigned int high_mm; unsigned int fence;
@@ -88,7 +88,7 @@ static struct {*/ unsigned int weight;enum intel_vgpu_edid edid; -char *name; +const char *name; } vgpu_types[] = {/* Fixed vGPU type table */ { MB_TO_BYTES(64), MB_TO_BYTES(384), 4, VGPU_WEIGHT(8), GVT_EDID_1024_768, "8" },
Signature · 1 line
2.34.1
Re: [PATCH 9/9] drm/i915/gvt: Constify vgpu_types
Quoted 22 lines · Rikard Falkeborn
It is never modified, so make it const to allow the compiler to put it in read-only memory. While at it, make name a const char*.
Signed-off-by Rikard Falkeborn <[email protected]>--- drivers/gpu/drm/i915/gvt/vgpu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/gpu/drm/i915/gvt/vgpu.c +1
-1@@ -77,7 +77,7 @@ void populate_pvinfo_page(struct intel_vgpu *vgpu)#define VGPU_WEIGHT (vgpu_num) \ (VGPU_MAX_WEIGHT / (vgpu_num)) -static struct { +static const struct { unsigned int low_mm; unsigned int high_mm; unsigned int fence;
drivers/gpu/drm/i915/gvt/vgpu.c static struct { · line 94
Quoted 8 lines
drivers/gpu/drm/i915/gvt/vgpu.c +1
-1@@ -88,7 +88,7 @@ static struct {*/ unsigned int weight;enum intel_vgpu_edid edid; -char *name; +const char *name; } vgpu_types[] = {/* Fixed vGPU type table */ { MB_TO_BYTES(64), MB_TO_BYTES(384), 4, VGPU_WEIGHT(8), GVT_EDID_1024_768, "8" },
Patchwork
CI[Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for drm/i915/gvt: Constify static structs
In reply to Rikard Falkeborn== Series Details ==
== Series Details ==
Series: drm/i915/gvt: Constify static structs
URL : https://patchwork.freedesktop.org/series/97616/
State : warning
== Summary ==
$ dim checkpatch origin/drm-tip ad6d0d2d2854 drm/i915/gvt: Constify intel_gvt_gtt_pte_ops 9f75a74af3af drm/i915/gvt: Constify intel_gvt_gtt_pte_ops -:30: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #30: FILE: drivers/gpu/drm/i915/gvt/gtt.c:530: +static void update_entry_type_for_real(const struct intel_gvt_gtt_pte_ops *pte_ops, struct intel_gvt_gtt_entry *entry, bool ips)
total: 0 errors, 0 warnings, 1 checks, 256 lines checked b150cdd67e79 drm/i915/gvt: Constify intel_gvt_irq_ops e41696ad17dc drm/i915/gvt: Constify intel_gvt_sched_policy_ops 431473d1ea36 drm/i915/gvt: Constify gvt_mmio_block 6b20e5f39324 drm/i915/gvt: Constify cmd_interrupt_events d11cda723a89 drm/i915/gvt: Constify formats f75eaccd8a90 drm/i915/gvt: Constify gtt_type_table_entry 1b4f726b33b2 drm/i915/gvt: Constify vgpu_types
Patchwork
CI[Intel-gfx] ✗ Fi.CI.BAT: failure for drm/i915/gvt: Constify static structs
In reply to Rikard Falkeborn== Series Details ==
== Series Details ==
Series: drm/i915/gvt: Constify static structs
URL : https://patchwork.freedesktop.org/series/97616/
State : failure
== Summary ==
CI Bug Log - changes from CI_DRM_10965 -> Patchwork_21763
====================================================
Summary
-------
**FAILURE**
Serious unknown changes coming with Patchwork_21763 absolutely need to be verified manually.
If you think the reported changes have nothing to do with the changes introduced in Patchwork_21763, please notify your bug team to allow them to document this new failure mode, which will reduce false positives in CI.
External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21763/index.html
Participating hosts (43 -> 31)
------------------------------
Missing (12): fi-ilk-m540 bat-dg1-6 bat-dg1-5 fi-hsw-4200u fi-bsw-cyan bat-adlp-6 bat-adlp-4 fi-ctg-p8600 fi-kbl-x1275 fi-bdw-samus bat-jsl-2 bat-jsl-1
Possible new issues
-------------------
Here are the unknown changes that may have been introduced in Patchwork_21763:
### CI changes ###
#### Possible regressions ####
* boot:
- fi-ivb-3770: [PASS][1] -> [FAIL][2]
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10965/fi-ivb-3770/boot.html
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21763/fi-ivb-3770/boot.html
Known issues
------------
Here are the changes found in Patchwork_21763 that come from known issues:
### IGT changes ###
#### Issues hit ####
* igt@amdgpu/amd_basic@query-info:
- fi-bsw-kefka: NOTRUN -> [SKIP][3] ([fdo#109271]) +35 similar issues
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21763/fi-bsw-kefka/igt@amdgpu/[email protected]
* igt@amdgpu/amd_basic@semaphore:
- fi-bsw-nick: NOTRUN -> [SKIP][4] ([fdo#109271]) +17 similar issues
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21763/fi-bsw-nick/igt@amdgpu/[email protected]
* igt@gem_exec_parallel@engines:
- fi-skl-6600u: NOTRUN -> [FAIL][5] ([i915#4547])
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21763/fi-skl-6600u/igt@[email protected]
* igt@i915_selftest@live@gt_engines:
- fi-rkl-guc: [PASS][6] -> [INCOMPLETE][7] ([i915#4432])
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10965/fi-rkl-guc/igt@i915_selftest@live@gt_engines.html
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21763/fi-rkl-guc/igt@i915_selftest@live@gt_engines.html
* igt@kms_chamelium@hdmi-edid-read:
- fi-bsw-kefka: NOTRUN -> [SKIP][8] ([fdo#109271] / [fdo#111827]) +8 similar issues
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21763/fi-bsw-kefka/igt@[email protected]
* igt@runner@aborted:
- fi-skl-6600u: NOTRUN -> [FAIL][9] ([i915#3363] / [i915#4312])
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21763/fi-skl-6600u/igt@[email protected]
- fi-rkl-guc: NOTRUN -> [FAIL][10] ([i915#3928] / [i915#4312])
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21763/fi-rkl-guc/igt@[email protected]
#### Possible fixes ####
* igt@gem_exec_suspend@basic-s0:
- fi-bsw-kefka: [INCOMPLETE][11] ([i915#2539]) -> [PASS][12]
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10965/fi-bsw-kefka/igt@[email protected]
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21763/fi-bsw-kefka/igt@[email protected]
* igt@gem_exec_suspend@basic-s3:
- fi-tgl-1115g4: [FAIL][13] ([i915#1888]) -> [PASS][14]
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10965/fi-tgl-1115g4/igt@[email protected]
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21763/fi-tgl-1115g4/igt@[email protected]
* igt@i915_selftest@live@late_gt_pm:
- fi-bsw-nick: [DMESG-FAIL][15] ([i915#2927] / [i915#3428]) -> [PASS][16]
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10965/fi-bsw-nick/igt@i915_selftest@live@late_gt_pm.html
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21763/fi-bsw-nick/igt@i915_selftest@live@late_gt_pm.html
[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
[fdo#111827]: https://bugs.freedesktop.org/show_bug.cgi?id=111827
[i915#1888]: https://gitlab.freedesktop.org/drm/intel/issues/1888
[i915#2539]: https://gitlab.freedesktop.org/drm/intel/issues/2539
[i915#2927]: https://gitlab.freedesktop.org/drm/intel/issues/2927
[i915#3363]: https://gitlab.freedesktop.org/drm/intel/issues/3363
[i915#3428]: https://gitlab.freedesktop.org/drm/intel/issues/3428
[i915#3928]: https://gitlab.freedesktop.org/drm/intel/issues/3928
[i915#4312]: https://gitlab.freedesktop.org/drm/intel/issues/4312
[i915#4432]: https://gitlab.freedesktop.org/drm/intel/issues/4432
[i915#4547]: https://gitlab.freedesktop.org/drm/intel/issues/4547
Build changes
-------------
* Linux: CI_DRM_10965 -> Patchwork_21763
CI-20190529: 20190529
CI_DRM_10965: e9dedc5d0907d96371774cacca10160a167c5cd2 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_6300: f69bd65fa9f72b7d5e5a5a22981f16d034334761 @ https://gitlab.freedesktop.org/drm/igt-gpu-tools.git
Patchwork_21763: 1b4f726b33b29872094bf21ed6b84899ef79fd54 @ git://anongit.freedesktop.org/gfx-ci/linux
== Linux commits ==
1b4f726b33b2 drm/i915/gvt: Constify vgpu_types f75eaccd8a90 drm/i915/gvt: Constify gtt_type_table_entry d11cda723a89 drm/i915/gvt: Constify formats 6b20e5f39324 drm/i915/gvt: Constify cmd_interrupt_events 431473d1ea36 drm/i915/gvt: Constify gvt_mmio_block e41696ad17dc drm/i915/gvt: Constify intel_gvt_sched_policy_ops b150cdd67e79 drm/i915/gvt: Constify intel_gvt_irq_ops 9f75a74af3af drm/i915/gvt: Constify intel_gvt_gtt_pte_ops ad6d0d2d2854 drm/i915/gvt: Constify intel_gvt_gtt_pte_ops
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21763/index.html
Quoted 18 lines · Rikard Falkeborn
Constify a number of static structs that are never modified to allow the compiler to put them in read-only memory. In order to do this, constify a number of local variables and pointers in structs.
This is most important for structs that contain function pointers, and the patches for those structs are placed first in the series.
Rikard Falkeborn (9):
drm/i915/gvt: Constifyintel_gvt_gtt_pte_opsdrm/i915/gvt: Constifyintel_gvt_gtt_pte_opsdrm/i915/gvt: Constifyintel_gvt_irq_opsdrm/i915/gvt: Constifyintel_gvt_sched_policy_opsdrm/i915/gvt: Constifygvt_mmio_blockdrm/i915/gvt: Constifycmd_interrupt_eventsdrm/i915/gvt: Constify formats drm/i915/gvt: Constifygtt_type_table_entrydrm/i915/gvt: Constifyvgpu_types
Quoted 13 lines
drivers/gpu/drm/i915/gvt/cmd_parser.c | 2 +- drivers/gpu/drm/i915/gvt/fb_decoder.c | 24 ++++----- drivers/gpu/drm/i915/gvt/gtt.c | 68 ++++++++++++------------- drivers/gpu/drm/i915/gvt/gtt.h | 4 +- drivers/gpu/drm/i915/gvt/gvt.h | 2 +- drivers/gpu/drm/i915/gvt/handlers.c | 12 ++--- drivers/gpu/drm/i915/gvt/interrupt.c | 10 ++-- drivers/gpu/drm/i915/gvt/interrupt.h | 2 +- drivers/gpu/drm/i915/gvt/sched_policy.c | 2 +- drivers/gpu/drm/i915/gvt/scheduler.h | 2 +- drivers/gpu/drm/i915/gvt/vgpu.c | 4 +- 11 files changed, 66 insertions(+), 66 deletions(-)
Thanks so much for the contribuition. You only need to refine the PATCH 2 a little bit and re-send it.
Quoted 32 lines · Zhi A
Quoted 18 lines · Rikard Falkeborn
Constify a number of static structs that are never modified to allow the compiler to put them in read-only memory. In order to do this, constify a number of local variables and pointers in structs.
This is most important for structs that contain function pointers, and the patches for those structs are placed first in the series.
Rikard Falkeborn (9):
drm/i915/gvt: Constifyintel_gvt_gtt_pte_opsdrm/i915/gvt: Constifyintel_gvt_gtt_pte_opsdrm/i915/gvt: Constifyintel_gvt_irq_opsdrm/i915/gvt: Constifyintel_gvt_sched_policy_opsdrm/i915/gvt: Constifygvt_mmio_blockdrm/i915/gvt: Constifycmd_interrupt_eventsdrm/i915/gvt: Constify formats drm/i915/gvt: Constifygtt_type_table_entrydrm/i915/gvt: Constifyvgpu_typesQuoted 13 lines
drivers/gpu/drm/i915/gvt/cmd_parser.c | 2 +- drivers/gpu/drm/i915/gvt/fb_decoder.c | 24 ++++----- drivers/gpu/drm/i915/gvt/gtt.c | 68 ++++++++++++------------- drivers/gpu/drm/i915/gvt/gtt.h | 4 +- drivers/gpu/drm/i915/gvt/gvt.h | 2 +- drivers/gpu/drm/i915/gvt/handlers.c | 12 ++--- drivers/gpu/drm/i915/gvt/interrupt.c | 10 ++-- drivers/gpu/drm/i915/gvt/interrupt.h | 2 +- drivers/gpu/drm/i915/gvt/sched_policy.c | 2 +- drivers/gpu/drm/i915/gvt/scheduler.h | 2 +- drivers/gpu/drm/i915/gvt/vgpu.c | 4 +- 11 files changed, 66 insertions(+), 66 deletions(-)
Quoted 3 lines
Thanks so much for the contribuition. You only need to refine the PATCH 2 a little bit and re-send it.
Thanks for reviewing. Just to clarify, did you mean patch 7 (since that's the one you commented on)? And is it enough to send just that patch or do you want the entire series resent?
Rikard
On 12/12/2021 3:25 PM, Rikard Falkeborn worte:
Quoted 33 lines · Zhi A
Quoted 32 lines · Rikard Falkeborn
Quoted 31 lines
Constify a number of static structs that are never modified to allow the compiler to put them in read-only memory. In order to do this, constify a number of local variables and pointers in structs.
This is most important for structs that contain function pointers, and the patches for those structs are placed first in the series.
Rikard Falkeborn (9):
drm/i915/gvt: Constifyintel_gvt_gtt_pte_opsdrm/i915/gvt: Constifyintel_gvt_gtt_pte_opsdrm/i915/gvt: Constifyintel_gvt_irq_opsdrm/i915/gvt: Constifyintel_gvt_sched_policy_opsdrm/i915/gvt: Constifygvt_mmio_blockdrm/i915/gvt: Constifycmd_interrupt_eventsdrm/i915/gvt: Constify formats drm/i915/gvt: Constifygtt_type_table_entrydrm/i915/gvt: Constifyvgpu_typesdrivers/gpu/drm/i915/gvt/cmd_parser.c | 2 +- drivers/gpu/drm/i915/gvt/fb_decoder.c | 24 ++++----- drivers/gpu/drm/i915/gvt/gtt.c | 68 ++++++++++++------------- drivers/gpu/drm/i915/gvt/gtt.h | 4 +- drivers/gpu/drm/i915/gvt/gvt.h | 2 +- drivers/gpu/drm/i915/gvt/handlers.c | 12 ++--- drivers/gpu/drm/i915/gvt/interrupt.c | 10 ++-- drivers/gpu/drm/i915/gvt/interrupt.h | 2 +- drivers/gpu/drm/i915/gvt/sched_policy.c | 2 +- drivers/gpu/drm/i915/gvt/scheduler.h | 2 +- drivers/gpu/drm/i915/gvt/vgpu.c | 4 +- 11 files changed, 66 insertions(+), 66 deletions(-)
Quoted 8 lines
Quoted 3 lines
Thanks so much for the contribuition. You only need to refine the PATCH 2 a little bit and re-send it.
Thanks for reviewing. Just to clarify, did you mean patch 7 (since that's the one you commented on)? And is it enough to send just that patch or do you want the entire series resent?
Rikard
Hi Rikard, no worries then. I have already corrected them and queue them in the gvt-next branch, you can double check them if you like. They are going through a QA test cycle first and later start their journey to the upstream. All good. :) Thanks so much for the contribution again.
Zhi.