> Subject: [PATCH v3 05/31] drm/i915/bios: de/allocate VS/PE-O buffers' matrix > > Since all of the tables' rows are sticked together and hence form a giant > table,
* stuck > we could call it "buffers' table". This is not especially great lingo though > because there is a naming clash between superior "buffers' table" and tables > that form it. > > Alternatively we can treat each interior table as a column of couple struct > intel_ddi_buf_trans_entry's. Then after sticking all tables together > column-by- > column we obtain a matrix of struct intel_ddi_buf_trans_entry. We are > allowed to do that since every table has the same number of rows. > > This data structure's representation has the advantage that it resolves > aforementioned lingo clash while still being equivalent to "buffers' > table", simply reshaped. Thus it will be mentioned as "buffers' matrix". > > For the convenience of use, implementation assume transposition of the * assumes a .. > matrix described above: each table from VBT #57 forms one matrix's row and > each matrix's column represents one row of the table from VBT #57. > It allows us to use specific table without specifying table's row. > > Add pointer for matrix of intel_ddi_buf_trans_entry into intel_vbt_data. > Include intel_ddi_buf_trans.h in intel_bios.c to enable adding it. > > Name the pointer as bufs_mtrx. bufs_mtx would be a better fit, but it could > misleadingly indicate that it represents mutex. > > Allocate (num_tables x num_rows) matrix of intel_ddi_buf_trans_entry. > This "buffers' matrix" will be used to store all deparsed VS/PE-O tables from > VBT #57. Store matrix's pointer in intel_vbt_data. > > Deallocate whole matrix on driver removal. > > v2->v3 > - switch from kzalloc() into kzalloc_objs() > > Signed-off-by: Michał Grzelak <[email protected]> > --- > drivers/gpu/drm/i915/display/intel_bios.c | 21 ++++++++++++++++++- > .../gpu/drm/i915/display/intel_display_core.h | 1 + > 2 files changed, 21 insertions(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/i915/display/intel_bios.c > b/drivers/gpu/drm/i915/display/intel_bios.c > index d64668c1022a7..064eb4fda3f3a 100644 > --- a/drivers/gpu/drm/i915/display/intel_bios.c > +++ b/drivers/gpu/drm/i915/display/intel_bios.c > @@ -34,6 +34,7 @@ > #include <drm/drm_fixed.h> > #include <drm/drm_print.h> > > +#include "intel_ddi_buf_trans.h" > #include "intel_display.h" > #include "intel_display_core.h" > #include "intel_display_rpm.h" > @@ -2188,7 +2189,9 @@ parse_compression_parameters(struct > intel_display *display) static void parse_vswing_preemph_override(struct > intel_display *display) { > + union intel_ddi_buf_trans_entry **bufs_mtrx; > const struct bdb_vswing_preemph *block; > + u8 num_rows; > > if (display->vbt.version < 218) > return; > @@ -2199,10 +2202,18 @@ parse_vswing_preemph_override(struct > intel_display *display) > if (!block) > return; > > + num_rows = DISPLAY_VER(display) >= 14 ? 16 : 10; Have num rows declared in the previous patch itself rather than changing it here again > + > + bufs_mtrx = kzalloc_objs(*bufs_mtrx, block->num_tables); Null check to see if it actually got allocated for not. > + > + for (int idx = 0; idx < block->num_tables; idx++) Please declare the int i at start of function and use that we don’t do this incline declaration in a for loop in i915 > + bufs_mtrx[idx] = kzalloc_objs(**bufs_mtrx, num_rows); Same here, null check to see if it actually got allocated for not. Free the previous allocations if not allocated Regards, Suraj Kandpal > + > drm_dbg_kms(display->drm, "VS/PE-O parsing not yet supported\n"); > > + display->vbt.bufs_mtrx = bufs_mtrx; > display->vbt.num_tables = block->num_tables; > - display->vbt.num_rows = DISPLAY_VER(display) >= 14 ? 16 : 10; > + display->vbt.num_rows = num_rows; > } > > static u8 translate_iboost(struct intel_display *display, u8 val) @@ -3002,6 > +3013,7 @@ init_vbt_defaults(struct intel_display *display) > display->vbt.lvds_ssc_freq); > > /* Vswing / Preemphasis Override */ > + display->vbt.bufs_mtrx = NULL; > display->vbt.num_tables = 0; > display->vbt.num_rows = 0; > } > @@ -3385,6 +3397,13 @@ void intel_bios_driver_remove(struct intel_display > *display) > list_del(&entry->node); > kfree(entry); > } > + > + if (display->vbt.bufs_mtrx) { > + for (int idx = 0; idx < display->vbt.num_tables; idx++) > + kfree(display->vbt.bufs_mtrx[idx]); > + > + kfree(display->vbt.bufs_mtrx); > + } > } > > void intel_bios_fini_panel(struct intel_panel *panel) diff --git > a/drivers/gpu/drm/i915/display/intel_display_core.h > b/drivers/gpu/drm/i915/display/intel_display_core.h > index 36ea4873deeb0..a91397ecfe017 100644 > --- a/drivers/gpu/drm/i915/display/intel_display_core.h > +++ b/drivers/gpu/drm/i915/display/intel_display_core.h > @@ -242,6 +242,7 @@ struct intel_vbt_data { > struct list_head display_devices; > struct list_head bdb_blocks; > > + union intel_ddi_buf_trans_entry **bufs_mtrx; > int num_tables; > int num_rows; > > -- > 2.45.2
