mbox series

[v5,00/18] drm/msm: generate register header files

Message ID 20240401-fd-xml-shipped-v5-0-4bdb277a85a1@linaro.org
Headers show
Series drm/msm: generate register header files | expand

Message

Dmitry Baryshkov April 1, 2024, 2:42 a.m. UTC
Currently display-related register headers are generated from XML files
shipped withing Mesa source tree. This is not fully optimal: it requires
multi-stage process of the changes first being landed to Mesa and only
then synced to the kernel tree.

Move original XML files to the kernel tree and generate header files
when required. Display-related XMLs are going to be dropped from the
Mesa, with the kernel becoming the primary source. Adreno-related XMLs
are still going to handled by Mesa and should be synced from Mesa to the
kernel when required. The gen_header.py script should also be synced
between Mesa and the kernel tree.

Unless there are any objections, I'd like to consider this a final
revision with the target of it being merged for 6.10. Please review.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
---
Changes in v5:
- Updated gen_header.py to include licence header (Abhinav, Akhil)
- Split the #include rework to a separate patch (Abhinav)
- Link to v4: https://lore.kernel.org/r/20240323-fd-xml-shipped-v4-0-cca5e8457b9e@linaro.org

Changes in v4:
- Updated headers, schema and script to the latest version merged to
  Mesa
- Further split of Adreno XML / Adreno headers patches in order to pass
  through more ML filters.
- Dropped the RFC tag
- Link to v3: https://lore.kernel.org/r/20240315-fd-xml-shipped-v3-0-0fc122e36c53@linaro.org

Changes in v3:
- Split XML and git rm patches in hope to pass ML limitations
- Link to v2: https://lore.kernel.org/r/20240315-fd-xml-shipped-v2-0-7cd68ecc4320@linaro.org

Changes in v2:
- Removed the _shipped files, always generating the headers (Masahiro
  Yamada)
- Replaced headergen2 with gen_headers.py
- Simplify Makefile rules, making all Adreno objects depend on Adreno
  headers and all displau objects depend on all display headers
- Also handle Adreno registers
- Link to v1: https://lore.kernel.org/r/20240226-fd-xml-shipped-v1-0-86bb6c3346d2@linaro.org

---
Dmitry Baryshkov (18):
      drm/msm/mdp5: add writeback block bases
      drm/msm/hdmi: drop qfprom.xml.h
      drm/msm/dsi: drop mmss_cc.xml.h
      drm/msm: move msm_gpummu.c to adreno/a2xx_gpummu.c
      drm/msm: remove dependencies from core onto adreno headers
      drm/msm: import XML display registers database
      drm/msm: import A2xx-A4xx XML display registers database
      drm/msm: import A5xx XML display registers database
      drm/msm: import A6xx XML display registers database
      drm/msm: import gen_header.py script from Mesa
      drm/msm: generate headers on the fly
      drm/msm: drop display-related headers
      drm/msm: drop A2xx and common headers
      drm/msm: drop A3xx and A4xx headers
      drm/msm: drop A5xx header
      drm/msm: drop A6xx GMU header
      drm/msm: drop C++ parts of a6xx.xml.h
      drm/msm: drop A6xx header

 drivers/gpu/drm/msm/.gitignore                     |     1 +
 drivers/gpu/drm/msm/Makefile                       |    99 +-
 drivers/gpu/drm/msm/adreno/a2xx.xml.h              |  3251 -----
 drivers/gpu/drm/msm/adreno/a2xx_gpu.c              |     4 +-
 drivers/gpu/drm/msm/adreno/a2xx_gpu.h              |     4 +
 .../drm/msm/{msm_gpummu.c => adreno/a2xx_gpummu.c} |    45 +-
 drivers/gpu/drm/msm/adreno/a3xx.xml.h              |  3268 -----
 drivers/gpu/drm/msm/adreno/a4xx.xml.h              |  4379 -------
 drivers/gpu/drm/msm/adreno/a5xx.xml.h              |  5572 ---------
 drivers/gpu/drm/msm/adreno/a6xx.xml.h              | 11858 -------------------
 drivers/gpu/drm/msm/adreno/a6xx_gmu.xml.h          |   422 -
 drivers/gpu/drm/msm/adreno/adreno_common.xml.h     |   539 -
 drivers/gpu/drm/msm/adreno/adreno_pm4.xml.h        |  2803 -----
 drivers/gpu/drm/msm/disp/mdp4/mdp4.xml.h           |  1181 --
 drivers/gpu/drm/msm/disp/mdp5/mdp5.xml.h           |  1979 ----
 drivers/gpu/drm/msm/disp/mdp5/mdp5_cfg.h           |    11 +
 drivers/gpu/drm/msm/disp/mdp_common.xml.h          |   111 -
 drivers/gpu/drm/msm/dsi/dsi.xml.h                  |   790 --
 drivers/gpu/drm/msm/dsi/dsi_phy_10nm.xml.h         |   227 -
 drivers/gpu/drm/msm/dsi/dsi_phy_14nm.xml.h         |   309 -
 drivers/gpu/drm/msm/dsi/dsi_phy_20nm.xml.h         |   237 -
 drivers/gpu/drm/msm/dsi/dsi_phy_28nm.xml.h         |   384 -
 drivers/gpu/drm/msm/dsi/dsi_phy_28nm_8960.xml.h    |   286 -
 drivers/gpu/drm/msm/dsi/dsi_phy_7nm.xml.h          |   483 -
 drivers/gpu/drm/msm/dsi/mmss_cc.xml.h              |   131 -
 drivers/gpu/drm/msm/dsi/sfpb.xml.h                 |    70 -
 drivers/gpu/drm/msm/hdmi/hdmi.xml.h                |  1399 ---
 drivers/gpu/drm/msm/hdmi/qfprom.xml.h              |    61 -
 drivers/gpu/drm/msm/msm_drv.c                      |     3 +-
 drivers/gpu/drm/msm/msm_gpu.c                      |     2 +-
 drivers/gpu/drm/msm/msm_mmu.h                      |     5 -
 drivers/gpu/drm/msm/registers/.gitignore           |     4 +
 drivers/gpu/drm/msm/registers/adreno/a2xx.xml      |  1865 +++
 drivers/gpu/drm/msm/registers/adreno/a3xx.xml      |  1751 +++
 drivers/gpu/drm/msm/registers/adreno/a4xx.xml      |  2409 ++++
 drivers/gpu/drm/msm/registers/adreno/a5xx.xml      |  3039 +++++
 drivers/gpu/drm/msm/registers/adreno/a6xx.xml      |  4970 ++++++++
 drivers/gpu/drm/msm/registers/adreno/a6xx_gmu.xml  |   228 +
 .../gpu/drm/msm/registers/adreno/adreno_common.xml |   400 +
 .../gpu/drm/msm/registers/adreno/adreno_pm4.xml    |  2268 ++++
 drivers/gpu/drm/msm/registers/display/dsi.xml      |   390 +
 .../gpu/drm/msm/registers/display/dsi_phy_10nm.xml |   102 +
 .../gpu/drm/msm/registers/display/dsi_phy_14nm.xml |   135 +
 .../gpu/drm/msm/registers/display/dsi_phy_20nm.xml |   100 +
 .../gpu/drm/msm/registers/display/dsi_phy_28nm.xml |   180 +
 .../msm/registers/display/dsi_phy_28nm_8960.xml    |   134 +
 .../gpu/drm/msm/registers/display/dsi_phy_7nm.xml  |   230 +
 drivers/gpu/drm/msm/registers/display/edp.xml      |   239 +
 drivers/gpu/drm/msm/registers/display/hdmi.xml     |  1015 ++
 drivers/gpu/drm/msm/registers/display/mdp4.xml     |   504 +
 drivers/gpu/drm/msm/registers/display/mdp5.xml     |   806 ++
 .../gpu/drm/msm/registers/display/mdp_common.xml   |    90 +
 drivers/gpu/drm/msm/registers/display/msm.xml      |    32 +
 drivers/gpu/drm/msm/registers/display/sfpb.xml     |    17 +
 .../gpu/drm/msm/registers/freedreno_copyright.xml  |    40 +
 drivers/gpu/drm/msm/registers/gen_header.py        |   961 ++
 drivers/gpu/drm/msm/registers/rules-fd.xsd         |   404 +
 57 files changed, 22435 insertions(+), 39792 deletions(-)
---
base-commit: 13ee4a7161b6fd938aef6688ff43b163f6d83e37
change-id: 20240225-fd-xml-shipped-ba9a321cdedf

Best regards,

Comments

Jon Hunter April 12, 2024, 4:15 p.m. UTC | #1
Hi Dmitry,

On 01/04/2024 03:42, Dmitry Baryshkov wrote:
> Generate DRM/MSM headers on the fly during kernel build. This removes a
> need to push register changes to Mesa with the following manual
> synchronization step. Existing headers will be removed in the following
> commits (split away to ease reviews).
> 
> Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> ---
>   drivers/gpu/drm/msm/.gitignore |  1 +
>   drivers/gpu/drm/msm/Makefile   | 97 +++++++++++++++++++++++++++++++++---------
>   2 files changed, 77 insertions(+), 21 deletions(-)
> 
> diff --git a/drivers/gpu/drm/msm/.gitignore b/drivers/gpu/drm/msm/.gitignore
> new file mode 100644
> index 000000000000..9ab870da897d
> --- /dev/null
> +++ b/drivers/gpu/drm/msm/.gitignore
> @@ -0,0 +1 @@
> +generated/
> diff --git a/drivers/gpu/drm/msm/Makefile b/drivers/gpu/drm/msm/Makefile
> index 26ed4f443149..c861de58286c 100644
> --- a/drivers/gpu/drm/msm/Makefile
> +++ b/drivers/gpu/drm/msm/Makefile
> @@ -1,10 +1,11 @@
>   # SPDX-License-Identifier: GPL-2.0
>   ccflags-y := -I $(srctree)/$(src)
> +ccflags-y += -I $(obj)/generated
>   ccflags-y += -I $(srctree)/$(src)/disp/dpu1
>   ccflags-$(CONFIG_DRM_MSM_DSI) += -I $(srctree)/$(src)/dsi
>   ccflags-$(CONFIG_DRM_MSM_DP) += -I $(srctree)/$(src)/dp
>   
> -msm-y := \
> +adreno-y := \
>   	adreno/adreno_device.o \
>   	adreno/adreno_gpu.o \
>   	adreno/a2xx_gpu.o \
> @@ -18,7 +19,11 @@ msm-y := \
>   	adreno/a6xx_gmu.o \
>   	adreno/a6xx_hfi.o \
>   
> -msm-$(CONFIG_DRM_MSM_HDMI) += \
> +adreno-$(CONFIG_DEBUG_FS) += adreno/a5xx_debugfs.o \
> +
> +adreno-$(CONFIG_DRM_MSM_GPU_STATE)	+= adreno/a6xx_gpu_state.o
> +
> +msm-display-$(CONFIG_DRM_MSM_HDMI) += \
>   	hdmi/hdmi.o \
>   	hdmi/hdmi_audio.o \
>   	hdmi/hdmi_bridge.o \
> @@ -31,7 +36,7 @@ msm-$(CONFIG_DRM_MSM_HDMI) += \
>   	hdmi/hdmi_phy_8x74.o \
>   	hdmi/hdmi_pll_8960.o \
>   
> -msm-$(CONFIG_DRM_MSM_MDP4) += \
> +msm-display-$(CONFIG_DRM_MSM_MDP4) += \
>   	disp/mdp4/mdp4_crtc.o \
>   	disp/mdp4/mdp4_dsi_encoder.o \
>   	disp/mdp4/mdp4_dtv_encoder.o \
> @@ -42,7 +47,7 @@ msm-$(CONFIG_DRM_MSM_MDP4) += \
>   	disp/mdp4/mdp4_kms.o \
>   	disp/mdp4/mdp4_plane.o \
>   
> -msm-$(CONFIG_DRM_MSM_MDP5) += \
> +msm-display-$(CONFIG_DRM_MSM_MDP5) += \
>   	disp/mdp5/mdp5_cfg.o \
>   	disp/mdp5/mdp5_cmd_encoder.o \
>   	disp/mdp5/mdp5_ctl.o \
> @@ -55,7 +60,7 @@ msm-$(CONFIG_DRM_MSM_MDP5) += \
>   	disp/mdp5/mdp5_plane.o \
>   	disp/mdp5/mdp5_smp.o \
>   
> -msm-$(CONFIG_DRM_MSM_DPU) += \
> +msm-display-$(CONFIG_DRM_MSM_DPU) += \
>   	disp/dpu1/dpu_core_perf.o \
>   	disp/dpu1/dpu_crtc.o \
>   	disp/dpu1/dpu_encoder.o \
> @@ -85,14 +90,16 @@ msm-$(CONFIG_DRM_MSM_DPU) += \
>   	disp/dpu1/dpu_vbif.o \
>   	disp/dpu1/dpu_writeback.o
>   
> -msm-$(CONFIG_DRM_MSM_MDSS) += \
> +msm-display-$(CONFIG_DRM_MSM_MDSS) += \
>   	msm_mdss.o \
>   
> -msm-y += \
> +msm-display-y += \
>   	disp/mdp_format.o \
>   	disp/mdp_kms.o \
>   	disp/msm_disp_snapshot.o \
>   	disp/msm_disp_snapshot_util.o \
> +
> +msm-y += \
>   	msm_atomic.o \
>   	msm_atomic_tracepoints.o \
>   	msm_debugfs.o \
> @@ -115,12 +122,12 @@ msm-y += \
>   	msm_submitqueue.o \
>   	msm_gpu_tracepoints.o \
>   
> -msm-$(CONFIG_DEBUG_FS) += adreno/a5xx_debugfs.o \
> -	dp/dp_debug.o
> +msm-$(CONFIG_DRM_FBDEV_EMULATION) += msm_fbdev.o
>   
> -msm-$(CONFIG_DRM_MSM_GPU_STATE)	+= adreno/a6xx_gpu_state.o
> +msm-display-$(CONFIG_DEBUG_FS) += \
> +	dp/dp_debug.o
>   
> -msm-$(CONFIG_DRM_MSM_DP)+= dp/dp_aux.o \
> +msm-display-$(CONFIG_DRM_MSM_DP)+= dp/dp_aux.o \
>   	dp/dp_catalog.o \
>   	dp/dp_ctrl.o \
>   	dp/dp_display.o \
> @@ -130,21 +137,69 @@ msm-$(CONFIG_DRM_MSM_DP)+= dp/dp_aux.o \
>   	dp/dp_audio.o \
>   	dp/dp_utils.o
>   
> -msm-$(CONFIG_DRM_FBDEV_EMULATION) += msm_fbdev.o
> -
> -msm-$(CONFIG_DRM_MSM_HDMI_HDCP) += hdmi/hdmi_hdcp.o
> +msm-display-$(CONFIG_DRM_MSM_HDMI_HDCP) += hdmi/hdmi_hdcp.o
>   
> -msm-$(CONFIG_DRM_MSM_DSI) += dsi/dsi.o \
> +msm-display-$(CONFIG_DRM_MSM_DSI) += dsi/dsi.o \
>   			dsi/dsi_cfg.o \
>   			dsi/dsi_host.o \
>   			dsi/dsi_manager.o \
>   			dsi/phy/dsi_phy.o
>   
> -msm-$(CONFIG_DRM_MSM_DSI_28NM_PHY) += dsi/phy/dsi_phy_28nm.o
> -msm-$(CONFIG_DRM_MSM_DSI_20NM_PHY) += dsi/phy/dsi_phy_20nm.o
> -msm-$(CONFIG_DRM_MSM_DSI_28NM_8960_PHY) += dsi/phy/dsi_phy_28nm_8960.o
> -msm-$(CONFIG_DRM_MSM_DSI_14NM_PHY) += dsi/phy/dsi_phy_14nm.o
> -msm-$(CONFIG_DRM_MSM_DSI_10NM_PHY) += dsi/phy/dsi_phy_10nm.o
> -msm-$(CONFIG_DRM_MSM_DSI_7NM_PHY) += dsi/phy/dsi_phy_7nm.o
> +msm-display-$(CONFIG_DRM_MSM_DSI_28NM_PHY) += dsi/phy/dsi_phy_28nm.o
> +msm-display-$(CONFIG_DRM_MSM_DSI_20NM_PHY) += dsi/phy/dsi_phy_20nm.o
> +msm-display-$(CONFIG_DRM_MSM_DSI_28NM_8960_PHY) += dsi/phy/dsi_phy_28nm_8960.o
> +msm-display-$(CONFIG_DRM_MSM_DSI_14NM_PHY) += dsi/phy/dsi_phy_14nm.o
> +msm-display-$(CONFIG_DRM_MSM_DSI_10NM_PHY) += dsi/phy/dsi_phy_10nm.o
> +msm-display-$(CONFIG_DRM_MSM_DSI_7NM_PHY) += dsi/phy/dsi_phy_7nm.o
> +
> +msm-y += $(adreno-y) $(msm-display-y)
>   
>   obj-$(CONFIG_DRM_MSM)	+= msm.o
> +
> +quiet_cmd_headergen = GENHDR  $@
> +      cmd_headergen = mkdir -p $(obj)/generated && $(PYTHON3) $(srctree)/$(src)/registers/gen_header.py --rnn $(srctree)/$(src)/registers --xml $< c-defines > $@
> +
> +$(obj)/generated/%.xml.h: $(src)/registers/adreno/%.xml \
> +		$(src)/registers/adreno/adreno_common.xml \
> +		$(src)/registers/adreno/adreno_pm4.xml \
> +		$(src)/registers/freedreno_copyright.xml \
> +		$(src)/registers/gen_header.py \
> +		$(src)/registers/rules-fd.xsd \
> +		FORCE
> +	$(call if_changed,headergen)
> +
> +$(obj)/generated/%.xml.h: $(src)/registers/display/%.xml \
> +		$(src)/registers/freedreno_copyright.xml \
> +		$(src)/registers/gen_header.py \
> +		$(src)/registers/rules-fd.xsd \
> +		FORCE
> +	$(call if_changed,headergen)
> +
> +ADRENO_HEADERS = \
> +	generated/a2xx.xml.h \
> +	generated/a3xx.xml.h \
> +	generated/a4xx.xml.h \
> +	generated/a5xx.xml.h \
> +	generated/a6xx.xml.h \
> +	generated/a6xx_gmu.xml.h \
> +	generated/adreno_common.xml.h \
> +	generated/adreno_pm4.xml.h \
> +
> +DISPLAY_HEADERS = \
> +	generated/dsi_phy_7nm.xml.h \
> +	generated/dsi_phy_10nm.xml.h \
> +	generated/dsi_phy_14nm.xml.h \
> +	generated/dsi_phy_20nm.xml.h \
> +	generated/dsi_phy_28nm_8960.xml.h \
> +	generated/dsi_phy_28nm.xml.h \
> +	generated/dsi.xml.h \
> +	generated/hdmi.xml.h \
> +	generated/mdp4.xml.h \
> +	generated/mdp5.xml.h \
> +	generated/mdp_common.xml.h \
> +	generated/sfpb.xml.h
> +
> +$(addprefix $(obj)/,$(adreno-y)): $(addprefix $(obj)/,$(ADRENO_HEADERS))
> +$(addprefix $(obj)/,$(msm-display-y)): $(addprefix $(obj)/,$(DISPLAY_HEADERS))
> +
> +targets += $(ADRENO_HEADERS) $(DISPLAY_HEADERS)


I noticed that some of our builders were failing to build the latest
-next and it was after this commit that things broke. The builders
have an older version of python3 and the gen_headers.py script fails
in a couple places with syntax errors. The following changes
resolved the issues for python 3.5 ...

diff --git a/drivers/gpu/drm/msm/registers/gen_header.py b/drivers/gpu/drm/msm/registers/gen_header.py
index 9b2842d4a354..90d5c2991d05 100644
--- a/drivers/gpu/drm/msm/registers/gen_header.py
+++ b/drivers/gpu/drm/msm/registers/gen_header.py
@@ -323,7 +323,7 @@ class Array(object):
                         indices = []
                 if self.length != 1:
                         if self.fixed_offsets:
-                               indices.append((self.index_ctype(), None, f"__offset_{self.local_name}"))
+                               indices.append((self.index_ctype(), None, "__offset_%s" % self.local_name))
                         else:
                                 indices.append((self.index_ctype(), self.stride, None))
                 return indices
@@ -942,7 +942,8 @@ def main():
         parser.add_argument('--rnn', type=str, required=True)
         parser.add_argument('--xml', type=str, required=True)
  
-       subparsers = parser.add_subparsers(required=True)
+       subparsers = parser.add_subparsers()
+       subparsers.required = True
  

I know that anything before python 3.8 is now EOL, but I did see a
similar thread on dri-devel [0] for supporting python 3.6 and so
wanted to see if there is any objections to the above?

Thanks!
Jon

[0] https://lore.kernel.org/dri-devel/20240118123752.bl3qss3qbbxgvpdk@suse.de/
Dmitry Baryshkov April 12, 2024, 4:19 p.m. UTC | #2
On Fri, 12 Apr 2024 at 19:15, Jon Hunter <jonathanh@nvidia.com> wrote:
>
> Hi Dmitry,
>
> On 01/04/2024 03:42, Dmitry Baryshkov wrote:
> > Generate DRM/MSM headers on the fly during kernel build. This removes a
> > need to push register changes to Mesa with the following manual
> > synchronization step. Existing headers will be removed in the following
> > commits (split away to ease reviews).
> >
> > Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> > ---
> >   drivers/gpu/drm/msm/.gitignore |  1 +
> >   drivers/gpu/drm/msm/Makefile   | 97 +++++++++++++++++++++++++++++++++---------
> >   2 files changed, 77 insertions(+), 21 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/msm/.gitignore b/drivers/gpu/drm/msm/.gitignore
> > new file mode 100644
> > index 000000000000..9ab870da897d
> > --- /dev/null
> > +++ b/drivers/gpu/drm/msm/.gitignore
> > @@ -0,0 +1 @@
> > +generated/
> > diff --git a/drivers/gpu/drm/msm/Makefile b/drivers/gpu/drm/msm/Makefile
> > index 26ed4f443149..c861de58286c 100644
> > --- a/drivers/gpu/drm/msm/Makefile
> > +++ b/drivers/gpu/drm/msm/Makefile
> > @@ -1,10 +1,11 @@
> >   # SPDX-License-Identifier: GPL-2.0
> >   ccflags-y := -I $(srctree)/$(src)
> > +ccflags-y += -I $(obj)/generated
> >   ccflags-y += -I $(srctree)/$(src)/disp/dpu1
> >   ccflags-$(CONFIG_DRM_MSM_DSI) += -I $(srctree)/$(src)/dsi
> >   ccflags-$(CONFIG_DRM_MSM_DP) += -I $(srctree)/$(src)/dp
> >
> > -msm-y := \
> > +adreno-y := \
> >       adreno/adreno_device.o \
> >       adreno/adreno_gpu.o \
> >       adreno/a2xx_gpu.o \
> > @@ -18,7 +19,11 @@ msm-y := \
> >       adreno/a6xx_gmu.o \
> >       adreno/a6xx_hfi.o \
> >
> > -msm-$(CONFIG_DRM_MSM_HDMI) += \
> > +adreno-$(CONFIG_DEBUG_FS) += adreno/a5xx_debugfs.o \
> > +
> > +adreno-$(CONFIG_DRM_MSM_GPU_STATE)   += adreno/a6xx_gpu_state.o
> > +
> > +msm-display-$(CONFIG_DRM_MSM_HDMI) += \
> >       hdmi/hdmi.o \
> >       hdmi/hdmi_audio.o \
> >       hdmi/hdmi_bridge.o \
> > @@ -31,7 +36,7 @@ msm-$(CONFIG_DRM_MSM_HDMI) += \
> >       hdmi/hdmi_phy_8x74.o \
> >       hdmi/hdmi_pll_8960.o \
> >
> > -msm-$(CONFIG_DRM_MSM_MDP4) += \
> > +msm-display-$(CONFIG_DRM_MSM_MDP4) += \
> >       disp/mdp4/mdp4_crtc.o \
> >       disp/mdp4/mdp4_dsi_encoder.o \
> >       disp/mdp4/mdp4_dtv_encoder.o \
> > @@ -42,7 +47,7 @@ msm-$(CONFIG_DRM_MSM_MDP4) += \
> >       disp/mdp4/mdp4_kms.o \
> >       disp/mdp4/mdp4_plane.o \
> >
> > -msm-$(CONFIG_DRM_MSM_MDP5) += \
> > +msm-display-$(CONFIG_DRM_MSM_MDP5) += \
> >       disp/mdp5/mdp5_cfg.o \
> >       disp/mdp5/mdp5_cmd_encoder.o \
> >       disp/mdp5/mdp5_ctl.o \
> > @@ -55,7 +60,7 @@ msm-$(CONFIG_DRM_MSM_MDP5) += \
> >       disp/mdp5/mdp5_plane.o \
> >       disp/mdp5/mdp5_smp.o \
> >
> > -msm-$(CONFIG_DRM_MSM_DPU) += \
> > +msm-display-$(CONFIG_DRM_MSM_DPU) += \
> >       disp/dpu1/dpu_core_perf.o \
> >       disp/dpu1/dpu_crtc.o \
> >       disp/dpu1/dpu_encoder.o \
> > @@ -85,14 +90,16 @@ msm-$(CONFIG_DRM_MSM_DPU) += \
> >       disp/dpu1/dpu_vbif.o \
> >       disp/dpu1/dpu_writeback.o
> >
> > -msm-$(CONFIG_DRM_MSM_MDSS) += \
> > +msm-display-$(CONFIG_DRM_MSM_MDSS) += \
> >       msm_mdss.o \
> >
> > -msm-y += \
> > +msm-display-y += \
> >       disp/mdp_format.o \
> >       disp/mdp_kms.o \
> >       disp/msm_disp_snapshot.o \
> >       disp/msm_disp_snapshot_util.o \
> > +
> > +msm-y += \
> >       msm_atomic.o \
> >       msm_atomic_tracepoints.o \
> >       msm_debugfs.o \
> > @@ -115,12 +122,12 @@ msm-y += \
> >       msm_submitqueue.o \
> >       msm_gpu_tracepoints.o \
> >
> > -msm-$(CONFIG_DEBUG_FS) += adreno/a5xx_debugfs.o \
> > -     dp/dp_debug.o
> > +msm-$(CONFIG_DRM_FBDEV_EMULATION) += msm_fbdev.o
> >
> > -msm-$(CONFIG_DRM_MSM_GPU_STATE)      += adreno/a6xx_gpu_state.o
> > +msm-display-$(CONFIG_DEBUG_FS) += \
> > +     dp/dp_debug.o
> >
> > -msm-$(CONFIG_DRM_MSM_DP)+= dp/dp_aux.o \
> > +msm-display-$(CONFIG_DRM_MSM_DP)+= dp/dp_aux.o \
> >       dp/dp_catalog.o \
> >       dp/dp_ctrl.o \
> >       dp/dp_display.o \
> > @@ -130,21 +137,69 @@ msm-$(CONFIG_DRM_MSM_DP)+= dp/dp_aux.o \
> >       dp/dp_audio.o \
> >       dp/dp_utils.o
> >
> > -msm-$(CONFIG_DRM_FBDEV_EMULATION) += msm_fbdev.o
> > -
> > -msm-$(CONFIG_DRM_MSM_HDMI_HDCP) += hdmi/hdmi_hdcp.o
> > +msm-display-$(CONFIG_DRM_MSM_HDMI_HDCP) += hdmi/hdmi_hdcp.o
> >
> > -msm-$(CONFIG_DRM_MSM_DSI) += dsi/dsi.o \
> > +msm-display-$(CONFIG_DRM_MSM_DSI) += dsi/dsi.o \
> >                       dsi/dsi_cfg.o \
> >                       dsi/dsi_host.o \
> >                       dsi/dsi_manager.o \
> >                       dsi/phy/dsi_phy.o
> >
> > -msm-$(CONFIG_DRM_MSM_DSI_28NM_PHY) += dsi/phy/dsi_phy_28nm.o
> > -msm-$(CONFIG_DRM_MSM_DSI_20NM_PHY) += dsi/phy/dsi_phy_20nm.o
> > -msm-$(CONFIG_DRM_MSM_DSI_28NM_8960_PHY) += dsi/phy/dsi_phy_28nm_8960.o
> > -msm-$(CONFIG_DRM_MSM_DSI_14NM_PHY) += dsi/phy/dsi_phy_14nm.o
> > -msm-$(CONFIG_DRM_MSM_DSI_10NM_PHY) += dsi/phy/dsi_phy_10nm.o
> > -msm-$(CONFIG_DRM_MSM_DSI_7NM_PHY) += dsi/phy/dsi_phy_7nm.o
> > +msm-display-$(CONFIG_DRM_MSM_DSI_28NM_PHY) += dsi/phy/dsi_phy_28nm.o
> > +msm-display-$(CONFIG_DRM_MSM_DSI_20NM_PHY) += dsi/phy/dsi_phy_20nm.o
> > +msm-display-$(CONFIG_DRM_MSM_DSI_28NM_8960_PHY) += dsi/phy/dsi_phy_28nm_8960.o
> > +msm-display-$(CONFIG_DRM_MSM_DSI_14NM_PHY) += dsi/phy/dsi_phy_14nm.o
> > +msm-display-$(CONFIG_DRM_MSM_DSI_10NM_PHY) += dsi/phy/dsi_phy_10nm.o
> > +msm-display-$(CONFIG_DRM_MSM_DSI_7NM_PHY) += dsi/phy/dsi_phy_7nm.o
> > +
> > +msm-y += $(adreno-y) $(msm-display-y)
> >
> >   obj-$(CONFIG_DRM_MSM)       += msm.o
> > +
> > +quiet_cmd_headergen = GENHDR  $@
> > +      cmd_headergen = mkdir -p $(obj)/generated && $(PYTHON3) $(srctree)/$(src)/registers/gen_header.py --rnn $(srctree)/$(src)/registers --xml $< c-defines > $@
> > +
> > +$(obj)/generated/%.xml.h: $(src)/registers/adreno/%.xml \
> > +             $(src)/registers/adreno/adreno_common.xml \
> > +             $(src)/registers/adreno/adreno_pm4.xml \
> > +             $(src)/registers/freedreno_copyright.xml \
> > +             $(src)/registers/gen_header.py \
> > +             $(src)/registers/rules-fd.xsd \
> > +             FORCE
> > +     $(call if_changed,headergen)
> > +
> > +$(obj)/generated/%.xml.h: $(src)/registers/display/%.xml \
> > +             $(src)/registers/freedreno_copyright.xml \
> > +             $(src)/registers/gen_header.py \
> > +             $(src)/registers/rules-fd.xsd \
> > +             FORCE
> > +     $(call if_changed,headergen)
> > +
> > +ADRENO_HEADERS = \
> > +     generated/a2xx.xml.h \
> > +     generated/a3xx.xml.h \
> > +     generated/a4xx.xml.h \
> > +     generated/a5xx.xml.h \
> > +     generated/a6xx.xml.h \
> > +     generated/a6xx_gmu.xml.h \
> > +     generated/adreno_common.xml.h \
> > +     generated/adreno_pm4.xml.h \
> > +
> > +DISPLAY_HEADERS = \
> > +     generated/dsi_phy_7nm.xml.h \
> > +     generated/dsi_phy_10nm.xml.h \
> > +     generated/dsi_phy_14nm.xml.h \
> > +     generated/dsi_phy_20nm.xml.h \
> > +     generated/dsi_phy_28nm_8960.xml.h \
> > +     generated/dsi_phy_28nm.xml.h \
> > +     generated/dsi.xml.h \
> > +     generated/hdmi.xml.h \
> > +     generated/mdp4.xml.h \
> > +     generated/mdp5.xml.h \
> > +     generated/mdp_common.xml.h \
> > +     generated/sfpb.xml.h
> > +
> > +$(addprefix $(obj)/,$(adreno-y)): $(addprefix $(obj)/,$(ADRENO_HEADERS))
> > +$(addprefix $(obj)/,$(msm-display-y)): $(addprefix $(obj)/,$(DISPLAY_HEADERS))
> > +
> > +targets += $(ADRENO_HEADERS) $(DISPLAY_HEADERS)
>
>
> I noticed that some of our builders were failing to build the latest
> -next and it was after this commit that things broke. The builders
> have an older version of python3 and the gen_headers.py script fails
> in a couple places with syntax errors. The following changes
> resolved the issues for python 3.5 ...

Could you please post them as a proper patch?

>
> diff --git a/drivers/gpu/drm/msm/registers/gen_header.py b/drivers/gpu/drm/msm/registers/gen_header.py
> index 9b2842d4a354..90d5c2991d05 100644
> --- a/drivers/gpu/drm/msm/registers/gen_header.py
> +++ b/drivers/gpu/drm/msm/registers/gen_header.py
> @@ -323,7 +323,7 @@ class Array(object):
>                          indices = []
>                  if self.length != 1:
>                          if self.fixed_offsets:
> -                               indices.append((self.index_ctype(), None, f"__offset_{self.local_name}"))
> +                               indices.append((self.index_ctype(), None, "__offset_%s" % self.local_name))
>                          else:
>                                  indices.append((self.index_ctype(), self.stride, None))
>                  return indices
> @@ -942,7 +942,8 @@ def main():
>          parser.add_argument('--rnn', type=str, required=True)
>          parser.add_argument('--xml', type=str, required=True)
>
> -       subparsers = parser.add_subparsers(required=True)
> +       subparsers = parser.add_subparsers()
> +       subparsers.required = True
>
>
> I know that anything before python 3.8 is now EOL, but I did see a
> similar thread on dri-devel [0] for supporting python 3.6 and so
> wanted to see if there is any objections to the above?

I don't have any objections from my side.

>
> Thanks!
> Jon
>
> [0] https://lore.kernel.org/dri-devel/20240118123752.bl3qss3qbbxgvpdk@suse.de/
>
> --
> nvpublic
Jon Hunter April 12, 2024, 4:29 p.m. UTC | #3
On 12/04/2024 17:19, Dmitry Baryshkov wrote:
> On Fri, 12 Apr 2024 at 19:15, Jon Hunter <jonathanh@nvidia.com> wrote:
>>
>> Hi Dmitry,
>>
>> On 01/04/2024 03:42, Dmitry Baryshkov wrote:
>>> Generate DRM/MSM headers on the fly during kernel build. This removes a
>>> need to push register changes to Mesa with the following manual
>>> synchronization step. Existing headers will be removed in the following
>>> commits (split away to ease reviews).
>>>
>>> Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
>>> ---
>>>    drivers/gpu/drm/msm/.gitignore |  1 +
>>>    drivers/gpu/drm/msm/Makefile   | 97 +++++++++++++++++++++++++++++++++---------
>>>    2 files changed, 77 insertions(+), 21 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/msm/.gitignore b/drivers/gpu/drm/msm/.gitignore
>>> new file mode 100644
>>> index 000000000000..9ab870da897d
>>> --- /dev/null
>>> +++ b/drivers/gpu/drm/msm/.gitignore
>>> @@ -0,0 +1 @@
>>> +generated/
>>> diff --git a/drivers/gpu/drm/msm/Makefile b/drivers/gpu/drm/msm/Makefile
>>> index 26ed4f443149..c861de58286c 100644
>>> --- a/drivers/gpu/drm/msm/Makefile
>>> +++ b/drivers/gpu/drm/msm/Makefile
>>> @@ -1,10 +1,11 @@
>>>    # SPDX-License-Identifier: GPL-2.0
>>>    ccflags-y := -I $(srctree)/$(src)
>>> +ccflags-y += -I $(obj)/generated
>>>    ccflags-y += -I $(srctree)/$(src)/disp/dpu1
>>>    ccflags-$(CONFIG_DRM_MSM_DSI) += -I $(srctree)/$(src)/dsi
>>>    ccflags-$(CONFIG_DRM_MSM_DP) += -I $(srctree)/$(src)/dp
>>>
>>> -msm-y := \
>>> +adreno-y := \
>>>        adreno/adreno_device.o \
>>>        adreno/adreno_gpu.o \
>>>        adreno/a2xx_gpu.o \
>>> @@ -18,7 +19,11 @@ msm-y := \
>>>        adreno/a6xx_gmu.o \
>>>        adreno/a6xx_hfi.o \
>>>
>>> -msm-$(CONFIG_DRM_MSM_HDMI) += \
>>> +adreno-$(CONFIG_DEBUG_FS) += adreno/a5xx_debugfs.o \
>>> +
>>> +adreno-$(CONFIG_DRM_MSM_GPU_STATE)   += adreno/a6xx_gpu_state.o
>>> +
>>> +msm-display-$(CONFIG_DRM_MSM_HDMI) += \
>>>        hdmi/hdmi.o \
>>>        hdmi/hdmi_audio.o \
>>>        hdmi/hdmi_bridge.o \
>>> @@ -31,7 +36,7 @@ msm-$(CONFIG_DRM_MSM_HDMI) += \
>>>        hdmi/hdmi_phy_8x74.o \
>>>        hdmi/hdmi_pll_8960.o \
>>>
>>> -msm-$(CONFIG_DRM_MSM_MDP4) += \
>>> +msm-display-$(CONFIG_DRM_MSM_MDP4) += \
>>>        disp/mdp4/mdp4_crtc.o \
>>>        disp/mdp4/mdp4_dsi_encoder.o \
>>>        disp/mdp4/mdp4_dtv_encoder.o \
>>> @@ -42,7 +47,7 @@ msm-$(CONFIG_DRM_MSM_MDP4) += \
>>>        disp/mdp4/mdp4_kms.o \
>>>        disp/mdp4/mdp4_plane.o \
>>>
>>> -msm-$(CONFIG_DRM_MSM_MDP5) += \
>>> +msm-display-$(CONFIG_DRM_MSM_MDP5) += \
>>>        disp/mdp5/mdp5_cfg.o \
>>>        disp/mdp5/mdp5_cmd_encoder.o \
>>>        disp/mdp5/mdp5_ctl.o \
>>> @@ -55,7 +60,7 @@ msm-$(CONFIG_DRM_MSM_MDP5) += \
>>>        disp/mdp5/mdp5_plane.o \
>>>        disp/mdp5/mdp5_smp.o \
>>>
>>> -msm-$(CONFIG_DRM_MSM_DPU) += \
>>> +msm-display-$(CONFIG_DRM_MSM_DPU) += \
>>>        disp/dpu1/dpu_core_perf.o \
>>>        disp/dpu1/dpu_crtc.o \
>>>        disp/dpu1/dpu_encoder.o \
>>> @@ -85,14 +90,16 @@ msm-$(CONFIG_DRM_MSM_DPU) += \
>>>        disp/dpu1/dpu_vbif.o \
>>>        disp/dpu1/dpu_writeback.o
>>>
>>> -msm-$(CONFIG_DRM_MSM_MDSS) += \
>>> +msm-display-$(CONFIG_DRM_MSM_MDSS) += \
>>>        msm_mdss.o \
>>>
>>> -msm-y += \
>>> +msm-display-y += \
>>>        disp/mdp_format.o \
>>>        disp/mdp_kms.o \
>>>        disp/msm_disp_snapshot.o \
>>>        disp/msm_disp_snapshot_util.o \
>>> +
>>> +msm-y += \
>>>        msm_atomic.o \
>>>        msm_atomic_tracepoints.o \
>>>        msm_debugfs.o \
>>> @@ -115,12 +122,12 @@ msm-y += \
>>>        msm_submitqueue.o \
>>>        msm_gpu_tracepoints.o \
>>>
>>> -msm-$(CONFIG_DEBUG_FS) += adreno/a5xx_debugfs.o \
>>> -     dp/dp_debug.o
>>> +msm-$(CONFIG_DRM_FBDEV_EMULATION) += msm_fbdev.o
>>>
>>> -msm-$(CONFIG_DRM_MSM_GPU_STATE)      += adreno/a6xx_gpu_state.o
>>> +msm-display-$(CONFIG_DEBUG_FS) += \
>>> +     dp/dp_debug.o
>>>
>>> -msm-$(CONFIG_DRM_MSM_DP)+= dp/dp_aux.o \
>>> +msm-display-$(CONFIG_DRM_MSM_DP)+= dp/dp_aux.o \
>>>        dp/dp_catalog.o \
>>>        dp/dp_ctrl.o \
>>>        dp/dp_display.o \
>>> @@ -130,21 +137,69 @@ msm-$(CONFIG_DRM_MSM_DP)+= dp/dp_aux.o \
>>>        dp/dp_audio.o \
>>>        dp/dp_utils.o
>>>
>>> -msm-$(CONFIG_DRM_FBDEV_EMULATION) += msm_fbdev.o
>>> -
>>> -msm-$(CONFIG_DRM_MSM_HDMI_HDCP) += hdmi/hdmi_hdcp.o
>>> +msm-display-$(CONFIG_DRM_MSM_HDMI_HDCP) += hdmi/hdmi_hdcp.o
>>>
>>> -msm-$(CONFIG_DRM_MSM_DSI) += dsi/dsi.o \
>>> +msm-display-$(CONFIG_DRM_MSM_DSI) += dsi/dsi.o \
>>>                        dsi/dsi_cfg.o \
>>>                        dsi/dsi_host.o \
>>>                        dsi/dsi_manager.o \
>>>                        dsi/phy/dsi_phy.o
>>>
>>> -msm-$(CONFIG_DRM_MSM_DSI_28NM_PHY) += dsi/phy/dsi_phy_28nm.o
>>> -msm-$(CONFIG_DRM_MSM_DSI_20NM_PHY) += dsi/phy/dsi_phy_20nm.o
>>> -msm-$(CONFIG_DRM_MSM_DSI_28NM_8960_PHY) += dsi/phy/dsi_phy_28nm_8960.o
>>> -msm-$(CONFIG_DRM_MSM_DSI_14NM_PHY) += dsi/phy/dsi_phy_14nm.o
>>> -msm-$(CONFIG_DRM_MSM_DSI_10NM_PHY) += dsi/phy/dsi_phy_10nm.o
>>> -msm-$(CONFIG_DRM_MSM_DSI_7NM_PHY) += dsi/phy/dsi_phy_7nm.o
>>> +msm-display-$(CONFIG_DRM_MSM_DSI_28NM_PHY) += dsi/phy/dsi_phy_28nm.o
>>> +msm-display-$(CONFIG_DRM_MSM_DSI_20NM_PHY) += dsi/phy/dsi_phy_20nm.o
>>> +msm-display-$(CONFIG_DRM_MSM_DSI_28NM_8960_PHY) += dsi/phy/dsi_phy_28nm_8960.o
>>> +msm-display-$(CONFIG_DRM_MSM_DSI_14NM_PHY) += dsi/phy/dsi_phy_14nm.o
>>> +msm-display-$(CONFIG_DRM_MSM_DSI_10NM_PHY) += dsi/phy/dsi_phy_10nm.o
>>> +msm-display-$(CONFIG_DRM_MSM_DSI_7NM_PHY) += dsi/phy/dsi_phy_7nm.o
>>> +
>>> +msm-y += $(adreno-y) $(msm-display-y)
>>>
>>>    obj-$(CONFIG_DRM_MSM)       += msm.o
>>> +
>>> +quiet_cmd_headergen = GENHDR  $@
>>> +      cmd_headergen = mkdir -p $(obj)/generated && $(PYTHON3) $(srctree)/$(src)/registers/gen_header.py --rnn $(srctree)/$(src)/registers --xml $< c-defines > $@
>>> +
>>> +$(obj)/generated/%.xml.h: $(src)/registers/adreno/%.xml \
>>> +             $(src)/registers/adreno/adreno_common.xml \
>>> +             $(src)/registers/adreno/adreno_pm4.xml \
>>> +             $(src)/registers/freedreno_copyright.xml \
>>> +             $(src)/registers/gen_header.py \
>>> +             $(src)/registers/rules-fd.xsd \
>>> +             FORCE
>>> +     $(call if_changed,headergen)
>>> +
>>> +$(obj)/generated/%.xml.h: $(src)/registers/display/%.xml \
>>> +             $(src)/registers/freedreno_copyright.xml \
>>> +             $(src)/registers/gen_header.py \
>>> +             $(src)/registers/rules-fd.xsd \
>>> +             FORCE
>>> +     $(call if_changed,headergen)
>>> +
>>> +ADRENO_HEADERS = \
>>> +     generated/a2xx.xml.h \
>>> +     generated/a3xx.xml.h \
>>> +     generated/a4xx.xml.h \
>>> +     generated/a5xx.xml.h \
>>> +     generated/a6xx.xml.h \
>>> +     generated/a6xx_gmu.xml.h \
>>> +     generated/adreno_common.xml.h \
>>> +     generated/adreno_pm4.xml.h \
>>> +
>>> +DISPLAY_HEADERS = \
>>> +     generated/dsi_phy_7nm.xml.h \
>>> +     generated/dsi_phy_10nm.xml.h \
>>> +     generated/dsi_phy_14nm.xml.h \
>>> +     generated/dsi_phy_20nm.xml.h \
>>> +     generated/dsi_phy_28nm_8960.xml.h \
>>> +     generated/dsi_phy_28nm.xml.h \
>>> +     generated/dsi.xml.h \
>>> +     generated/hdmi.xml.h \
>>> +     generated/mdp4.xml.h \
>>> +     generated/mdp5.xml.h \
>>> +     generated/mdp_common.xml.h \
>>> +     generated/sfpb.xml.h
>>> +
>>> +$(addprefix $(obj)/,$(adreno-y)): $(addprefix $(obj)/,$(ADRENO_HEADERS))
>>> +$(addprefix $(obj)/,$(msm-display-y)): $(addprefix $(obj)/,$(DISPLAY_HEADERS))
>>> +
>>> +targets += $(ADRENO_HEADERS) $(DISPLAY_HEADERS)
>>
>>
>> I noticed that some of our builders were failing to build the latest
>> -next and it was after this commit that things broke. The builders
>> have an older version of python3 and the gen_headers.py script fails
>> in a couple places with syntax errors. The following changes
>> resolved the issues for python 3.5 ...
> 
> Could you please post them as a proper patch?

Yes absolutely, I just wanted to get some feedback first in case there 
was anything I was overlooking.

>> diff --git a/drivers/gpu/drm/msm/registers/gen_header.py b/drivers/gpu/drm/msm/registers/gen_header.py
>> index 9b2842d4a354..90d5c2991d05 100644
>> --- a/drivers/gpu/drm/msm/registers/gen_header.py
>> +++ b/drivers/gpu/drm/msm/registers/gen_header.py
>> @@ -323,7 +323,7 @@ class Array(object):
>>                           indices = []
>>                   if self.length != 1:
>>                           if self.fixed_offsets:
>> -                               indices.append((self.index_ctype(), None, f"__offset_{self.local_name}"))
>> +                               indices.append((self.index_ctype(), None, "__offset_%s" % self.local_name))
>>                           else:
>>                                   indices.append((self.index_ctype(), self.stride, None))
>>                   return indices
>> @@ -942,7 +942,8 @@ def main():
>>           parser.add_argument('--rnn', type=str, required=True)
>>           parser.add_argument('--xml', type=str, required=True)
>>
>> -       subparsers = parser.add_subparsers(required=True)
>> +       subparsers = parser.add_subparsers()
>> +       subparsers.required = True
>>
>>
>> I know that anything before python 3.8 is now EOL, but I did see a
>> similar thread on dri-devel [0] for supporting python 3.6 and so
>> wanted to see if there is any objections to the above?
> 
> I don't have any objections from my side.

OK, great!

Jon