All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/22] drm: Review of mode copies
@ 2022-02-18 10:03 ` Ville Syrjala
  0 siblings, 0 replies; 157+ messages in thread
From: Ville Syrjala @ 2022-02-18 10:03 UTC (permalink / raw)
  To: dri-devel
  Cc: intel-gfx, Abhinav Kumar, Alain Volmat, Alex Deucher, amd-gfx,
	Andrzej Hajda, Aurabindo Pillai, Chen Feng, Chun-Kuang Hu,
	Emma Anholt, freedreno, Harry Wentland, Heiko Stübner,
	Jernej Skrabec, John Stultz, Jonas Karlman, Jyri Sarha,
	Laurent Pinchart, Leo Li, linux-arm-kernel, linux-arm-msm,
	linux-rockchip, Maxime Ripard, Neil Armstrong, Nikola Cornij,
	Patrik Jakobsson, Philipp Zabel, Rob Clark, Robert Foss,
	Rodrigo Siqueira, Sam Ravnborg, Sandy Huang, Sean Paul,
	Thierry Reding, Tian Tao, Tomi Valkeinen, Xinliang Liu,
	Xinwei Kong

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

I might be taking this a bit too far, but the lack of
consistency in our methods to copy drm_display_mode
structs around is bugging me.

The main worry is the embedded list head, which if
clobbered could lead to list corruption. I'd also
prefer to make sure even the valid list heads don't
propagate between copies since that makes no sense.

While going through some of the code I also spotted
some very weird on stack copies being made for no
reason at all. I elimininated a few of them here,
but there could certainly be more lurking in the
shadows.

Cc: Abhinav Kumar <quic_abhinavk@quicinc.com>
Cc: Alain Volmat <alain.volmat@foss.st.com>
Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: amd-gfx@lists.freedesktop.org
Cc: Andrzej Hajda <andrzej.hajda@intel.com>
Cc: Aurabindo Pillai <aurabindo.pillai@amd.com>
Cc: Chen Feng <puck.chen@hisilicon.com>
Cc: Chun-Kuang Hu <chunkuang.hu@kernel.org>
Cc: Emma Anholt <emma@anholt.net>
Cc: freedreno@lists.freedesktop.org
Cc: Harry Wentland <harry.wentland@amd.com>
Cc: "Heiko Stübner" <heiko@sntech.de>
Cc: Jernej Skrabec <jernej.skrabec@gmail.com>
Cc: John Stultz <john.stultz@linaro.org>
Cc: Jonas Karlman <jonas@kwiboo.se>
Cc: Jyri Sarha <jyri.sarha@iki.fi>
Cc: Laurent Pinchart <Laurent.pinchart@ideasonboard.com>
Cc: Leo Li <sunpeng.li@amd.com>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-arm-msm@vger.kernel.org
Cc: linux-rockchip@lists.infradead.org
Cc: Maxime Ripard <mripard@kernel.org>
Cc: Neil Armstrong <narmstrong@baylibre.com>
Cc: Nikola Cornij <nikola.cornij@amd.com>
Cc: Patrik Jakobsson <patrik.r.jakobsson@gmail.com>
Cc: Philipp Zabel <p.zabel@pengutronix.de>
Cc: Rob Clark <robdclark@gmail.com>
Cc: Robert Foss <robert.foss@linaro.org>
Cc: Rodrigo Siqueira <Rodrigo.Siqueira@amd.com>
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: Sandy Huang <hjc@rock-chips.com>
Cc: Sean Paul <sean@poorly.run>
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: Tian Tao <tiantao6@hisilicon.com>
Cc: Tomi Valkeinen <tomba@kernel.org>
Cc: Xinliang Liu <xinliang.liu@linaro.org>
Cc: Xinwei Kong <kong.kongxinwei@hisilicon.com>

Ville Syrjälä (22):
  drm: Add drm_mode_init()
  drm/amdgpu: Remove pointless on stack mode copies
  drm/amdgpu: Use drm_mode_init() for on-stack modes
  drm/amdgpu: Use drm_mode_copy()
  drm/radeon: Use drm_mode_copy()
  drm/bridge: Use drm_mode_copy()
  drm/gma500: Use drm_mode_copy()
  drm/hisilicon: Use drm_mode_init() for on-stack modes
  drm/imx: Use drm_mode_duplicate()
  drm/msm: Nuke weird on stack mode copy
  drm/msm: Use drm_mode_init() for on-stack modes
  drm/msm: Use drm_mode_copy()
  drm/mtk: Use drm_mode_init() for on-stack modes
  drm/rockchip: Use drm_mode_copy()
  drm/sti: Use drm_mode_copy()
  drm/tilcdc: Use drm_mode_copy()
  drm/vc4: Use drm_mode_copy()
  drm/i915: Use drm_mode_init() for on-stack modes
  drm/i915: Use drm_mode_copy()
  drm/panel: Use drm_mode_duplicate()
  drm: Use drm_mode_init() for on-stack modes
  drm: Use drm_mode_copy()

 .../gpu/drm/amd/amdgpu/amdgpu_connectors.c    |  4 +-
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 41 ++++++++++---------
 drivers/gpu/drm/bridge/nwl-dsi.c              |  2 +-
 drivers/gpu/drm/bridge/synopsys/dw-hdmi.c     |  2 +-
 drivers/gpu/drm/bridge/tc358767.c             |  2 +-
 drivers/gpu/drm/drm_crtc_helper.c             | 12 +++---
 drivers/gpu/drm/drm_edid.c                    |  8 +++-
 drivers/gpu/drm/drm_modes.c                   | 21 +++++++++-
 drivers/gpu/drm/drm_vblank.c                  |  2 +-
 drivers/gpu/drm/gma500/oaktrail_crtc.c        |  8 +---
 drivers/gpu/drm/hisilicon/kirin/dw_drm_dsi.c  |  2 +-
 drivers/gpu/drm/i915/display/intel_display.c  | 20 +++++----
 drivers/gpu/drm/imx/imx-ldb.c                 |  3 +-
 drivers/gpu/drm/mediatek/mtk_hdmi.c           |  2 +-
 .../drm/msm/disp/dpu1/dpu_encoder_phys_cmd.c  |  2 +-
 .../drm/msm/disp/dpu1/dpu_encoder_phys_vid.c  |  9 ++--
 drivers/gpu/drm/msm/dp/dp_display.c           |  2 +-
 drivers/gpu/drm/msm/dp/dp_drm.c               | 10 ++---
 drivers/gpu/drm/panel/panel-truly-nt35597.c   |  3 +-
 .../gpu/drm/panel/panel-visionox-rm69299.c    |  4 +-
 drivers/gpu/drm/radeon/radeon_connectors.c    |  4 +-
 drivers/gpu/drm/rockchip/cdn-dp-core.c        |  2 +-
 drivers/gpu/drm/rockchip/inno_hdmi.c          |  2 +-
 drivers/gpu/drm/rockchip/rk3066_hdmi.c        |  2 +-
 drivers/gpu/drm/sti/sti_dvo.c                 |  2 +-
 drivers/gpu/drm/sti/sti_hda.c                 |  2 +-
 drivers/gpu/drm/sti/sti_hdmi.c                |  2 +-
 drivers/gpu/drm/tilcdc/tilcdc_crtc.c          |  2 +-
 drivers/gpu/drm/vc4/vc4_hdmi.c                |  5 +--
 include/drm/drm_modes.h                       |  2 +
 30 files changed, 105 insertions(+), 79 deletions(-)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 157+ messages in thread

* [PATCH 00/22] drm: Review of mode copies
@ 2022-02-18 10:03 ` Ville Syrjala
  0 siblings, 0 replies; 157+ messages in thread
From: Ville Syrjala @ 2022-02-18 10:03 UTC (permalink / raw)
  To: dri-devel
  Cc: intel-gfx, Abhinav Kumar, Alain Volmat, Alex Deucher, amd-gfx,
	Andrzej Hajda, Aurabindo Pillai, Chen Feng, Chun-Kuang Hu,
	Emma Anholt, freedreno, Harry Wentland, Heiko Stübner,
	Jernej Skrabec, John Stultz, Jonas Karlman, Jyri Sarha,
	Laurent Pinchart, Leo Li, linux-arm-kernel, linux-arm-msm,
	linux-rockchip, Maxime Ripard, Neil Armstrong, Nikola Cornij,
	Patrik Jakobsson, Philipp Zabel, Rob Clark, Robert Foss,
	Rodrigo Siqueira, Sam Ravnborg, Sandy Huang, Sean Paul,
	Thierry Reding, Tian Tao, Tomi Valkeinen, Xinliang Liu,
	Xinwei Kong

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

I might be taking this a bit too far, but the lack of
consistency in our methods to copy drm_display_mode
structs around is bugging me.

The main worry is the embedded list head, which if
clobbered could lead to list corruption. I'd also
prefer to make sure even the valid list heads don't
propagate between copies since that makes no sense.

While going through some of the code I also spotted
some very weird on stack copies being made for no
reason at all. I elimininated a few of them here,
but there could certainly be more lurking in the
shadows.

Cc: Abhinav Kumar <quic_abhinavk@quicinc.com>
Cc: Alain Volmat <alain.volmat@foss.st.com>
Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: amd-gfx@lists.freedesktop.org
Cc: Andrzej Hajda <andrzej.hajda@intel.com>
Cc: Aurabindo Pillai <aurabindo.pillai@amd.com>
Cc: Chen Feng <puck.chen@hisilicon.com>
Cc: Chun-Kuang Hu <chunkuang.hu@kernel.org>
Cc: Emma Anholt <emma@anholt.net>
Cc: freedreno@lists.freedesktop.org
Cc: Harry Wentland <harry.wentland@amd.com>
Cc: "Heiko Stübner" <heiko@sntech.de>
Cc: Jernej Skrabec <jernej.skrabec@gmail.com>
Cc: John Stultz <john.stultz@linaro.org>
Cc: Jonas Karlman <jonas@kwiboo.se>
Cc: Jyri Sarha <jyri.sarha@iki.fi>
Cc: Laurent Pinchart <Laurent.pinchart@ideasonboard.com>
Cc: Leo Li <sunpeng.li@amd.com>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-arm-msm@vger.kernel.org
Cc: linux-rockchip@lists.infradead.org
Cc: Maxime Ripard <mripard@kernel.org>
Cc: Neil Armstrong <narmstrong@baylibre.com>
Cc: Nikola Cornij <nikola.cornij@amd.com>
Cc: Patrik Jakobsson <patrik.r.jakobsson@gmail.com>
Cc: Philipp Zabel <p.zabel@pengutronix.de>
Cc: Rob Clark <robdclark@gmail.com>
Cc: Robert Foss <robert.foss@linaro.org>
Cc: Rodrigo Siqueira <Rodrigo.Siqueira@amd.com>
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: Sandy Huang <hjc@rock-chips.com>
Cc: Sean Paul <sean@poorly.run>
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: Tian Tao <tiantao6@hisilicon.com>
Cc: Tomi Valkeinen <tomba@kernel.org>
Cc: Xinliang Liu <xinliang.liu@linaro.org>
Cc: Xinwei Kong <kong.kongxinwei@hisilicon.com>

Ville Syrjälä (22):
  drm: Add drm_mode_init()
  drm/amdgpu: Remove pointless on stack mode copies
  drm/amdgpu: Use drm_mode_init() for on-stack modes
  drm/amdgpu: Use drm_mode_copy()
  drm/radeon: Use drm_mode_copy()
  drm/bridge: Use drm_mode_copy()
  drm/gma500: Use drm_mode_copy()
  drm/hisilicon: Use drm_mode_init() for on-stack modes
  drm/imx: Use drm_mode_duplicate()
  drm/msm: Nuke weird on stack mode copy
  drm/msm: Use drm_mode_init() for on-stack modes
  drm/msm: Use drm_mode_copy()
  drm/mtk: Use drm_mode_init() for on-stack modes
  drm/rockchip: Use drm_mode_copy()
  drm/sti: Use drm_mode_copy()
  drm/tilcdc: Use drm_mode_copy()
  drm/vc4: Use drm_mode_copy()
  drm/i915: Use drm_mode_init() for on-stack modes
  drm/i915: Use drm_mode_copy()
  drm/panel: Use drm_mode_duplicate()
  drm: Use drm_mode_init() for on-stack modes
  drm: Use drm_mode_copy()

 .../gpu/drm/amd/amdgpu/amdgpu_connectors.c    |  4 +-
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 41 ++++++++++---------
 drivers/gpu/drm/bridge/nwl-dsi.c              |  2 +-
 drivers/gpu/drm/bridge/synopsys/dw-hdmi.c     |  2 +-
 drivers/gpu/drm/bridge/tc358767.c             |  2 +-
 drivers/gpu/drm/drm_crtc_helper.c             | 12 +++---
 drivers/gpu/drm/drm_edid.c                    |  8 +++-
 drivers/gpu/drm/drm_modes.c                   | 21 +++++++++-
 drivers/gpu/drm/drm_vblank.c                  |  2 +-
 drivers/gpu/drm/gma500/oaktrail_crtc.c        |  8 +---
 drivers/gpu/drm/hisilicon/kirin/dw_drm_dsi.c  |  2 +-
 drivers/gpu/drm/i915/display/intel_display.c  | 20 +++++----
 drivers/gpu/drm/imx/imx-ldb.c                 |  3 +-
 drivers/gpu/drm/mediatek/mtk_hdmi.c           |  2 +-
 .../drm/msm/disp/dpu1/dpu_encoder_phys_cmd.c  |  2 +-
 .../drm/msm/disp/dpu1/dpu_encoder_phys_vid.c  |  9 ++--
 drivers/gpu/drm/msm/dp/dp_display.c           |  2 +-
 drivers/gpu/drm/msm/dp/dp_drm.c               | 10 ++---
 drivers/gpu/drm/panel/panel-truly-nt35597.c   |  3 +-
 .../gpu/drm/panel/panel-visionox-rm69299.c    |  4 +-
 drivers/gpu/drm/radeon/radeon_connectors.c    |  4 +-
 drivers/gpu/drm/rockchip/cdn-dp-core.c        |  2 +-
 drivers/gpu/drm/rockchip/inno_hdmi.c          |  2 +-
 drivers/gpu/drm/rockchip/rk3066_hdmi.c        |  2 +-
 drivers/gpu/drm/sti/sti_dvo.c                 |  2 +-
 drivers/gpu/drm/sti/sti_hda.c                 |  2 +-
 drivers/gpu/drm/sti/sti_hdmi.c                |  2 +-
 drivers/gpu/drm/tilcdc/tilcdc_crtc.c          |  2 +-
 drivers/gpu/drm/vc4/vc4_hdmi.c                |  5 +--
 include/drm/drm_modes.h                       |  2 +
 30 files changed, 105 insertions(+), 79 deletions(-)

-- 
2.34.1


_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

^ permalink raw reply	[flat|nested] 157+ messages in thread

* [PATCH 00/22] drm: Review of mode copies
@ 2022-02-18 10:03 ` Ville Syrjala
  0 siblings, 0 replies; 157+ messages in thread
From: Ville Syrjala @ 2022-02-18 10:03 UTC (permalink / raw)
  To: dri-devel
  Cc: Emma Anholt, Neil Armstrong, Xinliang Liu, Thierry Reding,
	Jernej Skrabec, Andrzej Hajda, Sam Ravnborg, Rodrigo Siqueira,
	amd-gfx, linux-rockchip, Xinwei Kong, Aurabindo Pillai,
	Chen Feng, Alain Volmat, Chun-Kuang Hu, Jonas Karlman, Leo Li,
	linux-arm-msm, intel-gfx, Abhinav Kumar, Nikola Cornij,
	Sean Paul, linux-arm-kernel, Tomi Valkeinen, Jyri Sarha,
	Sandy Huang, Robert Foss, Alex Deucher, Tian Tao, freedreno,
	Laurent Pinchart

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

I might be taking this a bit too far, but the lack of
consistency in our methods to copy drm_display_mode
structs around is bugging me.

The main worry is the embedded list head, which if
clobbered could lead to list corruption. I'd also
prefer to make sure even the valid list heads don't
propagate between copies since that makes no sense.

While going through some of the code I also spotted
some very weird on stack copies being made for no
reason at all. I elimininated a few of them here,
but there could certainly be more lurking in the
shadows.

Cc: Abhinav Kumar <quic_abhinavk@quicinc.com>
Cc: Alain Volmat <alain.volmat@foss.st.com>
Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: amd-gfx@lists.freedesktop.org
Cc: Andrzej Hajda <andrzej.hajda@intel.com>
Cc: Aurabindo Pillai <aurabindo.pillai@amd.com>
Cc: Chen Feng <puck.chen@hisilicon.com>
Cc: Chun-Kuang Hu <chunkuang.hu@kernel.org>
Cc: Emma Anholt <emma@anholt.net>
Cc: freedreno@lists.freedesktop.org
Cc: Harry Wentland <harry.wentland@amd.com>
Cc: "Heiko Stübner" <heiko@sntech.de>
Cc: Jernej Skrabec <jernej.skrabec@gmail.com>
Cc: John Stultz <john.stultz@linaro.org>
Cc: Jonas Karlman <jonas@kwiboo.se>
Cc: Jyri Sarha <jyri.sarha@iki.fi>
Cc: Laurent Pinchart <Laurent.pinchart@ideasonboard.com>
Cc: Leo Li <sunpeng.li@amd.com>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-arm-msm@vger.kernel.org
Cc: linux-rockchip@lists.infradead.org
Cc: Maxime Ripard <mripard@kernel.org>
Cc: Neil Armstrong <narmstrong@baylibre.com>
Cc: Nikola Cornij <nikola.cornij@amd.com>
Cc: Patrik Jakobsson <patrik.r.jakobsson@gmail.com>
Cc: Philipp Zabel <p.zabel@pengutronix.de>
Cc: Rob Clark <robdclark@gmail.com>
Cc: Robert Foss <robert.foss@linaro.org>
Cc: Rodrigo Siqueira <Rodrigo.Siqueira@amd.com>
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: Sandy Huang <hjc@rock-chips.com>
Cc: Sean Paul <sean@poorly.run>
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: Tian Tao <tiantao6@hisilicon.com>
Cc: Tomi Valkeinen <tomba@kernel.org>
Cc: Xinliang Liu <xinliang.liu@linaro.org>
Cc: Xinwei Kong <kong.kongxinwei@hisilicon.com>

Ville Syrjälä (22):
  drm: Add drm_mode_init()
  drm/amdgpu: Remove pointless on stack mode copies
  drm/amdgpu: Use drm_mode_init() for on-stack modes
  drm/amdgpu: Use drm_mode_copy()
  drm/radeon: Use drm_mode_copy()
  drm/bridge: Use drm_mode_copy()
  drm/gma500: Use drm_mode_copy()
  drm/hisilicon: Use drm_mode_init() for on-stack modes
  drm/imx: Use drm_mode_duplicate()
  drm/msm: Nuke weird on stack mode copy
  drm/msm: Use drm_mode_init() for on-stack modes
  drm/msm: Use drm_mode_copy()
  drm/mtk: Use drm_mode_init() for on-stack modes
  drm/rockchip: Use drm_mode_copy()
  drm/sti: Use drm_mode_copy()
  drm/tilcdc: Use drm_mode_copy()
  drm/vc4: Use drm_mode_copy()
  drm/i915: Use drm_mode_init() for on-stack modes
  drm/i915: Use drm_mode_copy()
  drm/panel: Use drm_mode_duplicate()
  drm: Use drm_mode_init() for on-stack modes
  drm: Use drm_mode_copy()

 .../gpu/drm/amd/amdgpu/amdgpu_connectors.c    |  4 +-
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 41 ++++++++++---------
 drivers/gpu/drm/bridge/nwl-dsi.c              |  2 +-
 drivers/gpu/drm/bridge/synopsys/dw-hdmi.c     |  2 +-
 drivers/gpu/drm/bridge/tc358767.c             |  2 +-
 drivers/gpu/drm/drm_crtc_helper.c             | 12 +++---
 drivers/gpu/drm/drm_edid.c                    |  8 +++-
 drivers/gpu/drm/drm_modes.c                   | 21 +++++++++-
 drivers/gpu/drm/drm_vblank.c                  |  2 +-
 drivers/gpu/drm/gma500/oaktrail_crtc.c        |  8 +---
 drivers/gpu/drm/hisilicon/kirin/dw_drm_dsi.c  |  2 +-
 drivers/gpu/drm/i915/display/intel_display.c  | 20 +++++----
 drivers/gpu/drm/imx/imx-ldb.c                 |  3 +-
 drivers/gpu/drm/mediatek/mtk_hdmi.c           |  2 +-
 .../drm/msm/disp/dpu1/dpu_encoder_phys_cmd.c  |  2 +-
 .../drm/msm/disp/dpu1/dpu_encoder_phys_vid.c  |  9 ++--
 drivers/gpu/drm/msm/dp/dp_display.c           |  2 +-
 drivers/gpu/drm/msm/dp/dp_drm.c               | 10 ++---
 drivers/gpu/drm/panel/panel-truly-nt35597.c   |  3 +-
 .../gpu/drm/panel/panel-visionox-rm69299.c    |  4 +-
 drivers/gpu/drm/radeon/radeon_connectors.c    |  4 +-
 drivers/gpu/drm/rockchip/cdn-dp-core.c        |  2 +-
 drivers/gpu/drm/rockchip/inno_hdmi.c          |  2 +-
 drivers/gpu/drm/rockchip/rk3066_hdmi.c        |  2 +-
 drivers/gpu/drm/sti/sti_dvo.c                 |  2 +-
 drivers/gpu/drm/sti/sti_hda.c                 |  2 +-
 drivers/gpu/drm/sti/sti_hdmi.c                |  2 +-
 drivers/gpu/drm/tilcdc/tilcdc_crtc.c          |  2 +-
 drivers/gpu/drm/vc4/vc4_hdmi.c                |  5 +--
 include/drm/drm_modes.h                       |  2 +
 30 files changed, 105 insertions(+), 79 deletions(-)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 157+ messages in thread

* [Intel-gfx] [PATCH 00/22] drm: Review of mode copies
@ 2022-02-18 10:03 ` Ville Syrjala
  0 siblings, 0 replies; 157+ messages in thread
From: Ville Syrjala @ 2022-02-18 10:03 UTC (permalink / raw)
  To: dri-devel
  Cc: Heiko Stübner, Emma Anholt, Neil Armstrong, Xinliang Liu,
	Jernej Skrabec, Andrzej Hajda, Sam Ravnborg, Rodrigo Siqueira,
	amd-gfx, linux-rockchip, Xinwei Kong, Aurabindo Pillai,
	Chen Feng, Alain Volmat, Harry Wentland, Chun-Kuang Hu,
	Jonas Karlman, Leo Li, linux-arm-msm, intel-gfx, Abhinav Kumar,
	Maxime Ripard, Nikola Cornij, John Stultz, linux-arm-kernel,
	Tomi Valkeinen, Jyri Sarha, Sandy Huang, Robert Foss,
	Philipp Zabel, Alex Deucher, Tian Tao, freedreno,
	Laurent Pinchart

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

I might be taking this a bit too far, but the lack of
consistency in our methods to copy drm_display_mode
structs around is bugging me.

The main worry is the embedded list head, which if
clobbered could lead to list corruption. I'd also
prefer to make sure even the valid list heads don't
propagate between copies since that makes no sense.

While going through some of the code I also spotted
some very weird on stack copies being made for no
reason at all. I elimininated a few of them here,
but there could certainly be more lurking in the
shadows.

Cc: Abhinav Kumar <quic_abhinavk@quicinc.com>
Cc: Alain Volmat <alain.volmat@foss.st.com>
Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: amd-gfx@lists.freedesktop.org
Cc: Andrzej Hajda <andrzej.hajda@intel.com>
Cc: Aurabindo Pillai <aurabindo.pillai@amd.com>
Cc: Chen Feng <puck.chen@hisilicon.com>
Cc: Chun-Kuang Hu <chunkuang.hu@kernel.org>
Cc: Emma Anholt <emma@anholt.net>
Cc: freedreno@lists.freedesktop.org
Cc: Harry Wentland <harry.wentland@amd.com>
Cc: "Heiko Stübner" <heiko@sntech.de>
Cc: Jernej Skrabec <jernej.skrabec@gmail.com>
Cc: John Stultz <john.stultz@linaro.org>
Cc: Jonas Karlman <jonas@kwiboo.se>
Cc: Jyri Sarha <jyri.sarha@iki.fi>
Cc: Laurent Pinchart <Laurent.pinchart@ideasonboard.com>
Cc: Leo Li <sunpeng.li@amd.com>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-arm-msm@vger.kernel.org
Cc: linux-rockchip@lists.infradead.org
Cc: Maxime Ripard <mripard@kernel.org>
Cc: Neil Armstrong <narmstrong@baylibre.com>
Cc: Nikola Cornij <nikola.cornij@amd.com>
Cc: Patrik Jakobsson <patrik.r.jakobsson@gmail.com>
Cc: Philipp Zabel <p.zabel@pengutronix.de>
Cc: Rob Clark <robdclark@gmail.com>
Cc: Robert Foss <robert.foss@linaro.org>
Cc: Rodrigo Siqueira <Rodrigo.Siqueira@amd.com>
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: Sandy Huang <hjc@rock-chips.com>
Cc: Sean Paul <sean@poorly.run>
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: Tian Tao <tiantao6@hisilicon.com>
Cc: Tomi Valkeinen <tomba@kernel.org>
Cc: Xinliang Liu <xinliang.liu@linaro.org>
Cc: Xinwei Kong <kong.kongxinwei@hisilicon.com>

Ville Syrjälä (22):
  drm: Add drm_mode_init()
  drm/amdgpu: Remove pointless on stack mode copies
  drm/amdgpu: Use drm_mode_init() for on-stack modes
  drm/amdgpu: Use drm_mode_copy()
  drm/radeon: Use drm_mode_copy()
  drm/bridge: Use drm_mode_copy()
  drm/gma500: Use drm_mode_copy()
  drm/hisilicon: Use drm_mode_init() for on-stack modes
  drm/imx: Use drm_mode_duplicate()
  drm/msm: Nuke weird on stack mode copy
  drm/msm: Use drm_mode_init() for on-stack modes
  drm/msm: Use drm_mode_copy()
  drm/mtk: Use drm_mode_init() for on-stack modes
  drm/rockchip: Use drm_mode_copy()
  drm/sti: Use drm_mode_copy()
  drm/tilcdc: Use drm_mode_copy()
  drm/vc4: Use drm_mode_copy()
  drm/i915: Use drm_mode_init() for on-stack modes
  drm/i915: Use drm_mode_copy()
  drm/panel: Use drm_mode_duplicate()
  drm: Use drm_mode_init() for on-stack modes
  drm: Use drm_mode_copy()

 .../gpu/drm/amd/amdgpu/amdgpu_connectors.c    |  4 +-
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 41 ++++++++++---------
 drivers/gpu/drm/bridge/nwl-dsi.c              |  2 +-
 drivers/gpu/drm/bridge/synopsys/dw-hdmi.c     |  2 +-
 drivers/gpu/drm/bridge/tc358767.c             |  2 +-
 drivers/gpu/drm/drm_crtc_helper.c             | 12 +++---
 drivers/gpu/drm/drm_edid.c                    |  8 +++-
 drivers/gpu/drm/drm_modes.c                   | 21 +++++++++-
 drivers/gpu/drm/drm_vblank.c                  |  2 +-
 drivers/gpu/drm/gma500/oaktrail_crtc.c        |  8 +---
 drivers/gpu/drm/hisilicon/kirin/dw_drm_dsi.c  |  2 +-
 drivers/gpu/drm/i915/display/intel_display.c  | 20 +++++----
 drivers/gpu/drm/imx/imx-ldb.c                 |  3 +-
 drivers/gpu/drm/mediatek/mtk_hdmi.c           |  2 +-
 .../drm/msm/disp/dpu1/dpu_encoder_phys_cmd.c  |  2 +-
 .../drm/msm/disp/dpu1/dpu_encoder_phys_vid.c  |  9 ++--
 drivers/gpu/drm/msm/dp/dp_display.c           |  2 +-
 drivers/gpu/drm/msm/dp/dp_drm.c               | 10 ++---
 drivers/gpu/drm/panel/panel-truly-nt35597.c   |  3 +-
 .../gpu/drm/panel/panel-visionox-rm69299.c    |  4 +-
 drivers/gpu/drm/radeon/radeon_connectors.c    |  4 +-
 drivers/gpu/drm/rockchip/cdn-dp-core.c        |  2 +-
 drivers/gpu/drm/rockchip/inno_hdmi.c          |  2 +-
 drivers/gpu/drm/rockchip/rk3066_hdmi.c        |  2 +-
 drivers/gpu/drm/sti/sti_dvo.c                 |  2 +-
 drivers/gpu/drm/sti/sti_hda.c                 |  2 +-
 drivers/gpu/drm/sti/sti_hdmi.c                |  2 +-
 drivers/gpu/drm/tilcdc/tilcdc_crtc.c          |  2 +-
 drivers/gpu/drm/vc4/vc4_hdmi.c                |  5 +--
 include/drm/drm_modes.h                       |  2 +
 30 files changed, 105 insertions(+), 79 deletions(-)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 157+ messages in thread

* [PATCH 00/22] drm: Review of mode copies
@ 2022-02-18 10:03 ` Ville Syrjala
  0 siblings, 0 replies; 157+ messages in thread
From: Ville Syrjala @ 2022-02-18 10:03 UTC (permalink / raw)
  To: dri-devel
  Cc: Heiko Stübner, Emma Anholt, Neil Armstrong, Xinliang Liu,
	Thierry Reding, Jernej Skrabec, Andrzej Hajda, Sam Ravnborg,
	Rodrigo Siqueira, amd-gfx, linux-rockchip, Xinwei Kong,
	Aurabindo Pillai, Chen Feng, Alain Volmat, Harry Wentland,
	Chun-Kuang Hu, Jonas Karlman, Leo Li, linux-arm-msm, intel-gfx,
	Abhinav Kumar, Maxime Ripard, Nikola Cornij, John Stultz,
	Sean Paul, linux-arm-kernel, Tomi Valkeinen, Jyri Sarha,
	Sandy Huang, Robert Foss, Patrik Jakobsson, Rob Clark,
	Philipp Zabel, Alex Deucher, Tian Tao, freedreno,
	Laurent Pinchart

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

I might be taking this a bit too far, but the lack of
consistency in our methods to copy drm_display_mode
structs around is bugging me.

The main worry is the embedded list head, which if
clobbered could lead to list corruption. I'd also
prefer to make sure even the valid list heads don't
propagate between copies since that makes no sense.

While going through some of the code I also spotted
some very weird on stack copies being made for no
reason at all. I elimininated a few of them here,
but there could certainly be more lurking in the
shadows.

Cc: Abhinav Kumar <quic_abhinavk@quicinc.com>
Cc: Alain Volmat <alain.volmat@foss.st.com>
Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: amd-gfx@lists.freedesktop.org
Cc: Andrzej Hajda <andrzej.hajda@intel.com>
Cc: Aurabindo Pillai <aurabindo.pillai@amd.com>
Cc: Chen Feng <puck.chen@hisilicon.com>
Cc: Chun-Kuang Hu <chunkuang.hu@kernel.org>
Cc: Emma Anholt <emma@anholt.net>
Cc: freedreno@lists.freedesktop.org
Cc: Harry Wentland <harry.wentland@amd.com>
Cc: "Heiko Stübner" <heiko@sntech.de>
Cc: Jernej Skrabec <jernej.skrabec@gmail.com>
Cc: John Stultz <john.stultz@linaro.org>
Cc: Jonas Karlman <jonas@kwiboo.se>
Cc: Jyri Sarha <jyri.sarha@iki.fi>
Cc: Laurent Pinchart <Laurent.pinchart@ideasonboard.com>
Cc: Leo Li <sunpeng.li@amd.com>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-arm-msm@vger.kernel.org
Cc: linux-rockchip@lists.infradead.org
Cc: Maxime Ripard <mripard@kernel.org>
Cc: Neil Armstrong <narmstrong@baylibre.com>
Cc: Nikola Cornij <nikola.cornij@amd.com>
Cc: Patrik Jakobsson <patrik.r.jakobsson@gmail.com>
Cc: Philipp Zabel <p.zabel@pengutronix.de>
Cc: Rob Clark <robdclark@gmail.com>
Cc: Robert Foss <robert.foss@linaro.org>
Cc: Rodrigo Siqueira <Rodrigo.Siqueira@amd.com>
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: Sandy Huang <hjc@rock-chips.com>
Cc: Sean Paul <sean@poorly.run>
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: Tian Tao <tiantao6@hisilicon.com>
Cc: Tomi Valkeinen <tomba@kernel.org>
Cc: Xinliang Liu <xinliang.liu@linaro.org>
Cc: Xinwei Kong <kong.kongxinwei@hisilicon.com>

Ville Syrjälä (22):
  drm: Add drm_mode_init()
  drm/amdgpu: Remove pointless on stack mode copies
  drm/amdgpu: Use drm_mode_init() for on-stack modes
  drm/amdgpu: Use drm_mode_copy()
  drm/radeon: Use drm_mode_copy()
  drm/bridge: Use drm_mode_copy()
  drm/gma500: Use drm_mode_copy()
  drm/hisilicon: Use drm_mode_init() for on-stack modes
  drm/imx: Use drm_mode_duplicate()
  drm/msm: Nuke weird on stack mode copy
  drm/msm: Use drm_mode_init() for on-stack modes
  drm/msm: Use drm_mode_copy()
  drm/mtk: Use drm_mode_init() for on-stack modes
  drm/rockchip: Use drm_mode_copy()
  drm/sti: Use drm_mode_copy()
  drm/tilcdc: Use drm_mode_copy()
  drm/vc4: Use drm_mode_copy()
  drm/i915: Use drm_mode_init() for on-stack modes
  drm/i915: Use drm_mode_copy()
  drm/panel: Use drm_mode_duplicate()
  drm: Use drm_mode_init() for on-stack modes
  drm: Use drm_mode_copy()

 .../gpu/drm/amd/amdgpu/amdgpu_connectors.c    |  4 +-
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 41 ++++++++++---------
 drivers/gpu/drm/bridge/nwl-dsi.c              |  2 +-
 drivers/gpu/drm/bridge/synopsys/dw-hdmi.c     |  2 +-
 drivers/gpu/drm/bridge/tc358767.c             |  2 +-
 drivers/gpu/drm/drm_crtc_helper.c             | 12 +++---
 drivers/gpu/drm/drm_edid.c                    |  8 +++-
 drivers/gpu/drm/drm_modes.c                   | 21 +++++++++-
 drivers/gpu/drm/drm_vblank.c                  |  2 +-
 drivers/gpu/drm/gma500/oaktrail_crtc.c        |  8 +---
 drivers/gpu/drm/hisilicon/kirin/dw_drm_dsi.c  |  2 +-
 drivers/gpu/drm/i915/display/intel_display.c  | 20 +++++----
 drivers/gpu/drm/imx/imx-ldb.c                 |  3 +-
 drivers/gpu/drm/mediatek/mtk_hdmi.c           |  2 +-
 .../drm/msm/disp/dpu1/dpu_encoder_phys_cmd.c  |  2 +-
 .../drm/msm/disp/dpu1/dpu_encoder_phys_vid.c  |  9 ++--
 drivers/gpu/drm/msm/dp/dp_display.c           |  2 +-
 drivers/gpu/drm/msm/dp/dp_drm.c               | 10 ++---
 drivers/gpu/drm/panel/panel-truly-nt35597.c   |  3 +-
 .../gpu/drm/panel/panel-visionox-rm69299.c    |  4 +-
 drivers/gpu/drm/radeon/radeon_connectors.c    |  4 +-
 drivers/gpu/drm/rockchip/cdn-dp-core.c        |  2 +-
 drivers/gpu/drm/rockchip/inno_hdmi.c          |  2 +-
 drivers/gpu/drm/rockchip/rk3066_hdmi.c        |  2 +-
 drivers/gpu/drm/sti/sti_dvo.c                 |  2 +-
 drivers/gpu/drm/sti/sti_hda.c                 |  2 +-
 drivers/gpu/drm/sti/sti_hdmi.c                |  2 +-
 drivers/gpu/drm/tilcdc/tilcdc_crtc.c          |  2 +-
 drivers/gpu/drm/vc4/vc4_hdmi.c                |  5 +--
 include/drm/drm_modes.h                       |  2 +
 30 files changed, 105 insertions(+), 79 deletions(-)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 157+ messages in thread

* [PATCH 00/22] drm: Review of mode copies
@ 2022-02-18 10:03 ` Ville Syrjala
  0 siblings, 0 replies; 157+ messages in thread
From: Ville Syrjala @ 2022-02-18 10:03 UTC (permalink / raw)
  To: dri-devel
  Cc: intel-gfx, Abhinav Kumar, Alain Volmat, Alex Deucher, amd-gfx,
	Andrzej Hajda, Aurabindo Pillai, Chen Feng, Chun-Kuang Hu,
	Emma Anholt, freedreno, Harry Wentland, Heiko Stübner,
	Jernej Skrabec, John Stultz, Jonas Karlman, Jyri Sarha,
	Laurent Pinchart, Leo Li, linux-arm-kernel, linux-arm-msm,
	linux-rockchip, Maxime Ripard, Neil Armstrong, Nikola Cornij,
	Patrik Jakobsson, Philipp Zabel, Rob Clark, Robert Foss,
	Rodrigo Siqueira, Sam Ravnborg, Sandy Huang, Sean Paul,
	Thierry Reding, Tian Tao, Tomi Valkeinen, Xinliang Liu,
	Xinwei Kong

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

I might be taking this a bit too far, but the lack of
consistency in our methods to copy drm_display_mode
structs around is bugging me.

The main worry is the embedded list head, which if
clobbered could lead to list corruption. I'd also
prefer to make sure even the valid list heads don't
propagate between copies since that makes no sense.

While going through some of the code I also spotted
some very weird on stack copies being made for no
reason at all. I elimininated a few of them here,
but there could certainly be more lurking in the
shadows.

Cc: Abhinav Kumar <quic_abhinavk@quicinc.com>
Cc: Alain Volmat <alain.volmat@foss.st.com>
Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: amd-gfx@lists.freedesktop.org
Cc: Andrzej Hajda <andrzej.hajda@intel.com>
Cc: Aurabindo Pillai <aurabindo.pillai@amd.com>
Cc: Chen Feng <puck.chen@hisilicon.com>
Cc: Chun-Kuang Hu <chunkuang.hu@kernel.org>
Cc: Emma Anholt <emma@anholt.net>
Cc: freedreno@lists.freedesktop.org
Cc: Harry Wentland <harry.wentland@amd.com>
Cc: "Heiko Stübner" <heiko@sntech.de>
Cc: Jernej Skrabec <jernej.skrabec@gmail.com>
Cc: John Stultz <john.stultz@linaro.org>
Cc: Jonas Karlman <jonas@kwiboo.se>
Cc: Jyri Sarha <jyri.sarha@iki.fi>
Cc: Laurent Pinchart <Laurent.pinchart@ideasonboard.com>
Cc: Leo Li <sunpeng.li@amd.com>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-arm-msm@vger.kernel.org
Cc: linux-rockchip@lists.infradead.org
Cc: Maxime Ripard <mripard@kernel.org>
Cc: Neil Armstrong <narmstrong@baylibre.com>
Cc: Nikola Cornij <nikola.cornij@amd.com>
Cc: Patrik Jakobsson <patrik.r.jakobsson@gmail.com>
Cc: Philipp Zabel <p.zabel@pengutronix.de>
Cc: Rob Clark <robdclark@gmail.com>
Cc: Robert Foss <robert.foss@linaro.org>
Cc: Rodrigo Siqueira <Rodrigo.Siqueira@amd.com>
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: Sandy Huang <hjc@rock-chips.com>
Cc: Sean Paul <sean@poorly.run>
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: Tian Tao <tiantao6@hisilicon.com>
Cc: Tomi Valkeinen <tomba@kernel.org>
Cc: Xinliang Liu <xinliang.liu@linaro.org>
Cc: Xinwei Kong <kong.kongxinwei@hisilicon.com>

Ville Syrjälä (22):
  drm: Add drm_mode_init()
  drm/amdgpu: Remove pointless on stack mode copies
  drm/amdgpu: Use drm_mode_init() for on-stack modes
  drm/amdgpu: Use drm_mode_copy()
  drm/radeon: Use drm_mode_copy()
  drm/bridge: Use drm_mode_copy()
  drm/gma500: Use drm_mode_copy()
  drm/hisilicon: Use drm_mode_init() for on-stack modes
  drm/imx: Use drm_mode_duplicate()
  drm/msm: Nuke weird on stack mode copy
  drm/msm: Use drm_mode_init() for on-stack modes
  drm/msm: Use drm_mode_copy()
  drm/mtk: Use drm_mode_init() for on-stack modes
  drm/rockchip: Use drm_mode_copy()
  drm/sti: Use drm_mode_copy()
  drm/tilcdc: Use drm_mode_copy()
  drm/vc4: Use drm_mode_copy()
  drm/i915: Use drm_mode_init() for on-stack modes
  drm/i915: Use drm_mode_copy()
  drm/panel: Use drm_mode_duplicate()
  drm: Use drm_mode_init() for on-stack modes
  drm: Use drm_mode_copy()

 .../gpu/drm/amd/amdgpu/amdgpu_connectors.c    |  4 +-
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 41 ++++++++++---------
 drivers/gpu/drm/bridge/nwl-dsi.c              |  2 +-
 drivers/gpu/drm/bridge/synopsys/dw-hdmi.c     |  2 +-
 drivers/gpu/drm/bridge/tc358767.c             |  2 +-
 drivers/gpu/drm/drm_crtc_helper.c             | 12 +++---
 drivers/gpu/drm/drm_edid.c                    |  8 +++-
 drivers/gpu/drm/drm_modes.c                   | 21 +++++++++-
 drivers/gpu/drm/drm_vblank.c                  |  2 +-
 drivers/gpu/drm/gma500/oaktrail_crtc.c        |  8 +---
 drivers/gpu/drm/hisilicon/kirin/dw_drm_dsi.c  |  2 +-
 drivers/gpu/drm/i915/display/intel_display.c  | 20 +++++----
 drivers/gpu/drm/imx/imx-ldb.c                 |  3 +-
 drivers/gpu/drm/mediatek/mtk_hdmi.c           |  2 +-
 .../drm/msm/disp/dpu1/dpu_encoder_phys_cmd.c  |  2 +-
 .../drm/msm/disp/dpu1/dpu_encoder_phys_vid.c  |  9 ++--
 drivers/gpu/drm/msm/dp/dp_display.c           |  2 +-
 drivers/gpu/drm/msm/dp/dp_drm.c               | 10 ++---
 drivers/gpu/drm/panel/panel-truly-nt35597.c   |  3 +-
 .../gpu/drm/panel/panel-visionox-rm69299.c    |  4 +-
 drivers/gpu/drm/radeon/radeon_connectors.c    |  4 +-
 drivers/gpu/drm/rockchip/cdn-dp-core.c        |  2 +-
 drivers/gpu/drm/rockchip/inno_hdmi.c          |  2 +-
 drivers/gpu/drm/rockchip/rk3066_hdmi.c        |  2 +-
 drivers/gpu/drm/sti/sti_dvo.c                 |  2 +-
 drivers/gpu/drm/sti/sti_hda.c                 |  2 +-
 drivers/gpu/drm/sti/sti_hdmi.c                |  2 +-
 drivers/gpu/drm/tilcdc/tilcdc_crtc.c          |  2 +-
 drivers/gpu/drm/vc4/vc4_hdmi.c                |  5 +--
 include/drm/drm_modes.h                       |  2 +
 30 files changed, 105 insertions(+), 79 deletions(-)

-- 
2.34.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 157+ messages in thread

* [PATCH 01/22] drm: Add drm_mode_init()
  2022-02-18 10:03 ` Ville Syrjala
@ 2022-02-18 10:03   ` Ville Syrjala
  -1 siblings, 0 replies; 157+ messages in thread
From: Ville Syrjala @ 2022-02-18 10:03 UTC (permalink / raw)
  To: dri-devel; +Cc: intel-gfx

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Add a variant of drm_mode_copy() that explicitly clears out
the list head of the destination mode. Helpful to guarantee
we don't have stack garbage left in there for on-stack modes.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/drm_modes.c | 17 +++++++++++++++++
 include/drm/drm_modes.h     |  2 ++
 2 files changed, 19 insertions(+)

diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c
index 96b13e36293c..40d4ce4a1da4 100644
--- a/drivers/gpu/drm/drm_modes.c
+++ b/drivers/gpu/drm/drm_modes.c
@@ -892,6 +892,23 @@ void drm_mode_copy(struct drm_display_mode *dst, const struct drm_display_mode *
 }
 EXPORT_SYMBOL(drm_mode_copy);
 
+/**
+ * drm_mode_init - initialize the mode from another mode
+ * @dst: mode to overwrite
+ * @src: mode to copy
+ *
+ * Copy an existing mode into another mode, zeroing the
+ * list head of the destination mode. Typically used
+ * to guarantee the list head is not left with stack
+ * garbage in on-stack modes.
+ */
+void drm_mode_init(struct drm_display_mode *dst, const struct drm_display_mode *src)
+{
+	memset(dst, 0, sizeof(*dst));
+	drm_mode_copy(dst, src);
+}
+EXPORT_SYMBOL(drm_mode_init);
+
 /**
  * drm_mode_duplicate - allocate and duplicate an existing mode
  * @dev: drm_device to allocate the duplicated mode for
diff --git a/include/drm/drm_modes.h b/include/drm/drm_modes.h
index 29ba4adf0c53..e6e5a588fab1 100644
--- a/include/drm/drm_modes.h
+++ b/include/drm/drm_modes.h
@@ -484,6 +484,8 @@ void drm_mode_set_crtcinfo(struct drm_display_mode *p,
 			   int adjust_flags);
 void drm_mode_copy(struct drm_display_mode *dst,
 		   const struct drm_display_mode *src);
+void drm_mode_init(struct drm_display_mode *dst,
+		   const struct drm_display_mode *src);
 struct drm_display_mode *drm_mode_duplicate(struct drm_device *dev,
 					    const struct drm_display_mode *mode);
 bool drm_mode_match(const struct drm_display_mode *mode1,
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 157+ messages in thread

* [Intel-gfx] [PATCH 01/22] drm: Add drm_mode_init()
@ 2022-02-18 10:03   ` Ville Syrjala
  0 siblings, 0 replies; 157+ messages in thread
From: Ville Syrjala @ 2022-02-18 10:03 UTC (permalink / raw)
  To: dri-devel; +Cc: intel-gfx

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Add a variant of drm_mode_copy() that explicitly clears out
the list head of the destination mode. Helpful to guarantee
we don't have stack garbage left in there for on-stack modes.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/drm_modes.c | 17 +++++++++++++++++
 include/drm/drm_modes.h     |  2 ++
 2 files changed, 19 insertions(+)

diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c
index 96b13e36293c..40d4ce4a1da4 100644
--- a/drivers/gpu/drm/drm_modes.c
+++ b/drivers/gpu/drm/drm_modes.c
@@ -892,6 +892,23 @@ void drm_mode_copy(struct drm_display_mode *dst, const struct drm_display_mode *
 }
 EXPORT_SYMBOL(drm_mode_copy);
 
+/**
+ * drm_mode_init - initialize the mode from another mode
+ * @dst: mode to overwrite
+ * @src: mode to copy
+ *
+ * Copy an existing mode into another mode, zeroing the
+ * list head of the destination mode. Typically used
+ * to guarantee the list head is not left with stack
+ * garbage in on-stack modes.
+ */
+void drm_mode_init(struct drm_display_mode *dst, const struct drm_display_mode *src)
+{
+	memset(dst, 0, sizeof(*dst));
+	drm_mode_copy(dst, src);
+}
+EXPORT_SYMBOL(drm_mode_init);
+
 /**
  * drm_mode_duplicate - allocate and duplicate an existing mode
  * @dev: drm_device to allocate the duplicated mode for
diff --git a/include/drm/drm_modes.h b/include/drm/drm_modes.h
index 29ba4adf0c53..e6e5a588fab1 100644
--- a/include/drm/drm_modes.h
+++ b/include/drm/drm_modes.h
@@ -484,6 +484,8 @@ void drm_mode_set_crtcinfo(struct drm_display_mode *p,
 			   int adjust_flags);
 void drm_mode_copy(struct drm_display_mode *dst,
 		   const struct drm_display_mode *src);
+void drm_mode_init(struct drm_display_mode *dst,
+		   const struct drm_display_mode *src);
 struct drm_display_mode *drm_mode_duplicate(struct drm_device *dev,
 					    const struct drm_display_mode *mode);
 bool drm_mode_match(const struct drm_display_mode *mode1,
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 157+ messages in thread

* [PATCH 02/22] drm/amdgpu: Remove pointless on stack mode copies
  2022-02-18 10:03 ` Ville Syrjala
  (?)
@ 2022-02-18 10:03   ` Ville Syrjala
  -1 siblings, 0 replies; 157+ messages in thread
From: Ville Syrjala @ 2022-02-18 10:03 UTC (permalink / raw)
  To: dri-devel
  Cc: Leo Li, intel-gfx, Rodrigo Siqueira, amd-gfx, Nikola Cornij,
	Aurabindo Pillai, Alex Deucher

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

These on stack copies of the modes appear to be pointless.
Just look at the originals directly.

Cc: Harry Wentland <harry.wentland@amd.com>
Cc: Leo Li <sunpeng.li@amd.com>
Cc: Rodrigo Siqueira <Rodrigo.Siqueira@amd.com>
Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: amd-gfx@lists.freedesktop.org
Cc: Nikola Cornij <nikola.cornij@amd.com>
Cc: Aurabindo Pillai <aurabindo.pillai@amd.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 32 +++++++++----------
 1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index 21dba337dab0..65aab0d086b6 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -10139,27 +10139,27 @@ static bool
 is_timing_unchanged_for_freesync(struct drm_crtc_state *old_crtc_state,
 				 struct drm_crtc_state *new_crtc_state)
 {
-	struct drm_display_mode old_mode, new_mode;
+	const struct drm_display_mode *old_mode, *new_mode;
 
 	if (!old_crtc_state || !new_crtc_state)
 		return false;
 
-	old_mode = old_crtc_state->mode;
-	new_mode = new_crtc_state->mode;
+	old_mode = &old_crtc_state->mode;
+	new_mode = &new_crtc_state->mode;
 
-	if (old_mode.clock       == new_mode.clock &&
-	    old_mode.hdisplay    == new_mode.hdisplay &&
-	    old_mode.vdisplay    == new_mode.vdisplay &&
-	    old_mode.htotal      == new_mode.htotal &&
-	    old_mode.vtotal      != new_mode.vtotal &&
-	    old_mode.hsync_start == new_mode.hsync_start &&
-	    old_mode.vsync_start != new_mode.vsync_start &&
-	    old_mode.hsync_end   == new_mode.hsync_end &&
-	    old_mode.vsync_end   != new_mode.vsync_end &&
-	    old_mode.hskew       == new_mode.hskew &&
-	    old_mode.vscan       == new_mode.vscan &&
-	    (old_mode.vsync_end - old_mode.vsync_start) ==
-	    (new_mode.vsync_end - new_mode.vsync_start))
+	if (old_mode->clock       == new_mode->clock &&
+	    old_mode->hdisplay    == new_mode->hdisplay &&
+	    old_mode->vdisplay    == new_mode->vdisplay &&
+	    old_mode->htotal      == new_mode->htotal &&
+	    old_mode->vtotal      != new_mode->vtotal &&
+	    old_mode->hsync_start == new_mode->hsync_start &&
+	    old_mode->vsync_start != new_mode->vsync_start &&
+	    old_mode->hsync_end   == new_mode->hsync_end &&
+	    old_mode->vsync_end   != new_mode->vsync_end &&
+	    old_mode->hskew       == new_mode->hskew &&
+	    old_mode->vscan       == new_mode->vscan &&
+	    (old_mode->vsync_end - old_mode->vsync_start) ==
+	    (new_mode->vsync_end - new_mode->vsync_start))
 		return true;
 
 	return false;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 157+ messages in thread

* [Intel-gfx] [PATCH 02/22] drm/amdgpu: Remove pointless on stack mode copies
@ 2022-02-18 10:03   ` Ville Syrjala
  0 siblings, 0 replies; 157+ messages in thread
From: Ville Syrjala @ 2022-02-18 10:03 UTC (permalink / raw)
  To: dri-devel
  Cc: Leo Li, intel-gfx, Rodrigo Siqueira, amd-gfx, Nikola Cornij,
	Aurabindo Pillai, Alex Deucher, Harry Wentland

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

These on stack copies of the modes appear to be pointless.
Just look at the originals directly.

Cc: Harry Wentland <harry.wentland@amd.com>
Cc: Leo Li <sunpeng.li@amd.com>
Cc: Rodrigo Siqueira <Rodrigo.Siqueira@amd.com>
Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: amd-gfx@lists.freedesktop.org
Cc: Nikola Cornij <nikola.cornij@amd.com>
Cc: Aurabindo Pillai <aurabindo.pillai@amd.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 32 +++++++++----------
 1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index 21dba337dab0..65aab0d086b6 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -10139,27 +10139,27 @@ static bool
 is_timing_unchanged_for_freesync(struct drm_crtc_state *old_crtc_state,
 				 struct drm_crtc_state *new_crtc_state)
 {
-	struct drm_display_mode old_mode, new_mode;
+	const struct drm_display_mode *old_mode, *new_mode;
 
 	if (!old_crtc_state || !new_crtc_state)
 		return false;
 
-	old_mode = old_crtc_state->mode;
-	new_mode = new_crtc_state->mode;
+	old_mode = &old_crtc_state->mode;
+	new_mode = &new_crtc_state->mode;
 
-	if (old_mode.clock       == new_mode.clock &&
-	    old_mode.hdisplay    == new_mode.hdisplay &&
-	    old_mode.vdisplay    == new_mode.vdisplay &&
-	    old_mode.htotal      == new_mode.htotal &&
-	    old_mode.vtotal      != new_mode.vtotal &&
-	    old_mode.hsync_start == new_mode.hsync_start &&
-	    old_mode.vsync_start != new_mode.vsync_start &&
-	    old_mode.hsync_end   == new_mode.hsync_end &&
-	    old_mode.vsync_end   != new_mode.vsync_end &&
-	    old_mode.hskew       == new_mode.hskew &&
-	    old_mode.vscan       == new_mode.vscan &&
-	    (old_mode.vsync_end - old_mode.vsync_start) ==
-	    (new_mode.vsync_end - new_mode.vsync_start))
+	if (old_mode->clock       == new_mode->clock &&
+	    old_mode->hdisplay    == new_mode->hdisplay &&
+	    old_mode->vdisplay    == new_mode->vdisplay &&
+	    old_mode->htotal      == new_mode->htotal &&
+	    old_mode->vtotal      != new_mode->vtotal &&
+	    old_mode->hsync_start == new_mode->hsync_start &&
+	    old_mode->vsync_start != new_mode->vsync_start &&
+	    old_mode->hsync_end   == new_mode->hsync_end &&
+	    old_mode->vsync_end   != new_mode->vsync_end &&
+	    old_mode->hskew       == new_mode->hskew &&
+	    old_mode->vscan       == new_mode->vscan &&
+	    (old_mode->vsync_end - old_mode->vsync_start) ==
+	    (new_mode->vsync_end - new_mode->vsync_start))
 		return true;
 
 	return false;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 157+ messages in thread

* [PATCH 02/22] drm/amdgpu: Remove pointless on stack mode copies
@ 2022-02-18 10:03   ` Ville Syrjala
  0 siblings, 0 replies; 157+ messages in thread
From: Ville Syrjala @ 2022-02-18 10:03 UTC (permalink / raw)
  To: dri-devel
  Cc: Leo Li, intel-gfx, Rodrigo Siqueira, amd-gfx, Nikola Cornij,
	Aurabindo Pillai, Alex Deucher, Harry Wentland

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

These on stack copies of the modes appear to be pointless.
Just look at the originals directly.

Cc: Harry Wentland <harry.wentland@amd.com>
Cc: Leo Li <sunpeng.li@amd.com>
Cc: Rodrigo Siqueira <Rodrigo.Siqueira@amd.com>
Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: amd-gfx@lists.freedesktop.org
Cc: Nikola Cornij <nikola.cornij@amd.com>
Cc: Aurabindo Pillai <aurabindo.pillai@amd.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 32 +++++++++----------
 1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index 21dba337dab0..65aab0d086b6 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -10139,27 +10139,27 @@ static bool
 is_timing_unchanged_for_freesync(struct drm_crtc_state *old_crtc_state,
 				 struct drm_crtc_state *new_crtc_state)
 {
-	struct drm_display_mode old_mode, new_mode;
+	const struct drm_display_mode *old_mode, *new_mode;
 
 	if (!old_crtc_state || !new_crtc_state)
 		return false;
 
-	old_mode = old_crtc_state->mode;
-	new_mode = new_crtc_state->mode;
+	old_mode = &old_crtc_state->mode;
+	new_mode = &new_crtc_state->mode;
 
-	if (old_mode.clock       == new_mode.clock &&
-	    old_mode.hdisplay    == new_mode.hdisplay &&
-	    old_mode.vdisplay    == new_mode.vdisplay &&
-	    old_mode.htotal      == new_mode.htotal &&
-	    old_mode.vtotal      != new_mode.vtotal &&
-	    old_mode.hsync_start == new_mode.hsync_start &&
-	    old_mode.vsync_start != new_mode.vsync_start &&
-	    old_mode.hsync_end   == new_mode.hsync_end &&
-	    old_mode.vsync_end   != new_mode.vsync_end &&
-	    old_mode.hskew       == new_mode.hskew &&
-	    old_mode.vscan       == new_mode.vscan &&
-	    (old_mode.vsync_end - old_mode.vsync_start) ==
-	    (new_mode.vsync_end - new_mode.vsync_start))
+	if (old_mode->clock       == new_mode->clock &&
+	    old_mode->hdisplay    == new_mode->hdisplay &&
+	    old_mode->vdisplay    == new_mode->vdisplay &&
+	    old_mode->htotal      == new_mode->htotal &&
+	    old_mode->vtotal      != new_mode->vtotal &&
+	    old_mode->hsync_start == new_mode->hsync_start &&
+	    old_mode->vsync_start != new_mode->vsync_start &&
+	    old_mode->hsync_end   == new_mode->hsync_end &&
+	    old_mode->vsync_end   != new_mode->vsync_end &&
+	    old_mode->hskew       == new_mode->hskew &&
+	    old_mode->vscan       == new_mode->vscan &&
+	    (old_mode->vsync_end - old_mode->vsync_start) ==
+	    (new_mode->vsync_end - new_mode->vsync_start))
 		return true;
 
 	return false;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 157+ messages in thread

* [PATCH 03/22] drm/amdgpu: Use drm_mode_init() for on-stack modes
  2022-02-18 10:03 ` Ville Syrjala
  (?)
@ 2022-02-18 10:03   ` Ville Syrjala
  -1 siblings, 0 replies; 157+ messages in thread
From: Ville Syrjala @ 2022-02-18 10:03 UTC (permalink / raw)
  To: dri-devel; +Cc: Leo Li, intel-gfx, Rodrigo Siqueira, amd-gfx, Alex Deucher

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Initialize on-stack modes with drm_mode_init() to guarantee
no stack garbage in the list head, or that we aren't copying
over another mode's list head.

Based on the following cocci script, with manual fixups:
@decl@
identifier M;
expression E;
@@
- struct drm_display_mode M = E;
+ struct drm_display_mode M;

@@
identifier decl.M;
expression decl.E;
statement S, S1;
@@
struct drm_display_mode M;
... when != S
+ drm_mode_init(&M, &E);
+
S1

@@
expression decl.E;
@@
- &*E
+ E

Cc: Harry Wentland <harry.wentland@amd.com>
Cc: Leo Li <sunpeng.li@amd.com>
Cc: Rodrigo Siqueira <Rodrigo.Siqueira@amd.com>
Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: amd-gfx@lists.freedesktop.org
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index 65aab0d086b6..bd23c9e481eb 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -6361,7 +6361,7 @@ create_stream_for_sink(struct amdgpu_dm_connector *aconnector,
 	const struct drm_connector_state *con_state =
 		dm_state ? &dm_state->base : NULL;
 	struct dc_stream_state *stream = NULL;
-	struct drm_display_mode mode = *drm_mode;
+	struct drm_display_mode mode;
 	struct drm_display_mode saved_mode;
 	struct drm_display_mode *freesync_mode = NULL;
 	bool native_mode_found = false;
@@ -6374,6 +6374,7 @@ create_stream_for_sink(struct amdgpu_dm_connector *aconnector,
 #endif
 	struct dc_sink *sink = NULL;
 
+	drm_mode_init(&mode, drm_mode);
 	memset(&saved_mode, 0, sizeof(saved_mode));
 
 	if (aconnector == NULL) {
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 157+ messages in thread

* [Intel-gfx] [PATCH 03/22] drm/amdgpu: Use drm_mode_init() for on-stack modes
@ 2022-02-18 10:03   ` Ville Syrjala
  0 siblings, 0 replies; 157+ messages in thread
From: Ville Syrjala @ 2022-02-18 10:03 UTC (permalink / raw)
  To: dri-devel
  Cc: Leo Li, intel-gfx, Rodrigo Siqueira, amd-gfx, Alex Deucher,
	Harry Wentland

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Initialize on-stack modes with drm_mode_init() to guarantee
no stack garbage in the list head, or that we aren't copying
over another mode's list head.

Based on the following cocci script, with manual fixups:
@decl@
identifier M;
expression E;
@@
- struct drm_display_mode M = E;
+ struct drm_display_mode M;

@@
identifier decl.M;
expression decl.E;
statement S, S1;
@@
struct drm_display_mode M;
... when != S
+ drm_mode_init(&M, &E);
+
S1

@@
expression decl.E;
@@
- &*E
+ E

Cc: Harry Wentland <harry.wentland@amd.com>
Cc: Leo Li <sunpeng.li@amd.com>
Cc: Rodrigo Siqueira <Rodrigo.Siqueira@amd.com>
Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: amd-gfx@lists.freedesktop.org
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index 65aab0d086b6..bd23c9e481eb 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -6361,7 +6361,7 @@ create_stream_for_sink(struct amdgpu_dm_connector *aconnector,
 	const struct drm_connector_state *con_state =
 		dm_state ? &dm_state->base : NULL;
 	struct dc_stream_state *stream = NULL;
-	struct drm_display_mode mode = *drm_mode;
+	struct drm_display_mode mode;
 	struct drm_display_mode saved_mode;
 	struct drm_display_mode *freesync_mode = NULL;
 	bool native_mode_found = false;
@@ -6374,6 +6374,7 @@ create_stream_for_sink(struct amdgpu_dm_connector *aconnector,
 #endif
 	struct dc_sink *sink = NULL;
 
+	drm_mode_init(&mode, drm_mode);
 	memset(&saved_mode, 0, sizeof(saved_mode));
 
 	if (aconnector == NULL) {
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 157+ messages in thread

* [PATCH 03/22] drm/amdgpu: Use drm_mode_init() for on-stack modes
@ 2022-02-18 10:03   ` Ville Syrjala
  0 siblings, 0 replies; 157+ messages in thread
From: Ville Syrjala @ 2022-02-18 10:03 UTC (permalink / raw)
  To: dri-devel
  Cc: Leo Li, intel-gfx, Rodrigo Siqueira, amd-gfx, Alex Deucher,
	Harry Wentland

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Initialize on-stack modes with drm_mode_init() to guarantee
no stack garbage in the list head, or that we aren't copying
over another mode's list head.

Based on the following cocci script, with manual fixups:
@decl@
identifier M;
expression E;
@@
- struct drm_display_mode M = E;
+ struct drm_display_mode M;

@@
identifier decl.M;
expression decl.E;
statement S, S1;
@@
struct drm_display_mode M;
... when != S
+ drm_mode_init(&M, &E);
+
S1

@@
expression decl.E;
@@
- &*E
+ E

Cc: Harry Wentland <harry.wentland@amd.com>
Cc: Leo Li <sunpeng.li@amd.com>
Cc: Rodrigo Siqueira <Rodrigo.Siqueira@amd.com>
Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: amd-gfx@lists.freedesktop.org
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index 65aab0d086b6..bd23c9e481eb 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -6361,7 +6361,7 @@ create_stream_for_sink(struct amdgpu_dm_connector *aconnector,
 	const struct drm_connector_state *con_state =
 		dm_state ? &dm_state->base : NULL;
 	struct dc_stream_state *stream = NULL;
-	struct drm_display_mode mode = *drm_mode;
+	struct drm_display_mode mode;
 	struct drm_display_mode saved_mode;
 	struct drm_display_mode *freesync_mode = NULL;
 	bool native_mode_found = false;
@@ -6374,6 +6374,7 @@ create_stream_for_sink(struct amdgpu_dm_connector *aconnector,
 #endif
 	struct dc_sink *sink = NULL;
 
+	drm_mode_init(&mode, drm_mode);
 	memset(&saved_mode, 0, sizeof(saved_mode));
 
 	if (aconnector == NULL) {
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 157+ messages in thread

* [PATCH 04/22] drm/amdgpu: Use drm_mode_copy()
  2022-02-18 10:03 ` Ville Syrjala
  (?)
@ 2022-02-18 10:03   ` Ville Syrjala
  -1 siblings, 0 replies; 157+ messages in thread
From: Ville Syrjala @ 2022-02-18 10:03 UTC (permalink / raw)
  To: dri-devel; +Cc: Leo Li, intel-gfx, Rodrigo Siqueira, amd-gfx, Alex Deucher

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

struct drm_display_mode embeds a list head, so overwriting
the full struct with another one will corrupt the list
(if the destination mode is on a list). Use drm_mode_copy()
instead which explicitly preserves the list head of
the destination mode.

Even if we know the destination mode is not on any list
using drm_mode_copy() seems decent as it sets a good
example. Bad examples of not using it might eventually
get copied into code where preserving the list head
actually matters.

Obviously one case not covered here is when the mode
itself is embedded in a larger structure and the whole
structure is copied. But if we are careful when copying
into modes embedded in structures I think we can be a
little more reassured that bogus list heads haven't been
propagated in.

@is_mode_copy@
@@
drm_mode_copy(...)
{
...
}

@depends on !is_mode_copy@
struct drm_display_mode *mode;
expression E, S;
@@
(
- *mode = E
+ drm_mode_copy(mode, &E)
|
- memcpy(mode, E, S)
+ drm_mode_copy(mode, E)
)

@depends on !is_mode_copy@
struct drm_display_mode mode;
expression E;
@@
(
- mode = E
+ drm_mode_copy(&mode, &E)
|
- memcpy(&mode, E, S)
+ drm_mode_copy(&mode, E)
)

@@
struct drm_display_mode *mode;
@@
- &*mode
+ mode

Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: Harry Wentland <harry.wentland@amd.com>
Cc: Leo Li <sunpeng.li@amd.com>
Cc: Rodrigo Siqueira <Rodrigo.Siqueira@amd.com>
Cc: amd-gfx@lists.freedesktop.org
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c    | 4 ++--
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
index fa20261aa928..673078faa27a 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
@@ -626,7 +626,7 @@ amdgpu_connector_fixup_lcd_native_mode(struct drm_encoder *encoder,
 		if (mode->type & DRM_MODE_TYPE_PREFERRED) {
 			if (mode->hdisplay != native_mode->hdisplay ||
 			    mode->vdisplay != native_mode->vdisplay)
-				memcpy(native_mode, mode, sizeof(*mode));
+				drm_mode_copy(native_mode, mode);
 		}
 	}
 
@@ -635,7 +635,7 @@ amdgpu_connector_fixup_lcd_native_mode(struct drm_encoder *encoder,
 		list_for_each_entry_safe(mode, t, &connector->probed_modes, head) {
 			if (mode->hdisplay == native_mode->hdisplay &&
 			    mode->vdisplay == native_mode->vdisplay) {
-				*native_mode = *mode;
+				drm_mode_copy(native_mode, mode);
 				drm_mode_set_crtcinfo(native_mode, CRTC_INTERLACE_HALVE_V);
 				DRM_DEBUG_KMS("Determined LVDS native mode details from EDID\n");
 				break;
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index bd23c9e481eb..514280699ad5 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -6318,7 +6318,7 @@ get_highest_refresh_rate_mode(struct amdgpu_dm_connector *aconnector,
 		}
 	}
 
-	aconnector->freesync_vid_base = *m_pref;
+	drm_mode_copy(&aconnector->freesync_vid_base, m_pref);
 	return m_pref;
 }
 
@@ -6432,8 +6432,8 @@ create_stream_for_sink(struct amdgpu_dm_connector *aconnector,
 		recalculate_timing = is_freesync_video_mode(&mode, aconnector);
 		if (recalculate_timing) {
 			freesync_mode = get_highest_refresh_rate_mode(aconnector, false);
-			saved_mode = mode;
-			mode = *freesync_mode;
+			drm_mode_copy(&saved_mode, &mode);
+			drm_mode_copy(&mode, freesync_mode);
 		} else {
 			decide_crtc_timing_for_drm_display_mode(
 				&mode, preferred_mode, scale);
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 157+ messages in thread

* [Intel-gfx] [PATCH 04/22] drm/amdgpu: Use drm_mode_copy()
@ 2022-02-18 10:03   ` Ville Syrjala
  0 siblings, 0 replies; 157+ messages in thread
From: Ville Syrjala @ 2022-02-18 10:03 UTC (permalink / raw)
  To: dri-devel
  Cc: Leo Li, intel-gfx, Rodrigo Siqueira, amd-gfx, Alex Deucher,
	Harry Wentland

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

struct drm_display_mode embeds a list head, so overwriting
the full struct with another one will corrupt the list
(if the destination mode is on a list). Use drm_mode_copy()
instead which explicitly preserves the list head of
the destination mode.

Even if we know the destination mode is not on any list
using drm_mode_copy() seems decent as it sets a good
example. Bad examples of not using it might eventually
get copied into code where preserving the list head
actually matters.

Obviously one case not covered here is when the mode
itself is embedded in a larger structure and the whole
structure is copied. But if we are careful when copying
into modes embedded in structures I think we can be a
little more reassured that bogus list heads haven't been
propagated in.

@is_mode_copy@
@@
drm_mode_copy(...)
{
...
}

@depends on !is_mode_copy@
struct drm_display_mode *mode;
expression E, S;
@@
(
- *mode = E
+ drm_mode_copy(mode, &E)
|
- memcpy(mode, E, S)
+ drm_mode_copy(mode, E)
)

@depends on !is_mode_copy@
struct drm_display_mode mode;
expression E;
@@
(
- mode = E
+ drm_mode_copy(&mode, &E)
|
- memcpy(&mode, E, S)
+ drm_mode_copy(&mode, E)
)

@@
struct drm_display_mode *mode;
@@
- &*mode
+ mode

Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: Harry Wentland <harry.wentland@amd.com>
Cc: Leo Li <sunpeng.li@amd.com>
Cc: Rodrigo Siqueira <Rodrigo.Siqueira@amd.com>
Cc: amd-gfx@lists.freedesktop.org
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c    | 4 ++--
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
index fa20261aa928..673078faa27a 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
@@ -626,7 +626,7 @@ amdgpu_connector_fixup_lcd_native_mode(struct drm_encoder *encoder,
 		if (mode->type & DRM_MODE_TYPE_PREFERRED) {
 			if (mode->hdisplay != native_mode->hdisplay ||
 			    mode->vdisplay != native_mode->vdisplay)
-				memcpy(native_mode, mode, sizeof(*mode));
+				drm_mode_copy(native_mode, mode);
 		}
 	}
 
@@ -635,7 +635,7 @@ amdgpu_connector_fixup_lcd_native_mode(struct drm_encoder *encoder,
 		list_for_each_entry_safe(mode, t, &connector->probed_modes, head) {
 			if (mode->hdisplay == native_mode->hdisplay &&
 			    mode->vdisplay == native_mode->vdisplay) {
-				*native_mode = *mode;
+				drm_mode_copy(native_mode, mode);
 				drm_mode_set_crtcinfo(native_mode, CRTC_INTERLACE_HALVE_V);
 				DRM_DEBUG_KMS("Determined LVDS native mode details from EDID\n");
 				break;
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index bd23c9e481eb..514280699ad5 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -6318,7 +6318,7 @@ get_highest_refresh_rate_mode(struct amdgpu_dm_connector *aconnector,
 		}
 	}
 
-	aconnector->freesync_vid_base = *m_pref;
+	drm_mode_copy(&aconnector->freesync_vid_base, m_pref);
 	return m_pref;
 }
 
@@ -6432,8 +6432,8 @@ create_stream_for_sink(struct amdgpu_dm_connector *aconnector,
 		recalculate_timing = is_freesync_video_mode(&mode, aconnector);
 		if (recalculate_timing) {
 			freesync_mode = get_highest_refresh_rate_mode(aconnector, false);
-			saved_mode = mode;
-			mode = *freesync_mode;
+			drm_mode_copy(&saved_mode, &mode);
+			drm_mode_copy(&mode, freesync_mode);
 		} else {
 			decide_crtc_timing_for_drm_display_mode(
 				&mode, preferred_mode, scale);
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 157+ messages in thread

* [PATCH 04/22] drm/amdgpu: Use drm_mode_copy()
@ 2022-02-18 10:03   ` Ville Syrjala
  0 siblings, 0 replies; 157+ messages in thread
From: Ville Syrjala @ 2022-02-18 10:03 UTC (permalink / raw)
  To: dri-devel
  Cc: Leo Li, intel-gfx, Rodrigo Siqueira, amd-gfx, Alex Deucher,
	Harry Wentland

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

struct drm_display_mode embeds a list head, so overwriting
the full struct with another one will corrupt the list
(if the destination mode is on a list). Use drm_mode_copy()
instead which explicitly preserves the list head of
the destination mode.

Even if we know the destination mode is not on any list
using drm_mode_copy() seems decent as it sets a good
example. Bad examples of not using it might eventually
get copied into code where preserving the list head
actually matters.

Obviously one case not covered here is when the mode
itself is embedded in a larger structure and the whole
structure is copied. But if we are careful when copying
into modes embedded in structures I think we can be a
little more reassured that bogus list heads haven't been
propagated in.

@is_mode_copy@
@@
drm_mode_copy(...)
{
...
}

@depends on !is_mode_copy@
struct drm_display_mode *mode;
expression E, S;
@@
(
- *mode = E
+ drm_mode_copy(mode, &E)
|
- memcpy(mode, E, S)
+ drm_mode_copy(mode, E)
)

@depends on !is_mode_copy@
struct drm_display_mode mode;
expression E;
@@
(
- mode = E
+ drm_mode_copy(&mode, &E)
|
- memcpy(&mode, E, S)
+ drm_mode_copy(&mode, E)
)

@@
struct drm_display_mode *mode;
@@
- &*mode
+ mode

Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: Harry Wentland <harry.wentland@amd.com>
Cc: Leo Li <sunpeng.li@amd.com>
Cc: Rodrigo Siqueira <Rodrigo.Siqueira@amd.com>
Cc: amd-gfx@lists.freedesktop.org
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c    | 4 ++--
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
index fa20261aa928..673078faa27a 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
@@ -626,7 +626,7 @@ amdgpu_connector_fixup_lcd_native_mode(struct drm_encoder *encoder,
 		if (mode->type & DRM_MODE_TYPE_PREFERRED) {
 			if (mode->hdisplay != native_mode->hdisplay ||
 			    mode->vdisplay != native_mode->vdisplay)
-				memcpy(native_mode, mode, sizeof(*mode));
+				drm_mode_copy(native_mode, mode);
 		}
 	}
 
@@ -635,7 +635,7 @@ amdgpu_connector_fixup_lcd_native_mode(struct drm_encoder *encoder,
 		list_for_each_entry_safe(mode, t, &connector->probed_modes, head) {
 			if (mode->hdisplay == native_mode->hdisplay &&
 			    mode->vdisplay == native_mode->vdisplay) {
-				*native_mode = *mode;
+				drm_mode_copy(native_mode, mode);
 				drm_mode_set_crtcinfo(native_mode, CRTC_INTERLACE_HALVE_V);
 				DRM_DEBUG_KMS("Determined LVDS native mode details from EDID\n");
 				break;
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index bd23c9e481eb..514280699ad5 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -6318,7 +6318,7 @@ get_highest_refresh_rate_mode(struct amdgpu_dm_connector *aconnector,
 		}
 	}
 
-	aconnector->freesync_vid_base = *m_pref;
+	drm_mode_copy(&aconnector->freesync_vid_base, m_pref);
 	return m_pref;
 }
 
@@ -6432,8 +6432,8 @@ create_stream_for_sink(struct amdgpu_dm_connector *aconnector,
 		recalculate_timing = is_freesync_video_mode(&mode, aconnector);
 		if (recalculate_timing) {
 			freesync_mode = get_highest_refresh_rate_mode(aconnector, false);
-			saved_mode = mode;
-			mode = *freesync_mode;
+			drm_mode_copy(&saved_mode, &mode);
+			drm_mode_copy(&mode, freesync_mode);
 		} else {
 			decide_crtc_timing_for_drm_display_mode(
 				&mode, preferred_mode, scale);
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 157+ messages in thread

* [PATCH 05/22] drm/radeon: Use drm_mode_copy()
  2022-02-18 10:03 ` Ville Syrjala
@ 2022-02-18 10:03   ` Ville Syrjala
  -1 siblings, 0 replies; 157+ messages in thread
From: Ville Syrjala @ 2022-02-18 10:03 UTC (permalink / raw)
  To: dri-devel; +Cc: Alex Deucher, intel-gfx, amd-gfx

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

struct drm_display_mode embeds a list head, so overwriting
the full struct with another one will corrupt the list
(if the destination mode is on a list). Use drm_mode_copy()
instead which explicitly preserves the list head of
the destination mode.

Even if we know the destination mode is not on any list
using drm_mode_copy() seems decent as it sets a good
example. Bad examples of not using it might eventually
get copied into code where preserving the list head
actually matters.

Obviously one case not covered here is when the mode
itself is embedded in a larger structure and the whole
structure is copied. But if we are careful when copying
into modes embedded in structures I think we can be a
little more reassured that bogus list heads haven't been
propagated in.

@is_mode_copy@
@@
drm_mode_copy(...)
{
...
}

@depends on !is_mode_copy@
struct drm_display_mode *mode;
expression E, S;
@@
(
- *mode = E
+ drm_mode_copy(mode, &E)
|
- memcpy(mode, E, S)
+ drm_mode_copy(mode, E)
)

@depends on !is_mode_copy@
struct drm_display_mode mode;
expression E;
@@
(
- mode = E
+ drm_mode_copy(&mode, &E)
|
- memcpy(&mode, E, S)
+ drm_mode_copy(&mode, E)
)

@@
struct drm_display_mode *mode;
@@
- &*mode
+ mode

Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: amd-gfx@lists.freedesktop.org
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/radeon/radeon_connectors.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon_connectors.c b/drivers/gpu/drm/radeon/radeon_connectors.c
index a7925a8290b2..0cb1345c6ba4 100644
--- a/drivers/gpu/drm/radeon/radeon_connectors.c
+++ b/drivers/gpu/drm/radeon/radeon_connectors.c
@@ -777,7 +777,7 @@ static void radeon_fixup_lvds_native_mode(struct drm_encoder *encoder,
 		if (mode->type & DRM_MODE_TYPE_PREFERRED) {
 			if (mode->hdisplay != native_mode->hdisplay ||
 			    mode->vdisplay != native_mode->vdisplay)
-				memcpy(native_mode, mode, sizeof(*mode));
+				drm_mode_copy(native_mode, mode);
 		}
 	}
 
@@ -786,7 +786,7 @@ static void radeon_fixup_lvds_native_mode(struct drm_encoder *encoder,
 		list_for_each_entry_safe(mode, t, &connector->probed_modes, head) {
 			if (mode->hdisplay == native_mode->hdisplay &&
 			    mode->vdisplay == native_mode->vdisplay) {
-				*native_mode = *mode;
+				drm_mode_copy(native_mode, mode);
 				drm_mode_set_crtcinfo(native_mode, CRTC_INTERLACE_HALVE_V);
 				DRM_DEBUG_KMS("Determined LVDS native mode details from EDID\n");
 				break;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 157+ messages in thread

* [Intel-gfx] [PATCH 05/22] drm/radeon: Use drm_mode_copy()
@ 2022-02-18 10:03   ` Ville Syrjala
  0 siblings, 0 replies; 157+ messages in thread
From: Ville Syrjala @ 2022-02-18 10:03 UTC (permalink / raw)
  To: dri-devel; +Cc: Alex Deucher, intel-gfx, amd-gfx

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

struct drm_display_mode embeds a list head, so overwriting
the full struct with another one will corrupt the list
(if the destination mode is on a list). Use drm_mode_copy()
instead which explicitly preserves the list head of
the destination mode.

Even if we know the destination mode is not on any list
using drm_mode_copy() seems decent as it sets a good
example. Bad examples of not using it might eventually
get copied into code where preserving the list head
actually matters.

Obviously one case not covered here is when the mode
itself is embedded in a larger structure and the whole
structure is copied. But if we are careful when copying
into modes embedded in structures I think we can be a
little more reassured that bogus list heads haven't been
propagated in.

@is_mode_copy@
@@
drm_mode_copy(...)
{
...
}

@depends on !is_mode_copy@
struct drm_display_mode *mode;
expression E, S;
@@
(
- *mode = E
+ drm_mode_copy(mode, &E)
|
- memcpy(mode, E, S)
+ drm_mode_copy(mode, E)
)

@depends on !is_mode_copy@
struct drm_display_mode mode;
expression E;
@@
(
- mode = E
+ drm_mode_copy(&mode, &E)
|
- memcpy(&mode, E, S)
+ drm_mode_copy(&mode, E)
)

@@
struct drm_display_mode *mode;
@@
- &*mode
+ mode

Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: amd-gfx@lists.freedesktop.org
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/radeon/radeon_connectors.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon_connectors.c b/drivers/gpu/drm/radeon/radeon_connectors.c
index a7925a8290b2..0cb1345c6ba4 100644
--- a/drivers/gpu/drm/radeon/radeon_connectors.c
+++ b/drivers/gpu/drm/radeon/radeon_connectors.c
@@ -777,7 +777,7 @@ static void radeon_fixup_lvds_native_mode(struct drm_encoder *encoder,
 		if (mode->type & DRM_MODE_TYPE_PREFERRED) {
 			if (mode->hdisplay != native_mode->hdisplay ||
 			    mode->vdisplay != native_mode->vdisplay)
-				memcpy(native_mode, mode, sizeof(*mode));
+				drm_mode_copy(native_mode, mode);
 		}
 	}
 
@@ -786,7 +786,7 @@ static void radeon_fixup_lvds_native_mode(struct drm_encoder *encoder,
 		list_for_each_entry_safe(mode, t, &connector->probed_modes, head) {
 			if (mode->hdisplay == native_mode->hdisplay &&
 			    mode->vdisplay == native_mode->vdisplay) {
-				*native_mode = *mode;
+				drm_mode_copy(native_mode, mode);
 				drm_mode_set_crtcinfo(native_mode, CRTC_INTERLACE_HALVE_V);
 				DRM_DEBUG_KMS("Determined LVDS native mode details from EDID\n");
 				break;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 157+ messages in thread

* [PATCH 06/22] drm/bridge: Use drm_mode_copy()
  2022-02-18 10:03 ` Ville Syrjala
@ 2022-02-18 10:03   ` Ville Syrjala
  -1 siblings, 0 replies; 157+ messages in thread
From: Ville Syrjala @ 2022-02-18 10:03 UTC (permalink / raw)
  To: dri-devel
  Cc: Jernej Skrabec, Jonas Karlman, intel-gfx, Neil Armstrong,
	Robert Foss, Laurent Pinchart, Andrzej Hajda

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

struct drm_display_mode embeds a list head, so overwriting
the full struct with another one will corrupt the list
(if the destination mode is on a list). Use drm_mode_copy()
instead which explicitly preserves the list head of
the destination mode.

Even if we know the destination mode is not on any list
using drm_mode_copy() seems decent as it sets a good
example. Bad examples of not using it might eventually
get copied into code where preserving the list head
actually matters.

Obviously one case not covered here is when the mode
itself is embedded in a larger structure and the whole
structure is copied. But if we are careful when copying
into modes embedded in structures I think we can be a
little more reassured that bogus list heads haven't been
propagated in.

@is_mode_copy@
@@
drm_mode_copy(...)
{
...
}

@depends on !is_mode_copy@
struct drm_display_mode *mode;
expression E, S;
@@
(
- *mode = E
+ drm_mode_copy(mode, &E)
|
- memcpy(mode, E, S)
+ drm_mode_copy(mode, E)
)

@depends on !is_mode_copy@
struct drm_display_mode mode;
expression E;
@@
(
- mode = E
+ drm_mode_copy(&mode, &E)
|
- memcpy(&mode, E, S)
+ drm_mode_copy(&mode, E)
)

@@
struct drm_display_mode *mode;
@@
- &*mode
+ mode

Cc: Andrzej Hajda <andrzej.hajda@intel.com>
Cc: Neil Armstrong <narmstrong@baylibre.com>
Cc: Robert Foss <robert.foss@linaro.org>
Cc: Laurent Pinchart <Laurent.pinchart@ideasonboard.com>
Cc: Jonas Karlman <jonas@kwiboo.se>
Cc: Jernej Skrabec <jernej.skrabec@gmail.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/bridge/nwl-dsi.c          | 2 +-
 drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 2 +-
 drivers/gpu/drm/bridge/tc358767.c         | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/bridge/nwl-dsi.c b/drivers/gpu/drm/bridge/nwl-dsi.c
index 963a6794735f..881cf338d5cf 100644
--- a/drivers/gpu/drm/bridge/nwl-dsi.c
+++ b/drivers/gpu/drm/bridge/nwl-dsi.c
@@ -857,7 +857,7 @@ nwl_dsi_bridge_mode_set(struct drm_bridge *bridge,
 	/* Save the new desired phy config */
 	memcpy(&dsi->phy_cfg, &new_cfg, sizeof(new_cfg));
 
-	memcpy(&dsi->mode, adjusted_mode, sizeof(dsi->mode));
+	drm_mode_copy(&dsi->mode, adjusted_mode);
 	drm_mode_debug_printmodeline(adjusted_mode);
 
 	if (pm_runtime_resume_and_get(dev) < 0)
diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
index 4befc104d220..a563460f8d20 100644
--- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
+++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
@@ -2830,7 +2830,7 @@ static void dw_hdmi_bridge_mode_set(struct drm_bridge *bridge,
 	mutex_lock(&hdmi->mutex);
 
 	/* Store the display mode for plugin/DKMS poweron events */
-	memcpy(&hdmi->previous_mode, mode, sizeof(hdmi->previous_mode));
+	drm_mode_copy(&hdmi->previous_mode, mode);
 
 	mutex_unlock(&hdmi->mutex);
 }
diff --git a/drivers/gpu/drm/bridge/tc358767.c b/drivers/gpu/drm/bridge/tc358767.c
index c23e0abc65e8..7f9574b17caa 100644
--- a/drivers/gpu/drm/bridge/tc358767.c
+++ b/drivers/gpu/drm/bridge/tc358767.c
@@ -1312,7 +1312,7 @@ static void tc_bridge_mode_set(struct drm_bridge *bridge,
 {
 	struct tc_data *tc = bridge_to_tc(bridge);
 
-	tc->mode = *mode;
+	drm_mode_copy(&tc->mode, mode);
 }
 
 static struct edid *tc_get_edid(struct drm_bridge *bridge,
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 157+ messages in thread

* [Intel-gfx] [PATCH 06/22] drm/bridge: Use drm_mode_copy()
@ 2022-02-18 10:03   ` Ville Syrjala
  0 siblings, 0 replies; 157+ messages in thread
From: Ville Syrjala @ 2022-02-18 10:03 UTC (permalink / raw)
  To: dri-devel
  Cc: Jernej Skrabec, Jonas Karlman, intel-gfx, Neil Armstrong,
	Robert Foss, Laurent Pinchart, Andrzej Hajda

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

struct drm_display_mode embeds a list head, so overwriting
the full struct with another one will corrupt the list
(if the destination mode is on a list). Use drm_mode_copy()
instead which explicitly preserves the list head of
the destination mode.

Even if we know the destination mode is not on any list
using drm_mode_copy() seems decent as it sets a good
example. Bad examples of not using it might eventually
get copied into code where preserving the list head
actually matters.

Obviously one case not covered here is when the mode
itself is embedded in a larger structure and the whole
structure is copied. But if we are careful when copying
into modes embedded in structures I think we can be a
little more reassured that bogus list heads haven't been
propagated in.

@is_mode_copy@
@@
drm_mode_copy(...)
{
...
}

@depends on !is_mode_copy@
struct drm_display_mode *mode;
expression E, S;
@@
(
- *mode = E
+ drm_mode_copy(mode, &E)
|
- memcpy(mode, E, S)
+ drm_mode_copy(mode, E)
)

@depends on !is_mode_copy@
struct drm_display_mode mode;
expression E;
@@
(
- mode = E
+ drm_mode_copy(&mode, &E)
|
- memcpy(&mode, E, S)
+ drm_mode_copy(&mode, E)
)

@@
struct drm_display_mode *mode;
@@
- &*mode
+ mode

Cc: Andrzej Hajda <andrzej.hajda@intel.com>
Cc: Neil Armstrong <narmstrong@baylibre.com>
Cc: Robert Foss <robert.foss@linaro.org>
Cc: Laurent Pinchart <Laurent.pinchart@ideasonboard.com>
Cc: Jonas Karlman <jonas@kwiboo.se>
Cc: Jernej Skrabec <jernej.skrabec@gmail.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/bridge/nwl-dsi.c          | 2 +-
 drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 2 +-
 drivers/gpu/drm/bridge/tc358767.c         | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/bridge/nwl-dsi.c b/drivers/gpu/drm/bridge/nwl-dsi.c
index 963a6794735f..881cf338d5cf 100644
--- a/drivers/gpu/drm/bridge/nwl-dsi.c
+++ b/drivers/gpu/drm/bridge/nwl-dsi.c
@@ -857,7 +857,7 @@ nwl_dsi_bridge_mode_set(struct drm_bridge *bridge,
 	/* Save the new desired phy config */
 	memcpy(&dsi->phy_cfg, &new_cfg, sizeof(new_cfg));
 
-	memcpy(&dsi->mode, adjusted_mode, sizeof(dsi->mode));
+	drm_mode_copy(&dsi->mode, adjusted_mode);
 	drm_mode_debug_printmodeline(adjusted_mode);
 
 	if (pm_runtime_resume_and_get(dev) < 0)
diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
index 4befc104d220..a563460f8d20 100644
--- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
+++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
@@ -2830,7 +2830,7 @@ static void dw_hdmi_bridge_mode_set(struct drm_bridge *bridge,
 	mutex_lock(&hdmi->mutex);
 
 	/* Store the display mode for plugin/DKMS poweron events */
-	memcpy(&hdmi->previous_mode, mode, sizeof(hdmi->previous_mode));
+	drm_mode_copy(&hdmi->previous_mode, mode);
 
 	mutex_unlock(&hdmi->mutex);
 }
diff --git a/drivers/gpu/drm/bridge/tc358767.c b/drivers/gpu/drm/bridge/tc358767.c
index c23e0abc65e8..7f9574b17caa 100644
--- a/drivers/gpu/drm/bridge/tc358767.c
+++ b/drivers/gpu/drm/bridge/tc358767.c
@@ -1312,7 +1312,7 @@ static void tc_bridge_mode_set(struct drm_bridge *bridge,
 {
 	struct tc_data *tc = bridge_to_tc(bridge);
 
-	tc->mode = *mode;
+	drm_mode_copy(&tc->mode, mode);
 }
 
 static struct edid *tc_get_edid(struct drm_bridge *bridge,
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 157+ messages in thread

* [PATCH 07/22] drm/gma500: Use drm_mode_copy()
  2022-02-18 10:03 ` Ville Syrjala
@ 2022-02-18 10:03   ` Ville Syrjala
  -1 siblings, 0 replies; 157+ messages in thread
From: Ville Syrjala @ 2022-02-18 10:03 UTC (permalink / raw)
  To: dri-devel; +Cc: intel-gfx

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

struct drm_display_mode embeds a list head, so overwriting
the full struct with another one will corrupt the list
(if the destination mode is on a list). Use drm_mode_copy()
instead which explicitly preserves the list head of
the destination mode.

Even if we know the destination mode is not on any list
using drm_mode_copy() seems decent as it sets a good
example. Bad examples of not using it might eventually
get copied into code where preserving the list head
actually matters.

Obviously one case not covered here is when the mode
itself is embedded in a larger structure and the whole
structure is copied. But if we are careful when copying
into modes embedded in structures I think we can be a
little more reassured that bogus list heads haven't been
propagated in.

@is_mode_copy@
@@
drm_mode_copy(...)
{
...
}

@depends on !is_mode_copy@
struct drm_display_mode *mode;
expression E, S;
@@
(
- *mode = E
+ drm_mode_copy(mode, &E)
|
- memcpy(mode, E, S)
+ drm_mode_copy(mode, E)
)

@depends on !is_mode_copy@
struct drm_display_mode mode;
expression E;
@@
(
- mode = E
+ drm_mode_copy(&mode, &E)
|
- memcpy(&mode, E, S)
+ drm_mode_copy(&mode, E)
)

@@
struct drm_display_mode *mode;
@@
- &*mode
+ mode

Cc: Patrik Jakobsson <patrik.r.jakobsson@gmail.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/gma500/oaktrail_crtc.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/gma500/oaktrail_crtc.c b/drivers/gpu/drm/gma500/oaktrail_crtc.c
index 36c7c2686c90..79fc602b35bc 100644
--- a/drivers/gpu/drm/gma500/oaktrail_crtc.c
+++ b/drivers/gpu/drm/gma500/oaktrail_crtc.c
@@ -385,12 +385,8 @@ static int oaktrail_crtc_mode_set(struct drm_crtc *crtc,
 	if (!gma_power_begin(dev, true))
 		return 0;
 
-	memcpy(&gma_crtc->saved_mode,
-		mode,
-		sizeof(struct drm_display_mode));
-	memcpy(&gma_crtc->saved_adjusted_mode,
-		adjusted_mode,
-		sizeof(struct drm_display_mode));
+	drm_mode_copy(&gma_crtc->saved_mode, mode);
+	drm_mode_copy(&gma_crtc->saved_adjusted_mode, adjusted_mode);
 
 	list_for_each_entry(connector, &mode_config->connector_list, head) {
 		if (!connector->encoder || connector->encoder->crtc != crtc)
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 157+ messages in thread

* [Intel-gfx] [PATCH 07/22] drm/gma500: Use drm_mode_copy()
@ 2022-02-18 10:03   ` Ville Syrjala
  0 siblings, 0 replies; 157+ messages in thread
From: Ville Syrjala @ 2022-02-18 10:03 UTC (permalink / raw)
  To: dri-devel; +Cc: intel-gfx

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

struct drm_display_mode embeds a list head, so overwriting
the full struct with another one will corrupt the list
(if the destination mode is on a list). Use drm_mode_copy()
instead which explicitly preserves the list head of
the destination mode.

Even if we know the destination mode is not on any list
using drm_mode_copy() seems decent as it sets a good
example. Bad examples of not using it might eventually
get copied into code where preserving the list head
actually matters.

Obviously one case not covered here is when the mode
itself is embedded in a larger structure and the whole
structure is copied. But if we are careful when copying
into modes embedded in structures I think we can be a
little more reassured that bogus list heads haven't been
propagated in.

@is_mode_copy@
@@
drm_mode_copy(...)
{
...
}

@depends on !is_mode_copy@
struct drm_display_mode *mode;
expression E, S;
@@
(
- *mode = E
+ drm_mode_copy(mode, &E)
|
- memcpy(mode, E, S)
+ drm_mode_copy(mode, E)
)

@depends on !is_mode_copy@
struct drm_display_mode mode;
expression E;
@@
(
- mode = E
+ drm_mode_copy(&mode, &E)
|
- memcpy(&mode, E, S)
+ drm_mode_copy(&mode, E)
)

@@
struct drm_display_mode *mode;
@@
- &*mode
+ mode

Cc: Patrik Jakobsson <patrik.r.jakobsson@gmail.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/gma500/oaktrail_crtc.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/gma500/oaktrail_crtc.c b/drivers/gpu/drm/gma500/oaktrail_crtc.c
index 36c7c2686c90..79fc602b35bc 100644
--- a/drivers/gpu/drm/gma500/oaktrail_crtc.c
+++ b/drivers/gpu/drm/gma500/oaktrail_crtc.c
@@ -385,12 +385,8 @@ static int oaktrail_crtc_mode_set(struct drm_crtc *crtc,
 	if (!gma_power_begin(dev, true))
 		return 0;
 
-	memcpy(&gma_crtc->saved_mode,
-		mode,
-		sizeof(struct drm_display_mode));
-	memcpy(&gma_crtc->saved_adjusted_mode,
-		adjusted_mode,
-		sizeof(struct drm_display_mode));
+	drm_mode_copy(&gma_crtc->saved_mode, mode);
+	drm_mode_copy(&gma_crtc->saved_adjusted_mode, adjusted_mode);
 
 	list_for_each_entry(connector, &mode_config->connector_list, head) {
 		if (!connector->encoder || connector->encoder->crtc != crtc)
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 157+ messages in thread

* [PATCH 08/22] drm/hisilicon: Use drm_mode_init() for on-stack modes
  2022-02-18 10:03 ` Ville Syrjala
@ 2022-02-18 10:03   ` Ville Syrjala
  -1 siblings, 0 replies; 157+ messages in thread
From: Ville Syrjala @ 2022-02-18 10:03 UTC (permalink / raw)
  To: dri-devel; +Cc: Xinliang Liu, Chen Feng, intel-gfx, Xinwei Kong, Tian Tao

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Initialize on-stack modes with drm_mode_init() to guarantee
no stack garbage in the list head.

Cc: Xinliang Liu <xinliang.liu@linaro.org>
Cc: Tian Tao <tiantao6@hisilicon.com>
Cc: John Stultz <john.stultz@linaro.org>
Cc: Xinwei Kong <kong.kongxinwei@hisilicon.com>
Cc: Chen Feng <puck.chen@hisilicon.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/hisilicon/kirin/dw_drm_dsi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/hisilicon/kirin/dw_drm_dsi.c b/drivers/gpu/drm/hisilicon/kirin/dw_drm_dsi.c
index 1d556482bb46..53bd2dbf38cd 100644
--- a/drivers/gpu/drm/hisilicon/kirin/dw_drm_dsi.c
+++ b/drivers/gpu/drm/hisilicon/kirin/dw_drm_dsi.c
@@ -657,7 +657,7 @@ static enum drm_mode_status dsi_encoder_mode_valid(struct drm_encoder *encoder,
 		 * reset adj_mode to the mode value each time,
 		 * so we don't adjust the mode twice
 		 */
-		drm_mode_copy(&adj_mode, mode);
+		drm_mode_init(&adj_mode, mode);
 
 		crtc_funcs = crtc->helper_private;
 		if (crtc_funcs && crtc_funcs->mode_fixup)
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 157+ messages in thread

* [Intel-gfx] [PATCH 08/22] drm/hisilicon: Use drm_mode_init() for on-stack modes
@ 2022-02-18 10:03   ` Ville Syrjala
  0 siblings, 0 replies; 157+ messages in thread
From: Ville Syrjala @ 2022-02-18 10:03 UTC (permalink / raw)
  To: dri-devel
  Cc: Xinliang Liu, Chen Feng, intel-gfx, Xinwei Kong, John Stultz, Tian Tao

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Initialize on-stack modes with drm_mode_init() to guarantee
no stack garbage in the list head.

Cc: Xinliang Liu <xinliang.liu@linaro.org>
Cc: Tian Tao <tiantao6@hisilicon.com>
Cc: John Stultz <john.stultz@linaro.org>
Cc: Xinwei Kong <kong.kongxinwei@hisilicon.com>
Cc: Chen Feng <puck.chen@hisilicon.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/hisilicon/kirin/dw_drm_dsi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/hisilicon/kirin/dw_drm_dsi.c b/drivers/gpu/drm/hisilicon/kirin/dw_drm_dsi.c
index 1d556482bb46..53bd2dbf38cd 100644
--- a/drivers/gpu/drm/hisilicon/kirin/dw_drm_dsi.c
+++ b/drivers/gpu/drm/hisilicon/kirin/dw_drm_dsi.c
@@ -657,7 +657,7 @@ static enum drm_mode_status dsi_encoder_mode_valid(struct drm_encoder *encoder,
 		 * reset adj_mode to the mode value each time,
 		 * so we don't adjust the mode twice
 		 */
-		drm_mode_copy(&adj_mode, mode);
+		drm_mode_init(&adj_mode, mode);
 
 		crtc_funcs = crtc->helper_private;
 		if (crtc_funcs && crtc_funcs->mode_fixup)
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 157+ messages in thread

* [PATCH 09/22] drm/imx: Use drm_mode_duplicate()
  2022-02-18 10:03 ` Ville Syrjala
@ 2022-02-18 10:03   ` Ville Syrjala
  -1 siblings, 0 replies; 157+ messages in thread
From: Ville Syrjala @ 2022-02-18 10:03 UTC (permalink / raw)
  To: dri-devel; +Cc: intel-gfx

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Replace the hand rolled drm_mode_duplicate() with the
real thing.

@is_dup@
@@
drm_mode_duplicate(...)
{ ... }

@depends on !is_dup@
expression dev, oldmode;
identifier newmode;
@@
- newmode = drm_mode_create(dev);
+ newmode = drm_mode_duplicate(dev, oldmode);
  ...
- drm_mode_copy(newmode, oldmode);

Cc: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/imx/imx-ldb.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/imx/imx-ldb.c b/drivers/gpu/drm/imx/imx-ldb.c
index e5078d03020d..c8cf819f39ce 100644
--- a/drivers/gpu/drm/imx/imx-ldb.c
+++ b/drivers/gpu/drm/imx/imx-ldb.c
@@ -150,10 +150,9 @@ static int imx_ldb_connector_get_modes(struct drm_connector *connector)
 	if (imx_ldb_ch->mode_valid) {
 		struct drm_display_mode *mode;
 
-		mode = drm_mode_create(connector->dev);
+		mode = drm_mode_duplicate(connector->dev, &imx_ldb_ch->mode);
 		if (!mode)
 			return -EINVAL;
-		drm_mode_copy(mode, &imx_ldb_ch->mode);
 		mode->type |= DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED;
 		drm_mode_probed_add(connector, mode);
 		num_modes++;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 157+ messages in thread

* [Intel-gfx] [PATCH 09/22] drm/imx: Use drm_mode_duplicate()
@ 2022-02-18 10:03   ` Ville Syrjala
  0 siblings, 0 replies; 157+ messages in thread
From: Ville Syrjala @ 2022-02-18 10:03 UTC (permalink / raw)
  To: dri-devel; +Cc: intel-gfx, Philipp Zabel

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Replace the hand rolled drm_mode_duplicate() with the
real thing.

@is_dup@
@@
drm_mode_duplicate(...)
{ ... }

@depends on !is_dup@
expression dev, oldmode;
identifier newmode;
@@
- newmode = drm_mode_create(dev);
+ newmode = drm_mode_duplicate(dev, oldmode);
  ...
- drm_mode_copy(newmode, oldmode);

Cc: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/imx/imx-ldb.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/imx/imx-ldb.c b/drivers/gpu/drm/imx/imx-ldb.c
index e5078d03020d..c8cf819f39ce 100644
--- a/drivers/gpu/drm/imx/imx-ldb.c
+++ b/drivers/gpu/drm/imx/imx-ldb.c
@@ -150,10 +150,9 @@ static int imx_ldb_connector_get_modes(struct drm_connector *connector)
 	if (imx_ldb_ch->mode_valid) {
 		struct drm_display_mode *mode;
 
-		mode = drm_mode_create(connector->dev);
+		mode = drm_mode_duplicate(connector->dev, &imx_ldb_ch->mode);
 		if (!mode)
 			return -EINVAL;
-		drm_mode_copy(mode, &imx_ldb_ch->mode);
 		mode->type |= DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED;
 		drm_mode_probed_add(connector, mode);
 		num_modes++;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 157+ messages in thread

* [PATCH 10/22] drm/msm: Nuke weird on stack mode copy
  2022-02-18 10:03 ` Ville Syrjala
  (?)
@ 2022-02-18 10:03   ` Ville Syrjala
  -1 siblings, 0 replies; 157+ messages in thread
From: Ville Syrjala @ 2022-02-18 10:03 UTC (permalink / raw)
  To: dri-devel
  Cc: intel-gfx, Rob Clark, Sean Paul, Abhinav Kumar, linux-arm-msm, freedreno

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

This on stack middle man mode looks entirely pointless.
Just duplicate the original mode directly.

Cc: Rob Clark <robdclark@gmail.com>
Cc: Sean Paul <sean@poorly.run>
Cc: Abhinav Kumar <quic_abhinavk@quicinc.com>
Cc: linux-arm-msm@vger.kernel.org
Cc: freedreno@lists.freedesktop.org
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/msm/dp/dp_drm.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/msm/dp/dp_drm.c b/drivers/gpu/drm/msm/dp/dp_drm.c
index d4d360d19eba..09188d02aa1e 100644
--- a/drivers/gpu/drm/msm/dp/dp_drm.c
+++ b/drivers/gpu/drm/msm/dp/dp_drm.c
@@ -56,7 +56,7 @@ static int dp_connector_get_modes(struct drm_connector *connector)
 	int rc = 0;
 	struct msm_dp *dp;
 	struct dp_display_mode *dp_mode = NULL;
-	struct drm_display_mode *m, drm_mode;
+	struct drm_display_mode *m;
 
 	if (!connector)
 		return 0;
@@ -82,13 +82,11 @@ static int dp_connector_get_modes(struct drm_connector *connector)
 			return rc;
 		}
 		if (dp_mode->drm_mode.clock) { /* valid DP mode */
-			memset(&drm_mode, 0x0, sizeof(drm_mode));
-			drm_mode_copy(&drm_mode, &dp_mode->drm_mode);
-			m = drm_mode_duplicate(connector->dev, &drm_mode);
+			m = drm_mode_duplicate(connector->dev, &dp_mode->drm_mode);
 			if (!m) {
 				DRM_ERROR("failed to add mode %ux%u\n",
-				       drm_mode.hdisplay,
-				       drm_mode.vdisplay);
+					  dp_mode->drm_mode.hdisplay,
+					  dp_mode->drm_mode.vdisplay);
 				kfree(dp_mode);
 				return 0;
 			}
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 157+ messages in thread

* [PATCH 10/22] drm/msm: Nuke weird on stack mode copy
@ 2022-02-18 10:03   ` Ville Syrjala
  0 siblings, 0 replies; 157+ messages in thread
From: Ville Syrjala @ 2022-02-18 10:03 UTC (permalink / raw)
  To: dri-devel; +Cc: Sean Paul, linux-arm-msm, intel-gfx, Abhinav Kumar, freedreno

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

This on stack middle man mode looks entirely pointless.
Just duplicate the original mode directly.

Cc: Rob Clark <robdclark@gmail.com>
Cc: Sean Paul <sean@poorly.run>
Cc: Abhinav Kumar <quic_abhinavk@quicinc.com>
Cc: linux-arm-msm@vger.kernel.org
Cc: freedreno@lists.freedesktop.org
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/msm/dp/dp_drm.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/msm/dp/dp_drm.c b/drivers/gpu/drm/msm/dp/dp_drm.c
index d4d360d19eba..09188d02aa1e 100644
--- a/drivers/gpu/drm/msm/dp/dp_drm.c
+++ b/drivers/gpu/drm/msm/dp/dp_drm.c
@@ -56,7 +56,7 @@ static int dp_connector_get_modes(struct drm_connector *connector)
 	int rc = 0;
 	struct msm_dp *dp;
 	struct dp_display_mode *dp_mode = NULL;
-	struct drm_display_mode *m, drm_mode;
+	struct drm_display_mode *m;
 
 	if (!connector)
 		return 0;
@@ -82,13 +82,11 @@ static int dp_connector_get_modes(struct drm_connector *connector)
 			return rc;
 		}
 		if (dp_mode->drm_mode.clock) { /* valid DP mode */
-			memset(&drm_mode, 0x0, sizeof(drm_mode));
-			drm_mode_copy(&drm_mode, &dp_mode->drm_mode);
-			m = drm_mode_duplicate(connector->dev, &drm_mode);
+			m = drm_mode_duplicate(connector->dev, &dp_mode->drm_mode);
 			if (!m) {
 				DRM_ERROR("failed to add mode %ux%u\n",
-				       drm_mode.hdisplay,
-				       drm_mode.vdisplay);
+					  dp_mode->drm_mode.hdisplay,
+					  dp_mode->drm_mode.vdisplay);
 				kfree(dp_mode);
 				return 0;
 			}
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 157+ messages in thread

* [Intel-gfx] [PATCH 10/22] drm/msm: Nuke weird on stack mode copy
@ 2022-02-18 10:03   ` Ville Syrjala
  0 siblings, 0 replies; 157+ messages in thread
From: Ville Syrjala @ 2022-02-18 10:03 UTC (permalink / raw)
  To: dri-devel; +Cc: linux-arm-msm, intel-gfx, Abhinav Kumar, freedreno

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

This on stack middle man mode looks entirely pointless.
Just duplicate the original mode directly.

Cc: Rob Clark <robdclark@gmail.com>
Cc: Sean Paul <sean@poorly.run>
Cc: Abhinav Kumar <quic_abhinavk@quicinc.com>
Cc: linux-arm-msm@vger.kernel.org
Cc: freedreno@lists.freedesktop.org
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/msm/dp/dp_drm.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/msm/dp/dp_drm.c b/drivers/gpu/drm/msm/dp/dp_drm.c
index d4d360d19eba..09188d02aa1e 100644
--- a/drivers/gpu/drm/msm/dp/dp_drm.c
+++ b/drivers/gpu/drm/msm/dp/dp_drm.c
@@ -56,7 +56,7 @@ static int dp_connector_get_modes(struct drm_connector *connector)
 	int rc = 0;
 	struct msm_dp *dp;
 	struct dp_display_mode *dp_mode = NULL;
-	struct drm_display_mode *m, drm_mode;
+	struct drm_display_mode *m;
 
 	if (!connector)
 		return 0;
@@ -82,13 +82,11 @@ static int dp_connector_get_modes(struct drm_connector *connector)
 			return rc;
 		}
 		if (dp_mode->drm_mode.clock) { /* valid DP mode */
-			memset(&drm_mode, 0x0, sizeof(drm_mode));
-			drm_mode_copy(&drm_mode, &dp_mode->drm_mode);
-			m = drm_mode_duplicate(connector->dev, &drm_mode);
+			m = drm_mode_duplicate(connector->dev, &dp_mode->drm_mode);
 			if (!m) {
 				DRM_ERROR("failed to add mode %ux%u\n",
-				       drm_mode.hdisplay,
-				       drm_mode.vdisplay);
+					  dp_mode->drm_mode.hdisplay,
+					  dp_mode->drm_mode.vdisplay);
 				kfree(dp_mode);
 				return 0;
 			}
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 157+ messages in thread

* [PATCH 11/22] drm/msm: Use drm_mode_init() for on-stack modes
  2022-02-18 10:03 ` Ville Syrjala
  (?)
@ 2022-02-18 10:03   ` Ville Syrjala
  -1 siblings, 0 replies; 157+ messages in thread
From: Ville Syrjala @ 2022-02-18 10:03 UTC (permalink / raw)
  To: dri-devel
  Cc: intel-gfx, Rob Clark, Sean Paul, Abhinav Kumar, linux-arm-msm, freedreno

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Initialize on-stack modes with drm_mode_init() to guarantee
no stack garbage in the list head, or that we aren't copying
over another mode's list head.

Based on the following cocci script, with manual fixups:
@decl@
identifier M;
expression E;
@@
- struct drm_display_mode M = E;
+ struct drm_display_mode M;

@@
identifier decl.M;
expression decl.E;
statement S, S1;
@@
struct drm_display_mode M;
... when != S
+ drm_mode_init(&M, &E);
+
S1

@@
expression decl.E;
@@
- &*E
+ E

Cc: Rob Clark <robdclark@gmail.com>
Cc: Sean Paul <sean@poorly.run>
Cc: Abhinav Kumar <quic_abhinavk@quicinc.com>
Cc: linux-arm-msm@vger.kernel.org
Cc: freedreno@lists.freedesktop.org
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c
index ddd9d89cd456..e7813c6f7bd9 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c
@@ -248,12 +248,13 @@ static void dpu_encoder_phys_vid_setup_timing_engine(
 	unsigned long lock_flags;
 	struct dpu_hw_intf_cfg intf_cfg = { 0 };
 
+	drm_mode_init(&mode, &phys_enc->cached_mode);
+
 	if (!phys_enc->hw_ctl->ops.setup_intf_cfg) {
 		DPU_ERROR("invalid encoder %d\n", phys_enc != NULL);
 		return;
 	}
 
-	mode = phys_enc->cached_mode;
 	if (!phys_enc->hw_intf->ops.setup_timing_gen) {
 		DPU_ERROR("timing engine setup is not supported\n");
 		return;
@@ -652,7 +653,9 @@ static int dpu_encoder_phys_vid_get_frame_count(
 {
 	struct intf_status s = {0};
 	u32 fetch_start = 0;
-	struct drm_display_mode mode = phys_enc->cached_mode;
+	struct drm_display_mode mode;
+
+	drm_mode_init(&mode, &phys_enc->cached_mode);
 
 	if (!dpu_encoder_phys_vid_is_master(phys_enc))
 		return -EINVAL;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 157+ messages in thread

* [PATCH 11/22] drm/msm: Use drm_mode_init() for on-stack modes
@ 2022-02-18 10:03   ` Ville Syrjala
  0 siblings, 0 replies; 157+ messages in thread
From: Ville Syrjala @ 2022-02-18 10:03 UTC (permalink / raw)
  To: dri-devel; +Cc: Sean Paul, linux-arm-msm, intel-gfx, Abhinav Kumar, freedreno

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Initialize on-stack modes with drm_mode_init() to guarantee
no stack garbage in the list head, or that we aren't copying
over another mode's list head.

Based on the following cocci script, with manual fixups:
@decl@
identifier M;
expression E;
@@
- struct drm_display_mode M = E;
+ struct drm_display_mode M;

@@
identifier decl.M;
expression decl.E;
statement S, S1;
@@
struct drm_display_mode M;
... when != S
+ drm_mode_init(&M, &E);
+
S1

@@
expression decl.E;
@@
- &*E
+ E

Cc: Rob Clark <robdclark@gmail.com>
Cc: Sean Paul <sean@poorly.run>
Cc: Abhinav Kumar <quic_abhinavk@quicinc.com>
Cc: linux-arm-msm@vger.kernel.org
Cc: freedreno@lists.freedesktop.org
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c
index ddd9d89cd456..e7813c6f7bd9 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c
@@ -248,12 +248,13 @@ static void dpu_encoder_phys_vid_setup_timing_engine(
 	unsigned long lock_flags;
 	struct dpu_hw_intf_cfg intf_cfg = { 0 };
 
+	drm_mode_init(&mode, &phys_enc->cached_mode);
+
 	if (!phys_enc->hw_ctl->ops.setup_intf_cfg) {
 		DPU_ERROR("invalid encoder %d\n", phys_enc != NULL);
 		return;
 	}
 
-	mode = phys_enc->cached_mode;
 	if (!phys_enc->hw_intf->ops.setup_timing_gen) {
 		DPU_ERROR("timing engine setup is not supported\n");
 		return;
@@ -652,7 +653,9 @@ static int dpu_encoder_phys_vid_get_frame_count(
 {
 	struct intf_status s = {0};
 	u32 fetch_start = 0;
-	struct drm_display_mode mode = phys_enc->cached_mode;
+	struct drm_display_mode mode;
+
+	drm_mode_init(&mode, &phys_enc->cached_mode);
 
 	if (!dpu_encoder_phys_vid_is_master(phys_enc))
 		return -EINVAL;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 157+ messages in thread

* [Intel-gfx] [PATCH 11/22] drm/msm: Use drm_mode_init() for on-stack modes
@ 2022-02-18 10:03   ` Ville Syrjala
  0 siblings, 0 replies; 157+ messages in thread
From: Ville Syrjala @ 2022-02-18 10:03 UTC (permalink / raw)
  To: dri-devel; +Cc: linux-arm-msm, intel-gfx, Abhinav Kumar, freedreno

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Initialize on-stack modes with drm_mode_init() to guarantee
no stack garbage in the list head, or that we aren't copying
over another mode's list head.

Based on the following cocci script, with manual fixups:
@decl@
identifier M;
expression E;
@@
- struct drm_display_mode M = E;
+ struct drm_display_mode M;

@@
identifier decl.M;
expression decl.E;
statement S, S1;
@@
struct drm_display_mode M;
... when != S
+ drm_mode_init(&M, &E);
+
S1

@@
expression decl.E;
@@
- &*E
+ E

Cc: Rob Clark <robdclark@gmail.com>
Cc: Sean Paul <sean@poorly.run>
Cc: Abhinav Kumar <quic_abhinavk@quicinc.com>
Cc: linux-arm-msm@vger.kernel.org
Cc: freedreno@lists.freedesktop.org
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c
index ddd9d89cd456..e7813c6f7bd9 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c
@@ -248,12 +248,13 @@ static void dpu_encoder_phys_vid_setup_timing_engine(
 	unsigned long lock_flags;
 	struct dpu_hw_intf_cfg intf_cfg = { 0 };
 
+	drm_mode_init(&mode, &phys_enc->cached_mode);
+
 	if (!phys_enc->hw_ctl->ops.setup_intf_cfg) {
 		DPU_ERROR("invalid encoder %d\n", phys_enc != NULL);
 		return;
 	}
 
-	mode = phys_enc->cached_mode;
 	if (!phys_enc->hw_intf->ops.setup_timing_gen) {
 		DPU_ERROR("timing engine setup is not supported\n");
 		return;
@@ -652,7 +653,9 @@ static int dpu_encoder_phys_vid_get_frame_count(
 {
 	struct intf_status s = {0};
 	u32 fetch_start = 0;
-	struct drm_display_mode mode = phys_enc->cached_mode;
+	struct drm_display_mode mode;
+
+	drm_mode_init(&mode, &phys_enc->cached_mode);
 
 	if (!dpu_encoder_phys_vid_is_master(phys_enc))
 		return -EINVAL;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 157+ messages in thread

* [PATCH 12/22] drm/msm: Use drm_mode_copy()
  2022-02-18 10:03 ` Ville Syrjala
  (?)
@ 2022-02-18 10:03   ` Ville Syrjala
  -1 siblings, 0 replies; 157+ messages in thread
From: Ville Syrjala @ 2022-02-18 10:03 UTC (permalink / raw)
  To: dri-devel
  Cc: intel-gfx, Rob Clark, Sean Paul, Abhinav Kumar, linux-arm-msm, freedreno

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

struct drm_display_mode embeds a list head, so overwriting
the full struct with another one will corrupt the list
(if the destination mode is on a list). Use drm_mode_copy()
instead which explicitly preserves the list head of
the destination mode.

Even if we know the destination mode is not on any list
using drm_mode_copy() seems decent as it sets a good
example. Bad examples of not using it might eventually
get copied into code where preserving the list head
actually matters.

Obviously one case not covered here is when the mode
itself is embedded in a larger structure and the whole
structure is copied. But if we are careful when copying
into modes embedded in structures I think we can be a
little more reassured that bogus list heads haven't been
propagated in.

@is_mode_copy@
@@
drm_mode_copy(...)
{
...
}

@depends on !is_mode_copy@
struct drm_display_mode *mode;
expression E, S;
@@
(
- *mode = E
+ drm_mode_copy(mode, &E)
|
- memcpy(mode, E, S)
+ drm_mode_copy(mode, E)
)

@depends on !is_mode_copy@
struct drm_display_mode mode;
expression E;
@@
(
- mode = E
+ drm_mode_copy(&mode, &E)
|
- memcpy(&mode, E, S)
+ drm_mode_copy(&mode, E)
)

@@
struct drm_display_mode *mode;
@@
- &*mode
+ mode

Cc: Rob Clark <robdclark@gmail.com>
Cc: Sean Paul <sean@poorly.run>
Cc: Abhinav Kumar <quic_abhinavk@quicinc.com>
Cc: linux-arm-msm@vger.kernel.org
Cc: freedreno@lists.freedesktop.org
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_cmd.c | 2 +-
 drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c | 2 +-
 drivers/gpu/drm/msm/dp/dp_display.c                  | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_cmd.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_cmd.c
index 34a6940d12c5..57592052af23 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_cmd.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_cmd.c
@@ -157,7 +157,7 @@ static void dpu_encoder_phys_cmd_mode_set(
 		DPU_ERROR("invalid args\n");
 		return;
 	}
-	phys_enc->cached_mode = *adj_mode;
+	drm_mode_copy(&phys_enc->cached_mode, adj_mode);
 	DPU_DEBUG_CMDENC(cmd_enc, "caching mode:\n");
 	drm_mode_debug_printmodeline(adj_mode);
 
diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c
index e7813c6f7bd9..d5deca07b65a 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c
@@ -370,7 +370,7 @@ static void dpu_encoder_phys_vid_mode_set(
 	struct dpu_encoder_irq *irq;
 
 	if (adj_mode) {
-		phys_enc->cached_mode = *adj_mode;
+		drm_mode_copy(&phys_enc->cached_mode, adj_mode);
 		drm_mode_debug_printmodeline(adj_mode);
 		DPU_DEBUG_VIDENC(phys_enc, "caching mode:\n");
 	}
diff --git a/drivers/gpu/drm/msm/dp/dp_display.c b/drivers/gpu/drm/msm/dp/dp_display.c
index 7cc4d21f2091..2ed6028ca8d6 100644
--- a/drivers/gpu/drm/msm/dp/dp_display.c
+++ b/drivers/gpu/drm/msm/dp/dp_display.c
@@ -825,7 +825,7 @@ static int dp_display_set_mode(struct msm_dp *dp_display,
 
 	dp = container_of(dp_display, struct dp_display_private, dp_display);
 
-	dp->panel->dp_mode.drm_mode = mode->drm_mode;
+	drm_mode_copy(&dp->panel->dp_mode.drm_mode, &mode->drm_mode);
 	dp->panel->dp_mode.bpp = mode->bpp;
 	dp->panel->dp_mode.capabilities = mode->capabilities;
 	dp_panel_init_panel_info(dp->panel);
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 157+ messages in thread

* [PATCH 12/22] drm/msm: Use drm_mode_copy()
@ 2022-02-18 10:03   ` Ville Syrjala
  0 siblings, 0 replies; 157+ messages in thread
From: Ville Syrjala @ 2022-02-18 10:03 UTC (permalink / raw)
  To: dri-devel; +Cc: Sean Paul, linux-arm-msm, intel-gfx, Abhinav Kumar, freedreno

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

struct drm_display_mode embeds a list head, so overwriting
the full struct with another one will corrupt the list
(if the destination mode is on a list). Use drm_mode_copy()
instead which explicitly preserves the list head of
the destination mode.

Even if we know the destination mode is not on any list
using drm_mode_copy() seems decent as it sets a good
example. Bad examples of not using it might eventually
get copied into code where preserving the list head
actually matters.

Obviously one case not covered here is when the mode
itself is embedded in a larger structure and the whole
structure is copied. But if we are careful when copying
into modes embedded in structures I think we can be a
little more reassured that bogus list heads haven't been
propagated in.

@is_mode_copy@
@@
drm_mode_copy(...)
{
...
}

@depends on !is_mode_copy@
struct drm_display_mode *mode;
expression E, S;
@@
(
- *mode = E
+ drm_mode_copy(mode, &E)
|
- memcpy(mode, E, S)
+ drm_mode_copy(mode, E)
)

@depends on !is_mode_copy@
struct drm_display_mode mode;
expression E;
@@
(
- mode = E
+ drm_mode_copy(&mode, &E)
|
- memcpy(&mode, E, S)
+ drm_mode_copy(&mode, E)
)

@@
struct drm_display_mode *mode;
@@
- &*mode
+ mode

Cc: Rob Clark <robdclark@gmail.com>
Cc: Sean Paul <sean@poorly.run>
Cc: Abhinav Kumar <quic_abhinavk@quicinc.com>
Cc: linux-arm-msm@vger.kernel.org
Cc: freedreno@lists.freedesktop.org
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_cmd.c | 2 +-
 drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c | 2 +-
 drivers/gpu/drm/msm/dp/dp_display.c                  | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_cmd.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_cmd.c
index 34a6940d12c5..57592052af23 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_cmd.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_cmd.c
@@ -157,7 +157,7 @@ static void dpu_encoder_phys_cmd_mode_set(
 		DPU_ERROR("invalid args\n");
 		return;
 	}
-	phys_enc->cached_mode = *adj_mode;
+	drm_mode_copy(&phys_enc->cached_mode, adj_mode);
 	DPU_DEBUG_CMDENC(cmd_enc, "caching mode:\n");
 	drm_mode_debug_printmodeline(adj_mode);
 
diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c
index e7813c6f7bd9..d5deca07b65a 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c
@@ -370,7 +370,7 @@ static void dpu_encoder_phys_vid_mode_set(
 	struct dpu_encoder_irq *irq;
 
 	if (adj_mode) {
-		phys_enc->cached_mode = *adj_mode;
+		drm_mode_copy(&phys_enc->cached_mode, adj_mode);
 		drm_mode_debug_printmodeline(adj_mode);
 		DPU_DEBUG_VIDENC(phys_enc, "caching mode:\n");
 	}
diff --git a/drivers/gpu/drm/msm/dp/dp_display.c b/drivers/gpu/drm/msm/dp/dp_display.c
index 7cc4d21f2091..2ed6028ca8d6 100644
--- a/drivers/gpu/drm/msm/dp/dp_display.c
+++ b/drivers/gpu/drm/msm/dp/dp_display.c
@@ -825,7 +825,7 @@ static int dp_display_set_mode(struct msm_dp *dp_display,
 
 	dp = container_of(dp_display, struct dp_display_private, dp_display);
 
-	dp->panel->dp_mode.drm_mode = mode->drm_mode;
+	drm_mode_copy(&dp->panel->dp_mode.drm_mode, &mode->drm_mode);
 	dp->panel->dp_mode.bpp = mode->bpp;
 	dp->panel->dp_mode.capabilities = mode->capabilities;
 	dp_panel_init_panel_info(dp->panel);
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 157+ messages in thread

* [Intel-gfx] [PATCH 12/22] drm/msm: Use drm_mode_copy()
@ 2022-02-18 10:03   ` Ville Syrjala
  0 siblings, 0 replies; 157+ messages in thread
From: Ville Syrjala @ 2022-02-18 10:03 UTC (permalink / raw)
  To: dri-devel; +Cc: linux-arm-msm, intel-gfx, Abhinav Kumar, freedreno

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

struct drm_display_mode embeds a list head, so overwriting
the full struct with another one will corrupt the list
(if the destination mode is on a list). Use drm_mode_copy()
instead which explicitly preserves the list head of
the destination mode.

Even if we know the destination mode is not on any list
using drm_mode_copy() seems decent as it sets a good
example. Bad examples of not using it might eventually
get copied into code where preserving the list head
actually matters.

Obviously one case not covered here is when the mode
itself is embedded in a larger structure and the whole
structure is copied. But if we are careful when copying
into modes embedded in structures I think we can be a
little more reassured that bogus list heads haven't been
propagated in.

@is_mode_copy@
@@
drm_mode_copy(...)
{
...
}

@depends on !is_mode_copy@
struct drm_display_mode *mode;
expression E, S;
@@
(
- *mode = E
+ drm_mode_copy(mode, &E)
|
- memcpy(mode, E, S)
+ drm_mode_copy(mode, E)
)

@depends on !is_mode_copy@
struct drm_display_mode mode;
expression E;
@@
(
- mode = E
+ drm_mode_copy(&mode, &E)
|
- memcpy(&mode, E, S)
+ drm_mode_copy(&mode, E)
)

@@
struct drm_display_mode *mode;
@@
- &*mode
+ mode

Cc: Rob Clark <robdclark@gmail.com>
Cc: Sean Paul <sean@poorly.run>
Cc: Abhinav Kumar <quic_abhinavk@quicinc.com>
Cc: linux-arm-msm@vger.kernel.org
Cc: freedreno@lists.freedesktop.org
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_cmd.c | 2 +-
 drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c | 2 +-
 drivers/gpu/drm/msm/dp/dp_display.c                  | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_cmd.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_cmd.c
index 34a6940d12c5..57592052af23 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_cmd.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_cmd.c
@@ -157,7 +157,7 @@ static void dpu_encoder_phys_cmd_mode_set(
 		DPU_ERROR("invalid args\n");
 		return;
 	}
-	phys_enc->cached_mode = *adj_mode;
+	drm_mode_copy(&phys_enc->cached_mode, adj_mode);
 	DPU_DEBUG_CMDENC(cmd_enc, "caching mode:\n");
 	drm_mode_debug_printmodeline(adj_mode);
 
diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c
index e7813c6f7bd9..d5deca07b65a 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c
@@ -370,7 +370,7 @@ static void dpu_encoder_phys_vid_mode_set(
 	struct dpu_encoder_irq *irq;
 
 	if (adj_mode) {
-		phys_enc->cached_mode = *adj_mode;
+		drm_mode_copy(&phys_enc->cached_mode, adj_mode);
 		drm_mode_debug_printmodeline(adj_mode);
 		DPU_DEBUG_VIDENC(phys_enc, "caching mode:\n");
 	}
diff --git a/drivers/gpu/drm/msm/dp/dp_display.c b/drivers/gpu/drm/msm/dp/dp_display.c
index 7cc4d21f2091..2ed6028ca8d6 100644
--- a/drivers/gpu/drm/msm/dp/dp_display.c
+++ b/drivers/gpu/drm/msm/dp/dp_display.c
@@ -825,7 +825,7 @@ static int dp_display_set_mode(struct msm_dp *dp_display,
 
 	dp = container_of(dp_display, struct dp_display_private, dp_display);
 
-	dp->panel->dp_mode.drm_mode = mode->drm_mode;
+	drm_mode_copy(&dp->panel->dp_mode.drm_mode, &mode->drm_mode);
 	dp->panel->dp_mode.bpp = mode->bpp;
 	dp->panel->dp_mode.capabilities = mode->capabilities;
 	dp_panel_init_panel_info(dp->panel);
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 157+ messages in thread

* [PATCH 13/22] drm/mtk: Use drm_mode_init() for on-stack modes
  2022-02-18 10:03 ` Ville Syrjala
@ 2022-02-18 10:03   ` Ville Syrjala
  -1 siblings, 0 replies; 157+ messages in thread
From: Ville Syrjala @ 2022-02-18 10:03 UTC (permalink / raw)
  To: dri-devel; +Cc: Chun-Kuang Hu, intel-gfx

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Initialize on-stack modes with drm_mode_init() to guarantee
no stack garbage in the list head.

Based on the following cocci script, with manual fixups:
@decl@
identifier M;
expression E;
@@
- struct drm_display_mode M = E;
+ struct drm_display_mode M;

@@
identifier decl.M;
expression decl.E;
statement S, S1;
@@
struct drm_display_mode M;
... when != S
+ drm_mode_init(&M, &E);
+
S1

@@
expression decl.E;
@@
- &*E
+ E

Cc: Chun-Kuang Hu <chunkuang.hu@kernel.org>
Cc: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/mediatek/mtk_hdmi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/mediatek/mtk_hdmi.c b/drivers/gpu/drm/mediatek/mtk_hdmi.c
index 3196189429bc..30f879e68a2b 100644
--- a/drivers/gpu/drm/mediatek/mtk_hdmi.c
+++ b/drivers/gpu/drm/mediatek/mtk_hdmi.c
@@ -1218,7 +1218,7 @@ static int mtk_hdmi_bridge_mode_valid(struct drm_bridge *bridge,
 	if (next_bridge) {
 		struct drm_display_mode adjusted_mode;
 
-		drm_mode_copy(&adjusted_mode, mode);
+		drm_mode_init(&adjusted_mode, mode);
 		if (!drm_bridge_chain_mode_fixup(next_bridge, mode,
 						 &adjusted_mode))
 			return MODE_BAD;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 157+ messages in thread

* [Intel-gfx] [PATCH 13/22] drm/mtk: Use drm_mode_init() for on-stack modes
@ 2022-02-18 10:03   ` Ville Syrjala
  0 siblings, 0 replies; 157+ messages in thread
From: Ville Syrjala @ 2022-02-18 10:03 UTC (permalink / raw)
  To: dri-devel; +Cc: Chun-Kuang Hu, intel-gfx, Philipp Zabel

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Initialize on-stack modes with drm_mode_init() to guarantee
no stack garbage in the list head.

Based on the following cocci script, with manual fixups:
@decl@
identifier M;
expression E;
@@
- struct drm_display_mode M = E;
+ struct drm_display_mode M;

@@
identifier decl.M;
expression decl.E;
statement S, S1;
@@
struct drm_display_mode M;
... when != S
+ drm_mode_init(&M, &E);
+
S1

@@
expression decl.E;
@@
- &*E
+ E

Cc: Chun-Kuang Hu <chunkuang.hu@kernel.org>
Cc: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/mediatek/mtk_hdmi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/mediatek/mtk_hdmi.c b/drivers/gpu/drm/mediatek/mtk_hdmi.c
index 3196189429bc..30f879e68a2b 100644
--- a/drivers/gpu/drm/mediatek/mtk_hdmi.c
+++ b/drivers/gpu/drm/mediatek/mtk_hdmi.c
@@ -1218,7 +1218,7 @@ static int mtk_hdmi_bridge_mode_valid(struct drm_bridge *bridge,
 	if (next_bridge) {
 		struct drm_display_mode adjusted_mode;
 
-		drm_mode_copy(&adjusted_mode, mode);
+		drm_mode_init(&adjusted_mode, mode);
 		if (!drm_bridge_chain_mode_fixup(next_bridge, mode,
 						 &adjusted_mode))
 			return MODE_BAD;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 157+ messages in thread

* [PATCH 14/22] drm/rockchip: Use drm_mode_copy()
  2022-02-18 10:03 ` Ville Syrjala
  (?)
  (?)
@ 2022-02-18 10:03   ` Ville Syrjala
  -1 siblings, 0 replies; 157+ messages in thread
From: Ville Syrjala @ 2022-02-18 10:03 UTC (permalink / raw)
  To: dri-devel; +Cc: linux-rockchip, intel-gfx, Sandy Huang, linux-arm-kernel

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

struct drm_display_mode embeds a list head, so overwriting
the full struct with another one will corrupt the list
(if the destination mode is on a list). Use drm_mode_copy()
instead which explicitly preserves the list head of
the destination mode.

Even if we know the destination mode is not on any list
using drm_mode_copy() seems decent as it sets a good
example. Bad examples of not using it might eventually
get copied into code where preserving the list head
actually matters.

Obviously one case not covered here is when the mode
itself is embedded in a larger structure and the whole
structure is copied. But if we are careful when copying
into modes embedded in structures I think we can be a
little more reassured that bogus list heads haven't been
propagated in.

@is_mode_copy@
@@
drm_mode_copy(...)
{
...
}

@depends on !is_mode_copy@
struct drm_display_mode *mode;
expression E, S;
@@
(
- *mode = E
+ drm_mode_copy(mode, &E)
|
- memcpy(mode, E, S)
+ drm_mode_copy(mode, E)
)

@depends on !is_mode_copy@
struct drm_display_mode mode;
expression E;
@@
(
- mode = E
+ drm_mode_copy(&mode, &E)
|
- memcpy(&mode, E, S)
+ drm_mode_copy(&mode, E)
)

@@
struct drm_display_mode *mode;
@@
- &*mode
+ mode

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: Sandy Huang <hjc@rock-chips.com>
Cc: "Heiko Stübner" <heiko@sntech.de>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-rockchip@lists.infradead.org
---
 drivers/gpu/drm/rockchip/cdn-dp-core.c | 2 +-
 drivers/gpu/drm/rockchip/inno_hdmi.c   | 2 +-
 drivers/gpu/drm/rockchip/rk3066_hdmi.c | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/rockchip/cdn-dp-core.c b/drivers/gpu/drm/rockchip/cdn-dp-core.c
index 4740cc14beb8..adf1027a3f20 100644
--- a/drivers/gpu/drm/rockchip/cdn-dp-core.c
+++ b/drivers/gpu/drm/rockchip/cdn-dp-core.c
@@ -564,7 +564,7 @@ static void cdn_dp_encoder_mode_set(struct drm_encoder *encoder,
 	video->v_sync_polarity = !!(mode->flags & DRM_MODE_FLAG_NVSYNC);
 	video->h_sync_polarity = !!(mode->flags & DRM_MODE_FLAG_NHSYNC);
 
-	memcpy(&dp->mode, adjusted, sizeof(*mode));
+	drm_mode_copy(&dp->mode, adjusted);
 }
 
 static bool cdn_dp_check_link_status(struct cdn_dp_device *dp)
diff --git a/drivers/gpu/drm/rockchip/inno_hdmi.c b/drivers/gpu/drm/rockchip/inno_hdmi.c
index 046e8ec2a71c..740196d30fba 100644
--- a/drivers/gpu/drm/rockchip/inno_hdmi.c
+++ b/drivers/gpu/drm/rockchip/inno_hdmi.c
@@ -488,7 +488,7 @@ static void inno_hdmi_encoder_mode_set(struct drm_encoder *encoder,
 	inno_hdmi_setup(hdmi, adj_mode);
 
 	/* Store the display mode for plugin/DPMS poweron events */
-	memcpy(&hdmi->previous_mode, adj_mode, sizeof(hdmi->previous_mode));
+	drm_mode_copy(&hdmi->previous_mode, adj_mode);
 }
 
 static void inno_hdmi_encoder_enable(struct drm_encoder *encoder)
diff --git a/drivers/gpu/drm/rockchip/rk3066_hdmi.c b/drivers/gpu/drm/rockchip/rk3066_hdmi.c
index 1c546c3a8998..17e7c40a9e7b 100644
--- a/drivers/gpu/drm/rockchip/rk3066_hdmi.c
+++ b/drivers/gpu/drm/rockchip/rk3066_hdmi.c
@@ -383,7 +383,7 @@ rk3066_hdmi_encoder_mode_set(struct drm_encoder *encoder,
 	struct rk3066_hdmi *hdmi = to_rk3066_hdmi(encoder);
 
 	/* Store the display mode for plugin/DPMS poweron events. */
-	memcpy(&hdmi->previous_mode, adj_mode, sizeof(hdmi->previous_mode));
+	drm_mode_copy(&hdmi->previous_mode, adj_mode);
 }
 
 static void rk3066_hdmi_encoder_enable(struct drm_encoder *encoder)
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 157+ messages in thread

* [Intel-gfx] [PATCH 14/22] drm/rockchip: Use drm_mode_copy()
@ 2022-02-18 10:03   ` Ville Syrjala
  0 siblings, 0 replies; 157+ messages in thread
From: Ville Syrjala @ 2022-02-18 10:03 UTC (permalink / raw)
  To: dri-devel
  Cc: linux-rockchip, intel-gfx, Sandy Huang, linux-arm-kernel,
	Heiko Stübner

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

struct drm_display_mode embeds a list head, so overwriting
the full struct with another one will corrupt the list
(if the destination mode is on a list). Use drm_mode_copy()
instead which explicitly preserves the list head of
the destination mode.

Even if we know the destination mode is not on any list
using drm_mode_copy() seems decent as it sets a good
example. Bad examples of not using it might eventually
get copied into code where preserving the list head
actually matters.

Obviously one case not covered here is when the mode
itself is embedded in a larger structure and the whole
structure is copied. But if we are careful when copying
into modes embedded in structures I think we can be a
little more reassured that bogus list heads haven't been
propagated in.

@is_mode_copy@
@@
drm_mode_copy(...)
{
...
}

@depends on !is_mode_copy@
struct drm_display_mode *mode;
expression E, S;
@@
(
- *mode = E
+ drm_mode_copy(mode, &E)
|
- memcpy(mode, E, S)
+ drm_mode_copy(mode, E)
)

@depends on !is_mode_copy@
struct drm_display_mode mode;
expression E;
@@
(
- mode = E
+ drm_mode_copy(&mode, &E)
|
- memcpy(&mode, E, S)
+ drm_mode_copy(&mode, E)
)

@@
struct drm_display_mode *mode;
@@
- &*mode
+ mode

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: Sandy Huang <hjc@rock-chips.com>
Cc: "Heiko Stübner" <heiko@sntech.de>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-rockchip@lists.infradead.org
---
 drivers/gpu/drm/rockchip/cdn-dp-core.c | 2 +-
 drivers/gpu/drm/rockchip/inno_hdmi.c   | 2 +-
 drivers/gpu/drm/rockchip/rk3066_hdmi.c | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/rockchip/cdn-dp-core.c b/drivers/gpu/drm/rockchip/cdn-dp-core.c
index 4740cc14beb8..adf1027a3f20 100644
--- a/drivers/gpu/drm/rockchip/cdn-dp-core.c
+++ b/drivers/gpu/drm/rockchip/cdn-dp-core.c
@@ -564,7 +564,7 @@ static void cdn_dp_encoder_mode_set(struct drm_encoder *encoder,
 	video->v_sync_polarity = !!(mode->flags & DRM_MODE_FLAG_NVSYNC);
 	video->h_sync_polarity = !!(mode->flags & DRM_MODE_FLAG_NHSYNC);
 
-	memcpy(&dp->mode, adjusted, sizeof(*mode));
+	drm_mode_copy(&dp->mode, adjusted);
 }
 
 static bool cdn_dp_check_link_status(struct cdn_dp_device *dp)
diff --git a/drivers/gpu/drm/rockchip/inno_hdmi.c b/drivers/gpu/drm/rockchip/inno_hdmi.c
index 046e8ec2a71c..740196d30fba 100644
--- a/drivers/gpu/drm/rockchip/inno_hdmi.c
+++ b/drivers/gpu/drm/rockchip/inno_hdmi.c
@@ -488,7 +488,7 @@ static void inno_hdmi_encoder_mode_set(struct drm_encoder *encoder,
 	inno_hdmi_setup(hdmi, adj_mode);
 
 	/* Store the display mode for plugin/DPMS poweron events */
-	memcpy(&hdmi->previous_mode, adj_mode, sizeof(hdmi->previous_mode));
+	drm_mode_copy(&hdmi->previous_mode, adj_mode);
 }
 
 static void inno_hdmi_encoder_enable(struct drm_encoder *encoder)
diff --git a/drivers/gpu/drm/rockchip/rk3066_hdmi.c b/drivers/gpu/drm/rockchip/rk3066_hdmi.c
index 1c546c3a8998..17e7c40a9e7b 100644
--- a/drivers/gpu/drm/rockchip/rk3066_hdmi.c
+++ b/drivers/gpu/drm/rockchip/rk3066_hdmi.c
@@ -383,7 +383,7 @@ rk3066_hdmi_encoder_mode_set(struct drm_encoder *encoder,
 	struct rk3066_hdmi *hdmi = to_rk3066_hdmi(encoder);
 
 	/* Store the display mode for plugin/DPMS poweron events. */
-	memcpy(&hdmi->previous_mode, adj_mode, sizeof(hdmi->previous_mode));
+	drm_mode_copy(&hdmi->previous_mode, adj_mode);
 }
 
 static void rk3066_hdmi_encoder_enable(struct drm_encoder *encoder)
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 157+ messages in thread

* [PATCH 14/22] drm/rockchip: Use drm_mode_copy()
@ 2022-02-18 10:03   ` Ville Syrjala
  0 siblings, 0 replies; 157+ messages in thread
From: Ville Syrjala @ 2022-02-18 10:03 UTC (permalink / raw)
  To: dri-devel
  Cc: intel-gfx, Sandy Huang, Heiko Stübner, linux-arm-kernel,
	linux-rockchip

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

struct drm_display_mode embeds a list head, so overwriting
the full struct with another one will corrupt the list
(if the destination mode is on a list). Use drm_mode_copy()
instead which explicitly preserves the list head of
the destination mode.

Even if we know the destination mode is not on any list
using drm_mode_copy() seems decent as it sets a good
example. Bad examples of not using it might eventually
get copied into code where preserving the list head
actually matters.

Obviously one case not covered here is when the mode
itself is embedded in a larger structure and the whole
structure is copied. But if we are careful when copying
into modes embedded in structures I think we can be a
little more reassured that bogus list heads haven't been
propagated in.

@is_mode_copy@
@@
drm_mode_copy(...)
{
...
}

@depends on !is_mode_copy@
struct drm_display_mode *mode;
expression E, S;
@@
(
- *mode = E
+ drm_mode_copy(mode, &E)
|
- memcpy(mode, E, S)
+ drm_mode_copy(mode, E)
)

@depends on !is_mode_copy@
struct drm_display_mode mode;
expression E;
@@
(
- mode = E
+ drm_mode_copy(&mode, &E)
|
- memcpy(&mode, E, S)
+ drm_mode_copy(&mode, E)
)

@@
struct drm_display_mode *mode;
@@
- &*mode
+ mode

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: Sandy Huang <hjc@rock-chips.com>
Cc: "Heiko Stübner" <heiko@sntech.de>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-rockchip@lists.infradead.org
---
 drivers/gpu/drm/rockchip/cdn-dp-core.c | 2 +-
 drivers/gpu/drm/rockchip/inno_hdmi.c   | 2 +-
 drivers/gpu/drm/rockchip/rk3066_hdmi.c | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/rockchip/cdn-dp-core.c b/drivers/gpu/drm/rockchip/cdn-dp-core.c
index 4740cc14beb8..adf1027a3f20 100644
--- a/drivers/gpu/drm/rockchip/cdn-dp-core.c
+++ b/drivers/gpu/drm/rockchip/cdn-dp-core.c
@@ -564,7 +564,7 @@ static void cdn_dp_encoder_mode_set(struct drm_encoder *encoder,
 	video->v_sync_polarity = !!(mode->flags & DRM_MODE_FLAG_NVSYNC);
 	video->h_sync_polarity = !!(mode->flags & DRM_MODE_FLAG_NHSYNC);
 
-	memcpy(&dp->mode, adjusted, sizeof(*mode));
+	drm_mode_copy(&dp->mode, adjusted);
 }
 
 static bool cdn_dp_check_link_status(struct cdn_dp_device *dp)
diff --git a/drivers/gpu/drm/rockchip/inno_hdmi.c b/drivers/gpu/drm/rockchip/inno_hdmi.c
index 046e8ec2a71c..740196d30fba 100644
--- a/drivers/gpu/drm/rockchip/inno_hdmi.c
+++ b/drivers/gpu/drm/rockchip/inno_hdmi.c
@@ -488,7 +488,7 @@ static void inno_hdmi_encoder_mode_set(struct drm_encoder *encoder,
 	inno_hdmi_setup(hdmi, adj_mode);
 
 	/* Store the display mode for plugin/DPMS poweron events */
-	memcpy(&hdmi->previous_mode, adj_mode, sizeof(hdmi->previous_mode));
+	drm_mode_copy(&hdmi->previous_mode, adj_mode);
 }
 
 static void inno_hdmi_encoder_enable(struct drm_encoder *encoder)
diff --git a/drivers/gpu/drm/rockchip/rk3066_hdmi.c b/drivers/gpu/drm/rockchip/rk3066_hdmi.c
index 1c546c3a8998..17e7c40a9e7b 100644
--- a/drivers/gpu/drm/rockchip/rk3066_hdmi.c
+++ b/drivers/gpu/drm/rockchip/rk3066_hdmi.c
@@ -383,7 +383,7 @@ rk3066_hdmi_encoder_mode_set(struct drm_encoder *encoder,
 	struct rk3066_hdmi *hdmi = to_rk3066_hdmi(encoder);
 
 	/* Store the display mode for plugin/DPMS poweron events. */
-	memcpy(&hdmi->previous_mode, adj_mode, sizeof(hdmi->previous_mode));
+	drm_mode_copy(&hdmi->previous_mode, adj_mode);
 }
 
 static void rk3066_hdmi_encoder_enable(struct drm_encoder *encoder)
-- 
2.34.1


_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

^ permalink raw reply related	[flat|nested] 157+ messages in thread

* [PATCH 14/22] drm/rockchip: Use drm_mode_copy()
@ 2022-02-18 10:03   ` Ville Syrjala
  0 siblings, 0 replies; 157+ messages in thread
From: Ville Syrjala @ 2022-02-18 10:03 UTC (permalink / raw)
  To: dri-devel
  Cc: intel-gfx, Sandy Huang, Heiko Stübner, linux-arm-kernel,
	linux-rockchip

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

struct drm_display_mode embeds a list head, so overwriting
the full struct with another one will corrupt the list
(if the destination mode is on a list). Use drm_mode_copy()
instead which explicitly preserves the list head of
the destination mode.

Even if we know the destination mode is not on any list
using drm_mode_copy() seems decent as it sets a good
example. Bad examples of not using it might eventually
get copied into code where preserving the list head
actually matters.

Obviously one case not covered here is when the mode
itself is embedded in a larger structure and the whole
structure is copied. But if we are careful when copying
into modes embedded in structures I think we can be a
little more reassured that bogus list heads haven't been
propagated in.

@is_mode_copy@
@@
drm_mode_copy(...)
{
...
}

@depends on !is_mode_copy@
struct drm_display_mode *mode;
expression E, S;
@@
(
- *mode = E
+ drm_mode_copy(mode, &E)
|
- memcpy(mode, E, S)
+ drm_mode_copy(mode, E)
)

@depends on !is_mode_copy@
struct drm_display_mode mode;
expression E;
@@
(
- mode = E
+ drm_mode_copy(&mode, &E)
|
- memcpy(&mode, E, S)
+ drm_mode_copy(&mode, E)
)

@@
struct drm_display_mode *mode;
@@
- &*mode
+ mode

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: Sandy Huang <hjc@rock-chips.com>
Cc: "Heiko Stübner" <heiko@sntech.de>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-rockchip@lists.infradead.org
---
 drivers/gpu/drm/rockchip/cdn-dp-core.c | 2 +-
 drivers/gpu/drm/rockchip/inno_hdmi.c   | 2 +-
 drivers/gpu/drm/rockchip/rk3066_hdmi.c | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/rockchip/cdn-dp-core.c b/drivers/gpu/drm/rockchip/cdn-dp-core.c
index 4740cc14beb8..adf1027a3f20 100644
--- a/drivers/gpu/drm/rockchip/cdn-dp-core.c
+++ b/drivers/gpu/drm/rockchip/cdn-dp-core.c
@@ -564,7 +564,7 @@ static void cdn_dp_encoder_mode_set(struct drm_encoder *encoder,
 	video->v_sync_polarity = !!(mode->flags & DRM_MODE_FLAG_NVSYNC);
 	video->h_sync_polarity = !!(mode->flags & DRM_MODE_FLAG_NHSYNC);
 
-	memcpy(&dp->mode, adjusted, sizeof(*mode));
+	drm_mode_copy(&dp->mode, adjusted);
 }
 
 static bool cdn_dp_check_link_status(struct cdn_dp_device *dp)
diff --git a/drivers/gpu/drm/rockchip/inno_hdmi.c b/drivers/gpu/drm/rockchip/inno_hdmi.c
index 046e8ec2a71c..740196d30fba 100644
--- a/drivers/gpu/drm/rockchip/inno_hdmi.c
+++ b/drivers/gpu/drm/rockchip/inno_hdmi.c
@@ -488,7 +488,7 @@ static void inno_hdmi_encoder_mode_set(struct drm_encoder *encoder,
 	inno_hdmi_setup(hdmi, adj_mode);
 
 	/* Store the display mode for plugin/DPMS poweron events */
-	memcpy(&hdmi->previous_mode, adj_mode, sizeof(hdmi->previous_mode));
+	drm_mode_copy(&hdmi->previous_mode, adj_mode);
 }
 
 static void inno_hdmi_encoder_enable(struct drm_encoder *encoder)
diff --git a/drivers/gpu/drm/rockchip/rk3066_hdmi.c b/drivers/gpu/drm/rockchip/rk3066_hdmi.c
index 1c546c3a8998..17e7c40a9e7b 100644
--- a/drivers/gpu/drm/rockchip/rk3066_hdmi.c
+++ b/drivers/gpu/drm/rockchip/rk3066_hdmi.c
@@ -383,7 +383,7 @@ rk3066_hdmi_encoder_mode_set(struct drm_encoder *encoder,
 	struct rk3066_hdmi *hdmi = to_rk3066_hdmi(encoder);
 
 	/* Store the display mode for plugin/DPMS poweron events. */
-	memcpy(&hdmi->previous_mode, adj_mode, sizeof(hdmi->previous_mode));
+	drm_mode_copy(&hdmi->previous_mode, adj_mode);
 }
 
 static void rk3066_hdmi_encoder_enable(struct drm_encoder *encoder)
-- 
2.34.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 157+ messages in thread

* [PATCH 15/22] drm/sti: Use drm_mode_copy()
  2022-02-18 10:03 ` Ville Syrjala
@ 2022-02-18 10:03   ` Ville Syrjala
  -1 siblings, 0 replies; 157+ messages in thread
From: Ville Syrjala @ 2022-02-18 10:03 UTC (permalink / raw)
  To: dri-devel; +Cc: Alain Volmat, intel-gfx

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

struct drm_display_mode embeds a list head, so overwriting
the full struct with another one will corrupt the list
(if the destination mode is on a list). Use drm_mode_copy()
instead which explicitly preserves the list head of
the destination mode.

Even if we know the destination mode is not on any list
using drm_mode_copy() seems decent as it sets a good
example. Bad examples of not using it might eventually
get copied into code where preserving the list head
actually matters.

Obviously one case not covered here is when the mode
itself is embedded in a larger structure and the whole
structure is copied. But if we are careful when copying
into modes embedded in structures I think we can be a
little more reassured that bogus list heads haven't been
propagated in.

@is_mode_copy@
@@
drm_mode_copy(...)
{
...
}

@depends on !is_mode_copy@
struct drm_display_mode *mode;
expression E, S;
@@
(
- *mode = E
+ drm_mode_copy(mode, &E)
|
- memcpy(mode, E, S)
+ drm_mode_copy(mode, E)
)

@depends on !is_mode_copy@
struct drm_display_mode mode;
expression E;
@@
(
- mode = E
+ drm_mode_copy(&mode, &E)
|
- memcpy(&mode, E, S)
+ drm_mode_copy(&mode, E)
)

@@
struct drm_display_mode *mode;
@@
- &*mode
+ mode

Cc: Alain Volmat <alain.volmat@foss.st.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/sti/sti_dvo.c  | 2 +-
 drivers/gpu/drm/sti/sti_hda.c  | 2 +-
 drivers/gpu/drm/sti/sti_hdmi.c | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/sti/sti_dvo.c b/drivers/gpu/drm/sti/sti_dvo.c
index b6ee8a82e656..f3a5616b7daf 100644
--- a/drivers/gpu/drm/sti/sti_dvo.c
+++ b/drivers/gpu/drm/sti/sti_dvo.c
@@ -288,7 +288,7 @@ static void sti_dvo_set_mode(struct drm_bridge *bridge,
 
 	DRM_DEBUG_DRIVER("\n");
 
-	memcpy(&dvo->mode, mode, sizeof(struct drm_display_mode));
+	drm_mode_copy(&dvo->mode, mode);
 
 	/* According to the path used (main or aux), the dvo clocks should
 	 * have a different parent clock. */
diff --git a/drivers/gpu/drm/sti/sti_hda.c b/drivers/gpu/drm/sti/sti_hda.c
index 03f3377f918c..c9e6db15ab66 100644
--- a/drivers/gpu/drm/sti/sti_hda.c
+++ b/drivers/gpu/drm/sti/sti_hda.c
@@ -523,7 +523,7 @@ static void sti_hda_set_mode(struct drm_bridge *bridge,
 
 	DRM_DEBUG_DRIVER("\n");
 
-	memcpy(&hda->mode, mode, sizeof(struct drm_display_mode));
+	drm_mode_copy(&hda->mode, mode);
 
 	if (!hda_get_mode_idx(hda->mode, &mode_idx)) {
 		DRM_ERROR("Undefined mode\n");
diff --git a/drivers/gpu/drm/sti/sti_hdmi.c b/drivers/gpu/drm/sti/sti_hdmi.c
index f3ace11209dd..bb2a2868de2d 100644
--- a/drivers/gpu/drm/sti/sti_hdmi.c
+++ b/drivers/gpu/drm/sti/sti_hdmi.c
@@ -940,7 +940,7 @@ static void sti_hdmi_set_mode(struct drm_bridge *bridge,
 	DRM_DEBUG_DRIVER("\n");
 
 	/* Copy the drm display mode in the connector local structure */
-	memcpy(&hdmi->mode, mode, sizeof(struct drm_display_mode));
+	drm_mode_copy(&hdmi->mode, mode);
 
 	/* Update clock framerate according to the selected mode */
 	ret = clk_set_rate(hdmi->clk_pix, mode->clock * 1000);
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 157+ messages in thread

* [Intel-gfx] [PATCH 15/22] drm/sti: Use drm_mode_copy()
@ 2022-02-18 10:03   ` Ville Syrjala
  0 siblings, 0 replies; 157+ messages in thread
From: Ville Syrjala @ 2022-02-18 10:03 UTC (permalink / raw)
  To: dri-devel; +Cc: Alain Volmat, intel-gfx

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

struct drm_display_mode embeds a list head, so overwriting
the full struct with another one will corrupt the list
(if the destination mode is on a list). Use drm_mode_copy()
instead which explicitly preserves the list head of
the destination mode.

Even if we know the destination mode is not on any list
using drm_mode_copy() seems decent as it sets a good
example. Bad examples of not using it might eventually
get copied into code where preserving the list head
actually matters.

Obviously one case not covered here is when the mode
itself is embedded in a larger structure and the whole
structure is copied. But if we are careful when copying
into modes embedded in structures I think we can be a
little more reassured that bogus list heads haven't been
propagated in.

@is_mode_copy@
@@
drm_mode_copy(...)
{
...
}

@depends on !is_mode_copy@
struct drm_display_mode *mode;
expression E, S;
@@
(
- *mode = E
+ drm_mode_copy(mode, &E)
|
- memcpy(mode, E, S)
+ drm_mode_copy(mode, E)
)

@depends on !is_mode_copy@
struct drm_display_mode mode;
expression E;
@@
(
- mode = E
+ drm_mode_copy(&mode, &E)
|
- memcpy(&mode, E, S)
+ drm_mode_copy(&mode, E)
)

@@
struct drm_display_mode *mode;
@@
- &*mode
+ mode

Cc: Alain Volmat <alain.volmat@foss.st.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/sti/sti_dvo.c  | 2 +-
 drivers/gpu/drm/sti/sti_hda.c  | 2 +-
 drivers/gpu/drm/sti/sti_hdmi.c | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/sti/sti_dvo.c b/drivers/gpu/drm/sti/sti_dvo.c
index b6ee8a82e656..f3a5616b7daf 100644
--- a/drivers/gpu/drm/sti/sti_dvo.c
+++ b/drivers/gpu/drm/sti/sti_dvo.c
@@ -288,7 +288,7 @@ static void sti_dvo_set_mode(struct drm_bridge *bridge,
 
 	DRM_DEBUG_DRIVER("\n");
 
-	memcpy(&dvo->mode, mode, sizeof(struct drm_display_mode));
+	drm_mode_copy(&dvo->mode, mode);
 
 	/* According to the path used (main or aux), the dvo clocks should
 	 * have a different parent clock. */
diff --git a/drivers/gpu/drm/sti/sti_hda.c b/drivers/gpu/drm/sti/sti_hda.c
index 03f3377f918c..c9e6db15ab66 100644
--- a/drivers/gpu/drm/sti/sti_hda.c
+++ b/drivers/gpu/drm/sti/sti_hda.c
@@ -523,7 +523,7 @@ static void sti_hda_set_mode(struct drm_bridge *bridge,
 
 	DRM_DEBUG_DRIVER("\n");
 
-	memcpy(&hda->mode, mode, sizeof(struct drm_display_mode));
+	drm_mode_copy(&hda->mode, mode);
 
 	if (!hda_get_mode_idx(hda->mode, &mode_idx)) {
 		DRM_ERROR("Undefined mode\n");
diff --git a/drivers/gpu/drm/sti/sti_hdmi.c b/drivers/gpu/drm/sti/sti_hdmi.c
index f3ace11209dd..bb2a2868de2d 100644
--- a/drivers/gpu/drm/sti/sti_hdmi.c
+++ b/drivers/gpu/drm/sti/sti_hdmi.c
@@ -940,7 +940,7 @@ static void sti_hdmi_set_mode(struct drm_bridge *bridge,
 	DRM_DEBUG_DRIVER("\n");
 
 	/* Copy the drm display mode in the connector local structure */
-	memcpy(&hdmi->mode, mode, sizeof(struct drm_display_mode));
+	drm_mode_copy(&hdmi->mode, mode);
 
 	/* Update clock framerate according to the selected mode */
 	ret = clk_set_rate(hdmi->clk_pix, mode->clock * 1000);
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 157+ messages in thread

* [PATCH 16/22] drm/tilcdc: Use drm_mode_copy()
  2022-02-18 10:03 ` Ville Syrjala
@ 2022-02-18 10:03   ` Ville Syrjala
  -1 siblings, 0 replies; 157+ messages in thread
From: Ville Syrjala @ 2022-02-18 10:03 UTC (permalink / raw)
  To: dri-devel; +Cc: intel-gfx, Jyri Sarha, Tomi Valkeinen

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

struct drm_display_mode embeds a list head, so overwriting
the full struct with another one will corrupt the list
(if the destination mode is on a list). Use drm_mode_copy()
instead which explicitly preserves the list head of
the destination mode.

Even if we know the destination mode is not on any list
using drm_mode_copy() seems decent as it sets a good
example. Bad examples of not using it might eventually
get copied into code where preserving the list head
actually matters.

Obviously one case not covered here is when the mode
itself is embedded in a larger structure and the whole
structure is copied. But if we are careful when copying
into modes embedded in structures I think we can be a
little more reassured that bogus list heads haven't been
propagated in.

@is_mode_copy@
@@
drm_mode_copy(...)
{
...
}

@depends on !is_mode_copy@
struct drm_display_mode *mode;
expression E, S;
@@
(
- *mode = E
+ drm_mode_copy(mode, &E)
|
- memcpy(mode, E, S)
+ drm_mode_copy(mode, E)
)

@depends on !is_mode_copy@
struct drm_display_mode mode;
expression E;
@@
(
- mode = E
+ drm_mode_copy(&mode, &E)
|
- memcpy(&mode, E, S)
+ drm_mode_copy(&mode, E)
)

@@
struct drm_display_mode *mode;
@@
- &*mode
+ mode

Cc: Jyri Sarha <jyri.sarha@iki.fi>
Cc: Tomi Valkeinen <tomba@kernel.org>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/tilcdc/tilcdc_crtc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
index 29890d704cb4..853c6b443fff 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
@@ -433,7 +433,7 @@ static void tilcdc_crtc_set_mode(struct drm_crtc *crtc)
 
 	set_scanout(crtc, fb);
 
-	crtc->hwmode = crtc->state->adjusted_mode;
+	drm_mode_copy(&crtc->hwmode, &crtc->state->adjusted_mode);
 
 	tilcdc_crtc->hvtotal_us =
 		tilcdc_mode_hvtotal(&crtc->hwmode);
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 157+ messages in thread

* [Intel-gfx] [PATCH 16/22] drm/tilcdc: Use drm_mode_copy()
@ 2022-02-18 10:03   ` Ville Syrjala
  0 siblings, 0 replies; 157+ messages in thread
From: Ville Syrjala @ 2022-02-18 10:03 UTC (permalink / raw)
  To: dri-devel; +Cc: intel-gfx, Jyri Sarha, Tomi Valkeinen

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

struct drm_display_mode embeds a list head, so overwriting
the full struct with another one will corrupt the list
(if the destination mode is on a list). Use drm_mode_copy()
instead which explicitly preserves the list head of
the destination mode.

Even if we know the destination mode is not on any list
using drm_mode_copy() seems decent as it sets a good
example. Bad examples of not using it might eventually
get copied into code where preserving the list head
actually matters.

Obviously one case not covered here is when the mode
itself is embedded in a larger structure and the whole
structure is copied. But if we are careful when copying
into modes embedded in structures I think we can be a
little more reassured that bogus list heads haven't been
propagated in.

@is_mode_copy@
@@
drm_mode_copy(...)
{
...
}

@depends on !is_mode_copy@
struct drm_display_mode *mode;
expression E, S;
@@
(
- *mode = E
+ drm_mode_copy(mode, &E)
|
- memcpy(mode, E, S)
+ drm_mode_copy(mode, E)
)

@depends on !is_mode_copy@
struct drm_display_mode mode;
expression E;
@@
(
- mode = E
+ drm_mode_copy(&mode, &E)
|
- memcpy(&mode, E, S)
+ drm_mode_copy(&mode, E)
)

@@
struct drm_display_mode *mode;
@@
- &*mode
+ mode

Cc: Jyri Sarha <jyri.sarha@iki.fi>
Cc: Tomi Valkeinen <tomba@kernel.org>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/tilcdc/tilcdc_crtc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
index 29890d704cb4..853c6b443fff 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
@@ -433,7 +433,7 @@ static void tilcdc_crtc_set_mode(struct drm_crtc *crtc)
 
 	set_scanout(crtc, fb);
 
-	crtc->hwmode = crtc->state->adjusted_mode;
+	drm_mode_copy(&crtc->hwmode, &crtc->state->adjusted_mode);
 
 	tilcdc_crtc->hvtotal_us =
 		tilcdc_mode_hvtotal(&crtc->hwmode);
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 157+ messages in thread

* [Intel-gfx] [PATCH 17/22] drm/vc4: Use drm_mode_copy()
  2022-02-18 10:03 ` Ville Syrjala
@ 2022-02-18 10:03   ` Ville Syrjala
  -1 siblings, 0 replies; 157+ messages in thread
From: Ville Syrjala @ 2022-02-18 10:03 UTC (permalink / raw)
  To: dri-devel; +Cc: intel-gfx, Maxime Ripard, Emma Anholt

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

struct drm_display_mode embeds a list head, so overwriting
the full struct with another one will corrupt the list
(if the destination mode is on a list). Use drm_mode_copy()
instead which explicitly preserves the list head of
the destination mode.

Even if we know the destination mode is not on any list
using drm_mode_copy() seems decent as it sets a good
example. Bad examples of not using it might eventually
get copied into code where preserving the list head
actually matters.

Obviously one case not covered here is when the mode
itself is embedded in a larger structure and the whole
structure is copied. But if we are careful when copying
into modes embedded in structures I think we can be a
little more reassured that bogus list heads haven't been
propagated in.

@is_mode_copy@
@@
drm_mode_copy(...)
{
...
}

@depends on !is_mode_copy@
struct drm_display_mode *mode;
expression E, S;
@@
(
- *mode = E
+ drm_mode_copy(mode, &E)
|
- memcpy(mode, E, S)
+ drm_mode_copy(mode, E)
)

@depends on !is_mode_copy@
struct drm_display_mode mode;
expression E;
@@
(
- mode = E
+ drm_mode_copy(&mode, &E)
|
- memcpy(&mode, E, S)
+ drm_mode_copy(&mode, E)
)

@@
struct drm_display_mode *mode;
@@
- &*mode
+ mode

Cc: Emma Anholt <emma@anholt.net>
Cc: Maxime Ripard <mripard@kernel.org>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/vc4/vc4_hdmi.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c
index 5ac3216f2d4a..6c58b0fd13fb 100644
--- a/drivers/gpu/drm/vc4/vc4_hdmi.c
+++ b/drivers/gpu/drm/vc4/vc4_hdmi.c
@@ -1234,9 +1234,8 @@ static void vc4_hdmi_encoder_atomic_mode_set(struct drm_encoder *encoder,
 	struct vc4_hdmi *vc4_hdmi = encoder_to_vc4_hdmi(encoder);
 
 	mutex_lock(&vc4_hdmi->mutex);
-	memcpy(&vc4_hdmi->saved_adjusted_mode,
-	       &crtc_state->adjusted_mode,
-	       sizeof(vc4_hdmi->saved_adjusted_mode));
+	drm_mode_copy(&vc4_hdmi->saved_adjusted_mode,
+		      &crtc_state->adjusted_mode);
 	mutex_unlock(&vc4_hdmi->mutex);
 }
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 157+ messages in thread

* [PATCH 17/22] drm/vc4: Use drm_mode_copy()
@ 2022-02-18 10:03   ` Ville Syrjala
  0 siblings, 0 replies; 157+ messages in thread
From: Ville Syrjala @ 2022-02-18 10:03 UTC (permalink / raw)
  To: dri-devel; +Cc: intel-gfx, Emma Anholt

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

struct drm_display_mode embeds a list head, so overwriting
the full struct with another one will corrupt the list
(if the destination mode is on a list). Use drm_mode_copy()
instead which explicitly preserves the list head of
the destination mode.

Even if we know the destination mode is not on any list
using drm_mode_copy() seems decent as it sets a good
example. Bad examples of not using it might eventually
get copied into code where preserving the list head
actually matters.

Obviously one case not covered here is when the mode
itself is embedded in a larger structure and the whole
structure is copied. But if we are careful when copying
into modes embedded in structures I think we can be a
little more reassured that bogus list heads haven't been
propagated in.

@is_mode_copy@
@@
drm_mode_copy(...)
{
...
}

@depends on !is_mode_copy@
struct drm_display_mode *mode;
expression E, S;
@@
(
- *mode = E
+ drm_mode_copy(mode, &E)
|
- memcpy(mode, E, S)
+ drm_mode_copy(mode, E)
)

@depends on !is_mode_copy@
struct drm_display_mode mode;
expression E;
@@
(
- mode = E
+ drm_mode_copy(&mode, &E)
|
- memcpy(&mode, E, S)
+ drm_mode_copy(&mode, E)
)

@@
struct drm_display_mode *mode;
@@
- &*mode
+ mode

Cc: Emma Anholt <emma@anholt.net>
Cc: Maxime Ripard <mripard@kernel.org>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/vc4/vc4_hdmi.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c
index 5ac3216f2d4a..6c58b0fd13fb 100644
--- a/drivers/gpu/drm/vc4/vc4_hdmi.c
+++ b/drivers/gpu/drm/vc4/vc4_hdmi.c
@@ -1234,9 +1234,8 @@ static void vc4_hdmi_encoder_atomic_mode_set(struct drm_encoder *encoder,
 	struct vc4_hdmi *vc4_hdmi = encoder_to_vc4_hdmi(encoder);
 
 	mutex_lock(&vc4_hdmi->mutex);
-	memcpy(&vc4_hdmi->saved_adjusted_mode,
-	       &crtc_state->adjusted_mode,
-	       sizeof(vc4_hdmi->saved_adjusted_mode));
+	drm_mode_copy(&vc4_hdmi->saved_adjusted_mode,
+		      &crtc_state->adjusted_mode);
 	mutex_unlock(&vc4_hdmi->mutex);
 }
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 157+ messages in thread

* [PATCH 18/22] drm/i915: Use drm_mode_init() for on-stack modes
  2022-02-18 10:03 ` Ville Syrjala
@ 2022-02-18 10:03   ` Ville Syrjala
  -1 siblings, 0 replies; 157+ messages in thread
From: Ville Syrjala @ 2022-02-18 10:03 UTC (permalink / raw)
  To: dri-devel; +Cc: intel-gfx

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Initialize on-stack modes with drm_mode_init() to guarantee
no stack garbage in the list head, or that we aren't copying
over another mode's list head.

Based on the following cocci script, with manual fixups:
@decl@
identifier M;
expression E;
@@
- struct drm_display_mode M = E;
+ struct drm_display_mode M;

@@
identifier decl.M;
expression decl.E;
statement S, S1;
@@
struct drm_display_mode M;
... when != S
+ drm_mode_init(&M, &E);
+
S1

@@
expression decl.E;
@@
- &*E
+ E

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/i915/display/intel_display.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c
index 740620ef07ad..74c5a99ab276 100644
--- a/drivers/gpu/drm/i915/display/intel_display.c
+++ b/drivers/gpu/drm/i915/display/intel_display.c
@@ -6898,8 +6898,9 @@ intel_crtc_update_active_timings(const struct intel_crtc_state *crtc_state)
 {
 	struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
 	struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
-	struct drm_display_mode adjusted_mode =
-		crtc_state->hw.adjusted_mode;
+	struct drm_display_mode adjusted_mode;
+
+	drm_mode_init(&adjusted_mode, &crtc_state->hw.adjusted_mode);
 
 	if (crtc_state->vrr.enable) {
 		adjusted_mode.crtc_vtotal = crtc_state->vrr.vmax;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 157+ messages in thread

* [Intel-gfx] [PATCH 18/22] drm/i915: Use drm_mode_init() for on-stack modes
@ 2022-02-18 10:03   ` Ville Syrjala
  0 siblings, 0 replies; 157+ messages in thread
From: Ville Syrjala @ 2022-02-18 10:03 UTC (permalink / raw)
  To: dri-devel; +Cc: intel-gfx

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Initialize on-stack modes with drm_mode_init() to guarantee
no stack garbage in the list head, or that we aren't copying
over another mode's list head.

Based on the following cocci script, with manual fixups:
@decl@
identifier M;
expression E;
@@
- struct drm_display_mode M = E;
+ struct drm_display_mode M;

@@
identifier decl.M;
expression decl.E;
statement S, S1;
@@
struct drm_display_mode M;
... when != S
+ drm_mode_init(&M, &E);
+
S1

@@
expression decl.E;
@@
- &*E
+ E

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/i915/display/intel_display.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c
index 740620ef07ad..74c5a99ab276 100644
--- a/drivers/gpu/drm/i915/display/intel_display.c
+++ b/drivers/gpu/drm/i915/display/intel_display.c
@@ -6898,8 +6898,9 @@ intel_crtc_update_active_timings(const struct intel_crtc_state *crtc_state)
 {
 	struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
 	struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
-	struct drm_display_mode adjusted_mode =
-		crtc_state->hw.adjusted_mode;
+	struct drm_display_mode adjusted_mode;
+
+	drm_mode_init(&adjusted_mode, &crtc_state->hw.adjusted_mode);
 
 	if (crtc_state->vrr.enable) {
 		adjusted_mode.crtc_vtotal = crtc_state->vrr.vmax;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 157+ messages in thread

* [PATCH 19/22] drm/i915: Use drm_mode_copy()
  2022-02-18 10:03 ` Ville Syrjala
@ 2022-02-18 10:04   ` Ville Syrjala
  -1 siblings, 0 replies; 157+ messages in thread
From: Ville Syrjala @ 2022-02-18 10:04 UTC (permalink / raw)
  To: dri-devel; +Cc: intel-gfx

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

struct drm_display_mode embeds a list head, so overwriting
the full struct with another one will corrupt the list
(if the destination mode is on a list). Use drm_mode_copy()
instead which explicitly preserves the list head of
the destination mode.

Even if we know the destination mode is not on any list
using drm_mode_copy() seems decent as it sets a good
example. Bad examples of not using it might eventually
get copied into code where preserving the list head
actually matters.

Obviously one case not covered here is when the mode
itself is embedded in a larger structure and the whole
structure is copied. But if we are careful when copying
into modes embedded in structures I think we can be a
little more reassured that bogus list heads haven't been
propagated in.

@is_mode_copy@
@@
drm_mode_copy(...)
{
...
}

@depends on !is_mode_copy@
struct drm_display_mode *mode;
expression E, S;
@@
(
- *mode = E
+ drm_mode_copy(mode, &E)
|
- memcpy(mode, E, S)
+ drm_mode_copy(mode, E)
)

@depends on !is_mode_copy@
struct drm_display_mode mode;
expression E;
@@
(
- mode = E
+ drm_mode_copy(&mode, &E)
|
- memcpy(&mode, E, S)
+ drm_mode_copy(&mode, E)
)

@@
struct drm_display_mode *mode;
@@
- &*mode
+ mode

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/i915/display/intel_display.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c
index 74c5a99ab276..661e36435793 100644
--- a/drivers/gpu/drm/i915/display/intel_display.c
+++ b/drivers/gpu/drm/i915/display/intel_display.c
@@ -5506,8 +5506,10 @@ intel_crtc_copy_uapi_to_hw_state_modeset(struct intel_atomic_state *state,
 
 	crtc_state->hw.enable = crtc_state->uapi.enable;
 	crtc_state->hw.active = crtc_state->uapi.active;
-	crtc_state->hw.mode = crtc_state->uapi.mode;
-	crtc_state->hw.adjusted_mode = crtc_state->uapi.adjusted_mode;
+	drm_mode_copy(&crtc_state->hw.mode,
+		      &crtc_state->uapi.mode);
+	drm_mode_copy(&crtc_state->hw.adjusted_mode,
+		      &crtc_state->uapi.adjusted_mode);
 	crtc_state->hw.scaling_filter = crtc_state->uapi.scaling_filter;
 
 	intel_crtc_copy_uapi_to_hw_state_nomodeset(state, crtc);
@@ -5584,9 +5586,12 @@ copy_bigjoiner_crtc_state_modeset(struct intel_atomic_state *state,
 	memset(&slave_crtc_state->hw, 0, sizeof(slave_crtc_state->hw));
 	slave_crtc_state->hw.enable = master_crtc_state->hw.enable;
 	slave_crtc_state->hw.active = master_crtc_state->hw.active;
-	slave_crtc_state->hw.mode = master_crtc_state->hw.mode;
-	slave_crtc_state->hw.pipe_mode = master_crtc_state->hw.pipe_mode;
-	slave_crtc_state->hw.adjusted_mode = master_crtc_state->hw.adjusted_mode;
+	drm_mode_copy(&slave_crtc_state->hw.mode,
+		      &master_crtc_state->hw.mode);
+	drm_mode_copy(&slave_crtc_state->hw.pipe_mode,
+		      &master_crtc_state->hw.pipe_mode);
+	drm_mode_copy(&slave_crtc_state->hw.adjusted_mode,
+		      &master_crtc_state->hw.adjusted_mode);
 	slave_crtc_state->hw.scaling_filter = master_crtc_state->hw.scaling_filter;
 
 	copy_bigjoiner_crtc_state_nomodeset(state, slave_crtc);
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 157+ messages in thread

* [Intel-gfx] [PATCH 19/22] drm/i915: Use drm_mode_copy()
@ 2022-02-18 10:04   ` Ville Syrjala
  0 siblings, 0 replies; 157+ messages in thread
From: Ville Syrjala @ 2022-02-18 10:04 UTC (permalink / raw)
  To: dri-devel; +Cc: intel-gfx

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

struct drm_display_mode embeds a list head, so overwriting
the full struct with another one will corrupt the list
(if the destination mode is on a list). Use drm_mode_copy()
instead which explicitly preserves the list head of
the destination mode.

Even if we know the destination mode is not on any list
using drm_mode_copy() seems decent as it sets a good
example. Bad examples of not using it might eventually
get copied into code where preserving the list head
actually matters.

Obviously one case not covered here is when the mode
itself is embedded in a larger structure and the whole
structure is copied. But if we are careful when copying
into modes embedded in structures I think we can be a
little more reassured that bogus list heads haven't been
propagated in.

@is_mode_copy@
@@
drm_mode_copy(...)
{
...
}

@depends on !is_mode_copy@
struct drm_display_mode *mode;
expression E, S;
@@
(
- *mode = E
+ drm_mode_copy(mode, &E)
|
- memcpy(mode, E, S)
+ drm_mode_copy(mode, E)
)

@depends on !is_mode_copy@
struct drm_display_mode mode;
expression E;
@@
(
- mode = E
+ drm_mode_copy(&mode, &E)
|
- memcpy(&mode, E, S)
+ drm_mode_copy(&mode, E)
)

@@
struct drm_display_mode *mode;
@@
- &*mode
+ mode

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/i915/display/intel_display.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c
index 74c5a99ab276..661e36435793 100644
--- a/drivers/gpu/drm/i915/display/intel_display.c
+++ b/drivers/gpu/drm/i915/display/intel_display.c
@@ -5506,8 +5506,10 @@ intel_crtc_copy_uapi_to_hw_state_modeset(struct intel_atomic_state *state,
 
 	crtc_state->hw.enable = crtc_state->uapi.enable;
 	crtc_state->hw.active = crtc_state->uapi.active;
-	crtc_state->hw.mode = crtc_state->uapi.mode;
-	crtc_state->hw.adjusted_mode = crtc_state->uapi.adjusted_mode;
+	drm_mode_copy(&crtc_state->hw.mode,
+		      &crtc_state->uapi.mode);
+	drm_mode_copy(&crtc_state->hw.adjusted_mode,
+		      &crtc_state->uapi.adjusted_mode);
 	crtc_state->hw.scaling_filter = crtc_state->uapi.scaling_filter;
 
 	intel_crtc_copy_uapi_to_hw_state_nomodeset(state, crtc);
@@ -5584,9 +5586,12 @@ copy_bigjoiner_crtc_state_modeset(struct intel_atomic_state *state,
 	memset(&slave_crtc_state->hw, 0, sizeof(slave_crtc_state->hw));
 	slave_crtc_state->hw.enable = master_crtc_state->hw.enable;
 	slave_crtc_state->hw.active = master_crtc_state->hw.active;
-	slave_crtc_state->hw.mode = master_crtc_state->hw.mode;
-	slave_crtc_state->hw.pipe_mode = master_crtc_state->hw.pipe_mode;
-	slave_crtc_state->hw.adjusted_mode = master_crtc_state->hw.adjusted_mode;
+	drm_mode_copy(&slave_crtc_state->hw.mode,
+		      &master_crtc_state->hw.mode);
+	drm_mode_copy(&slave_crtc_state->hw.pipe_mode,
+		      &master_crtc_state->hw.pipe_mode);
+	drm_mode_copy(&slave_crtc_state->hw.adjusted_mode,
+		      &master_crtc_state->hw.adjusted_mode);
 	slave_crtc_state->hw.scaling_filter = master_crtc_state->hw.scaling_filter;
 
 	copy_bigjoiner_crtc_state_nomodeset(state, slave_crtc);
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 157+ messages in thread

* [PATCH 20/22] drm/panel: Use drm_mode_duplicate()
  2022-02-18 10:03 ` Ville Syrjala
@ 2022-02-18 10:04   ` Ville Syrjala
  -1 siblings, 0 replies; 157+ messages in thread
From: Ville Syrjala @ 2022-02-18 10:04 UTC (permalink / raw)
  To: dri-devel; +Cc: intel-gfx, Thierry Reding, Sam Ravnborg

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Replace the hand rolled drm_mode_duplicate() with the
real thing.

@is_dup@
@@
drm_mode_duplicate(...)
{ ... }

@depends on !is_dup@
expression dev, oldmode;
identifier newmode;
@@
- newmode = drm_mode_create(dev);
+ newmode = drm_mode_duplicate(dev, oldmode);
  ...
- drm_mode_copy(newmode, oldmode);

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: Sam Ravnborg <sam@ravnborg.org>
---
 drivers/gpu/drm/panel/panel-truly-nt35597.c    | 3 +--
 drivers/gpu/drm/panel/panel-visionox-rm69299.c | 4 ++--
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/panel/panel-truly-nt35597.c b/drivers/gpu/drm/panel/panel-truly-nt35597.c
index b24b92d93ea5..9ca5c7ff41d6 100644
--- a/drivers/gpu/drm/panel/panel-truly-nt35597.c
+++ b/drivers/gpu/drm/panel/panel-truly-nt35597.c
@@ -446,7 +446,7 @@ static int truly_nt35597_get_modes(struct drm_panel *panel,
 	const struct nt35597_config *config;
 
 	config = ctx->config;
-	mode = drm_mode_create(connector->dev);
+	mode = drm_mode_duplicate(connector->dev, config->dm);
 	if (!mode) {
 		dev_err(ctx->dev, "failed to create a new display mode\n");
 		return 0;
@@ -454,7 +454,6 @@ static int truly_nt35597_get_modes(struct drm_panel *panel,
 
 	connector->display_info.width_mm = config->width_mm;
 	connector->display_info.height_mm = config->height_mm;
-	drm_mode_copy(mode, config->dm);
 	mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED;
 	drm_mode_probed_add(connector, mode);
 
diff --git a/drivers/gpu/drm/panel/panel-visionox-rm69299.c b/drivers/gpu/drm/panel/panel-visionox-rm69299.c
index eb43503ec97b..db2443ac81d3 100644
--- a/drivers/gpu/drm/panel/panel-visionox-rm69299.c
+++ b/drivers/gpu/drm/panel/panel-visionox-rm69299.c
@@ -168,7 +168,8 @@ static int visionox_rm69299_get_modes(struct drm_panel *panel,
 	struct visionox_rm69299 *ctx = panel_to_ctx(panel);
 	struct drm_display_mode *mode;
 
-	mode = drm_mode_create(connector->dev);
+	mode = drm_mode_duplicate(connector->dev,
+				  &visionox_rm69299_1080x2248_60hz);
 	if (!mode) {
 		dev_err(ctx->panel.dev, "failed to create a new display mode\n");
 		return 0;
@@ -176,7 +177,6 @@ static int visionox_rm69299_get_modes(struct drm_panel *panel,
 
 	connector->display_info.width_mm = 74;
 	connector->display_info.height_mm = 131;
-	drm_mode_copy(mode, &visionox_rm69299_1080x2248_60hz);
 	mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED;
 	drm_mode_probed_add(connector, mode);
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 157+ messages in thread

* [Intel-gfx] [PATCH 20/22] drm/panel: Use drm_mode_duplicate()
@ 2022-02-18 10:04   ` Ville Syrjala
  0 siblings, 0 replies; 157+ messages in thread
From: Ville Syrjala @ 2022-02-18 10:04 UTC (permalink / raw)
  To: dri-devel; +Cc: intel-gfx, Sam Ravnborg

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Replace the hand rolled drm_mode_duplicate() with the
real thing.

@is_dup@
@@
drm_mode_duplicate(...)
{ ... }

@depends on !is_dup@
expression dev, oldmode;
identifier newmode;
@@
- newmode = drm_mode_create(dev);
+ newmode = drm_mode_duplicate(dev, oldmode);
  ...
- drm_mode_copy(newmode, oldmode);

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: Sam Ravnborg <sam@ravnborg.org>
---
 drivers/gpu/drm/panel/panel-truly-nt35597.c    | 3 +--
 drivers/gpu/drm/panel/panel-visionox-rm69299.c | 4 ++--
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/panel/panel-truly-nt35597.c b/drivers/gpu/drm/panel/panel-truly-nt35597.c
index b24b92d93ea5..9ca5c7ff41d6 100644
--- a/drivers/gpu/drm/panel/panel-truly-nt35597.c
+++ b/drivers/gpu/drm/panel/panel-truly-nt35597.c
@@ -446,7 +446,7 @@ static int truly_nt35597_get_modes(struct drm_panel *panel,
 	const struct nt35597_config *config;
 
 	config = ctx->config;
-	mode = drm_mode_create(connector->dev);
+	mode = drm_mode_duplicate(connector->dev, config->dm);
 	if (!mode) {
 		dev_err(ctx->dev, "failed to create a new display mode\n");
 		return 0;
@@ -454,7 +454,6 @@ static int truly_nt35597_get_modes(struct drm_panel *panel,
 
 	connector->display_info.width_mm = config->width_mm;
 	connector->display_info.height_mm = config->height_mm;
-	drm_mode_copy(mode, config->dm);
 	mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED;
 	drm_mode_probed_add(connector, mode);
 
diff --git a/drivers/gpu/drm/panel/panel-visionox-rm69299.c b/drivers/gpu/drm/panel/panel-visionox-rm69299.c
index eb43503ec97b..db2443ac81d3 100644
--- a/drivers/gpu/drm/panel/panel-visionox-rm69299.c
+++ b/drivers/gpu/drm/panel/panel-visionox-rm69299.c
@@ -168,7 +168,8 @@ static int visionox_rm69299_get_modes(struct drm_panel *panel,
 	struct visionox_rm69299 *ctx = panel_to_ctx(panel);
 	struct drm_display_mode *mode;
 
-	mode = drm_mode_create(connector->dev);
+	mode = drm_mode_duplicate(connector->dev,
+				  &visionox_rm69299_1080x2248_60hz);
 	if (!mode) {
 		dev_err(ctx->panel.dev, "failed to create a new display mode\n");
 		return 0;
@@ -176,7 +177,6 @@ static int visionox_rm69299_get_modes(struct drm_panel *panel,
 
 	connector->display_info.width_mm = 74;
 	connector->display_info.height_mm = 131;
-	drm_mode_copy(mode, &visionox_rm69299_1080x2248_60hz);
 	mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED;
 	drm_mode_probed_add(connector, mode);
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 157+ messages in thread

* [PATCH 21/22] drm: Use drm_mode_init() for on-stack modes
  2022-02-18 10:03 ` Ville Syrjala
@ 2022-02-18 10:04   ` Ville Syrjala
  -1 siblings, 0 replies; 157+ messages in thread
From: Ville Syrjala @ 2022-02-18 10:04 UTC (permalink / raw)
  To: dri-devel; +Cc: intel-gfx

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Initialize on-stack modes with drm_mode_init() to guarantee
no stack garbage in the list head, or that we aren't copying
over another mode's list head.

Based on the following cocci script, with manual fixups:
@decl@
identifier M;
expression E;
@@
- struct drm_display_mode M = E;
+ struct drm_display_mode M;

@@
identifier decl.M;
expression decl.E;
statement S, S1;
@@
struct drm_display_mode M;
... when != S
+ drm_mode_init(&M, &E);
+
S1

@@
expression decl.E;
@@
- &*E
+ E

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/drm_crtc_helper.c | 8 ++++----
 drivers/gpu/drm/drm_edid.c        | 8 ++++++--
 drivers/gpu/drm/drm_modes.c       | 4 +++-
 3 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c
index bff917531f33..a34aa009725f 100644
--- a/drivers/gpu/drm/drm_crtc_helper.c
+++ b/drivers/gpu/drm/drm_crtc_helper.c
@@ -297,8 +297,8 @@ bool drm_crtc_helper_set_mode(struct drm_crtc *crtc,
 		return false;
 	}
 
-	saved_mode = crtc->mode;
-	saved_hwmode = crtc->hwmode;
+	drm_mode_init(&saved_mode, &crtc->mode);
+	drm_mode_init(&saved_hwmode, &crtc->hwmode);
 	saved_x = crtc->x;
 	saved_y = crtc->y;
 
@@ -411,8 +411,8 @@ bool drm_crtc_helper_set_mode(struct drm_crtc *crtc,
 	drm_mode_destroy(dev, adjusted_mode);
 	if (!ret) {
 		crtc->enabled = saved_enabled;
-		crtc->mode = saved_mode;
-		crtc->hwmode = saved_hwmode;
+		drm_mode_copy(&crtc->mode, &saved_mode);
+		drm_mode_copy(&crtc->hwmode, &saved_hwmode);
 		crtc->x = saved_x;
 		crtc->y = saved_y;
 	}
diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index a7663f9a11d2..1156bfeabaf6 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -3476,9 +3476,11 @@ static u8 drm_match_cea_mode_clock_tolerance(const struct drm_display_mode *to_m
 		match_flags |= DRM_MODE_MATCH_ASPECT_RATIO;
 
 	for (vic = 1; vic < cea_num_vics(); vic = cea_next_vic(vic)) {
-		struct drm_display_mode cea_mode = *cea_mode_for_vic(vic);
+		struct drm_display_mode cea_mode;
 		unsigned int clock1, clock2;
 
+		drm_mode_init(&cea_mode, cea_mode_for_vic(vic));
+
 		/* Check both 60Hz and 59.94Hz */
 		clock1 = cea_mode.clock;
 		clock2 = cea_mode_alternate_clock(&cea_mode);
@@ -3515,9 +3517,11 @@ u8 drm_match_cea_mode(const struct drm_display_mode *to_match)
 		match_flags |= DRM_MODE_MATCH_ASPECT_RATIO;
 
 	for (vic = 1; vic < cea_num_vics(); vic = cea_next_vic(vic)) {
-		struct drm_display_mode cea_mode = *cea_mode_for_vic(vic);
+		struct drm_display_mode cea_mode;
 		unsigned int clock1, clock2;
 
+		drm_mode_init(&cea_mode, cea_mode_for_vic(vic));
+
 		/* Check both 60Hz and 59.94Hz */
 		clock1 = cea_mode.clock;
 		clock2 = cea_mode_alternate_clock(&cea_mode);
diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c
index 40d4ce4a1da4..86904d082ff2 100644
--- a/drivers/gpu/drm/drm_modes.c
+++ b/drivers/gpu/drm/drm_modes.c
@@ -788,7 +788,9 @@ EXPORT_SYMBOL(drm_mode_vrefresh);
 void drm_mode_get_hv_timing(const struct drm_display_mode *mode,
 			    int *hdisplay, int *vdisplay)
 {
-	struct drm_display_mode adjusted = *mode;
+	struct drm_display_mode adjusted;
+
+	drm_mode_init(&adjusted, mode);
 
 	drm_mode_set_crtcinfo(&adjusted, CRTC_STEREO_DOUBLE_ONLY);
 	*hdisplay = adjusted.crtc_hdisplay;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 157+ messages in thread

* [Intel-gfx] [PATCH 21/22] drm: Use drm_mode_init() for on-stack modes
@ 2022-02-18 10:04   ` Ville Syrjala
  0 siblings, 0 replies; 157+ messages in thread
From: Ville Syrjala @ 2022-02-18 10:04 UTC (permalink / raw)
  To: dri-devel; +Cc: intel-gfx

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Initialize on-stack modes with drm_mode_init() to guarantee
no stack garbage in the list head, or that we aren't copying
over another mode's list head.

Based on the following cocci script, with manual fixups:
@decl@
identifier M;
expression E;
@@
- struct drm_display_mode M = E;
+ struct drm_display_mode M;

@@
identifier decl.M;
expression decl.E;
statement S, S1;
@@
struct drm_display_mode M;
... when != S
+ drm_mode_init(&M, &E);
+
S1

@@
expression decl.E;
@@
- &*E
+ E

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/drm_crtc_helper.c | 8 ++++----
 drivers/gpu/drm/drm_edid.c        | 8 ++++++--
 drivers/gpu/drm/drm_modes.c       | 4 +++-
 3 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c
index bff917531f33..a34aa009725f 100644
--- a/drivers/gpu/drm/drm_crtc_helper.c
+++ b/drivers/gpu/drm/drm_crtc_helper.c
@@ -297,8 +297,8 @@ bool drm_crtc_helper_set_mode(struct drm_crtc *crtc,
 		return false;
 	}
 
-	saved_mode = crtc->mode;
-	saved_hwmode = crtc->hwmode;
+	drm_mode_init(&saved_mode, &crtc->mode);
+	drm_mode_init(&saved_hwmode, &crtc->hwmode);
 	saved_x = crtc->x;
 	saved_y = crtc->y;
 
@@ -411,8 +411,8 @@ bool drm_crtc_helper_set_mode(struct drm_crtc *crtc,
 	drm_mode_destroy(dev, adjusted_mode);
 	if (!ret) {
 		crtc->enabled = saved_enabled;
-		crtc->mode = saved_mode;
-		crtc->hwmode = saved_hwmode;
+		drm_mode_copy(&crtc->mode, &saved_mode);
+		drm_mode_copy(&crtc->hwmode, &saved_hwmode);
 		crtc->x = saved_x;
 		crtc->y = saved_y;
 	}
diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index a7663f9a11d2..1156bfeabaf6 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -3476,9 +3476,11 @@ static u8 drm_match_cea_mode_clock_tolerance(const struct drm_display_mode *to_m
 		match_flags |= DRM_MODE_MATCH_ASPECT_RATIO;
 
 	for (vic = 1; vic < cea_num_vics(); vic = cea_next_vic(vic)) {
-		struct drm_display_mode cea_mode = *cea_mode_for_vic(vic);
+		struct drm_display_mode cea_mode;
 		unsigned int clock1, clock2;
 
+		drm_mode_init(&cea_mode, cea_mode_for_vic(vic));
+
 		/* Check both 60Hz and 59.94Hz */
 		clock1 = cea_mode.clock;
 		clock2 = cea_mode_alternate_clock(&cea_mode);
@@ -3515,9 +3517,11 @@ u8 drm_match_cea_mode(const struct drm_display_mode *to_match)
 		match_flags |= DRM_MODE_MATCH_ASPECT_RATIO;
 
 	for (vic = 1; vic < cea_num_vics(); vic = cea_next_vic(vic)) {
-		struct drm_display_mode cea_mode = *cea_mode_for_vic(vic);
+		struct drm_display_mode cea_mode;
 		unsigned int clock1, clock2;
 
+		drm_mode_init(&cea_mode, cea_mode_for_vic(vic));
+
 		/* Check both 60Hz and 59.94Hz */
 		clock1 = cea_mode.clock;
 		clock2 = cea_mode_alternate_clock(&cea_mode);
diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c
index 40d4ce4a1da4..86904d082ff2 100644
--- a/drivers/gpu/drm/drm_modes.c
+++ b/drivers/gpu/drm/drm_modes.c
@@ -788,7 +788,9 @@ EXPORT_SYMBOL(drm_mode_vrefresh);
 void drm_mode_get_hv_timing(const struct drm_display_mode *mode,
 			    int *hdisplay, int *vdisplay)
 {
-	struct drm_display_mode adjusted = *mode;
+	struct drm_display_mode adjusted;
+
+	drm_mode_init(&adjusted, mode);
 
 	drm_mode_set_crtcinfo(&adjusted, CRTC_STEREO_DOUBLE_ONLY);
 	*hdisplay = adjusted.crtc_hdisplay;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 157+ messages in thread

* [PATCH 22/22] drm: Use drm_mode_copy()
  2022-02-18 10:03 ` Ville Syrjala
@ 2022-02-18 10:04   ` Ville Syrjala
  -1 siblings, 0 replies; 157+ messages in thread
From: Ville Syrjala @ 2022-02-18 10:04 UTC (permalink / raw)
  To: dri-devel; +Cc: intel-gfx

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

struct drm_display_mode embeds a list head, so overwriting
the full struct with another one will corrupt the list
(if the destination mode is on a list). Use drm_mode_copy()
instead which explicitly preserves the list head of
the destination mode.

Even if we know the destination mode is not on any list
using drm_mode_copy() seems decent as it sets a good
example. Bad examples of not using it might eventually
get copied into code where preserving the list head
actually matters.

Obviously one case not covered here is when the mode
itself is embedded in a larger structure and the whole
structure is copied. But if we are careful when copying
into modes embedded in structures I think we can be a
little more reassured that bogus list heads haven't been
propagated in.

@is_mode_copy@
@@
drm_mode_copy(...)
{
...
}

@depends on !is_mode_copy@
struct drm_display_mode *mode;
expression E, S;
@@
(
- *mode = E
+ drm_mode_copy(mode, &E)
|
- memcpy(mode, E, S)
+ drm_mode_copy(mode, E)
)

@depends on !is_mode_copy@
struct drm_display_mode mode;
expression E;
@@
(
- mode = E
+ drm_mode_copy(&mode, &E)
|
- memcpy(&mode, E, S)
+ drm_mode_copy(&mode, E)
)

@@
struct drm_display_mode *mode;
@@
- &*mode
+ mode

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/drm_crtc_helper.c | 4 ++--
 drivers/gpu/drm/drm_vblank.c      | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c
index a34aa009725f..b632825654a9 100644
--- a/drivers/gpu/drm/drm_crtc_helper.c
+++ b/drivers/gpu/drm/drm_crtc_helper.c
@@ -305,7 +305,7 @@ bool drm_crtc_helper_set_mode(struct drm_crtc *crtc,
 	/* Update crtc values up front so the driver can rely on them for mode
 	 * setting.
 	 */
-	crtc->mode = *mode;
+	drm_mode_copy(&crtc->mode, mode);
 	crtc->x = x;
 	crtc->y = y;
 
@@ -341,7 +341,7 @@ bool drm_crtc_helper_set_mode(struct drm_crtc *crtc,
 	}
 	DRM_DEBUG_KMS("[CRTC:%d:%s]\n", crtc->base.id, crtc->name);
 
-	crtc->hwmode = *adjusted_mode;
+	drm_mode_copy(&crtc->hwmode, adjusted_mode);
 
 	/* Prepare the encoders and CRTCs before setting the mode. */
 	drm_for_each_encoder(encoder, dev) {
diff --git a/drivers/gpu/drm/drm_vblank.c b/drivers/gpu/drm/drm_vblank.c
index b701cda86d0c..2ff31717a3de 100644
--- a/drivers/gpu/drm/drm_vblank.c
+++ b/drivers/gpu/drm/drm_vblank.c
@@ -644,7 +644,7 @@ void drm_calc_timestamping_constants(struct drm_crtc *crtc,
 
 	vblank->linedur_ns  = linedur_ns;
 	vblank->framedur_ns = framedur_ns;
-	vblank->hwmode = *mode;
+	drm_mode_copy(&vblank->hwmode, mode);
 
 	drm_dbg_core(dev,
 		     "crtc %u: hwmode: htotal %d, vtotal %d, vdisplay %d\n",
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 157+ messages in thread

* [Intel-gfx] [PATCH 22/22] drm: Use drm_mode_copy()
@ 2022-02-18 10:04   ` Ville Syrjala
  0 siblings, 0 replies; 157+ messages in thread
From: Ville Syrjala @ 2022-02-18 10:04 UTC (permalink / raw)
  To: dri-devel; +Cc: intel-gfx

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

struct drm_display_mode embeds a list head, so overwriting
the full struct with another one will corrupt the list
(if the destination mode is on a list). Use drm_mode_copy()
instead which explicitly preserves the list head of
the destination mode.

Even if we know the destination mode is not on any list
using drm_mode_copy() seems decent as it sets a good
example. Bad examples of not using it might eventually
get copied into code where preserving the list head
actually matters.

Obviously one case not covered here is when the mode
itself is embedded in a larger structure and the whole
structure is copied. But if we are careful when copying
into modes embedded in structures I think we can be a
little more reassured that bogus list heads haven't been
propagated in.

@is_mode_copy@
@@
drm_mode_copy(...)
{
...
}

@depends on !is_mode_copy@
struct drm_display_mode *mode;
expression E, S;
@@
(
- *mode = E
+ drm_mode_copy(mode, &E)
|
- memcpy(mode, E, S)
+ drm_mode_copy(mode, E)
)

@depends on !is_mode_copy@
struct drm_display_mode mode;
expression E;
@@
(
- mode = E
+ drm_mode_copy(&mode, &E)
|
- memcpy(&mode, E, S)
+ drm_mode_copy(&mode, E)
)

@@
struct drm_display_mode *mode;
@@
- &*mode
+ mode

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/drm_crtc_helper.c | 4 ++--
 drivers/gpu/drm/drm_vblank.c      | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c
index a34aa009725f..b632825654a9 100644
--- a/drivers/gpu/drm/drm_crtc_helper.c
+++ b/drivers/gpu/drm/drm_crtc_helper.c
@@ -305,7 +305,7 @@ bool drm_crtc_helper_set_mode(struct drm_crtc *crtc,
 	/* Update crtc values up front so the driver can rely on them for mode
 	 * setting.
 	 */
-	crtc->mode = *mode;
+	drm_mode_copy(&crtc->mode, mode);
 	crtc->x = x;
 	crtc->y = y;
 
@@ -341,7 +341,7 @@ bool drm_crtc_helper_set_mode(struct drm_crtc *crtc,
 	}
 	DRM_DEBUG_KMS("[CRTC:%d:%s]\n", crtc->base.id, crtc->name);
 
-	crtc->hwmode = *adjusted_mode;
+	drm_mode_copy(&crtc->hwmode, adjusted_mode);
 
 	/* Prepare the encoders and CRTCs before setting the mode. */
 	drm_for_each_encoder(encoder, dev) {
diff --git a/drivers/gpu/drm/drm_vblank.c b/drivers/gpu/drm/drm_vblank.c
index b701cda86d0c..2ff31717a3de 100644
--- a/drivers/gpu/drm/drm_vblank.c
+++ b/drivers/gpu/drm/drm_vblank.c
@@ -644,7 +644,7 @@ void drm_calc_timestamping_constants(struct drm_crtc *crtc,
 
 	vblank->linedur_ns  = linedur_ns;
 	vblank->framedur_ns = framedur_ns;
-	vblank->hwmode = *mode;
+	drm_mode_copy(&vblank->hwmode, mode);
 
 	drm_dbg_core(dev,
 		     "crtc %u: hwmode: htotal %d, vtotal %d, vdisplay %d\n",
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 157+ messages in thread

* Re: [PATCH 01/22] drm: Add drm_mode_init()
  2022-02-18 10:03   ` [Intel-gfx] " Ville Syrjala
@ 2022-02-18 11:22     ` Andrzej Hajda
  -1 siblings, 0 replies; 157+ messages in thread
From: Andrzej Hajda @ 2022-02-18 11:22 UTC (permalink / raw)
  To: Ville Syrjala, dri-devel; +Cc: intel-gfx



On 18.02.2022 11:03, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
> Add a variant of drm_mode_copy() that explicitly clears out
> the list head of the destination mode. Helpful to guarantee
> we don't have stack garbage left in there for on-stack modes.
>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---
>   drivers/gpu/drm/drm_modes.c | 17 +++++++++++++++++
>   include/drm/drm_modes.h     |  2 ++
>   2 files changed, 19 insertions(+)
>
> diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c
> index 96b13e36293c..40d4ce4a1da4 100644
> --- a/drivers/gpu/drm/drm_modes.c
> +++ b/drivers/gpu/drm/drm_modes.c
> @@ -892,6 +892,23 @@ void drm_mode_copy(struct drm_display_mode *dst, const struct drm_display_mode *
>   }
>   EXPORT_SYMBOL(drm_mode_copy);
>   
> +/**
> + * drm_mode_init - initialize the mode from another mode
> + * @dst: mode to overwrite
> + * @src: mode to copy
> + *
> + * Copy an existing mode into another mode, zeroing the
> + * list head of the destination mode. Typically used
> + * to guarantee the list head is not left with stack
> + * garbage in on-stack modes.
> + */
> +void drm_mode_init(struct drm_display_mode *dst, const struct drm_display_mode *src)
> +{
> +	memset(dst, 0, sizeof(*dst));

Why not just clear the list head? Or maybe poison it? It would be more 
cleaner.

I wonder why there is no such helper in list.h.


Regards
Andrzej

> +	drm_mode_copy(dst, src);
> +}
> +EXPORT_SYMBOL(drm_mode_init);
> +
>   /**
>    * drm_mode_duplicate - allocate and duplicate an existing mode
>    * @dev: drm_device to allocate the duplicated mode for
> diff --git a/include/drm/drm_modes.h b/include/drm/drm_modes.h
> index 29ba4adf0c53..e6e5a588fab1 100644
> --- a/include/drm/drm_modes.h
> +++ b/include/drm/drm_modes.h
> @@ -484,6 +484,8 @@ void drm_mode_set_crtcinfo(struct drm_display_mode *p,
>   			   int adjust_flags);
>   void drm_mode_copy(struct drm_display_mode *dst,
>   		   const struct drm_display_mode *src);
> +void drm_mode_init(struct drm_display_mode *dst,
> +		   const struct drm_display_mode *src);
>   struct drm_display_mode *drm_mode_duplicate(struct drm_device *dev,
>   					    const struct drm_display_mode *mode);
>   bool drm_mode_match(const struct drm_display_mode *mode1,


^ permalink raw reply	[flat|nested] 157+ messages in thread

* Re: [Intel-gfx] [PATCH 01/22] drm: Add drm_mode_init()
@ 2022-02-18 11:22     ` Andrzej Hajda
  0 siblings, 0 replies; 157+ messages in thread
From: Andrzej Hajda @ 2022-02-18 11:22 UTC (permalink / raw)
  To: Ville Syrjala, dri-devel; +Cc: intel-gfx



On 18.02.2022 11:03, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
> Add a variant of drm_mode_copy() that explicitly clears out
> the list head of the destination mode. Helpful to guarantee
> we don't have stack garbage left in there for on-stack modes.
>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---
>   drivers/gpu/drm/drm_modes.c | 17 +++++++++++++++++
>   include/drm/drm_modes.h     |  2 ++
>   2 files changed, 19 insertions(+)
>
> diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c
> index 96b13e36293c..40d4ce4a1da4 100644
> --- a/drivers/gpu/drm/drm_modes.c
> +++ b/drivers/gpu/drm/drm_modes.c
> @@ -892,6 +892,23 @@ void drm_mode_copy(struct drm_display_mode *dst, const struct drm_display_mode *
>   }
>   EXPORT_SYMBOL(drm_mode_copy);
>   
> +/**
> + * drm_mode_init - initialize the mode from another mode
> + * @dst: mode to overwrite
> + * @src: mode to copy
> + *
> + * Copy an existing mode into another mode, zeroing the
> + * list head of the destination mode. Typically used
> + * to guarantee the list head is not left with stack
> + * garbage in on-stack modes.
> + */
> +void drm_mode_init(struct drm_display_mode *dst, const struct drm_display_mode *src)
> +{
> +	memset(dst, 0, sizeof(*dst));

Why not just clear the list head? Or maybe poison it? It would be more 
cleaner.

I wonder why there is no such helper in list.h.


Regards
Andrzej

> +	drm_mode_copy(dst, src);
> +}
> +EXPORT_SYMBOL(drm_mode_init);
> +
>   /**
>    * drm_mode_duplicate - allocate and duplicate an existing mode
>    * @dev: drm_device to allocate the duplicated mode for
> diff --git a/include/drm/drm_modes.h b/include/drm/drm_modes.h
> index 29ba4adf0c53..e6e5a588fab1 100644
> --- a/include/drm/drm_modes.h
> +++ b/include/drm/drm_modes.h
> @@ -484,6 +484,8 @@ void drm_mode_set_crtcinfo(struct drm_display_mode *p,
>   			   int adjust_flags);
>   void drm_mode_copy(struct drm_display_mode *dst,
>   		   const struct drm_display_mode *src);
> +void drm_mode_init(struct drm_display_mode *dst,
> +		   const struct drm_display_mode *src);
>   struct drm_display_mode *drm_mode_duplicate(struct drm_device *dev,
>   					    const struct drm_display_mode *mode);
>   bool drm_mode_match(const struct drm_display_mode *mode1,


^ permalink raw reply	[flat|nested] 157+ messages in thread

* Re: [PATCH 06/22] drm/bridge: Use drm_mode_copy()
  2022-02-18 10:03   ` [Intel-gfx] " Ville Syrjala
@ 2022-02-18 11:25     ` Andrzej Hajda
  -1 siblings, 0 replies; 157+ messages in thread
From: Andrzej Hajda @ 2022-02-18 11:25 UTC (permalink / raw)
  To: Ville Syrjala, dri-devel
  Cc: Jernej Skrabec, Neil Armstrong, intel-gfx, Jonas Karlman,
	Robert Foss, Laurent Pinchart



On 18.02.2022 11:03, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
> struct drm_display_mode embeds a list head, so overwriting
> the full struct with another one will corrupt the list
> (if the destination mode is on a list). Use drm_mode_copy()
> instead which explicitly preserves the list head of
> the destination mode.
>
> Even if we know the destination mode is not on any list
> using drm_mode_copy() seems decent as it sets a good
> example. Bad examples of not using it might eventually
> get copied into code where preserving the list head
> actually matters.
>
> Obviously one case not covered here is when the mode
> itself is embedded in a larger structure and the whole
> structure is copied. But if we are careful when copying
> into modes embedded in structures I think we can be a
> little more reassured that bogus list heads haven't been
> propagated in.
>
> @is_mode_copy@
> @@
> drm_mode_copy(...)
> {
> ...
> }
>
> @depends on !is_mode_copy@
> struct drm_display_mode *mode;
> expression E, S;
> @@
> (
> - *mode = E
> + drm_mode_copy(mode, &E)
> |
> - memcpy(mode, E, S)
> + drm_mode_copy(mode, E)
> )
>
> @depends on !is_mode_copy@
> struct drm_display_mode mode;
> expression E;
> @@
> (
> - mode = E
> + drm_mode_copy(&mode, &E)
> |
> - memcpy(&mode, E, S)
> + drm_mode_copy(&mode, E)
> )
>
> @@
> struct drm_display_mode *mode;
> @@
> - &*mode
> + mode
>
> Cc: Andrzej Hajda <andrzej.hajda@intel.com>
> Cc: Neil Armstrong <narmstrong@baylibre.com>
> Cc: Robert Foss <robert.foss@linaro.org>
> Cc: Laurent Pinchart <Laurent.pinchart@ideasonboard.com>
> Cc: Jonas Karlman <jonas@kwiboo.se>
> Cc: Jernej Skrabec <jernej.skrabec@gmail.com>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

Reviewed-by: Andrzej Hajda <andrzej.hajda@intel.com>

Regards
Andrzej
> ---
>   drivers/gpu/drm/bridge/nwl-dsi.c          | 2 +-
>   drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 2 +-
>   drivers/gpu/drm/bridge/tc358767.c         | 2 +-
>   3 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/bridge/nwl-dsi.c b/drivers/gpu/drm/bridge/nwl-dsi.c
> index 963a6794735f..881cf338d5cf 100644
> --- a/drivers/gpu/drm/bridge/nwl-dsi.c
> +++ b/drivers/gpu/drm/bridge/nwl-dsi.c
> @@ -857,7 +857,7 @@ nwl_dsi_bridge_mode_set(struct drm_bridge *bridge,
>   	/* Save the new desired phy config */
>   	memcpy(&dsi->phy_cfg, &new_cfg, sizeof(new_cfg));
>   
> -	memcpy(&dsi->mode, adjusted_mode, sizeof(dsi->mode));
> +	drm_mode_copy(&dsi->mode, adjusted_mode);
>   	drm_mode_debug_printmodeline(adjusted_mode);
>   
>   	if (pm_runtime_resume_and_get(dev) < 0)
> diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
> index 4befc104d220..a563460f8d20 100644
> --- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
> +++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
> @@ -2830,7 +2830,7 @@ static void dw_hdmi_bridge_mode_set(struct drm_bridge *bridge,
>   	mutex_lock(&hdmi->mutex);
>   
>   	/* Store the display mode for plugin/DKMS poweron events */
> -	memcpy(&hdmi->previous_mode, mode, sizeof(hdmi->previous_mode));
> +	drm_mode_copy(&hdmi->previous_mode, mode);
>   
>   	mutex_unlock(&hdmi->mutex);
>   }
> diff --git a/drivers/gpu/drm/bridge/tc358767.c b/drivers/gpu/drm/bridge/tc358767.c
> index c23e0abc65e8..7f9574b17caa 100644
> --- a/drivers/gpu/drm/bridge/tc358767.c
> +++ b/drivers/gpu/drm/bridge/tc358767.c
> @@ -1312,7 +1312,7 @@ static void tc_bridge_mode_set(struct drm_bridge *bridge,
>   {
>   	struct tc_data *tc = bridge_to_tc(bridge);
>   
> -	tc->mode = *mode;
> +	drm_mode_copy(&tc->mode, mode);
>   }
>   
>   static struct edid *tc_get_edid(struct drm_bridge *bridge,


^ permalink raw reply	[flat|nested] 157+ messages in thread

* Re: [Intel-gfx] [PATCH 06/22] drm/bridge: Use drm_mode_copy()
@ 2022-02-18 11:25     ` Andrzej Hajda
  0 siblings, 0 replies; 157+ messages in thread
From: Andrzej Hajda @ 2022-02-18 11:25 UTC (permalink / raw)
  To: Ville Syrjala, dri-devel
  Cc: Jernej Skrabec, Neil Armstrong, intel-gfx, Jonas Karlman,
	Robert Foss, Laurent Pinchart



On 18.02.2022 11:03, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
> struct drm_display_mode embeds a list head, so overwriting
> the full struct with another one will corrupt the list
> (if the destination mode is on a list). Use drm_mode_copy()
> instead which explicitly preserves the list head of
> the destination mode.
>
> Even if we know the destination mode is not on any list
> using drm_mode_copy() seems decent as it sets a good
> example. Bad examples of not using it might eventually
> get copied into code where preserving the list head
> actually matters.
>
> Obviously one case not covered here is when the mode
> itself is embedded in a larger structure and the whole
> structure is copied. But if we are careful when copying
> into modes embedded in structures I think we can be a
> little more reassured that bogus list heads haven't been
> propagated in.
>
> @is_mode_copy@
> @@
> drm_mode_copy(...)
> {
> ...
> }
>
> @depends on !is_mode_copy@
> struct drm_display_mode *mode;
> expression E, S;
> @@
> (
> - *mode = E
> + drm_mode_copy(mode, &E)
> |
> - memcpy(mode, E, S)
> + drm_mode_copy(mode, E)
> )
>
> @depends on !is_mode_copy@
> struct drm_display_mode mode;
> expression E;
> @@
> (
> - mode = E
> + drm_mode_copy(&mode, &E)
> |
> - memcpy(&mode, E, S)
> + drm_mode_copy(&mode, E)
> )
>
> @@
> struct drm_display_mode *mode;
> @@
> - &*mode
> + mode
>
> Cc: Andrzej Hajda <andrzej.hajda@intel.com>
> Cc: Neil Armstrong <narmstrong@baylibre.com>
> Cc: Robert Foss <robert.foss@linaro.org>
> Cc: Laurent Pinchart <Laurent.pinchart@ideasonboard.com>
> Cc: Jonas Karlman <jonas@kwiboo.se>
> Cc: Jernej Skrabec <jernej.skrabec@gmail.com>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

Reviewed-by: Andrzej Hajda <andrzej.hajda@intel.com>

Regards
Andrzej
> ---
>   drivers/gpu/drm/bridge/nwl-dsi.c          | 2 +-
>   drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 2 +-
>   drivers/gpu/drm/bridge/tc358767.c         | 2 +-
>   3 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/bridge/nwl-dsi.c b/drivers/gpu/drm/bridge/nwl-dsi.c
> index 963a6794735f..881cf338d5cf 100644
> --- a/drivers/gpu/drm/bridge/nwl-dsi.c
> +++ b/drivers/gpu/drm/bridge/nwl-dsi.c
> @@ -857,7 +857,7 @@ nwl_dsi_bridge_mode_set(struct drm_bridge *bridge,
>   	/* Save the new desired phy config */
>   	memcpy(&dsi->phy_cfg, &new_cfg, sizeof(new_cfg));
>   
> -	memcpy(&dsi->mode, adjusted_mode, sizeof(dsi->mode));
> +	drm_mode_copy(&dsi->mode, adjusted_mode);
>   	drm_mode_debug_printmodeline(adjusted_mode);
>   
>   	if (pm_runtime_resume_and_get(dev) < 0)
> diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
> index 4befc104d220..a563460f8d20 100644
> --- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
> +++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
> @@ -2830,7 +2830,7 @@ static void dw_hdmi_bridge_mode_set(struct drm_bridge *bridge,
>   	mutex_lock(&hdmi->mutex);
>   
>   	/* Store the display mode for plugin/DKMS poweron events */
> -	memcpy(&hdmi->previous_mode, mode, sizeof(hdmi->previous_mode));
> +	drm_mode_copy(&hdmi->previous_mode, mode);
>   
>   	mutex_unlock(&hdmi->mutex);
>   }
> diff --git a/drivers/gpu/drm/bridge/tc358767.c b/drivers/gpu/drm/bridge/tc358767.c
> index c23e0abc65e8..7f9574b17caa 100644
> --- a/drivers/gpu/drm/bridge/tc358767.c
> +++ b/drivers/gpu/drm/bridge/tc358767.c
> @@ -1312,7 +1312,7 @@ static void tc_bridge_mode_set(struct drm_bridge *bridge,
>   {
>   	struct tc_data *tc = bridge_to_tc(bridge);
>   
> -	tc->mode = *mode;
> +	drm_mode_copy(&tc->mode, mode);
>   }
>   
>   static struct edid *tc_get_edid(struct drm_bridge *bridge,


^ permalink raw reply	[flat|nested] 157+ messages in thread

* Re: [PATCH 09/22] drm/imx: Use drm_mode_duplicate()
  2022-02-18 10:03   ` [Intel-gfx] " Ville Syrjala
@ 2022-02-18 11:42     ` Philipp Zabel
  -1 siblings, 0 replies; 157+ messages in thread
From: Philipp Zabel @ 2022-02-18 11:42 UTC (permalink / raw)
  To: Ville Syrjala, dri-devel; +Cc: intel-gfx

On Fri, 2022-02-18 at 12:03 +0200, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> Replace the hand rolled drm_mode_duplicate() with the
> real thing.
> 
> @is_dup@
> @@
> drm_mode_duplicate(...)
> { ... }
> 
> @depends on !is_dup@
> expression dev, oldmode;
> identifier newmode;
> @@
> - newmode = drm_mode_create(dev);
> + newmode = drm_mode_duplicate(dev, oldmode);
>   ...
> - drm_mode_copy(newmode, oldmode);
> 
> Cc: Philipp Zabel <p.zabel@pengutronix.de>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>

regards
Philipp

^ permalink raw reply	[flat|nested] 157+ messages in thread

* Re: [Intel-gfx] [PATCH 09/22] drm/imx: Use drm_mode_duplicate()
@ 2022-02-18 11:42     ` Philipp Zabel
  0 siblings, 0 replies; 157+ messages in thread
From: Philipp Zabel @ 2022-02-18 11:42 UTC (permalink / raw)
  To: Ville Syrjala, dri-devel; +Cc: intel-gfx

On Fri, 2022-02-18 at 12:03 +0200, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> Replace the hand rolled drm_mode_duplicate() with the
> real thing.
> 
> @is_dup@
> @@
> drm_mode_duplicate(...)
> { ... }
> 
> @depends on !is_dup@
> expression dev, oldmode;
> identifier newmode;
> @@
> - newmode = drm_mode_create(dev);
> + newmode = drm_mode_duplicate(dev, oldmode);
>   ...
> - drm_mode_copy(newmode, oldmode);
> 
> Cc: Philipp Zabel <p.zabel@pengutronix.de>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>

regards
Philipp

^ permalink raw reply	[flat|nested] 157+ messages in thread

* Re: [PATCH 20/22] drm/panel: Use drm_mode_duplicate()
  2022-02-18 10:04   ` [Intel-gfx] " Ville Syrjala
@ 2022-02-18 11:51     ` Sam Ravnborg
  -1 siblings, 0 replies; 157+ messages in thread
From: Sam Ravnborg @ 2022-02-18 11:51 UTC (permalink / raw)
  To: Ville Syrjala; +Cc: intel-gfx, Thierry Reding, dri-devel

Hi Ville,

On Fri, Feb 18, 2022 at 12:04:01PM +0200, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> Replace the hand rolled drm_mode_duplicate() with the
> real thing.
> 
> @is_dup@
> @@
> drm_mode_duplicate(...)
> { ... }
> 
> @depends on !is_dup@
> expression dev, oldmode;
> identifier newmode;
> @@
> - newmode = drm_mode_create(dev);
> + newmode = drm_mode_duplicate(dev, oldmode);
>   ...
> - drm_mode_copy(newmode, oldmode);
> 
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> Cc: Thierry Reding <thierry.reding@gmail.com>
> Cc: Sam Ravnborg <sam@ravnborg.org>

Looks good,
Acked-by: Sam Ravnborg <sam@ravnborg.org>

^ permalink raw reply	[flat|nested] 157+ messages in thread

* Re: [Intel-gfx] [PATCH 20/22] drm/panel: Use drm_mode_duplicate()
@ 2022-02-18 11:51     ` Sam Ravnborg
  0 siblings, 0 replies; 157+ messages in thread
From: Sam Ravnborg @ 2022-02-18 11:51 UTC (permalink / raw)
  To: Ville Syrjala; +Cc: intel-gfx, dri-devel

Hi Ville,

On Fri, Feb 18, 2022 at 12:04:01PM +0200, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> Replace the hand rolled drm_mode_duplicate() with the
> real thing.
> 
> @is_dup@
> @@
> drm_mode_duplicate(...)
> { ... }
> 
> @depends on !is_dup@
> expression dev, oldmode;
> identifier newmode;
> @@
> - newmode = drm_mode_create(dev);
> + newmode = drm_mode_duplicate(dev, oldmode);
>   ...
> - drm_mode_copy(newmode, oldmode);
> 
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> Cc: Thierry Reding <thierry.reding@gmail.com>
> Cc: Sam Ravnborg <sam@ravnborg.org>

Looks good,
Acked-by: Sam Ravnborg <sam@ravnborg.org>

^ permalink raw reply	[flat|nested] 157+ messages in thread

* Re: [PATCH 01/22] drm: Add drm_mode_init()
  2022-02-18 11:22     ` [Intel-gfx] " Andrzej Hajda
@ 2022-02-18 11:56       ` Ville Syrjälä
  -1 siblings, 0 replies; 157+ messages in thread
From: Ville Syrjälä @ 2022-02-18 11:56 UTC (permalink / raw)
  To: Andrzej Hajda; +Cc: intel-gfx, dri-devel

On Fri, Feb 18, 2022 at 12:22:44PM +0100, Andrzej Hajda wrote:
> 
> 
> On 18.02.2022 11:03, Ville Syrjala wrote:
> > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> >
> > Add a variant of drm_mode_copy() that explicitly clears out
> > the list head of the destination mode. Helpful to guarantee
> > we don't have stack garbage left in there for on-stack modes.
> >
> > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > ---
> >   drivers/gpu/drm/drm_modes.c | 17 +++++++++++++++++
> >   include/drm/drm_modes.h     |  2 ++
> >   2 files changed, 19 insertions(+)
> >
> > diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c
> > index 96b13e36293c..40d4ce4a1da4 100644
> > --- a/drivers/gpu/drm/drm_modes.c
> > +++ b/drivers/gpu/drm/drm_modes.c
> > @@ -892,6 +892,23 @@ void drm_mode_copy(struct drm_display_mode *dst, const struct drm_display_mode *
> >   }
> >   EXPORT_SYMBOL(drm_mode_copy);
> >   
> > +/**
> > + * drm_mode_init - initialize the mode from another mode
> > + * @dst: mode to overwrite
> > + * @src: mode to copy
> > + *
> > + * Copy an existing mode into another mode, zeroing the
> > + * list head of the destination mode. Typically used
> > + * to guarantee the list head is not left with stack
> > + * garbage in on-stack modes.
> > + */
> > +void drm_mode_init(struct drm_display_mode *dst, const struct drm_display_mode *src)
> > +{
> > +	memset(dst, 0, sizeof(*dst));
> 
> Why not just clear the list head? Or maybe poison it? It would be more 
> cleaner.

Then we have two places that need to be updated if some other field
gets introduced that needs preserving. With a full memset() we only
have to care about drm_mode_copy(). Don't see much point in
micro-optimizing this thing.

-- 
Ville Syrjälä
Intel

^ permalink raw reply	[flat|nested] 157+ messages in thread

* Re: [Intel-gfx] [PATCH 01/22] drm: Add drm_mode_init()
@ 2022-02-18 11:56       ` Ville Syrjälä
  0 siblings, 0 replies; 157+ messages in thread
From: Ville Syrjälä @ 2022-02-18 11:56 UTC (permalink / raw)
  To: Andrzej Hajda; +Cc: intel-gfx, dri-devel

On Fri, Feb 18, 2022 at 12:22:44PM +0100, Andrzej Hajda wrote:
> 
> 
> On 18.02.2022 11:03, Ville Syrjala wrote:
> > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> >
> > Add a variant of drm_mode_copy() that explicitly clears out
> > the list head of the destination mode. Helpful to guarantee
> > we don't have stack garbage left in there for on-stack modes.
> >
> > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > ---
> >   drivers/gpu/drm/drm_modes.c | 17 +++++++++++++++++
> >   include/drm/drm_modes.h     |  2 ++
> >   2 files changed, 19 insertions(+)
> >
> > diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c
> > index 96b13e36293c..40d4ce4a1da4 100644
> > --- a/drivers/gpu/drm/drm_modes.c
> > +++ b/drivers/gpu/drm/drm_modes.c
> > @@ -892,6 +892,23 @@ void drm_mode_copy(struct drm_display_mode *dst, const struct drm_display_mode *
> >   }
> >   EXPORT_SYMBOL(drm_mode_copy);
> >   
> > +/**
> > + * drm_mode_init - initialize the mode from another mode
> > + * @dst: mode to overwrite
> > + * @src: mode to copy
> > + *
> > + * Copy an existing mode into another mode, zeroing the
> > + * list head of the destination mode. Typically used
> > + * to guarantee the list head is not left with stack
> > + * garbage in on-stack modes.
> > + */
> > +void drm_mode_init(struct drm_display_mode *dst, const struct drm_display_mode *src)
> > +{
> > +	memset(dst, 0, sizeof(*dst));
> 
> Why not just clear the list head? Or maybe poison it? It would be more 
> cleaner.

Then we have two places that need to be updated if some other field
gets introduced that needs preserving. With a full memset() we only
have to care about drm_mode_copy(). Don't see much point in
micro-optimizing this thing.

-- 
Ville Syrjälä
Intel

^ permalink raw reply	[flat|nested] 157+ messages in thread

* Re: [PATCH 01/22] drm: Add drm_mode_init()
  2022-02-18 11:56       ` [Intel-gfx] " Ville Syrjälä
@ 2022-02-18 12:23         ` Andrzej Hajda
  -1 siblings, 0 replies; 157+ messages in thread
From: Andrzej Hajda @ 2022-02-18 12:23 UTC (permalink / raw)
  To: Ville Syrjälä; +Cc: intel-gfx, dri-devel



On 18.02.2022 12:56, Ville Syrjälä wrote:
> On Fri, Feb 18, 2022 at 12:22:44PM +0100, Andrzej Hajda wrote:
>>
>> On 18.02.2022 11:03, Ville Syrjala wrote:
>>> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>>>
>>> Add a variant of drm_mode_copy() that explicitly clears out
>>> the list head of the destination mode. Helpful to guarantee
>>> we don't have stack garbage left in there for on-stack modes.
>>>
>>> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
>>> ---
>>>    drivers/gpu/drm/drm_modes.c | 17 +++++++++++++++++
>>>    include/drm/drm_modes.h     |  2 ++
>>>    2 files changed, 19 insertions(+)
>>>
>>> diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c
>>> index 96b13e36293c..40d4ce4a1da4 100644
>>> --- a/drivers/gpu/drm/drm_modes.c
>>> +++ b/drivers/gpu/drm/drm_modes.c
>>> @@ -892,6 +892,23 @@ void drm_mode_copy(struct drm_display_mode *dst, const struct drm_display_mode *
>>>    }
>>>    EXPORT_SYMBOL(drm_mode_copy);
>>>    
>>> +/**
>>> + * drm_mode_init - initialize the mode from another mode
>>> + * @dst: mode to overwrite
>>> + * @src: mode to copy
>>> + *
>>> + * Copy an existing mode into another mode, zeroing the
>>> + * list head of the destination mode. Typically used
>>> + * to guarantee the list head is not left with stack
>>> + * garbage in on-stack modes.
>>> + */
>>> +void drm_mode_init(struct drm_display_mode *dst, const struct drm_display_mode *src)
>>> +{
>>> +	memset(dst, 0, sizeof(*dst));
>> Why not just clear the list head? Or maybe poison it? It would be more
>> cleaner.
> Then we have two places that need to be updated if some other field
> gets introduced that needs preserving. With a full memset() we only
> have to care about drm_mode_copy(). Don't see much point in
> micro-optimizing this thing.
>
In such case DOC should be modified to avoid updating it "if some other 
field..." :)

Anyway:
Reviewed-by: Andrzej Hajda <andrzej.hajda@intel.com>

Regards
Andrzej


^ permalink raw reply	[flat|nested] 157+ messages in thread

* Re: [Intel-gfx] [PATCH 01/22] drm: Add drm_mode_init()
@ 2022-02-18 12:23         ` Andrzej Hajda
  0 siblings, 0 replies; 157+ messages in thread
From: Andrzej Hajda @ 2022-02-18 12:23 UTC (permalink / raw)
  To: Ville Syrjälä; +Cc: intel-gfx, dri-devel



On 18.02.2022 12:56, Ville Syrjälä wrote:
> On Fri, Feb 18, 2022 at 12:22:44PM +0100, Andrzej Hajda wrote:
>>
>> On 18.02.2022 11:03, Ville Syrjala wrote:
>>> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>>>
>>> Add a variant of drm_mode_copy() that explicitly clears out
>>> the list head of the destination mode. Helpful to guarantee
>>> we don't have stack garbage left in there for on-stack modes.
>>>
>>> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
>>> ---
>>>    drivers/gpu/drm/drm_modes.c | 17 +++++++++++++++++
>>>    include/drm/drm_modes.h     |  2 ++
>>>    2 files changed, 19 insertions(+)
>>>
>>> diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c
>>> index 96b13e36293c..40d4ce4a1da4 100644
>>> --- a/drivers/gpu/drm/drm_modes.c
>>> +++ b/drivers/gpu/drm/drm_modes.c
>>> @@ -892,6 +892,23 @@ void drm_mode_copy(struct drm_display_mode *dst, const struct drm_display_mode *
>>>    }
>>>    EXPORT_SYMBOL(drm_mode_copy);
>>>    
>>> +/**
>>> + * drm_mode_init - initialize the mode from another mode
>>> + * @dst: mode to overwrite
>>> + * @src: mode to copy
>>> + *
>>> + * Copy an existing mode into another mode, zeroing the
>>> + * list head of the destination mode. Typically used
>>> + * to guarantee the list head is not left with stack
>>> + * garbage in on-stack modes.
>>> + */
>>> +void drm_mode_init(struct drm_display_mode *dst, const struct drm_display_mode *src)
>>> +{
>>> +	memset(dst, 0, sizeof(*dst));
>> Why not just clear the list head? Or maybe poison it? It would be more
>> cleaner.
> Then we have two places that need to be updated if some other field
> gets introduced that needs preserving. With a full memset() we only
> have to care about drm_mode_copy(). Don't see much point in
> micro-optimizing this thing.
>
In such case DOC should be modified to avoid updating it "if some other 
field..." :)

Anyway:
Reviewed-by: Andrzej Hajda <andrzej.hajda@intel.com>

Regards
Andrzej


^ permalink raw reply	[flat|nested] 157+ messages in thread

* [Intel-gfx] ✗ Fi.CI.SPARSE: warning for drm: Review of mode copies
  2022-02-18 10:03 ` Ville Syrjala
                   ` (26 preceding siblings ...)
  (?)
@ 2022-02-18 13:43 ` Patchwork
  -1 siblings, 0 replies; 157+ messages in thread
From: Patchwork @ 2022-02-18 13:43 UTC (permalink / raw)
  To: Ville Syrjälä; +Cc: intel-gfx

== Series Details ==

Series: drm: Review of mode copies
URL   : https://patchwork.freedesktop.org/series/100394/
State : warning

== Summary ==

$ dim sparse --fast origin/drm-tip
Sparse version: v0.6.2
Fast mode used, each commit won't be checked separately.
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:319:49: error: static assertion failed: "amd_sriov_msg_pf2vf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:319:49: error: static assertion failed: "amd_sriov_msg_pf2vf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:319:49: error: static assertion failed: "amd_sriov_msg_pf2vf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:319:49: error: static assertion failed: "amd_sriov_msg_pf2vf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:319:49: error: static assertion failed: "amd_sriov_msg_pf2vf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:319:49: error: static assertion failed: "amd_sriov_msg_pf2vf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:319:49: error: static assertion failed: "amd_sriov_msg_pf2vf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:319:49: error: static assertion failed: "amd_sriov_msg_pf2vf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:319:49: error: static assertion failed: "amd_sriov_msg_pf2vf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:319:49: error: static assertion failed: "amd_sriov_msg_pf2vf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:319:49: error: static assertion failed: "amd_sriov_msg_pf2vf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:319:49: error: static assertion failed: "amd_sriov_msg_pf2vf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:319:49: error: static assertion failed: "amd_sriov_msg_pf2vf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:319:49: error: static assertion failed: "amd_sriov_msg_pf2vf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:319:49: error: static assertion failed: "amd_sriov_msg_pf2vf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:319:49: error: static assertion failed: "amd_sriov_msg_pf2vf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:319:49: error: static assertion failed: "amd_sriov_msg_pf2vf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:319:49: error: static assertion failed: "amd_sriov_msg_pf2vf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:319:49: error: static assertion failed: "amd_sriov_msg_pf2vf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:319:49: error: static assertion failed: "amd_sriov_msg_pf2vf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:319:49: error: static assertion failed: "amd_sriov_msg_pf2vf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:319:49: error: static assertion failed: "amd_sriov_msg_pf2vf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:319:49: error: static assertion failed: "amd_sriov_msg_pf2vf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:319:49: error: static assertion failed: "amd_sriov_msg_pf2vf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:319:49: error: static assertion failed: "amd_sriov_msg_pf2vf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:319:49: error: static assertion failed: "amd_sriov_msg_pf2vf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:319:49: error: static assertion failed: "amd_sriov_msg_pf2vf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:319:49: error: static assertion failed: "amd_sriov_msg_pf2vf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:319:49: error: static assertion failed: "amd_sriov_msg_pf2vf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:319:49: error: static assertion failed: "amd_sriov_msg_pf2vf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:319:49: error: static assertion failed: "amd_sriov_msg_pf2vf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:319:49: error: static assertion failed: "amd_sriov_msg_pf2vf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:319:49: error: static assertion failed: "amd_sriov_msg_pf2vf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:319:49: error: static assertion failed: "amd_sriov_msg_pf2vf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:319:49: error: static assertion failed: "amd_sriov_msg_pf2vf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:319:49: error: static assertion failed: "amd_sriov_msg_pf2vf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:319:49: error: static assertion failed: "amd_sriov_msg_pf2vf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:319:49: error: static assertion failed: "amd_sriov_msg_pf2vf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:319:49: error: static assertion failed: "amd_sriov_msg_pf2vf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:319:49: error: static assertion failed: "amd_sriov_msg_pf2vf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:319:49: error: static assertion failed: "amd_sriov_msg_pf2vf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:319:49: error: static assertion failed: "amd_sriov_msg_pf2vf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:319:49: error: static assertion failed: "amd_sriov_msg_pf2vf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:319:49: error: static assertion failed: "amd_sriov_msg_pf2vf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:319:49: error: static assertion failed: "amd_sriov_msg_pf2vf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:319:49: error: static assertion failed: "amd_sriov_msg_pf2vf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:319:49: error: static assertion failed: "amd_sriov_msg_pf2vf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:319:49: error: static assertion failed: "amd_sriov_msg_pf2vf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:319:49: error: static assertion failed: "amd_sriov_msg_pf2vf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:319:49: error: static assertion failed: "amd_sriov_msg_pf2vf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:319:49: error: static assertion failed: "amd_sriov_msg_pf2vf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:319:49: error: static assertion failed: "amd_sriov_msg_pf2vf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:319:49: error: static assertion failed: "amd_sriov_msg_pf2vf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:319:49: error: static assertion failed: "amd_sriov_msg_pf2vf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:319:49: error: static assertion failed: "amd_sriov_msg_pf2vf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:319:49: error: static assertion failed: "amd_sriov_msg_pf2vf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:319:49: error: static assertion failed: "amd_sriov_msg_pf2vf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:319:49: error: static assertion failed: "amd_sriov_msg_pf2vf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:319:49: error: static assertion failed: "amd_sriov_msg_pf2vf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:319:49: error: static assertion failed: "amd_sriov_msg_pf2vf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:319:49: error: static assertion failed: "amd_sriov_msg_pf2vf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:319:49: error: static assertion failed: "amd_sriov_msg_pf2vf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:319:49: error: static assertion failed: "amd_sriov_msg_pf2vf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:319:49: error: static assertion failed: "amd_sriov_msg_pf2vf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:319:49: error: static assertion failed: "amd_sriov_msg_pf2vf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:319:49: error: static assertion failed: "amd_sriov_msg_pf2vf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:319:49: error: static assertion failed: "amd_sriov_msg_pf2vf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:319:49: error: static assertion failed: "amd_sriov_msg_pf2vf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:319:49: error: static assertion failed: "amd_sriov_msg_pf2vf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:319:49: error: static assertion failed: "amd_sriov_msg_pf2vf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:319:49: error: static assertion failed: "amd_sriov_msg_pf2vf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:319:49: error: static assertion failed: "amd_sriov_msg_pf2vf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:319:49: error: static assertion failed: "amd_sriov_msg_pf2vf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:319:49: error: static assertion failed: "amd_sriov_msg_pf2vf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:319:49: error: static assertion failed: "amd_sriov_msg_pf2vf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:319:49: error: static assertion failed: "amd_sriov_msg_pf2vf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:319:49: error: static assertion failed: "amd_sriov_msg_pf2vf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:319:49: error: static assertion failed: "amd_sriov_msg_pf2vf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:319:49: error: static assertion failed: "amd_sriov_msg_pf2vf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:319:49: error: static assertion failed: "amd_sriov_msg_pf2vf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:319:49: error: static assertion failed: "amd_sriov_msg_pf2vf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:319:49: error: static assertion failed: "amd_sriov_msg_pf2vf_info must be 1 KB"
+./drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:319:49: error: static assertion failed: "amd_sriov_msg_pf2vf_info must be 1 KB"
+drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:1420:25: error: incompatible types in comparison expression (different address spaces):
+drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:1420:25:    struct dma_fence *
+drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:1420:25:    struct dma_fence [noderef] __rcu *
+drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:1421:17: error: incompatible types in comparison expression (different address spaces):
+drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:1421:17:    struct dma_fence *
+drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:1421:17:    struct dma_fence [noderef] __rcu *
+drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:1480:17: error: incompatible types in comparison expression (different address spaces):
+drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:1480:17:    struct dma_fence *
+drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:1480:17:    struct dma_fence [noderef] __rcu *
+drivers/gpu/drm/amd/amdgpu/amdgpu_device.c:356:16: error: incompatible types in comparison expression (different type sizes):
+drivers/gpu/drm/amd/amdgpu/amdgpu_device.c:356:16:    unsigned long *
+drivers/gpu/drm/amd/amdgpu/amdgpu_device.c:356:16:    unsigned long long *
+drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c:295:25: error: incompatible types in comparison expression (different address spaces):
+drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c:295:25:    struct dma_fence *
+drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c:295:25:    struct dma_fence [noderef] __rcu *
+drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c:296:17: error: incompatible types in comparison expression (different address spaces):
+drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c:296:17:    struct dma_fence *
+drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c:296:17:    struct dma_fence [noderef] __rcu *
+drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c:345:17: error: incompatible types in comparison expression (different address spaces):
+drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c:345:17:    struct dma_fence *
+drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c:345:17:    struct dma_fence [noderef] __rcu *
+drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c:596:23: error: incompatible types in comparison expression (different address spaces):
+drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c:596:23:    struct dma_fence *
+drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c:596:23:    struct dma_fence [noderef] __rcu *
+drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c:598:25: error: incompatible types in comparison expression (different address spaces):
+drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c:598:25:    struct dma_fence *
+drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c:598:25:    struct dma_fence [noderef] __rcu *
+drivers/gpu/drm/amd/amdgpu/amdgpu_mca.c:120:1: warning: no newline at end of file
+drivers/gpu/drm/amd/amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+drivers/gpu/drm/amd/amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+drivers/gpu/drm/amd/amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+drivers/gpu/drm/amd/amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+drivers/gpu/drm/amd/amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+drivers/gpu/drm/amd/amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+drivers/gpu/drm/amd/amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+drivers/gpu/drm/amd/amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+drivers/gpu/drm/amd/amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+drivers/gpu/drm/amd/amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+drivers/gpu/drm/amd/amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+drivers/gpu/drm/amd/amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+drivers/gpu/drm/amd/amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+drivers/gpu/drm/amd/amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+drivers/gpu/drm/amd/amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+drivers/gpu/drm/amd/amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+drivers/gpu/drm/amd/amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+drivers/gpu/drm/amd/amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+drivers/gpu/drm/amd/amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+drivers/gpu/drm/amd/amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+drivers/gpu/drm/amd/amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+drivers/gpu/drm/amd/amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+drivers/gpu/drm/amd/amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+drivers/gpu/drm/amd/amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+drivers/gpu/drm/amd/amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+drivers/gpu/drm/amd/amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+drivers/gpu/drm/amd/amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+drivers/gpu/drm/amd/amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+drivers/gpu/drm/amd/amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+drivers/gpu/drm/amd/amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+drivers/gpu/drm/amd/amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+drivers/gpu/drm/amd/amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+drivers/gpu/drm/amd/amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+drivers/gpu/drm/amd/amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+drivers/gpu/drm/amd/amdgpu/amdgv_sriovmsg.h:315:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
+drivers/gpu/drm/amd/amdgpu/amdgv_sriovmsg.h:315



^ permalink raw reply	[flat|nested] 157+ messages in thread

* [Intel-gfx] ✓ Fi.CI.BAT: success for drm: Review of mode copies
  2022-02-18 10:03 ` Ville Syrjala
                   ` (27 preceding siblings ...)
  (?)
@ 2022-02-18 14:16 ` Patchwork
  -1 siblings, 0 replies; 157+ messages in thread
From: Patchwork @ 2022-02-18 14:16 UTC (permalink / raw)
  To: Ville Syrjälä; +Cc: intel-gfx

[-- Attachment #1: Type: text/plain, Size: 9704 bytes --]

== Series Details ==

Series: drm: Review of mode copies
URL   : https://patchwork.freedesktop.org/series/100394/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_11248 -> Patchwork_22330
====================================================

Summary
-------

  **SUCCESS**

  No regressions found.

  External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/index.html

Participating hosts (45 -> 44)
------------------------------

  Additional (1): fi-pnv-d510 
  Missing    (2): fi-bsw-cyan shard-tglu 

Possible new issues
-------------------

  Here are the unknown changes that may have been introduced in Patchwork_22330:

### IGT changes ###

#### Suppressed ####

  The following results come from untrusted machines, tests, or statuses.
  They do not affect the overall result.

  * igt@i915_selftest@live@hangcheck:
    - {bat-adlp-6}:       [PASS][1] -> [INCOMPLETE][2]
   [1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11248/bat-adlp-6/igt@i915_selftest@live@hangcheck.html
   [2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/bat-adlp-6/igt@i915_selftest@live@hangcheck.html

  
Known issues
------------

  Here are the changes found in Patchwork_22330 that come from known issues:

### IGT changes ###

#### Issues hit ####

  * igt@amdgpu/amd_cs_nop@sync-fork-compute0:
    - fi-snb-2600:        NOTRUN -> [SKIP][3] ([fdo#109271]) +17 similar issues
   [3]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/fi-snb-2600/igt@amdgpu/amd_cs_nop@sync-fork-compute0.html

  * igt@gem_exec_suspend@basic-s3@smem:
    - fi-bdw-5557u:       [PASS][4] -> [INCOMPLETE][5] ([i915#146])
   [4]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11248/fi-bdw-5557u/igt@gem_exec_suspend@basic-s3@smem.html
   [5]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/fi-bdw-5557u/igt@gem_exec_suspend@basic-s3@smem.html

  * igt@gem_huc_copy@huc-copy:
    - fi-skl-6600u:       NOTRUN -> [SKIP][6] ([fdo#109271] / [i915#2190])
   [6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/fi-skl-6600u/igt@gem_huc_copy@huc-copy.html
    - fi-pnv-d510:        NOTRUN -> [SKIP][7] ([fdo#109271]) +57 similar issues
   [7]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/fi-pnv-d510/igt@gem_huc_copy@huc-copy.html

  * igt@gem_lmem_swapping@verify-random:
    - fi-skl-6600u:       NOTRUN -> [SKIP][8] ([fdo#109271] / [i915#4613]) +3 similar issues
   [8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/fi-skl-6600u/igt@gem_lmem_swapping@verify-random.html

  * igt@i915_selftest@live@hangcheck:
    - fi-hsw-4770:        [PASS][9] -> [INCOMPLETE][10] ([i915#3303])
   [9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11248/fi-hsw-4770/igt@i915_selftest@live@hangcheck.html
   [10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/fi-hsw-4770/igt@i915_selftest@live@hangcheck.html

  * igt@i915_selftest@live@requests:
    - fi-blb-e6850:       [PASS][11] -> [DMESG-FAIL][12] ([i915#4528] / [i915#5026])
   [11]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11248/fi-blb-e6850/igt@i915_selftest@live@requests.html
   [12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/fi-blb-e6850/igt@i915_selftest@live@requests.html

  * igt@kms_chamelium@vga-edid-read:
    - fi-skl-6600u:       NOTRUN -> [SKIP][13] ([fdo#109271] / [fdo#111827]) +8 similar issues
   [13]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/fi-skl-6600u/igt@kms_chamelium@vga-edid-read.html

  * igt@kms_cursor_legacy@basic-busy-flip-before-cursor-legacy:
    - fi-skl-6600u:       NOTRUN -> [SKIP][14] ([fdo#109271]) +2 similar issues
   [14]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/fi-skl-6600u/igt@kms_cursor_legacy@basic-busy-flip-before-cursor-legacy.html

  * igt@kms_pipe_crc_basic@compare-crc-sanitycheck-pipe-d:
    - fi-skl-6600u:       NOTRUN -> [SKIP][15] ([fdo#109271] / [i915#533])
   [15]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/fi-skl-6600u/igt@kms_pipe_crc_basic@compare-crc-sanitycheck-pipe-d.html

  * igt@kms_psr@primary_page_flip:
    - fi-skl-6600u:       NOTRUN -> [FAIL][16] ([i915#4547])
   [16]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/fi-skl-6600u/igt@kms_psr@primary_page_flip.html

  * igt@runner@aborted:
    - fi-hsw-4770:        NOTRUN -> [FAIL][17] ([fdo#109271] / [i915#1436] / [i915#4312])
   [17]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/fi-hsw-4770/igt@runner@aborted.html
    - fi-blb-e6850:       NOTRUN -> [FAIL][18] ([fdo#109271] / [i915#2403] / [i915#2426] / [i915#4312])
   [18]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/fi-blb-e6850/igt@runner@aborted.html
    - fi-skl-6600u:       NOTRUN -> [FAIL][19] ([i915#4312])
   [19]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/fi-skl-6600u/igt@runner@aborted.html

  
#### Possible fixes ####

  * igt@i915_selftest@live@hangcheck:
    - bat-dg1-6:          [DMESG-FAIL][20] ([i915#4494] / [i915#4957]) -> [PASS][21]
   [20]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11248/bat-dg1-6/igt@i915_selftest@live@hangcheck.html
   [21]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/bat-dg1-6/igt@i915_selftest@live@hangcheck.html
    - fi-snb-2600:        [INCOMPLETE][22] ([i915#3921]) -> [PASS][23]
   [22]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11248/fi-snb-2600/igt@i915_selftest@live@hangcheck.html
   [23]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/fi-snb-2600/igt@i915_selftest@live@hangcheck.html

  * igt@kms_frontbuffer_tracking@basic:
    - fi-cml-u2:          [DMESG-WARN][24] ([i915#4269]) -> [PASS][25]
   [24]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11248/fi-cml-u2/igt@kms_frontbuffer_tracking@basic.html
   [25]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/fi-cml-u2/igt@kms_frontbuffer_tracking@basic.html

  * igt@kms_pipe_crc_basic@read-crc-pipe-b:
    - fi-cfl-8109u:       [DMESG-WARN][26] ([i915#295]) -> [PASS][27] +12 similar issues
   [26]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11248/fi-cfl-8109u/igt@kms_pipe_crc_basic@read-crc-pipe-b.html
   [27]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/fi-cfl-8109u/igt@kms_pipe_crc_basic@read-crc-pipe-b.html

  
#### Warnings ####

  * igt@i915_selftest@live@hangcheck:
    - bat-dg1-5:          [DMESG-FAIL][28] ([i915#4957]) -> [DMESG-FAIL][29] ([i915#4494] / [i915#4957])
   [28]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11248/bat-dg1-5/igt@i915_selftest@live@hangcheck.html
   [29]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/bat-dg1-5/igt@i915_selftest@live@hangcheck.html

  
  {name}: This element is suppressed. This means it is ignored when computing
          the status of the difference (SUCCESS, WARNING, or FAILURE).

  [fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
  [fdo#111827]: https://bugs.freedesktop.org/show_bug.cgi?id=111827
  [i915#1436]: https://gitlab.freedesktop.org/drm/intel/issues/1436
  [i915#146]: https://gitlab.freedesktop.org/drm/intel/issues/146
  [i915#2190]: https://gitlab.freedesktop.org/drm/intel/issues/2190
  [i915#2403]: https://gitlab.freedesktop.org/drm/intel/issues/2403
  [i915#2426]: https://gitlab.freedesktop.org/drm/intel/issues/2426
  [i915#295]: https://gitlab.freedesktop.org/drm/intel/issues/295
  [i915#3303]: https://gitlab.freedesktop.org/drm/intel/issues/3303
  [i915#3921]: https://gitlab.freedesktop.org/drm/intel/issues/3921
  [i915#4269]: https://gitlab.freedesktop.org/drm/intel/issues/4269
  [i915#4312]: https://gitlab.freedesktop.org/drm/intel/issues/4312
  [i915#4494]: https://gitlab.freedesktop.org/drm/intel/issues/4494
  [i915#4528]: https://gitlab.freedesktop.org/drm/intel/issues/4528
  [i915#4547]: https://gitlab.freedesktop.org/drm/intel/issues/4547
  [i915#4613]: https://gitlab.freedesktop.org/drm/intel/issues/4613
  [i915#4957]: https://gitlab.freedesktop.org/drm/intel/issues/4957
  [i915#5026]: https://gitlab.freedesktop.org/drm/intel/issues/5026
  [i915#533]: https://gitlab.freedesktop.org/drm/intel/issues/533


Build changes
-------------

  * Linux: CI_DRM_11248 -> Patchwork_22330

  CI-20190529: 20190529
  CI_DRM_11248: 8861c3684bdcd4c8cb8385fbc37a2d9033dff955 @ git://anongit.freedesktop.org/gfx-ci/linux
  IGT_6347: 37ea4c86f97c0e05fcb6b04cff72ec927930536e @ https://gitlab.freedesktop.org/drm/igt-gpu-tools.git
  Patchwork_22330: 950fc955a036ae574828aa14203ed9fc07fe0900 @ git://anongit.freedesktop.org/gfx-ci/linux


== Linux commits ==

950fc955a036 drm: Use drm_mode_copy()
b94948d78e9f drm: Use drm_mode_init() for on-stack modes
f84271d930db drm/panel: Use drm_mode_duplicate()
276d24d1417a drm/i915: Use drm_mode_copy()
504e28133d44 drm/i915: Use drm_mode_init() for on-stack modes
b6c95d6ebb89 drm/vc4: Use drm_mode_copy()
c9b80ec58e27 drm/tilcdc: Use drm_mode_copy()
7fca7fc81038 drm/sti: Use drm_mode_copy()
8638c264f5e7 drm/rockchip: Use drm_mode_copy()
4053f4603d4b drm/mtk: Use drm_mode_init() for on-stack modes
b89c110ef4dc drm/msm: Use drm_mode_copy()
0da547ebf332 drm/msm: Use drm_mode_init() for on-stack modes
689422fa9876 drm/msm: Nuke weird on stack mode copy
0914ad74172e drm/imx: Use drm_mode_duplicate()
b3e936908aec drm/hisilicon: Use drm_mode_init() for on-stack modes
89b7446299bc drm/gma500: Use drm_mode_copy()
006000c65793 drm/bridge: Use drm_mode_copy()
ffdcd369784b drm/radeon: Use drm_mode_copy()
a00ccc3d0a7c drm/amdgpu: Use drm_mode_copy()
53ab22b286e1 drm/amdgpu: Use drm_mode_init() for on-stack modes
8b58cd52cab8 drm/amdgpu: Remove pointless on stack mode copies
ec8eac53df11 drm: Add drm_mode_init()

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/index.html

[-- Attachment #2: Type: text/html, Size: 11759 bytes --]

^ permalink raw reply	[flat|nested] 157+ messages in thread

* Re: [PATCH 02/22] drm/amdgpu: Remove pointless on stack mode copies
  2022-02-18 10:03   ` [Intel-gfx] " Ville Syrjala
@ 2022-02-18 16:28     ` Harry Wentland
  -1 siblings, 0 replies; 157+ messages in thread
From: Harry Wentland @ 2022-02-18 16:28 UTC (permalink / raw)
  To: Ville Syrjala, dri-devel
  Cc: Leo Li, intel-gfx, Rodrigo Siqueira, amd-gfx, Nikola Cornij,
	Aurabindo Pillai, Alex Deucher



On 2022-02-18 05:03, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> These on stack copies of the modes appear to be pointless.
> Just look at the originals directly.
> 
> Cc: Harry Wentland <harry.wentland@amd.com>
> Cc: Leo Li <sunpeng.li@amd.com>
> Cc: Rodrigo Siqueira <Rodrigo.Siqueira@amd.com>
> Cc: Alex Deucher <alexander.deucher@amd.com>
> Cc: amd-gfx@lists.freedesktop.org
> Cc: Nikola Cornij <nikola.cornij@amd.com>
> Cc: Aurabindo Pillai <aurabindo.pillai@amd.com>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

Reviewed-by: Harry Wentland <harry.wentland@amd.com>

Harry

> ---
>  .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 32 +++++++++----------
>  1 file changed, 16 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> index 21dba337dab0..65aab0d086b6 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> @@ -10139,27 +10139,27 @@ static bool
>  is_timing_unchanged_for_freesync(struct drm_crtc_state *old_crtc_state,
>  				 struct drm_crtc_state *new_crtc_state)
>  {
> -	struct drm_display_mode old_mode, new_mode;
> +	const struct drm_display_mode *old_mode, *new_mode;
>  
>  	if (!old_crtc_state || !new_crtc_state)
>  		return false;
>  
> -	old_mode = old_crtc_state->mode;
> -	new_mode = new_crtc_state->mode;
> +	old_mode = &old_crtc_state->mode;
> +	new_mode = &new_crtc_state->mode;
>  
> -	if (old_mode.clock       == new_mode.clock &&
> -	    old_mode.hdisplay    == new_mode.hdisplay &&
> -	    old_mode.vdisplay    == new_mode.vdisplay &&
> -	    old_mode.htotal      == new_mode.htotal &&
> -	    old_mode.vtotal      != new_mode.vtotal &&
> -	    old_mode.hsync_start == new_mode.hsync_start &&
> -	    old_mode.vsync_start != new_mode.vsync_start &&
> -	    old_mode.hsync_end   == new_mode.hsync_end &&
> -	    old_mode.vsync_end   != new_mode.vsync_end &&
> -	    old_mode.hskew       == new_mode.hskew &&
> -	    old_mode.vscan       == new_mode.vscan &&
> -	    (old_mode.vsync_end - old_mode.vsync_start) ==
> -	    (new_mode.vsync_end - new_mode.vsync_start))
> +	if (old_mode->clock       == new_mode->clock &&
> +	    old_mode->hdisplay    == new_mode->hdisplay &&
> +	    old_mode->vdisplay    == new_mode->vdisplay &&
> +	    old_mode->htotal      == new_mode->htotal &&
> +	    old_mode->vtotal      != new_mode->vtotal &&
> +	    old_mode->hsync_start == new_mode->hsync_start &&
> +	    old_mode->vsync_start != new_mode->vsync_start &&
> +	    old_mode->hsync_end   == new_mode->hsync_end &&
> +	    old_mode->vsync_end   != new_mode->vsync_end &&
> +	    old_mode->hskew       == new_mode->hskew &&
> +	    old_mode->vscan       == new_mode->vscan &&
> +	    (old_mode->vsync_end - old_mode->vsync_start) ==
> +	    (new_mode->vsync_end - new_mode->vsync_start))
>  		return true;
>  
>  	return false;


^ permalink raw reply	[flat|nested] 157+ messages in thread

* Re: [Intel-gfx] [PATCH 02/22] drm/amdgpu: Remove pointless on stack mode copies
@ 2022-02-18 16:28     ` Harry Wentland
  0 siblings, 0 replies; 157+ messages in thread
From: Harry Wentland @ 2022-02-18 16:28 UTC (permalink / raw)
  To: Ville Syrjala, dri-devel
  Cc: Leo Li, intel-gfx, Rodrigo Siqueira, amd-gfx, Nikola Cornij,
	Aurabindo Pillai, Alex Deucher



On 2022-02-18 05:03, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> These on stack copies of the modes appear to be pointless.
> Just look at the originals directly.
> 
> Cc: Harry Wentland <harry.wentland@amd.com>
> Cc: Leo Li <sunpeng.li@amd.com>
> Cc: Rodrigo Siqueira <Rodrigo.Siqueira@amd.com>
> Cc: Alex Deucher <alexander.deucher@amd.com>
> Cc: amd-gfx@lists.freedesktop.org
> Cc: Nikola Cornij <nikola.cornij@amd.com>
> Cc: Aurabindo Pillai <aurabindo.pillai@amd.com>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

Reviewed-by: Harry Wentland <harry.wentland@amd.com>

Harry

> ---
>  .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 32 +++++++++----------
>  1 file changed, 16 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> index 21dba337dab0..65aab0d086b6 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> @@ -10139,27 +10139,27 @@ static bool
>  is_timing_unchanged_for_freesync(struct drm_crtc_state *old_crtc_state,
>  				 struct drm_crtc_state *new_crtc_state)
>  {
> -	struct drm_display_mode old_mode, new_mode;
> +	const struct drm_display_mode *old_mode, *new_mode;
>  
>  	if (!old_crtc_state || !new_crtc_state)
>  		return false;
>  
> -	old_mode = old_crtc_state->mode;
> -	new_mode = new_crtc_state->mode;
> +	old_mode = &old_crtc_state->mode;
> +	new_mode = &new_crtc_state->mode;
>  
> -	if (old_mode.clock       == new_mode.clock &&
> -	    old_mode.hdisplay    == new_mode.hdisplay &&
> -	    old_mode.vdisplay    == new_mode.vdisplay &&
> -	    old_mode.htotal      == new_mode.htotal &&
> -	    old_mode.vtotal      != new_mode.vtotal &&
> -	    old_mode.hsync_start == new_mode.hsync_start &&
> -	    old_mode.vsync_start != new_mode.vsync_start &&
> -	    old_mode.hsync_end   == new_mode.hsync_end &&
> -	    old_mode.vsync_end   != new_mode.vsync_end &&
> -	    old_mode.hskew       == new_mode.hskew &&
> -	    old_mode.vscan       == new_mode.vscan &&
> -	    (old_mode.vsync_end - old_mode.vsync_start) ==
> -	    (new_mode.vsync_end - new_mode.vsync_start))
> +	if (old_mode->clock       == new_mode->clock &&
> +	    old_mode->hdisplay    == new_mode->hdisplay &&
> +	    old_mode->vdisplay    == new_mode->vdisplay &&
> +	    old_mode->htotal      == new_mode->htotal &&
> +	    old_mode->vtotal      != new_mode->vtotal &&
> +	    old_mode->hsync_start == new_mode->hsync_start &&
> +	    old_mode->vsync_start != new_mode->vsync_start &&
> +	    old_mode->hsync_end   == new_mode->hsync_end &&
> +	    old_mode->vsync_end   != new_mode->vsync_end &&
> +	    old_mode->hskew       == new_mode->hskew &&
> +	    old_mode->vscan       == new_mode->vscan &&
> +	    (old_mode->vsync_end - old_mode->vsync_start) ==
> +	    (new_mode->vsync_end - new_mode->vsync_start))
>  		return true;
>  
>  	return false;


^ permalink raw reply	[flat|nested] 157+ messages in thread

* Re: [PATCH 03/22] drm/amdgpu: Use drm_mode_init() for on-stack modes
  2022-02-18 10:03   ` [Intel-gfx] " Ville Syrjala
@ 2022-02-18 16:30     ` Harry Wentland
  -1 siblings, 0 replies; 157+ messages in thread
From: Harry Wentland @ 2022-02-18 16:30 UTC (permalink / raw)
  To: Ville Syrjala, dri-devel
  Cc: Leo Li, Alex Deucher, intel-gfx, Rodrigo Siqueira, amd-gfx



On 2022-02-18 05:03, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> Initialize on-stack modes with drm_mode_init() to guarantee
> no stack garbage in the list head, or that we aren't copying
> over another mode's list head.
> 
> Based on the following cocci script, with manual fixups:
> @decl@
> identifier M;
> expression E;
> @@
> - struct drm_display_mode M = E;
> + struct drm_display_mode M;
> 
> @@
> identifier decl.M;
> expression decl.E;
> statement S, S1;
> @@
> struct drm_display_mode M;
> ... when != S
> + drm_mode_init(&M, &E);
> +
> S1
> 
> @@
> expression decl.E;
> @@
> - &*E
> + E
> 
> Cc: Harry Wentland <harry.wentland@amd.com>
> Cc: Leo Li <sunpeng.li@amd.com>
> Cc: Rodrigo Siqueira <Rodrigo.Siqueira@amd.com>
> Cc: Alex Deucher <alexander.deucher@amd.com>
> Cc: amd-gfx@lists.freedesktop.org
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

Reviewed-by: Harry Wentland <harry.wentland@amd.com>

Harry

> ---
>  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> index 65aab0d086b6..bd23c9e481eb 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> @@ -6361,7 +6361,7 @@ create_stream_for_sink(struct amdgpu_dm_connector *aconnector,
>  	const struct drm_connector_state *con_state =
>  		dm_state ? &dm_state->base : NULL;
>  	struct dc_stream_state *stream = NULL;
> -	struct drm_display_mode mode = *drm_mode;
> +	struct drm_display_mode mode;
>  	struct drm_display_mode saved_mode;
>  	struct drm_display_mode *freesync_mode = NULL;
>  	bool native_mode_found = false;
> @@ -6374,6 +6374,7 @@ create_stream_for_sink(struct amdgpu_dm_connector *aconnector,
>  #endif
>  	struct dc_sink *sink = NULL;
>  
> +	drm_mode_init(&mode, drm_mode);
>  	memset(&saved_mode, 0, sizeof(saved_mode));
>  
>  	if (aconnector == NULL) {


^ permalink raw reply	[flat|nested] 157+ messages in thread

* Re: [Intel-gfx] [PATCH 03/22] drm/amdgpu: Use drm_mode_init() for on-stack modes
@ 2022-02-18 16:30     ` Harry Wentland
  0 siblings, 0 replies; 157+ messages in thread
From: Harry Wentland @ 2022-02-18 16:30 UTC (permalink / raw)
  To: Ville Syrjala, dri-devel
  Cc: Leo Li, Alex Deucher, intel-gfx, Rodrigo Siqueira, amd-gfx



On 2022-02-18 05:03, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> Initialize on-stack modes with drm_mode_init() to guarantee
> no stack garbage in the list head, or that we aren't copying
> over another mode's list head.
> 
> Based on the following cocci script, with manual fixups:
> @decl@
> identifier M;
> expression E;
> @@
> - struct drm_display_mode M = E;
> + struct drm_display_mode M;
> 
> @@
> identifier decl.M;
> expression decl.E;
> statement S, S1;
> @@
> struct drm_display_mode M;
> ... when != S
> + drm_mode_init(&M, &E);
> +
> S1
> 
> @@
> expression decl.E;
> @@
> - &*E
> + E
> 
> Cc: Harry Wentland <harry.wentland@amd.com>
> Cc: Leo Li <sunpeng.li@amd.com>
> Cc: Rodrigo Siqueira <Rodrigo.Siqueira@amd.com>
> Cc: Alex Deucher <alexander.deucher@amd.com>
> Cc: amd-gfx@lists.freedesktop.org
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

Reviewed-by: Harry Wentland <harry.wentland@amd.com>

Harry

> ---
>  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> index 65aab0d086b6..bd23c9e481eb 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> @@ -6361,7 +6361,7 @@ create_stream_for_sink(struct amdgpu_dm_connector *aconnector,
>  	const struct drm_connector_state *con_state =
>  		dm_state ? &dm_state->base : NULL;
>  	struct dc_stream_state *stream = NULL;
> -	struct drm_display_mode mode = *drm_mode;
> +	struct drm_display_mode mode;
>  	struct drm_display_mode saved_mode;
>  	struct drm_display_mode *freesync_mode = NULL;
>  	bool native_mode_found = false;
> @@ -6374,6 +6374,7 @@ create_stream_for_sink(struct amdgpu_dm_connector *aconnector,
>  #endif
>  	struct dc_sink *sink = NULL;
>  
> +	drm_mode_init(&mode, drm_mode);
>  	memset(&saved_mode, 0, sizeof(saved_mode));
>  
>  	if (aconnector == NULL) {


^ permalink raw reply	[flat|nested] 157+ messages in thread

* Re: [PATCH 04/22] drm/amdgpu: Use drm_mode_copy()
  2022-02-18 10:03   ` [Intel-gfx] " Ville Syrjala
@ 2022-02-18 16:32     ` Harry Wentland
  -1 siblings, 0 replies; 157+ messages in thread
From: Harry Wentland @ 2022-02-18 16:32 UTC (permalink / raw)
  To: Ville Syrjala, dri-devel
  Cc: Leo Li, Alex Deucher, intel-gfx, Rodrigo Siqueira, amd-gfx



On 2022-02-18 05:03, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> struct drm_display_mode embeds a list head, so overwriting
> the full struct with another one will corrupt the list
> (if the destination mode is on a list). Use drm_mode_copy()
> instead which explicitly preserves the list head of
> the destination mode.
> 
> Even if we know the destination mode is not on any list
> using drm_mode_copy() seems decent as it sets a good
> example. Bad examples of not using it might eventually
> get copied into code where preserving the list head
> actually matters.
> 
> Obviously one case not covered here is when the mode
> itself is embedded in a larger structure and the whole
> structure is copied. But if we are careful when copying
> into modes embedded in structures I think we can be a
> little more reassured that bogus list heads haven't been
> propagated in.
> 
> @is_mode_copy@
> @@
> drm_mode_copy(...)
> {
> ...
> }
> 
> @depends on !is_mode_copy@
> struct drm_display_mode *mode;
> expression E, S;
> @@
> (
> - *mode = E
> + drm_mode_copy(mode, &E)
> |
> - memcpy(mode, E, S)
> + drm_mode_copy(mode, E)
> )
> 
> @depends on !is_mode_copy@
> struct drm_display_mode mode;
> expression E;
> @@
> (
> - mode = E
> + drm_mode_copy(&mode, &E)
> |
> - memcpy(&mode, E, S)
> + drm_mode_copy(&mode, E)
> )
> 
> @@
> struct drm_display_mode *mode;
> @@
> - &*mode
> + mode
> 
> Cc: Alex Deucher <alexander.deucher@amd.com>
> Cc: Harry Wentland <harry.wentland@amd.com>
> Cc: Leo Li <sunpeng.li@amd.com>
> Cc: Rodrigo Siqueira <Rodrigo.Siqueira@amd.com>
> Cc: amd-gfx@lists.freedesktop.org
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

Reviewed-by: Harry Wentland <harry.wentland@amd.com>

Harry

> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c    | 4 ++--
>  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 6 +++---
>  2 files changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
> index fa20261aa928..673078faa27a 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
> @@ -626,7 +626,7 @@ amdgpu_connector_fixup_lcd_native_mode(struct drm_encoder *encoder,
>  		if (mode->type & DRM_MODE_TYPE_PREFERRED) {
>  			if (mode->hdisplay != native_mode->hdisplay ||
>  			    mode->vdisplay != native_mode->vdisplay)
> -				memcpy(native_mode, mode, sizeof(*mode));
> +				drm_mode_copy(native_mode, mode);
>  		}
>  	}
>  
> @@ -635,7 +635,7 @@ amdgpu_connector_fixup_lcd_native_mode(struct drm_encoder *encoder,
>  		list_for_each_entry_safe(mode, t, &connector->probed_modes, head) {
>  			if (mode->hdisplay == native_mode->hdisplay &&
>  			    mode->vdisplay == native_mode->vdisplay) {
> -				*native_mode = *mode;
> +				drm_mode_copy(native_mode, mode);
>  				drm_mode_set_crtcinfo(native_mode, CRTC_INTERLACE_HALVE_V);
>  				DRM_DEBUG_KMS("Determined LVDS native mode details from EDID\n");
>  				break;
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> index bd23c9e481eb..514280699ad5 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> @@ -6318,7 +6318,7 @@ get_highest_refresh_rate_mode(struct amdgpu_dm_connector *aconnector,
>  		}
>  	}
>  
> -	aconnector->freesync_vid_base = *m_pref;
> +	drm_mode_copy(&aconnector->freesync_vid_base, m_pref);
>  	return m_pref;
>  }
>  
> @@ -6432,8 +6432,8 @@ create_stream_for_sink(struct amdgpu_dm_connector *aconnector,
>  		recalculate_timing = is_freesync_video_mode(&mode, aconnector);
>  		if (recalculate_timing) {
>  			freesync_mode = get_highest_refresh_rate_mode(aconnector, false);
> -			saved_mode = mode;
> -			mode = *freesync_mode;
> +			drm_mode_copy(&saved_mode, &mode);
> +			drm_mode_copy(&mode, freesync_mode);
>  		} else {
>  			decide_crtc_timing_for_drm_display_mode(
>  				&mode, preferred_mode, scale);


^ permalink raw reply	[flat|nested] 157+ messages in thread

* Re: [Intel-gfx] [PATCH 04/22] drm/amdgpu: Use drm_mode_copy()
@ 2022-02-18 16:32     ` Harry Wentland
  0 siblings, 0 replies; 157+ messages in thread
From: Harry Wentland @ 2022-02-18 16:32 UTC (permalink / raw)
  To: Ville Syrjala, dri-devel
  Cc: Leo Li, Alex Deucher, intel-gfx, Rodrigo Siqueira, amd-gfx



On 2022-02-18 05:03, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> struct drm_display_mode embeds a list head, so overwriting
> the full struct with another one will corrupt the list
> (if the destination mode is on a list). Use drm_mode_copy()
> instead which explicitly preserves the list head of
> the destination mode.
> 
> Even if we know the destination mode is not on any list
> using drm_mode_copy() seems decent as it sets a good
> example. Bad examples of not using it might eventually
> get copied into code where preserving the list head
> actually matters.
> 
> Obviously one case not covered here is when the mode
> itself is embedded in a larger structure and the whole
> structure is copied. But if we are careful when copying
> into modes embedded in structures I think we can be a
> little more reassured that bogus list heads haven't been
> propagated in.
> 
> @is_mode_copy@
> @@
> drm_mode_copy(...)
> {
> ...
> }
> 
> @depends on !is_mode_copy@
> struct drm_display_mode *mode;
> expression E, S;
> @@
> (
> - *mode = E
> + drm_mode_copy(mode, &E)
> |
> - memcpy(mode, E, S)
> + drm_mode_copy(mode, E)
> )
> 
> @depends on !is_mode_copy@
> struct drm_display_mode mode;
> expression E;
> @@
> (
> - mode = E
> + drm_mode_copy(&mode, &E)
> |
> - memcpy(&mode, E, S)
> + drm_mode_copy(&mode, E)
> )
> 
> @@
> struct drm_display_mode *mode;
> @@
> - &*mode
> + mode
> 
> Cc: Alex Deucher <alexander.deucher@amd.com>
> Cc: Harry Wentland <harry.wentland@amd.com>
> Cc: Leo Li <sunpeng.li@amd.com>
> Cc: Rodrigo Siqueira <Rodrigo.Siqueira@amd.com>
> Cc: amd-gfx@lists.freedesktop.org
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

Reviewed-by: Harry Wentland <harry.wentland@amd.com>

Harry

> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c    | 4 ++--
>  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 6 +++---
>  2 files changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
> index fa20261aa928..673078faa27a 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
> @@ -626,7 +626,7 @@ amdgpu_connector_fixup_lcd_native_mode(struct drm_encoder *encoder,
>  		if (mode->type & DRM_MODE_TYPE_PREFERRED) {
>  			if (mode->hdisplay != native_mode->hdisplay ||
>  			    mode->vdisplay != native_mode->vdisplay)
> -				memcpy(native_mode, mode, sizeof(*mode));
> +				drm_mode_copy(native_mode, mode);
>  		}
>  	}
>  
> @@ -635,7 +635,7 @@ amdgpu_connector_fixup_lcd_native_mode(struct drm_encoder *encoder,
>  		list_for_each_entry_safe(mode, t, &connector->probed_modes, head) {
>  			if (mode->hdisplay == native_mode->hdisplay &&
>  			    mode->vdisplay == native_mode->vdisplay) {
> -				*native_mode = *mode;
> +				drm_mode_copy(native_mode, mode);
>  				drm_mode_set_crtcinfo(native_mode, CRTC_INTERLACE_HALVE_V);
>  				DRM_DEBUG_KMS("Determined LVDS native mode details from EDID\n");
>  				break;
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> index bd23c9e481eb..514280699ad5 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> @@ -6318,7 +6318,7 @@ get_highest_refresh_rate_mode(struct amdgpu_dm_connector *aconnector,
>  		}
>  	}
>  
> -	aconnector->freesync_vid_base = *m_pref;
> +	drm_mode_copy(&aconnector->freesync_vid_base, m_pref);
>  	return m_pref;
>  }
>  
> @@ -6432,8 +6432,8 @@ create_stream_for_sink(struct amdgpu_dm_connector *aconnector,
>  		recalculate_timing = is_freesync_video_mode(&mode, aconnector);
>  		if (recalculate_timing) {
>  			freesync_mode = get_highest_refresh_rate_mode(aconnector, false);
> -			saved_mode = mode;
> -			mode = *freesync_mode;
> +			drm_mode_copy(&saved_mode, &mode);
> +			drm_mode_copy(&mode, freesync_mode);
>  		} else {
>  			decide_crtc_timing_for_drm_display_mode(
>  				&mode, preferred_mode, scale);


^ permalink raw reply	[flat|nested] 157+ messages in thread

* Re: [PATCH 01/22] drm: Add drm_mode_init()
  2022-02-18 10:03   ` [Intel-gfx] " Ville Syrjala
@ 2022-02-18 16:34     ` Harry Wentland
  -1 siblings, 0 replies; 157+ messages in thread
From: Harry Wentland @ 2022-02-18 16:34 UTC (permalink / raw)
  To: Ville Syrjala, dri-devel; +Cc: intel-gfx



On 2022-02-18 05:03, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> Add a variant of drm_mode_copy() that explicitly clears out
> the list head of the destination mode. Helpful to guarantee
> we don't have stack garbage left in there for on-stack modes.
> 
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

Reviewed-by: Harry Wentland <harry.wentland@amd.com>

Harry

> ---
>  drivers/gpu/drm/drm_modes.c | 17 +++++++++++++++++
>  include/drm/drm_modes.h     |  2 ++
>  2 files changed, 19 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c
> index 96b13e36293c..40d4ce4a1da4 100644
> --- a/drivers/gpu/drm/drm_modes.c
> +++ b/drivers/gpu/drm/drm_modes.c
> @@ -892,6 +892,23 @@ void drm_mode_copy(struct drm_display_mode *dst, const struct drm_display_mode *
>  }
>  EXPORT_SYMBOL(drm_mode_copy);
>  
> +/**
> + * drm_mode_init - initialize the mode from another mode
> + * @dst: mode to overwrite
> + * @src: mode to copy
> + *
> + * Copy an existing mode into another mode, zeroing the
> + * list head of the destination mode. Typically used
> + * to guarantee the list head is not left with stack
> + * garbage in on-stack modes.
> + */
> +void drm_mode_init(struct drm_display_mode *dst, const struct drm_display_mode *src)
> +{
> +	memset(dst, 0, sizeof(*dst));
> +	drm_mode_copy(dst, src);
> +}
> +EXPORT_SYMBOL(drm_mode_init);
> +
>  /**
>   * drm_mode_duplicate - allocate and duplicate an existing mode
>   * @dev: drm_device to allocate the duplicated mode for
> diff --git a/include/drm/drm_modes.h b/include/drm/drm_modes.h
> index 29ba4adf0c53..e6e5a588fab1 100644
> --- a/include/drm/drm_modes.h
> +++ b/include/drm/drm_modes.h
> @@ -484,6 +484,8 @@ void drm_mode_set_crtcinfo(struct drm_display_mode *p,
>  			   int adjust_flags);
>  void drm_mode_copy(struct drm_display_mode *dst,
>  		   const struct drm_display_mode *src);
> +void drm_mode_init(struct drm_display_mode *dst,
> +		   const struct drm_display_mode *src);
>  struct drm_display_mode *drm_mode_duplicate(struct drm_device *dev,
>  					    const struct drm_display_mode *mode);
>  bool drm_mode_match(const struct drm_display_mode *mode1,


^ permalink raw reply	[flat|nested] 157+ messages in thread

* Re: [Intel-gfx] [PATCH 01/22] drm: Add drm_mode_init()
@ 2022-02-18 16:34     ` Harry Wentland
  0 siblings, 0 replies; 157+ messages in thread
From: Harry Wentland @ 2022-02-18 16:34 UTC (permalink / raw)
  To: Ville Syrjala, dri-devel; +Cc: intel-gfx



On 2022-02-18 05:03, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> Add a variant of drm_mode_copy() that explicitly clears out
> the list head of the destination mode. Helpful to guarantee
> we don't have stack garbage left in there for on-stack modes.
> 
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

Reviewed-by: Harry Wentland <harry.wentland@amd.com>

Harry

> ---
>  drivers/gpu/drm/drm_modes.c | 17 +++++++++++++++++
>  include/drm/drm_modes.h     |  2 ++
>  2 files changed, 19 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c
> index 96b13e36293c..40d4ce4a1da4 100644
> --- a/drivers/gpu/drm/drm_modes.c
> +++ b/drivers/gpu/drm/drm_modes.c
> @@ -892,6 +892,23 @@ void drm_mode_copy(struct drm_display_mode *dst, const struct drm_display_mode *
>  }
>  EXPORT_SYMBOL(drm_mode_copy);
>  
> +/**
> + * drm_mode_init - initialize the mode from another mode
> + * @dst: mode to overwrite
> + * @src: mode to copy
> + *
> + * Copy an existing mode into another mode, zeroing the
> + * list head of the destination mode. Typically used
> + * to guarantee the list head is not left with stack
> + * garbage in on-stack modes.
> + */
> +void drm_mode_init(struct drm_display_mode *dst, const struct drm_display_mode *src)
> +{
> +	memset(dst, 0, sizeof(*dst));
> +	drm_mode_copy(dst, src);
> +}
> +EXPORT_SYMBOL(drm_mode_init);
> +
>  /**
>   * drm_mode_duplicate - allocate and duplicate an existing mode
>   * @dev: drm_device to allocate the duplicated mode for
> diff --git a/include/drm/drm_modes.h b/include/drm/drm_modes.h
> index 29ba4adf0c53..e6e5a588fab1 100644
> --- a/include/drm/drm_modes.h
> +++ b/include/drm/drm_modes.h
> @@ -484,6 +484,8 @@ void drm_mode_set_crtcinfo(struct drm_display_mode *p,
>  			   int adjust_flags);
>  void drm_mode_copy(struct drm_display_mode *dst,
>  		   const struct drm_display_mode *src);
> +void drm_mode_init(struct drm_display_mode *dst,
> +		   const struct drm_display_mode *src);
>  struct drm_display_mode *drm_mode_duplicate(struct drm_device *dev,
>  					    const struct drm_display_mode *mode);
>  bool drm_mode_match(const struct drm_display_mode *mode1,


^ permalink raw reply	[flat|nested] 157+ messages in thread

* Re: [PATCH 06/22] drm/bridge: Use drm_mode_copy()
  2022-02-18 10:03   ` [Intel-gfx] " Ville Syrjala
@ 2022-02-18 17:47     ` Laurent Pinchart
  -1 siblings, 0 replies; 157+ messages in thread
From: Laurent Pinchart @ 2022-02-18 17:47 UTC (permalink / raw)
  To: Ville Syrjala
  Cc: Jernej Skrabec, Jonas Karlman, intel-gfx, Neil Armstrong,
	Robert Foss, dri-devel, Andrzej Hajda

Hi Ville,

Thank you for the patch.

On Fri, Feb 18, 2022 at 12:03:47PM +0200, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> struct drm_display_mode embeds a list head, so overwriting
> the full struct with another one will corrupt the list
> (if the destination mode is on a list). Use drm_mode_copy()
> instead which explicitly preserves the list head of
> the destination mode.
> 
> Even if we know the destination mode is not on any list
> using drm_mode_copy() seems decent as it sets a good
> example. Bad examples of not using it might eventually
> get copied into code where preserving the list head
> actually matters.
> 
> Obviously one case not covered here is when the mode
> itself is embedded in a larger structure and the whole
> structure is copied. But if we are careful when copying
> into modes embedded in structures I think we can be a
> little more reassured that bogus list heads haven't been
> propagated in.
> 
> @is_mode_copy@
> @@
> drm_mode_copy(...)
> {
> ...
> }
> 
> @depends on !is_mode_copy@
> struct drm_display_mode *mode;
> expression E, S;
> @@
> (
> - *mode = E
> + drm_mode_copy(mode, &E)
> |
> - memcpy(mode, E, S)
> + drm_mode_copy(mode, E)
> )
> 
> @depends on !is_mode_copy@
> struct drm_display_mode mode;
> expression E;
> @@
> (
> - mode = E
> + drm_mode_copy(&mode, &E)
> |
> - memcpy(&mode, E, S)
> + drm_mode_copy(&mode, E)
> )
> 
> @@
> struct drm_display_mode *mode;
> @@
> - &*mode
> + mode
> 
> Cc: Andrzej Hajda <andrzej.hajda@intel.com>
> Cc: Neil Armstrong <narmstrong@baylibre.com>
> Cc: Robert Foss <robert.foss@linaro.org>
> Cc: Laurent Pinchart <Laurent.pinchart@ideasonboard.com>
> Cc: Jonas Karlman <jonas@kwiboo.se>
> Cc: Jernej Skrabec <jernej.skrabec@gmail.com>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
>  drivers/gpu/drm/bridge/nwl-dsi.c          | 2 +-
>  drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 2 +-
>  drivers/gpu/drm/bridge/tc358767.c         | 2 +-
>  3 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/bridge/nwl-dsi.c b/drivers/gpu/drm/bridge/nwl-dsi.c
> index 963a6794735f..881cf338d5cf 100644
> --- a/drivers/gpu/drm/bridge/nwl-dsi.c
> +++ b/drivers/gpu/drm/bridge/nwl-dsi.c
> @@ -857,7 +857,7 @@ nwl_dsi_bridge_mode_set(struct drm_bridge *bridge,
>  	/* Save the new desired phy config */
>  	memcpy(&dsi->phy_cfg, &new_cfg, sizeof(new_cfg));
>  
> -	memcpy(&dsi->mode, adjusted_mode, sizeof(dsi->mode));
> +	drm_mode_copy(&dsi->mode, adjusted_mode);
>  	drm_mode_debug_printmodeline(adjusted_mode);
>  
>  	if (pm_runtime_resume_and_get(dev) < 0)
> diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
> index 4befc104d220..a563460f8d20 100644
> --- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
> +++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
> @@ -2830,7 +2830,7 @@ static void dw_hdmi_bridge_mode_set(struct drm_bridge *bridge,
>  	mutex_lock(&hdmi->mutex);
>  
>  	/* Store the display mode for plugin/DKMS poweron events */
> -	memcpy(&hdmi->previous_mode, mode, sizeof(hdmi->previous_mode));
> +	drm_mode_copy(&hdmi->previous_mode, mode);
>  
>  	mutex_unlock(&hdmi->mutex);
>  }
> diff --git a/drivers/gpu/drm/bridge/tc358767.c b/drivers/gpu/drm/bridge/tc358767.c
> index c23e0abc65e8..7f9574b17caa 100644
> --- a/drivers/gpu/drm/bridge/tc358767.c
> +++ b/drivers/gpu/drm/bridge/tc358767.c
> @@ -1312,7 +1312,7 @@ static void tc_bridge_mode_set(struct drm_bridge *bridge,
>  {
>  	struct tc_data *tc = bridge_to_tc(bridge);
>  
> -	tc->mode = *mode;
> +	drm_mode_copy(&tc->mode, mode);
>  }
>  
>  static struct edid *tc_get_edid(struct drm_bridge *bridge,

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 157+ messages in thread

* Re: [Intel-gfx] [PATCH 06/22] drm/bridge: Use drm_mode_copy()
@ 2022-02-18 17:47     ` Laurent Pinchart
  0 siblings, 0 replies; 157+ messages in thread
From: Laurent Pinchart @ 2022-02-18 17:47 UTC (permalink / raw)
  To: Ville Syrjala
  Cc: Jernej Skrabec, Jonas Karlman, intel-gfx, Neil Armstrong,
	Robert Foss, dri-devel, Andrzej Hajda

Hi Ville,

Thank you for the patch.

On Fri, Feb 18, 2022 at 12:03:47PM +0200, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> struct drm_display_mode embeds a list head, so overwriting
> the full struct with another one will corrupt the list
> (if the destination mode is on a list). Use drm_mode_copy()
> instead which explicitly preserves the list head of
> the destination mode.
> 
> Even if we know the destination mode is not on any list
> using drm_mode_copy() seems decent as it sets a good
> example. Bad examples of not using it might eventually
> get copied into code where preserving the list head
> actually matters.
> 
> Obviously one case not covered here is when the mode
> itself is embedded in a larger structure and the whole
> structure is copied. But if we are careful when copying
> into modes embedded in structures I think we can be a
> little more reassured that bogus list heads haven't been
> propagated in.
> 
> @is_mode_copy@
> @@
> drm_mode_copy(...)
> {
> ...
> }
> 
> @depends on !is_mode_copy@
> struct drm_display_mode *mode;
> expression E, S;
> @@
> (
> - *mode = E
> + drm_mode_copy(mode, &E)
> |
> - memcpy(mode, E, S)
> + drm_mode_copy(mode, E)
> )
> 
> @depends on !is_mode_copy@
> struct drm_display_mode mode;
> expression E;
> @@
> (
> - mode = E
> + drm_mode_copy(&mode, &E)
> |
> - memcpy(&mode, E, S)
> + drm_mode_copy(&mode, E)
> )
> 
> @@
> struct drm_display_mode *mode;
> @@
> - &*mode
> + mode
> 
> Cc: Andrzej Hajda <andrzej.hajda@intel.com>
> Cc: Neil Armstrong <narmstrong@baylibre.com>
> Cc: Robert Foss <robert.foss@linaro.org>
> Cc: Laurent Pinchart <Laurent.pinchart@ideasonboard.com>
> Cc: Jonas Karlman <jonas@kwiboo.se>
> Cc: Jernej Skrabec <jernej.skrabec@gmail.com>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
>  drivers/gpu/drm/bridge/nwl-dsi.c          | 2 +-
>  drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 2 +-
>  drivers/gpu/drm/bridge/tc358767.c         | 2 +-
>  3 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/bridge/nwl-dsi.c b/drivers/gpu/drm/bridge/nwl-dsi.c
> index 963a6794735f..881cf338d5cf 100644
> --- a/drivers/gpu/drm/bridge/nwl-dsi.c
> +++ b/drivers/gpu/drm/bridge/nwl-dsi.c
> @@ -857,7 +857,7 @@ nwl_dsi_bridge_mode_set(struct drm_bridge *bridge,
>  	/* Save the new desired phy config */
>  	memcpy(&dsi->phy_cfg, &new_cfg, sizeof(new_cfg));
>  
> -	memcpy(&dsi->mode, adjusted_mode, sizeof(dsi->mode));
> +	drm_mode_copy(&dsi->mode, adjusted_mode);
>  	drm_mode_debug_printmodeline(adjusted_mode);
>  
>  	if (pm_runtime_resume_and_get(dev) < 0)
> diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
> index 4befc104d220..a563460f8d20 100644
> --- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
> +++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
> @@ -2830,7 +2830,7 @@ static void dw_hdmi_bridge_mode_set(struct drm_bridge *bridge,
>  	mutex_lock(&hdmi->mutex);
>  
>  	/* Store the display mode for plugin/DKMS poweron events */
> -	memcpy(&hdmi->previous_mode, mode, sizeof(hdmi->previous_mode));
> +	drm_mode_copy(&hdmi->previous_mode, mode);
>  
>  	mutex_unlock(&hdmi->mutex);
>  }
> diff --git a/drivers/gpu/drm/bridge/tc358767.c b/drivers/gpu/drm/bridge/tc358767.c
> index c23e0abc65e8..7f9574b17caa 100644
> --- a/drivers/gpu/drm/bridge/tc358767.c
> +++ b/drivers/gpu/drm/bridge/tc358767.c
> @@ -1312,7 +1312,7 @@ static void tc_bridge_mode_set(struct drm_bridge *bridge,
>  {
>  	struct tc_data *tc = bridge_to_tc(bridge);
>  
> -	tc->mode = *mode;
> +	drm_mode_copy(&tc->mode, mode);
>  }
>  
>  static struct edid *tc_get_edid(struct drm_bridge *bridge,

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 157+ messages in thread

* [Intel-gfx] ✗ Fi.CI.IGT: failure for drm: Review of mode copies
  2022-02-18 10:03 ` Ville Syrjala
                   ` (28 preceding siblings ...)
  (?)
@ 2022-02-19  5:06 ` Patchwork
  -1 siblings, 0 replies; 157+ messages in thread
From: Patchwork @ 2022-02-19  5:06 UTC (permalink / raw)
  To: Ville Syrjälä; +Cc: intel-gfx

[-- Attachment #1: Type: text/plain, Size: 30250 bytes --]

== Series Details ==

Series: drm: Review of mode copies
URL   : https://patchwork.freedesktop.org/series/100394/
State : failure

== Summary ==

CI Bug Log - changes from CI_DRM_11248_full -> Patchwork_22330_full
====================================================

Summary
-------

  **FAILURE**

  Serious unknown changes coming with Patchwork_22330_full absolutely need to be
  verified manually.
  
  If you think the reported changes have nothing to do with the changes
  introduced in Patchwork_22330_full, please notify your bug team to allow them
  to document this new failure mode, which will reduce false positives in CI.

  

Participating hosts (11 -> 11)
------------------------------

  No changes in participating hosts

Possible new issues
-------------------

  Here are the unknown changes that may have been introduced in Patchwork_22330_full:

### IGT changes ###

#### Possible regressions ####

  * igt@prime_self_import@export-vs-gem_close-race:
    - shard-snb:          [PASS][1] -> [FAIL][2]
   [1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11248/shard-snb5/igt@prime_self_import@export-vs-gem_close-race.html
   [2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-snb7/igt@prime_self_import@export-vs-gem_close-race.html

  
Known issues
------------

  Here are the changes found in Patchwork_22330_full that come from known issues:

### IGT changes ###

#### Issues hit ####

  * igt@gem_ctx_persistence@file:
    - shard-snb:          NOTRUN -> [SKIP][3] ([fdo#109271] / [i915#1099])
   [3]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-snb2/igt@gem_ctx_persistence@file.html

  * igt@gem_exec_balancer@parallel-balancer:
    - shard-iclb:         [PASS][4] -> [SKIP][5] ([i915#4525])
   [4]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11248/shard-iclb2/igt@gem_exec_balancer@parallel-balancer.html
   [5]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-iclb7/igt@gem_exec_balancer@parallel-balancer.html

  * igt@gem_exec_capture@pi@rcs0:
    - shard-skl:          [PASS][6] -> [INCOMPLETE][7] ([i915#4547])
   [6]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11248/shard-skl9/igt@gem_exec_capture@pi@rcs0.html
   [7]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-skl8/igt@gem_exec_capture@pi@rcs0.html

  * igt@gem_exec_fair@basic-deadline:
    - shard-skl:          NOTRUN -> [FAIL][8] ([i915#2846])
   [8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-skl10/igt@gem_exec_fair@basic-deadline.html

  * igt@gem_exec_fair@basic-none-share@rcs0:
    - shard-iclb:         [PASS][9] -> [FAIL][10] ([i915#2842])
   [9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11248/shard-iclb3/igt@gem_exec_fair@basic-none-share@rcs0.html
   [10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-iclb3/igt@gem_exec_fair@basic-none-share@rcs0.html

  * igt@gem_exec_fair@basic-pace-share@rcs0:
    - shard-tglb:         [PASS][11] -> [FAIL][12] ([i915#2842])
   [11]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11248/shard-tglb3/igt@gem_exec_fair@basic-pace-share@rcs0.html
   [12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-tglb6/igt@gem_exec_fair@basic-pace-share@rcs0.html
    - shard-glk:          [PASS][13] -> [FAIL][14] ([i915#2842])
   [13]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11248/shard-glk7/igt@gem_exec_fair@basic-pace-share@rcs0.html
   [14]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-glk2/igt@gem_exec_fair@basic-pace-share@rcs0.html

  * igt@gem_exec_whisper@basic-queues-forked-all:
    - shard-glk:          [PASS][15] -> [DMESG-WARN][16] ([i915#118]) +1 similar issue
   [15]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11248/shard-glk2/igt@gem_exec_whisper@basic-queues-forked-all.html
   [16]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-glk1/igt@gem_exec_whisper@basic-queues-forked-all.html

  * igt@gem_lmem_swapping@heavy-verify-random:
    - shard-iclb:         NOTRUN -> [SKIP][17] ([i915#4613])
   [17]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-iclb3/igt@gem_lmem_swapping@heavy-verify-random.html

  * igt@gem_lmem_swapping@parallel-multi:
    - shard-skl:          NOTRUN -> [SKIP][18] ([fdo#109271] / [i915#4613])
   [18]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-skl10/igt@gem_lmem_swapping@parallel-multi.html

  * igt@gem_lmem_swapping@random-engines:
    - shard-apl:          NOTRUN -> [SKIP][19] ([fdo#109271] / [i915#4613])
   [19]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-apl7/igt@gem_lmem_swapping@random-engines.html

  * igt@gem_pread@exhaustion:
    - shard-kbl:          NOTRUN -> [WARN][20] ([i915#2658])
   [20]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-kbl1/igt@gem_pread@exhaustion.html

  * igt@gem_render_copy@y-tiled-to-vebox-linear:
    - shard-iclb:         NOTRUN -> [SKIP][21] ([i915#768]) +1 similar issue
   [21]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-iclb5/igt@gem_render_copy@y-tiled-to-vebox-linear.html

  * igt@gem_userptr_blits@dmabuf-sync:
    - shard-iclb:         NOTRUN -> [SKIP][22] ([i915#3323])
   [22]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-iclb5/igt@gem_userptr_blits@dmabuf-sync.html

  * igt@gem_userptr_blits@unsync-overlap:
    - shard-iclb:         NOTRUN -> [SKIP][23] ([i915#3297]) +1 similar issue
   [23]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-iclb3/igt@gem_userptr_blits@unsync-overlap.html

  * igt@gen7_exec_parse@bitmasks:
    - shard-iclb:         NOTRUN -> [SKIP][24] ([fdo#109289]) +1 similar issue
   [24]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-iclb5/igt@gen7_exec_parse@bitmasks.html

  * igt@gen9_exec_parse@allowed-single:
    - shard-skl:          [PASS][25] -> [DMESG-WARN][26] ([i915#1436] / [i915#716])
   [25]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11248/shard-skl1/igt@gen9_exec_parse@allowed-single.html
   [26]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-skl4/igt@gen9_exec_parse@allowed-single.html

  * igt@i915_pm_dc@dc9-dpms:
    - shard-iclb:         [PASS][27] -> [SKIP][28] ([i915#4281])
   [27]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11248/shard-iclb4/igt@i915_pm_dc@dc9-dpms.html
   [28]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-iclb3/igt@i915_pm_dc@dc9-dpms.html

  * igt@i915_pm_rpm@modeset-non-lpsp:
    - shard-iclb:         NOTRUN -> [SKIP][29] ([fdo#110892])
   [29]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-iclb5/igt@i915_pm_rpm@modeset-non-lpsp.html

  * igt@i915_selftest@live@gt_pm:
    - shard-skl:          NOTRUN -> [DMESG-FAIL][30] ([i915#1886] / [i915#2291])
   [30]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-skl9/igt@i915_selftest@live@gt_pm.html

  * igt@kms_big_fb@linear-16bpp-rotate-90:
    - shard-iclb:         NOTRUN -> [SKIP][31] ([fdo#110725] / [fdo#111614]) +1 similar issue
   [31]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-iclb3/igt@kms_big_fb@linear-16bpp-rotate-90.html

  * igt@kms_big_fb@x-tiled-max-hw-stride-64bpp-rotate-0-hflip:
    - shard-kbl:          NOTRUN -> [SKIP][32] ([fdo#109271] / [i915#3777]) +1 similar issue
   [32]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-kbl1/igt@kms_big_fb@x-tiled-max-hw-stride-64bpp-rotate-0-hflip.html

  * igt@kms_big_fb@x-tiled-max-hw-stride-64bpp-rotate-180-hflip:
    - shard-apl:          NOTRUN -> [SKIP][33] ([fdo#109271] / [i915#3777]) +2 similar issues
   [33]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-apl7/igt@kms_big_fb@x-tiled-max-hw-stride-64bpp-rotate-180-hflip.html

  * igt@kms_big_fb@x-tiled-max-hw-stride-64bpp-rotate-180-hflip-async-flip:
    - shard-skl:          NOTRUN -> [SKIP][34] ([fdo#109271] / [i915#3777]) +1 similar issue
   [34]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-skl10/igt@kms_big_fb@x-tiled-max-hw-stride-64bpp-rotate-180-hflip-async-flip.html

  * igt@kms_big_fb@y-tiled-8bpp-rotate-270:
    - shard-apl:          NOTRUN -> [SKIP][35] ([fdo#109271]) +64 similar issues
   [35]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-apl4/igt@kms_big_fb@y-tiled-8bpp-rotate-270.html

  * igt@kms_big_fb@yf-tiled-16bpp-rotate-270:
    - shard-tglb:         NOTRUN -> [SKIP][36] ([fdo#111615])
   [36]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-tglb6/igt@kms_big_fb@yf-tiled-16bpp-rotate-270.html

  * igt@kms_big_fb@yf-tiled-64bpp-rotate-90:
    - shard-iclb:         NOTRUN -> [SKIP][37] ([fdo#110723]) +1 similar issue
   [37]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-iclb3/igt@kms_big_fb@yf-tiled-64bpp-rotate-90.html

  * igt@kms_big_fb@yf-tiled-max-hw-stride-32bpp-rotate-0-async-flip:
    - shard-skl:          NOTRUN -> [FAIL][38] ([i915#3743]) +1 similar issue
   [38]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-skl10/igt@kms_big_fb@yf-tiled-max-hw-stride-32bpp-rotate-0-async-flip.html

  * igt@kms_big_joiner@2x-modeset:
    - shard-iclb:         NOTRUN -> [SKIP][39] ([i915#2705])
   [39]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-iclb5/igt@kms_big_joiner@2x-modeset.html

  * igt@kms_ccs@pipe-a-ccs-on-another-bo-y_tiled_gen12_mc_ccs:
    - shard-kbl:          NOTRUN -> [SKIP][40] ([fdo#109271] / [i915#3886]) +3 similar issues
   [40]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-kbl1/igt@kms_ccs@pipe-a-ccs-on-another-bo-y_tiled_gen12_mc_ccs.html

  * igt@kms_ccs@pipe-b-random-ccs-data-y_tiled_gen12_mc_ccs:
    - shard-iclb:         NOTRUN -> [SKIP][41] ([fdo#109278] / [i915#3886]) +3 similar issues
   [41]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-iclb5/igt@kms_ccs@pipe-b-random-ccs-data-y_tiled_gen12_mc_ccs.html

  * igt@kms_ccs@pipe-c-bad-rotation-90-y_tiled_gen12_rc_ccs_cc:
    - shard-skl:          NOTRUN -> [SKIP][42] ([fdo#109271] / [i915#3886]) +5 similar issues
   [42]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-skl4/igt@kms_ccs@pipe-c-bad-rotation-90-y_tiled_gen12_rc_ccs_cc.html
    - shard-apl:          NOTRUN -> [SKIP][43] ([fdo#109271] / [i915#3886]) +3 similar issues
   [43]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-apl4/igt@kms_ccs@pipe-c-bad-rotation-90-y_tiled_gen12_rc_ccs_cc.html

  * igt@kms_chamelium@hdmi-hpd-storm-disable:
    - shard-skl:          NOTRUN -> [SKIP][44] ([fdo#109271] / [fdo#111827]) +8 similar issues
   [44]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-skl9/igt@kms_chamelium@hdmi-hpd-storm-disable.html

  * igt@kms_color@pipe-d-ctm-0-5:
    - shard-iclb:         NOTRUN -> [SKIP][45] ([fdo#109278] / [i915#1149]) +1 similar issue
   [45]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-iclb5/igt@kms_color@pipe-d-ctm-0-5.html

  * igt@kms_color_chamelium@pipe-a-ctm-limited-range:
    - shard-apl:          NOTRUN -> [SKIP][46] ([fdo#109271] / [fdo#111827]) +2 similar issues
   [46]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-apl7/igt@kms_color_chamelium@pipe-a-ctm-limited-range.html

  * igt@kms_color_chamelium@pipe-a-ctm-negative:
    - shard-snb:          NOTRUN -> [SKIP][47] ([fdo#109271] / [fdo#111827]) +2 similar issues
   [47]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-snb2/igt@kms_color_chamelium@pipe-a-ctm-negative.html

  * igt@kms_color_chamelium@pipe-b-degamma:
    - shard-kbl:          NOTRUN -> [SKIP][48] ([fdo#109271] / [fdo#111827]) +4 similar issues
   [48]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-kbl1/igt@kms_color_chamelium@pipe-b-degamma.html

  * igt@kms_color_chamelium@pipe-c-ctm-limited-range:
    - shard-iclb:         NOTRUN -> [SKIP][49] ([fdo#109284] / [fdo#111827]) +2 similar issues
   [49]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-iclb5/igt@kms_color_chamelium@pipe-c-ctm-limited-range.html

  * igt@kms_content_protection@legacy:
    - shard-iclb:         NOTRUN -> [SKIP][50] ([fdo#109300] / [fdo#111066])
   [50]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-iclb5/igt@kms_content_protection@legacy.html

  * igt@kms_cursor_crc@pipe-a-cursor-max-size-onscreen:
    - shard-kbl:          NOTRUN -> [SKIP][51] ([fdo#109271]) +60 similar issues
   [51]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-kbl1/igt@kms_cursor_crc@pipe-a-cursor-max-size-onscreen.html

  * igt@kms_cursor_crc@pipe-c-cursor-32x10-onscreen:
    - shard-tglb:         NOTRUN -> [SKIP][52] ([i915#3359])
   [52]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-tglb6/igt@kms_cursor_crc@pipe-c-cursor-32x10-onscreen.html

  * igt@kms_cursor_crc@pipe-c-cursor-512x512-rapid-movement:
    - shard-iclb:         NOTRUN -> [SKIP][53] ([fdo#109278] / [fdo#109279]) +1 similar issue
   [53]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-iclb5/igt@kms_cursor_crc@pipe-c-cursor-512x512-rapid-movement.html

  * igt@kms_cursor_crc@pipe-d-cursor-32x10-offscreen:
    - shard-iclb:         NOTRUN -> [SKIP][54] ([fdo#109278]) +9 similar issues
   [54]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-iclb3/igt@kms_cursor_crc@pipe-d-cursor-32x10-offscreen.html

  * igt@kms_cursor_legacy@cursora-vs-flipb-varying-size:
    - shard-iclb:         NOTRUN -> [SKIP][55] ([fdo#109274] / [fdo#109278])
   [55]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-iclb5/igt@kms_cursor_legacy@cursora-vs-flipb-varying-size.html

  * igt@kms_dp_tiled_display@basic-test-pattern-with-chamelium:
    - shard-iclb:         NOTRUN -> [SKIP][56] ([i915#3528])
   [56]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-iclb5/igt@kms_dp_tiled_display@basic-test-pattern-with-chamelium.html

  * igt@kms_fbcon_fbt@fbc-suspend:
    - shard-apl:          [PASS][57] -> [INCOMPLETE][58] ([i915#180] / [i915#1982])
   [57]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11248/shard-apl7/igt@kms_fbcon_fbt@fbc-suspend.html
   [58]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-apl1/igt@kms_fbcon_fbt@fbc-suspend.html

  * igt@kms_flip@2x-flip-vs-modeset-vs-hang:
    - shard-iclb:         NOTRUN -> [SKIP][59] ([fdo#109274]) +2 similar issues
   [59]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-iclb3/igt@kms_flip@2x-flip-vs-modeset-vs-hang.html

  * igt@kms_flip@flip-vs-expired-vblank@a-hdmi-a2:
    - shard-glk:          [PASS][60] -> [FAIL][61] ([i915#79])
   [60]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11248/shard-glk7/igt@kms_flip@flip-vs-expired-vblank@a-hdmi-a2.html
   [61]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-glk2/igt@kms_flip@flip-vs-expired-vblank@a-hdmi-a2.html

  * igt@kms_flip@flip-vs-suspend@a-dp1:
    - shard-apl:          [PASS][62] -> [DMESG-WARN][63] ([i915#180]) +1 similar issue
   [62]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11248/shard-apl1/igt@kms_flip@flip-vs-suspend@a-dp1.html
   [63]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-apl8/igt@kms_flip@flip-vs-suspend@a-dp1.html

  * igt@kms_flip_scaled_crc@flip-32bpp-ytile-to-32bpp-ytileccs-downscaling:
    - shard-skl:          NOTRUN -> [INCOMPLETE][64] ([i915#3701])
   [64]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-skl4/igt@kms_flip_scaled_crc@flip-32bpp-ytile-to-32bpp-ytileccs-downscaling.html

  * igt@kms_flip_scaled_crc@flip-32bpp-ytile-to-32bpp-ytileccs-upscaling:
    - shard-glk:          [PASS][65] -> [FAIL][66] ([i915#4911])
   [65]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11248/shard-glk9/igt@kms_flip_scaled_crc@flip-32bpp-ytile-to-32bpp-ytileccs-upscaling.html
   [66]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-glk8/igt@kms_flip_scaled_crc@flip-32bpp-ytile-to-32bpp-ytileccs-upscaling.html

  * igt@kms_frontbuffer_tracking@fbcpsr-1p-primscrn-indfb-msflip-blt:
    - shard-skl:          NOTRUN -> [SKIP][67] ([fdo#109271]) +125 similar issues
   [67]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-skl10/igt@kms_frontbuffer_tracking@fbcpsr-1p-primscrn-indfb-msflip-blt.html

  * igt@kms_frontbuffer_tracking@fbcpsr-2p-primscrn-spr-indfb-draw-mmap-gtt:
    - shard-tglb:         NOTRUN -> [SKIP][68] ([fdo#109280] / [fdo#111825]) +1 similar issue
   [68]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-tglb6/igt@kms_frontbuffer_tracking@fbcpsr-2p-primscrn-spr-indfb-draw-mmap-gtt.html

  * igt@kms_frontbuffer_tracking@fbcpsr-2p-scndscrn-cur-indfb-draw-mmap-cpu:
    - shard-iclb:         NOTRUN -> [SKIP][69] ([fdo#109280]) +8 similar issues
   [69]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-iclb5/igt@kms_frontbuffer_tracking@fbcpsr-2p-scndscrn-cur-indfb-draw-mmap-cpu.html

  * igt@kms_hdr@bpc-switch-suspend:
    - shard-kbl:          [PASS][70] -> [DMESG-WARN][71] ([i915#180]) +4 similar issues
   [70]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11248/shard-kbl1/igt@kms_hdr@bpc-switch-suspend.html
   [71]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-kbl4/igt@kms_hdr@bpc-switch-suspend.html
    - shard-skl:          NOTRUN -> [FAIL][72] ([i915#1188])
   [72]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-skl10/igt@kms_hdr@bpc-switch-suspend.html

  * igt@kms_hdr@static-toggle-dpms:
    - shard-iclb:         NOTRUN -> [SKIP][73] ([i915#1187]) +1 similar issue
   [73]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-iclb3/igt@kms_hdr@static-toggle-dpms.html

  * igt@kms_pipe_crc_basic@suspend-read-crc-pipe-d:
    - shard-skl:          NOTRUN -> [SKIP][74] ([fdo#109271] / [i915#533])
   [74]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-skl4/igt@kms_pipe_crc_basic@suspend-read-crc-pipe-d.html
    - shard-kbl:          NOTRUN -> [SKIP][75] ([fdo#109271] / [i915#533])
   [75]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-kbl1/igt@kms_pipe_crc_basic@suspend-read-crc-pipe-d.html
    - shard-apl:          NOTRUN -> [SKIP][76] ([fdo#109271] / [i915#533])
   [76]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-apl4/igt@kms_pipe_crc_basic@suspend-read-crc-pipe-d.html

  * igt@kms_plane_alpha_blend@pipe-c-alpha-7efc:
    - shard-apl:          NOTRUN -> [FAIL][77] ([fdo#108145] / [i915#265])
   [77]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-apl7/igt@kms_plane_alpha_blend@pipe-c-alpha-7efc.html

  * igt@kms_plane_alpha_blend@pipe-c-alpha-basic:
    - shard-skl:          NOTRUN -> [FAIL][78] ([fdo#108145] / [i915#265])
   [78]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-skl10/igt@kms_plane_alpha_blend@pipe-c-alpha-basic.html

  * igt@kms_plane_alpha_blend@pipe-c-alpha-transparent-fb:
    - shard-skl:          NOTRUN -> [FAIL][79] ([i915#265])
   [79]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-skl9/igt@kms_plane_alpha_blend@pipe-c-alpha-transparent-fb.html

  * igt@kms_psr2_su@page_flip-p010:
    - shard-kbl:          NOTRUN -> [SKIP][80] ([fdo#109271] / [i915#658])
   [80]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-kbl1/igt@kms_psr2_su@page_flip-p010.html

  * igt@kms_psr@psr2_basic:
    - shard-iclb:         NOTRUN -> [SKIP][81] ([fdo#109441])
   [81]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-iclb5/igt@kms_psr@psr2_basic.html

  * igt@kms_psr@psr2_primary_mmap_cpu:
    - shard-iclb:         [PASS][82] -> [SKIP][83] ([fdo#109441]) +1 similar issue
   [82]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11248/shard-iclb2/igt@kms_psr@psr2_primary_mmap_cpu.html
   [83]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-iclb7/igt@kms_psr@psr2_primary_mmap_cpu.html

  * igt@kms_universal_plane@disable-primary-vs-flip-pipe-d:
    - shard-snb:          NOTRUN -> [SKIP][84] ([fdo#109271]) +80 similar issues
   [84]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-snb2/igt@kms_universal_plane@disable-primary-vs-flip-pipe-d.html

  * igt@kms_vblank@pipe-a-ts-continuation-modeset-hang:
    - shard-glk:          [PASS][85] -> [TIMEOUT][86] ([i915#5140])
   [85]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11248/shard-glk6/igt@kms_vblank@pipe-a-ts-continuation-modeset-hang.html
   [86]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-glk6/igt@kms_vblank@pipe-a-ts-continuation-modeset-hang.html

  * igt@kms_vblank@pipe-a-ts-continuation-suspend:
    - shard-kbl:          [PASS][87] -> [DMESG-WARN][88] ([i915#180] / [i915#295])
   [87]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11248/shard-kbl1/igt@kms_vblank@pipe-a-ts-continuation-suspend.html
   [88]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-kbl7/igt@kms_vblank@pipe-a-ts-continuation-suspend.html
    - shard-apl:          [PASS][89] -> [DMESG-WARN][90] ([i915#180] / [i915#295])
   [89]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11248/shard-apl2/igt@kms_vblank@pipe-a-ts-continuation-suspend.html
   [90]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-apl2/igt@kms_vblank@pipe-a-ts-continuation-suspend.html

  * igt@kms_writeback@writeback-pixel-formats:
    - shard-skl:          NOTRUN -> [SKIP][91] ([fdo#109271] / [i915#2437])
   [91]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-skl10/igt@kms_writeback@writeback-pixel-formats.html

  * igt@nouveau_crc@ctx-flip-threshold-reset-after-capture:
    - shard-iclb:         NOTRUN -> [SKIP][92] ([i915#2530])
   [92]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-iclb5/igt@nouveau_crc@ctx-flip-threshold-reset-after-capture.html

  * igt@perf@polling-parameterized:
    - shard-skl:          [PASS][93] -> [FAIL][94] ([i915#1542])
   [93]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11248/shard-skl9/igt@perf@polling-parameterized.html
   [94]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-skl1/igt@perf@polling-parameterized.html

  * igt@perf_pmu@module-unload:
    - shard-iclb:         NOTRUN -> [FAIL][95] ([i915#5136])
   [95]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-iclb5/igt@perf_pmu@module-unload.html

  * igt@prime_nv_test@i915_import_cpu_mmap:
    - shard-iclb:         NOTRUN -> [SKIP][96] ([fdo#109291]) +1 similar issue
   [96]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-iclb5/igt@prime_nv_test@i915_import_cpu_mmap.html

  * igt@sysfs_clients@pidname:
    - shard-apl:          NOTRUN -> [SKIP][97] ([fdo#109271] / [i915#2994]) +1 similar issue
   [97]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-apl4/igt@sysfs_clients@pidname.html
    - shard-skl:          NOTRUN -> [SKIP][98] ([fdo#109271] / [i915#2994]) +2 similar issues
   [98]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-skl4/igt@sysfs_clients@pidname.html
    - shard-kbl:          NOTRUN -> [SKIP][99] ([fdo#109271] / [i915#2994])
   [99]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-kbl1/igt@sysfs_clients@pidname.html

  
#### Possible fixes ####

  * igt@gem_eio@kms:
    - shard-snb:          [SKIP][100] ([fdo#109271]) -> [PASS][101]
   [100]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11248/shard-snb2/igt@gem_eio@kms.html
   [101]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-snb7/igt@gem_eio@kms.html

  * igt@gem_exec_fair@basic-throttle@rcs0:
    - shard-iclb:         [FAIL][102] ([i915#2849]) -> [PASS][103]
   [102]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11248/shard-iclb5/igt@gem_exec_fair@basic-throttle@rcs0.html
   [103]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-iclb5/igt@gem_exec_fair@basic-throttle@rcs0.html

  * igt@i915_module_load@reload-with-fault-injection:
    - shard-tglb:         [TIMEOUT][104] ([i915#3953]) -> [PASS][105]
   [104]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11248/shard-tglb2/igt@i915_module_load@reload-with-fault-injection.html
   [105]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-tglb1/igt@i915_module_load@reload-with-fault-injection.html

  * igt@i915_selftest@live@hangcheck:
    - shard-snb:          [INCOMPLETE][106] ([i915#3921]) -> [PASS][107]
   [106]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11248/shard-snb2/igt@i915_selftest@live@hangcheck.html
   [107]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-snb2/igt@i915_selftest@live@hangcheck.html

  * igt@kms_big_fb@x-tiled-8bpp-rotate-180:
    - shard-glk:          [FAIL][108] ([i915#5138]) -> [PASS][109]
   [108]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11248/shard-glk7/igt@kms_big_fb@x-tiled-8bpp-rotate-180.html
   [109]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-glk2/igt@kms_big_fb@x-tiled-8bpp-rotate-180.html

  * igt@kms_color@pipe-c-ctm-0-5:
    - shard-skl:          [DMESG-WARN][110] ([i915#1982]) -> [PASS][111] +2 similar issues
   [110]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11248/shard-skl1/igt@kms_color@pipe-c-ctm-0-5.html
   [111]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-skl10/igt@kms_color@pipe-c-ctm-0-5.html

  * igt@kms_cursor_legacy@flip-vs-cursor-toggle:
    - shard-iclb:         [FAIL][112] ([i915#2346]) -> [PASS][113]
   [112]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11248/shard-iclb7/igt@kms_cursor_legacy@flip-vs-cursor-toggle.html
   [113]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-iclb6/igt@kms_cursor_legacy@flip-vs-cursor-toggle.html

  * igt@kms_flip@flip-vs-suspend-interruptible@b-edp1:
    - shard-tglb:         [DMESG-WARN][114] ([i915#2411] / [i915#2867]) -> [PASS][115] +1 similar issue
   [114]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11248/shard-tglb2/igt@kms_flip@flip-vs-suspend-interruptible@b-edp1.html
   [115]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-tglb1/igt@kms_flip@flip-vs-suspend-interruptible@b-edp1.html

  * igt@kms_flip@plain-flip-ts-check-interruptible@c-hdmi-a1:
    - shard-glk:          [FAIL][116] ([i915#2122]) -> [PASS][117]
   [116]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11248/shard-glk1/igt@kms_flip@plain-flip-ts-check-interruptible@c-hdmi-a1.html
   [117]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-glk7/igt@kms_flip@plain-flip-ts-check-interruptible@c-hdmi-a1.html

  * igt@kms_hdr@bpc-switch:
    - shard-skl:          [FAIL][118] ([i915#1188]) -> [PASS][119]
   [118]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11248/shard-skl4/igt@kms_hdr@bpc-switch.html
   [119]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-skl1/igt@kms_hdr@bpc-switch.html

  * igt@kms_plane@plane-panning-bottom-right-suspend@pipe-a-planes:
    - shard-apl:          [DMESG-WARN][120] ([i915#180]) -> [PASS][121] +1 similar issue
   [120]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11248/shard-apl8/igt@kms_plane@plane-panning-bottom-right-suspend@pipe-a-planes.html
   [121]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-apl4/igt@kms_plane@plane-panning-bottom-right-suspend@pipe-a-planes.html

  * igt@kms_psr@psr2_dpms:
    - shard-iclb:         [SKIP][122] ([fdo#109441]) -> [PASS][123] +1 similar issue
   [122]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11248/shard-iclb4/igt@kms_psr@psr2_dpms.html
   [123]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-iclb2/igt@kms_psr@psr2_dpms.html

  * igt@kms_setmode@basic:
    - shard-glk:          [FAIL][124] ([i915#31]) -> [PASS][125]
   [124]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11248/shard-glk2/igt@kms_setmode@basic.html
   [125]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-glk1/igt@kms_setmode@basic.html

  * igt@perf_pmu@rc6-suspend:
    - shard-kbl:          [DMESG-WARN][126] ([i915#180]) -> [PASS][127] +1 similar issue
   [126]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11248/shard-kbl4/igt@perf_pmu@rc6-suspend.html
   [127]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-kbl1/igt@perf_pmu@rc6-suspend.html

  
#### Warnings ####

  * igt@gem_exec_balancer@parallel-out-fence:
    - shard-iclb:         [DMESG-WARN][128] ([i915#5076]) -> [SKIP][129] ([i915#4525]) +1 similar issue
   [128]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11248/shard-iclb4/igt@gem_exec_balancer@parallel-out-fence.html
   [129]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-iclb3/igt@gem_exec_balancer@parallel-out-fence.html

  * igt@i915_pm_rc6_residency@rc6-idle:
    - shard-iclb:         [WARN][130] ([i915#1804] / [i915#2684]) -> [WARN][131] ([i915#2684])
   [130]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11248/shard-iclb6/igt@i915_pm_rc6_residency@rc6-idle.html
   [131]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-iclb8/igt@i915_pm_rc6_residency@rc6-idle.html

  * igt@kms_cursor_crc@pipe-a-cursor-128x128-offscreen:
    - shard-glk:          [FAIL][132] ([i915#1888] / [i915#3444]) -> [DMESG-FAIL][133] ([i915#118] / [i915#1888])
   [132]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11248/shard-glk6/igt@kms_cursor_crc@pipe-a-cursor-128x128-offscreen.html
   [133]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/shard-glk6/igt@kms_cursor_crc@pipe-a-cursor-128x128-offscreen.html

  * igt@runner@aborted:
    - shard-kbl:          ([FAIL][134], [FAIL][135], [FAIL][136], [FAIL][137], [FAIL][138], [FAIL][139], [FAIL][140], [FAIL][141], [FAIL][142], [FAIL][143], [FAIL][144], [FAIL][145], [FAIL][146], [FAIL][147], [FAIL][148], [FAIL][149]) ([i915#1436] / [i915#180] / [i915#1814] / [i915#2426] / [i915#3002] / [i915#4312]) -> ([FAIL][150], [FAIL][151], [FAIL][152], [FAIL][153], [FAIL][154], [FAIL][155], [FAIL][156], [FAIL][157], [FAIL][158], [FAIL][159], [FAIL][160], [FAIL][161], [FAIL][162], [FAIL][163], [FAIL][164], [FAIL][165]) ([fdo#109271] / [i915#1436] / [i915#180] / [i915#1814] / [i915#2426] / [i915#4312] / [i915#602])
   [134]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11248/shard-kbl7/igt@runner@aborted.html
   [135]: https://intel-gfx-ci.01.

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22330/index.html

[-- Attachment #2: Type: text/html, Size: 33482 bytes --]

^ permalink raw reply	[flat|nested] 157+ messages in thread

* Re: (subset) [Intel-gfx] [PATCH 17/22] drm/vc4: Use drm_mode_copy()
  2022-02-18 10:03   ` Ville Syrjala
@ 2022-02-21 10:13     ` Maxime Ripard
  -1 siblings, 0 replies; 157+ messages in thread
From: Maxime Ripard @ 2022-02-21 10:13 UTC (permalink / raw)
  To: dri-devel, Ville Syrjala; +Cc: intel-gfx, Maxime Ripard, Emma Anholt

On Fri, 18 Feb 2022 12:03:58 +0200, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> struct drm_display_mode embeds a list head, so overwriting
> the full struct with another one will corrupt the list
> (if the destination mode is on a list). Use drm_mode_copy()
> instead which explicitly preserves the list head of
> the destination mode.
> 
> [...]

Applied to drm/drm-misc (drm-misc-next).

Thanks!
Maxime

^ permalink raw reply	[flat|nested] 157+ messages in thread

* Re: [Intel-gfx] (subset) [PATCH 17/22] drm/vc4: Use drm_mode_copy()
@ 2022-02-21 10:13     ` Maxime Ripard
  0 siblings, 0 replies; 157+ messages in thread
From: Maxime Ripard @ 2022-02-21 10:13 UTC (permalink / raw)
  To: dri-devel, Ville Syrjala
  Cc: intel-gfx, Maxime Ripard, Maxime Ripard, Emma Anholt

On Fri, 18 Feb 2022 12:03:58 +0200, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> struct drm_display_mode embeds a list head, so overwriting
> the full struct with another one will corrupt the list
> (if the destination mode is on a list). Use drm_mode_copy()
> instead which explicitly preserves the list head of
> the destination mode.
> 
> [...]

Applied to drm/drm-misc (drm-misc-next).

Thanks!
Maxime

^ permalink raw reply	[flat|nested] 157+ messages in thread

* Re: [PATCH 00/22] drm: Review of mode copies
  2022-02-18 10:03 ` Ville Syrjala
                     ` (3 preceding siblings ...)
  (?)
@ 2022-03-14 22:11   ` Ville Syrjälä
  -1 siblings, 0 replies; 157+ messages in thread
From: Ville Syrjälä @ 2022-03-14 22:11 UTC (permalink / raw)
  To: dri-devel
  Cc: intel-gfx, Abhinav Kumar, Alain Volmat, Alex Deucher, amd-gfx,
	Andrzej Hajda, Aurabindo Pillai, Chen Feng, Chun-Kuang Hu,
	Emma Anholt, freedreno, Harry Wentland, Heiko Stübner,
	Jernej Skrabec, John Stultz, Jonas Karlman, Jyri Sarha,
	Laurent Pinchart, Leo Li, linux-arm-kernel, linux-arm-msm,
	linux-rockchip, Maxime Ripard, Neil Armstrong, Nikola Cornij,
	Patrik Jakobsson, Philipp Zabel, Rob Clark, Robert Foss,
	Rodrigo Siqueira, Sam Ravnborg, Sandy Huang, Sean Paul,
	Thierry Reding, Tian Tao, Tomi Valkeinen, Xinliang Liu,
	Xinwei Kong

On Fri, Feb 18, 2022 at 12:03:41PM +0200, Ville Syrjala wrote:
>   drm: Add drm_mode_init()
>   drm/bridge: Use drm_mode_copy()
>   drm/imx: Use drm_mode_duplicate()
>   drm/panel: Use drm_mode_duplicate()
>   drm/vc4: Use drm_mode_copy()
These have been pushed to drm-misc-next.

>   drm/amdgpu: Remove pointless on stack mode copies
>   drm/amdgpu: Use drm_mode_init() for on-stack modes
>   drm/amdgpu: Use drm_mode_copy()
amdgpu ones are reviewed, but I'll leave them for the
AMD folks to push to whichever tree they prefer.


The rest are still in need of review:
>   drm/radeon: Use drm_mode_copy()
>   drm/gma500: Use drm_mode_copy()
>   drm/hisilicon: Use drm_mode_init() for on-stack modes
>   drm/msm: Nuke weird on stack mode copy
>   drm/msm: Use drm_mode_init() for on-stack modes
>   drm/msm: Use drm_mode_copy()
>   drm/mtk: Use drm_mode_init() for on-stack modes
>   drm/rockchip: Use drm_mode_copy()
>   drm/sti: Use drm_mode_copy()
>   drm/tilcdc: Use drm_mode_copy()
>   drm/i915: Use drm_mode_init() for on-stack modes
>   drm/i915: Use drm_mode_copy()
>   drm: Use drm_mode_init() for on-stack modes
>   drm: Use drm_mode_copy()

-- 
Ville Syrjälä
Intel

^ permalink raw reply	[flat|nested] 157+ messages in thread

* Re: [PATCH 00/22] drm: Review of mode copies
@ 2022-03-14 22:11   ` Ville Syrjälä
  0 siblings, 0 replies; 157+ messages in thread
From: Ville Syrjälä @ 2022-03-14 22:11 UTC (permalink / raw)
  To: dri-devel
  Cc: intel-gfx, Abhinav Kumar, Alain Volmat, Alex Deucher, amd-gfx,
	Andrzej Hajda, Aurabindo Pillai, Chen Feng, Chun-Kuang Hu,
	Emma Anholt, freedreno, Harry Wentland, Heiko Stübner,
	Jernej Skrabec, John Stultz, Jonas Karlman, Jyri Sarha,
	Laurent Pinchart, Leo Li, linux-arm-kernel, linux-arm-msm,
	linux-rockchip, Maxime Ripard, Neil Armstrong, Nikola Cornij,
	Patrik Jakobsson, Philipp Zabel, Rob Clark, Robert Foss,
	Rodrigo Siqueira, Sam Ravnborg, Sandy Huang, Sean Paul,
	Thierry Reding, Tian Tao, Tomi Valkeinen, Xinliang Liu,
	Xinwei Kong

On Fri, Feb 18, 2022 at 12:03:41PM +0200, Ville Syrjala wrote:
>   drm: Add drm_mode_init()
>   drm/bridge: Use drm_mode_copy()
>   drm/imx: Use drm_mode_duplicate()
>   drm/panel: Use drm_mode_duplicate()
>   drm/vc4: Use drm_mode_copy()
These have been pushed to drm-misc-next.

>   drm/amdgpu: Remove pointless on stack mode copies
>   drm/amdgpu: Use drm_mode_init() for on-stack modes
>   drm/amdgpu: Use drm_mode_copy()
amdgpu ones are reviewed, but I'll leave them for the
AMD folks to push to whichever tree they prefer.


The rest are still in need of review:
>   drm/radeon: Use drm_mode_copy()
>   drm/gma500: Use drm_mode_copy()
>   drm/hisilicon: Use drm_mode_init() for on-stack modes
>   drm/msm: Nuke weird on stack mode copy
>   drm/msm: Use drm_mode_init() for on-stack modes
>   drm/msm: Use drm_mode_copy()
>   drm/mtk: Use drm_mode_init() for on-stack modes
>   drm/rockchip: Use drm_mode_copy()
>   drm/sti: Use drm_mode_copy()
>   drm/tilcdc: Use drm_mode_copy()
>   drm/i915: Use drm_mode_init() for on-stack modes
>   drm/i915: Use drm_mode_copy()
>   drm: Use drm_mode_init() for on-stack modes
>   drm: Use drm_mode_copy()

-- 
Ville Syrjälä
Intel

_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

^ permalink raw reply	[flat|nested] 157+ messages in thread

* Re: [PATCH 00/22] drm: Review of mode copies
@ 2022-03-14 22:11   ` Ville Syrjälä
  0 siblings, 0 replies; 157+ messages in thread
From: Ville Syrjälä @ 2022-03-14 22:11 UTC (permalink / raw)
  To: dri-devel
  Cc: Emma Anholt, Neil Armstrong, Xinliang Liu, Thierry Reding,
	Jernej Skrabec, Andrzej Hajda, Sam Ravnborg, Rodrigo Siqueira,
	amd-gfx, linux-rockchip, Xinwei Kong, Aurabindo Pillai,
	Chen Feng, Alain Volmat, Chun-Kuang Hu, Jonas Karlman, Leo Li,
	linux-arm-msm, intel-gfx, Abhinav Kumar, Nikola Cornij,
	Sean Paul, linux-arm-kernel, Tomi Valkeinen, Jyri Sarha,
	Sandy Huang, Robert Foss, Alex Deucher, Tian Tao, freedreno,
	Laurent Pinchart

On Fri, Feb 18, 2022 at 12:03:41PM +0200, Ville Syrjala wrote:
>   drm: Add drm_mode_init()
>   drm/bridge: Use drm_mode_copy()
>   drm/imx: Use drm_mode_duplicate()
>   drm/panel: Use drm_mode_duplicate()
>   drm/vc4: Use drm_mode_copy()
These have been pushed to drm-misc-next.

>   drm/amdgpu: Remove pointless on stack mode copies
>   drm/amdgpu: Use drm_mode_init() for on-stack modes
>   drm/amdgpu: Use drm_mode_copy()
amdgpu ones are reviewed, but I'll leave them for the
AMD folks to push to whichever tree they prefer.


The rest are still in need of review:
>   drm/radeon: Use drm_mode_copy()
>   drm/gma500: Use drm_mode_copy()
>   drm/hisilicon: Use drm_mode_init() for on-stack modes
>   drm/msm: Nuke weird on stack mode copy
>   drm/msm: Use drm_mode_init() for on-stack modes
>   drm/msm: Use drm_mode_copy()
>   drm/mtk: Use drm_mode_init() for on-stack modes
>   drm/rockchip: Use drm_mode_copy()
>   drm/sti: Use drm_mode_copy()
>   drm/tilcdc: Use drm_mode_copy()
>   drm/i915: Use drm_mode_init() for on-stack modes
>   drm/i915: Use drm_mode_copy()
>   drm: Use drm_mode_init() for on-stack modes
>   drm: Use drm_mode_copy()

-- 
Ville Syrjälä
Intel

^ permalink raw reply	[flat|nested] 157+ messages in thread

* Re: [Intel-gfx] [PATCH 00/22] drm: Review of mode copies
@ 2022-03-14 22:11   ` Ville Syrjälä
  0 siblings, 0 replies; 157+ messages in thread
From: Ville Syrjälä @ 2022-03-14 22:11 UTC (permalink / raw)
  To: dri-devel
  Cc: Heiko Stübner, Emma Anholt, Neil Armstrong, Xinliang Liu,
	Jernej Skrabec, Andrzej Hajda, Sam Ravnborg, Rodrigo Siqueira,
	amd-gfx, linux-rockchip, Xinwei Kong, Aurabindo Pillai,
	Chen Feng, Alain Volmat, Harry Wentland, Chun-Kuang Hu,
	Jonas Karlman, Leo Li, linux-arm-msm, intel-gfx, Abhinav Kumar,
	Maxime Ripard, Nikola Cornij, John Stultz, linux-arm-kernel,
	Tomi Valkeinen, Jyri Sarha, Sandy Huang, Robert Foss,
	Philipp Zabel, Alex Deucher, Tian Tao, freedreno,
	Laurent Pinchart

On Fri, Feb 18, 2022 at 12:03:41PM +0200, Ville Syrjala wrote:
>   drm: Add drm_mode_init()
>   drm/bridge: Use drm_mode_copy()
>   drm/imx: Use drm_mode_duplicate()
>   drm/panel: Use drm_mode_duplicate()
>   drm/vc4: Use drm_mode_copy()
These have been pushed to drm-misc-next.

>   drm/amdgpu: Remove pointless on stack mode copies
>   drm/amdgpu: Use drm_mode_init() for on-stack modes
>   drm/amdgpu: Use drm_mode_copy()
amdgpu ones are reviewed, but I'll leave them for the
AMD folks to push to whichever tree they prefer.


The rest are still in need of review:
>   drm/radeon: Use drm_mode_copy()
>   drm/gma500: Use drm_mode_copy()
>   drm/hisilicon: Use drm_mode_init() for on-stack modes
>   drm/msm: Nuke weird on stack mode copy
>   drm/msm: Use drm_mode_init() for on-stack modes
>   drm/msm: Use drm_mode_copy()
>   drm/mtk: Use drm_mode_init() for on-stack modes
>   drm/rockchip: Use drm_mode_copy()
>   drm/sti: Use drm_mode_copy()
>   drm/tilcdc: Use drm_mode_copy()
>   drm/i915: Use drm_mode_init() for on-stack modes
>   drm/i915: Use drm_mode_copy()
>   drm: Use drm_mode_init() for on-stack modes
>   drm: Use drm_mode_copy()

-- 
Ville Syrjälä
Intel

^ permalink raw reply	[flat|nested] 157+ messages in thread

* Re: [PATCH 00/22] drm: Review of mode copies
@ 2022-03-14 22:11   ` Ville Syrjälä
  0 siblings, 0 replies; 157+ messages in thread
From: Ville Syrjälä @ 2022-03-14 22:11 UTC (permalink / raw)
  To: dri-devel
  Cc: Heiko Stübner, Emma Anholt, Neil Armstrong, Xinliang Liu,
	Thierry Reding, Jernej Skrabec, Andrzej Hajda, Sam Ravnborg,
	Rodrigo Siqueira, amd-gfx, linux-rockchip, Xinwei Kong,
	Aurabindo Pillai, Chen Feng, Alain Volmat, Harry Wentland,
	Chun-Kuang Hu, Jonas Karlman, Leo Li, linux-arm-msm, intel-gfx,
	Abhinav Kumar, Maxime Ripard, Nikola Cornij, John Stultz,
	Sean Paul, linux-arm-kernel, Tomi Valkeinen, Jyri Sarha,
	Sandy Huang, Robert Foss, Patrik Jakobsson, Rob Clark,
	Philipp Zabel, Alex Deucher, Tian Tao, freedreno,
	Laurent Pinchart

On Fri, Feb 18, 2022 at 12:03:41PM +0200, Ville Syrjala wrote:
>   drm: Add drm_mode_init()
>   drm/bridge: Use drm_mode_copy()
>   drm/imx: Use drm_mode_duplicate()
>   drm/panel: Use drm_mode_duplicate()
>   drm/vc4: Use drm_mode_copy()
These have been pushed to drm-misc-next.

>   drm/amdgpu: Remove pointless on stack mode copies
>   drm/amdgpu: Use drm_mode_init() for on-stack modes
>   drm/amdgpu: Use drm_mode_copy()
amdgpu ones are reviewed, but I'll leave them for the
AMD folks to push to whichever tree they prefer.


The rest are still in need of review:
>   drm/radeon: Use drm_mode_copy()
>   drm/gma500: Use drm_mode_copy()
>   drm/hisilicon: Use drm_mode_init() for on-stack modes
>   drm/msm: Nuke weird on stack mode copy
>   drm/msm: Use drm_mode_init() for on-stack modes
>   drm/msm: Use drm_mode_copy()
>   drm/mtk: Use drm_mode_init() for on-stack modes
>   drm/rockchip: Use drm_mode_copy()
>   drm/sti: Use drm_mode_copy()
>   drm/tilcdc: Use drm_mode_copy()
>   drm/i915: Use drm_mode_init() for on-stack modes
>   drm/i915: Use drm_mode_copy()
>   drm: Use drm_mode_init() for on-stack modes
>   drm: Use drm_mode_copy()

-- 
Ville Syrjälä
Intel

^ permalink raw reply	[flat|nested] 157+ messages in thread

* Re: [PATCH 00/22] drm: Review of mode copies
@ 2022-03-14 22:11   ` Ville Syrjälä
  0 siblings, 0 replies; 157+ messages in thread
From: Ville Syrjälä @ 2022-03-14 22:11 UTC (permalink / raw)
  To: dri-devel
  Cc: intel-gfx, Abhinav Kumar, Alain Volmat, Alex Deucher, amd-gfx,
	Andrzej Hajda, Aurabindo Pillai, Chen Feng, Chun-Kuang Hu,
	Emma Anholt, freedreno, Harry Wentland, Heiko Stübner,
	Jernej Skrabec, John Stultz, Jonas Karlman, Jyri Sarha,
	Laurent Pinchart, Leo Li, linux-arm-kernel, linux-arm-msm,
	linux-rockchip, Maxime Ripard, Neil Armstrong, Nikola Cornij,
	Patrik Jakobsson, Philipp Zabel, Rob Clark, Robert Foss,
	Rodrigo Siqueira, Sam Ravnborg, Sandy Huang, Sean Paul,
	Thierry Reding, Tian Tao, Tomi Valkeinen, Xinliang Liu,
	Xinwei Kong

On Fri, Feb 18, 2022 at 12:03:41PM +0200, Ville Syrjala wrote:
>   drm: Add drm_mode_init()
>   drm/bridge: Use drm_mode_copy()
>   drm/imx: Use drm_mode_duplicate()
>   drm/panel: Use drm_mode_duplicate()
>   drm/vc4: Use drm_mode_copy()
These have been pushed to drm-misc-next.

>   drm/amdgpu: Remove pointless on stack mode copies
>   drm/amdgpu: Use drm_mode_init() for on-stack modes
>   drm/amdgpu: Use drm_mode_copy()
amdgpu ones are reviewed, but I'll leave them for the
AMD folks to push to whichever tree they prefer.


The rest are still in need of review:
>   drm/radeon: Use drm_mode_copy()
>   drm/gma500: Use drm_mode_copy()
>   drm/hisilicon: Use drm_mode_init() for on-stack modes
>   drm/msm: Nuke weird on stack mode copy
>   drm/msm: Use drm_mode_init() for on-stack modes
>   drm/msm: Use drm_mode_copy()
>   drm/mtk: Use drm_mode_init() for on-stack modes
>   drm/rockchip: Use drm_mode_copy()
>   drm/sti: Use drm_mode_copy()
>   drm/tilcdc: Use drm_mode_copy()
>   drm/i915: Use drm_mode_init() for on-stack modes
>   drm/i915: Use drm_mode_copy()
>   drm: Use drm_mode_init() for on-stack modes
>   drm: Use drm_mode_copy()

-- 
Ville Syrjälä
Intel

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 157+ messages in thread

* Re: [PATCH 16/22] drm/tilcdc: Use drm_mode_copy()
  2022-02-18 10:03   ` [Intel-gfx] " Ville Syrjala
@ 2022-03-15  4:54     ` Tomi Valkeinen
  -1 siblings, 0 replies; 157+ messages in thread
From: Tomi Valkeinen @ 2022-03-15  4:54 UTC (permalink / raw)
  To: Ville Syrjala, dri-devel; +Cc: intel-gfx, Jyri Sarha

On 18/02/2022 12:03, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> struct drm_display_mode embeds a list head, so overwriting
> the full struct with another one will corrupt the list
> (if the destination mode is on a list). Use drm_mode_copy()
> instead which explicitly preserves the list head of
> the destination mode.
> 
> Even if we know the destination mode is not on any list
> using drm_mode_copy() seems decent as it sets a good
> example. Bad examples of not using it might eventually
> get copied into code where preserving the list head
> actually matters.
> 
> Obviously one case not covered here is when the mode
> itself is embedded in a larger structure and the whole
> structure is copied. But if we are careful when copying
> into modes embedded in structures I think we can be a
> little more reassured that bogus list heads haven't been
> propagated in.
> 
> @is_mode_copy@
> @@
> drm_mode_copy(...)
> {
> ...
> }
> 
> @depends on !is_mode_copy@
> struct drm_display_mode *mode;
> expression E, S;
> @@
> (
> - *mode = E
> + drm_mode_copy(mode, &E)
> |
> - memcpy(mode, E, S)
> + drm_mode_copy(mode, E)
> )
> 
> @depends on !is_mode_copy@
> struct drm_display_mode mode;
> expression E;
> @@
> (
> - mode = E
> + drm_mode_copy(&mode, &E)
> |
> - memcpy(&mode, E, S)
> + drm_mode_copy(&mode, E)
> )
> 
> @@
> struct drm_display_mode *mode;
> @@
> - &*mode
> + mode
> 
> Cc: Jyri Sarha <jyri.sarha@iki.fi>
> Cc: Tomi Valkeinen <tomba@kernel.org>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---
>   drivers/gpu/drm/tilcdc/tilcdc_crtc.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
> index 29890d704cb4..853c6b443fff 100644
> --- a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
> +++ b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
> @@ -433,7 +433,7 @@ static void tilcdc_crtc_set_mode(struct drm_crtc *crtc)
>   
>   	set_scanout(crtc, fb);
>   
> -	crtc->hwmode = crtc->state->adjusted_mode;
> +	drm_mode_copy(&crtc->hwmode, &crtc->state->adjusted_mode);
>   
>   	tilcdc_crtc->hvtotal_us =
>   		tilcdc_mode_hvtotal(&crtc->hwmode);

Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>

  Tomi

^ permalink raw reply	[flat|nested] 157+ messages in thread

* Re: [Intel-gfx] [PATCH 16/22] drm/tilcdc: Use drm_mode_copy()
@ 2022-03-15  4:54     ` Tomi Valkeinen
  0 siblings, 0 replies; 157+ messages in thread
From: Tomi Valkeinen @ 2022-03-15  4:54 UTC (permalink / raw)
  To: Ville Syrjala, dri-devel; +Cc: intel-gfx, Jyri Sarha

On 18/02/2022 12:03, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> struct drm_display_mode embeds a list head, so overwriting
> the full struct with another one will corrupt the list
> (if the destination mode is on a list). Use drm_mode_copy()
> instead which explicitly preserves the list head of
> the destination mode.
> 
> Even if we know the destination mode is not on any list
> using drm_mode_copy() seems decent as it sets a good
> example. Bad examples of not using it might eventually
> get copied into code where preserving the list head
> actually matters.
> 
> Obviously one case not covered here is when the mode
> itself is embedded in a larger structure and the whole
> structure is copied. But if we are careful when copying
> into modes embedded in structures I think we can be a
> little more reassured that bogus list heads haven't been
> propagated in.
> 
> @is_mode_copy@
> @@
> drm_mode_copy(...)
> {
> ...
> }
> 
> @depends on !is_mode_copy@
> struct drm_display_mode *mode;
> expression E, S;
> @@
> (
> - *mode = E
> + drm_mode_copy(mode, &E)
> |
> - memcpy(mode, E, S)
> + drm_mode_copy(mode, E)
> )
> 
> @depends on !is_mode_copy@
> struct drm_display_mode mode;
> expression E;
> @@
> (
> - mode = E
> + drm_mode_copy(&mode, &E)
> |
> - memcpy(&mode, E, S)
> + drm_mode_copy(&mode, E)
> )
> 
> @@
> struct drm_display_mode *mode;
> @@
> - &*mode
> + mode
> 
> Cc: Jyri Sarha <jyri.sarha@iki.fi>
> Cc: Tomi Valkeinen <tomba@kernel.org>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---
>   drivers/gpu/drm/tilcdc/tilcdc_crtc.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
> index 29890d704cb4..853c6b443fff 100644
> --- a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
> +++ b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
> @@ -433,7 +433,7 @@ static void tilcdc_crtc_set_mode(struct drm_crtc *crtc)
>   
>   	set_scanout(crtc, fb);
>   
> -	crtc->hwmode = crtc->state->adjusted_mode;
> +	drm_mode_copy(&crtc->hwmode, &crtc->state->adjusted_mode);
>   
>   	tilcdc_crtc->hvtotal_us =
>   		tilcdc_mode_hvtotal(&crtc->hwmode);

Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>

  Tomi

^ permalink raw reply	[flat|nested] 157+ messages in thread

* Re: [PATCH 02/22] drm/amdgpu: Remove pointless on stack mode copies
  2022-02-18 16:28     ` [Intel-gfx] " Harry Wentland
  (?)
@ 2022-03-15 15:57       ` Alex Deucher
  -1 siblings, 0 replies; 157+ messages in thread
From: Alex Deucher @ 2022-03-15 15:57 UTC (permalink / raw)
  To: Harry Wentland
  Cc: Leo Li, Intel Graphics Development, Rodrigo Siqueira,
	amd-gfx list, Nikola Cornij, Aurabindo Pillai,
	Maling list - DRI developers, Alex Deucher

Applied.  Thanks!

Alex

On Fri, Feb 18, 2022 at 11:28 AM Harry Wentland <harry.wentland@amd.com> wrote:
>
>
>
> On 2022-02-18 05:03, Ville Syrjala wrote:
> > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> >
> > These on stack copies of the modes appear to be pointless.
> > Just look at the originals directly.
> >
> > Cc: Harry Wentland <harry.wentland@amd.com>
> > Cc: Leo Li <sunpeng.li@amd.com>
> > Cc: Rodrigo Siqueira <Rodrigo.Siqueira@amd.com>
> > Cc: Alex Deucher <alexander.deucher@amd.com>
> > Cc: amd-gfx@lists.freedesktop.org
> > Cc: Nikola Cornij <nikola.cornij@amd.com>
> > Cc: Aurabindo Pillai <aurabindo.pillai@amd.com>
> > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
> Reviewed-by: Harry Wentland <harry.wentland@amd.com>
>
> Harry
>
> > ---
> >  .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 32 +++++++++----------
> >  1 file changed, 16 insertions(+), 16 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> > index 21dba337dab0..65aab0d086b6 100644
> > --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> > +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> > @@ -10139,27 +10139,27 @@ static bool
> >  is_timing_unchanged_for_freesync(struct drm_crtc_state *old_crtc_state,
> >                                struct drm_crtc_state *new_crtc_state)
> >  {
> > -     struct drm_display_mode old_mode, new_mode;
> > +     const struct drm_display_mode *old_mode, *new_mode;
> >
> >       if (!old_crtc_state || !new_crtc_state)
> >               return false;
> >
> > -     old_mode = old_crtc_state->mode;
> > -     new_mode = new_crtc_state->mode;
> > +     old_mode = &old_crtc_state->mode;
> > +     new_mode = &new_crtc_state->mode;
> >
> > -     if (old_mode.clock       == new_mode.clock &&
> > -         old_mode.hdisplay    == new_mode.hdisplay &&
> > -         old_mode.vdisplay    == new_mode.vdisplay &&
> > -         old_mode.htotal      == new_mode.htotal &&
> > -         old_mode.vtotal      != new_mode.vtotal &&
> > -         old_mode.hsync_start == new_mode.hsync_start &&
> > -         old_mode.vsync_start != new_mode.vsync_start &&
> > -         old_mode.hsync_end   == new_mode.hsync_end &&
> > -         old_mode.vsync_end   != new_mode.vsync_end &&
> > -         old_mode.hskew       == new_mode.hskew &&
> > -         old_mode.vscan       == new_mode.vscan &&
> > -         (old_mode.vsync_end - old_mode.vsync_start) ==
> > -         (new_mode.vsync_end - new_mode.vsync_start))
> > +     if (old_mode->clock       == new_mode->clock &&
> > +         old_mode->hdisplay    == new_mode->hdisplay &&
> > +         old_mode->vdisplay    == new_mode->vdisplay &&
> > +         old_mode->htotal      == new_mode->htotal &&
> > +         old_mode->vtotal      != new_mode->vtotal &&
> > +         old_mode->hsync_start == new_mode->hsync_start &&
> > +         old_mode->vsync_start != new_mode->vsync_start &&
> > +         old_mode->hsync_end   == new_mode->hsync_end &&
> > +         old_mode->vsync_end   != new_mode->vsync_end &&
> > +         old_mode->hskew       == new_mode->hskew &&
> > +         old_mode->vscan       == new_mode->vscan &&
> > +         (old_mode->vsync_end - old_mode->vsync_start) ==
> > +         (new_mode->vsync_end - new_mode->vsync_start))
> >               return true;
> >
> >       return false;
>

^ permalink raw reply	[flat|nested] 157+ messages in thread

* Re: [Intel-gfx] [PATCH 02/22] drm/amdgpu: Remove pointless on stack mode copies
@ 2022-03-15 15:57       ` Alex Deucher
  0 siblings, 0 replies; 157+ messages in thread
From: Alex Deucher @ 2022-03-15 15:57 UTC (permalink / raw)
  To: Harry Wentland
  Cc: Leo Li, Intel Graphics Development, Rodrigo Siqueira,
	amd-gfx list, Nikola Cornij, Aurabindo Pillai,
	Maling list - DRI developers, Alex Deucher

Applied.  Thanks!

Alex

On Fri, Feb 18, 2022 at 11:28 AM Harry Wentland <harry.wentland@amd.com> wrote:
>
>
>
> On 2022-02-18 05:03, Ville Syrjala wrote:
> > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> >
> > These on stack copies of the modes appear to be pointless.
> > Just look at the originals directly.
> >
> > Cc: Harry Wentland <harry.wentland@amd.com>
> > Cc: Leo Li <sunpeng.li@amd.com>
> > Cc: Rodrigo Siqueira <Rodrigo.Siqueira@amd.com>
> > Cc: Alex Deucher <alexander.deucher@amd.com>
> > Cc: amd-gfx@lists.freedesktop.org
> > Cc: Nikola Cornij <nikola.cornij@amd.com>
> > Cc: Aurabindo Pillai <aurabindo.pillai@amd.com>
> > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
> Reviewed-by: Harry Wentland <harry.wentland@amd.com>
>
> Harry
>
> > ---
> >  .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 32 +++++++++----------
> >  1 file changed, 16 insertions(+), 16 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> > index 21dba337dab0..65aab0d086b6 100644
> > --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> > +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> > @@ -10139,27 +10139,27 @@ static bool
> >  is_timing_unchanged_for_freesync(struct drm_crtc_state *old_crtc_state,
> >                                struct drm_crtc_state *new_crtc_state)
> >  {
> > -     struct drm_display_mode old_mode, new_mode;
> > +     const struct drm_display_mode *old_mode, *new_mode;
> >
> >       if (!old_crtc_state || !new_crtc_state)
> >               return false;
> >
> > -     old_mode = old_crtc_state->mode;
> > -     new_mode = new_crtc_state->mode;
> > +     old_mode = &old_crtc_state->mode;
> > +     new_mode = &new_crtc_state->mode;
> >
> > -     if (old_mode.clock       == new_mode.clock &&
> > -         old_mode.hdisplay    == new_mode.hdisplay &&
> > -         old_mode.vdisplay    == new_mode.vdisplay &&
> > -         old_mode.htotal      == new_mode.htotal &&
> > -         old_mode.vtotal      != new_mode.vtotal &&
> > -         old_mode.hsync_start == new_mode.hsync_start &&
> > -         old_mode.vsync_start != new_mode.vsync_start &&
> > -         old_mode.hsync_end   == new_mode.hsync_end &&
> > -         old_mode.vsync_end   != new_mode.vsync_end &&
> > -         old_mode.hskew       == new_mode.hskew &&
> > -         old_mode.vscan       == new_mode.vscan &&
> > -         (old_mode.vsync_end - old_mode.vsync_start) ==
> > -         (new_mode.vsync_end - new_mode.vsync_start))
> > +     if (old_mode->clock       == new_mode->clock &&
> > +         old_mode->hdisplay    == new_mode->hdisplay &&
> > +         old_mode->vdisplay    == new_mode->vdisplay &&
> > +         old_mode->htotal      == new_mode->htotal &&
> > +         old_mode->vtotal      != new_mode->vtotal &&
> > +         old_mode->hsync_start == new_mode->hsync_start &&
> > +         old_mode->vsync_start != new_mode->vsync_start &&
> > +         old_mode->hsync_end   == new_mode->hsync_end &&
> > +         old_mode->vsync_end   != new_mode->vsync_end &&
> > +         old_mode->hskew       == new_mode->hskew &&
> > +         old_mode->vscan       == new_mode->vscan &&
> > +         (old_mode->vsync_end - old_mode->vsync_start) ==
> > +         (new_mode->vsync_end - new_mode->vsync_start))
> >               return true;
> >
> >       return false;
>

^ permalink raw reply	[flat|nested] 157+ messages in thread

* Re: [PATCH 02/22] drm/amdgpu: Remove pointless on stack mode copies
@ 2022-03-15 15:57       ` Alex Deucher
  0 siblings, 0 replies; 157+ messages in thread
From: Alex Deucher @ 2022-03-15 15:57 UTC (permalink / raw)
  To: Harry Wentland
  Cc: Leo Li, Intel Graphics Development, Rodrigo Siqueira,
	amd-gfx list, Nikola Cornij, Aurabindo Pillai,
	Maling list - DRI developers, Alex Deucher, Ville Syrjala

Applied.  Thanks!

Alex

On Fri, Feb 18, 2022 at 11:28 AM Harry Wentland <harry.wentland@amd.com> wrote:
>
>
>
> On 2022-02-18 05:03, Ville Syrjala wrote:
> > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> >
> > These on stack copies of the modes appear to be pointless.
> > Just look at the originals directly.
> >
> > Cc: Harry Wentland <harry.wentland@amd.com>
> > Cc: Leo Li <sunpeng.li@amd.com>
> > Cc: Rodrigo Siqueira <Rodrigo.Siqueira@amd.com>
> > Cc: Alex Deucher <alexander.deucher@amd.com>
> > Cc: amd-gfx@lists.freedesktop.org
> > Cc: Nikola Cornij <nikola.cornij@amd.com>
> > Cc: Aurabindo Pillai <aurabindo.pillai@amd.com>
> > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
> Reviewed-by: Harry Wentland <harry.wentland@amd.com>
>
> Harry
>
> > ---
> >  .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 32 +++++++++----------
> >  1 file changed, 16 insertions(+), 16 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> > index 21dba337dab0..65aab0d086b6 100644
> > --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> > +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> > @@ -10139,27 +10139,27 @@ static bool
> >  is_timing_unchanged_for_freesync(struct drm_crtc_state *old_crtc_state,
> >                                struct drm_crtc_state *new_crtc_state)
> >  {
> > -     struct drm_display_mode old_mode, new_mode;
> > +     const struct drm_display_mode *old_mode, *new_mode;
> >
> >       if (!old_crtc_state || !new_crtc_state)
> >               return false;
> >
> > -     old_mode = old_crtc_state->mode;
> > -     new_mode = new_crtc_state->mode;
> > +     old_mode = &old_crtc_state->mode;
> > +     new_mode = &new_crtc_state->mode;
> >
> > -     if (old_mode.clock       == new_mode.clock &&
> > -         old_mode.hdisplay    == new_mode.hdisplay &&
> > -         old_mode.vdisplay    == new_mode.vdisplay &&
> > -         old_mode.htotal      == new_mode.htotal &&
> > -         old_mode.vtotal      != new_mode.vtotal &&
> > -         old_mode.hsync_start == new_mode.hsync_start &&
> > -         old_mode.vsync_start != new_mode.vsync_start &&
> > -         old_mode.hsync_end   == new_mode.hsync_end &&
> > -         old_mode.vsync_end   != new_mode.vsync_end &&
> > -         old_mode.hskew       == new_mode.hskew &&
> > -         old_mode.vscan       == new_mode.vscan &&
> > -         (old_mode.vsync_end - old_mode.vsync_start) ==
> > -         (new_mode.vsync_end - new_mode.vsync_start))
> > +     if (old_mode->clock       == new_mode->clock &&
> > +         old_mode->hdisplay    == new_mode->hdisplay &&
> > +         old_mode->vdisplay    == new_mode->vdisplay &&
> > +         old_mode->htotal      == new_mode->htotal &&
> > +         old_mode->vtotal      != new_mode->vtotal &&
> > +         old_mode->hsync_start == new_mode->hsync_start &&
> > +         old_mode->vsync_start != new_mode->vsync_start &&
> > +         old_mode->hsync_end   == new_mode->hsync_end &&
> > +         old_mode->vsync_end   != new_mode->vsync_end &&
> > +         old_mode->hskew       == new_mode->hskew &&
> > +         old_mode->vscan       == new_mode->vscan &&
> > +         (old_mode->vsync_end - old_mode->vsync_start) ==
> > +         (new_mode->vsync_end - new_mode->vsync_start))
> >               return true;
> >
> >       return false;
>

^ permalink raw reply	[flat|nested] 157+ messages in thread

* Re: [PATCH 05/22] drm/radeon: Use drm_mode_copy()
  2022-02-18 10:03   ` [Intel-gfx] " Ville Syrjala
@ 2022-03-15 18:49     ` Alex Deucher
  -1 siblings, 0 replies; 157+ messages in thread
From: Alex Deucher @ 2022-03-15 18:49 UTC (permalink / raw)
  To: Ville Syrjala
  Cc: Alex Deucher, Intel Graphics Development, amd-gfx list,
	Maling list - DRI developers

Applied.  Thanks!

Alex

On Fri, Feb 18, 2022 at 5:04 AM Ville Syrjala
<ville.syrjala@linux.intel.com> wrote:
>
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
> struct drm_display_mode embeds a list head, so overwriting
> the full struct with another one will corrupt the list
> (if the destination mode is on a list). Use drm_mode_copy()
> instead which explicitly preserves the list head of
> the destination mode.
>
> Even if we know the destination mode is not on any list
> using drm_mode_copy() seems decent as it sets a good
> example. Bad examples of not using it might eventually
> get copied into code where preserving the list head
> actually matters.
>
> Obviously one case not covered here is when the mode
> itself is embedded in a larger structure and the whole
> structure is copied. But if we are careful when copying
> into modes embedded in structures I think we can be a
> little more reassured that bogus list heads haven't been
> propagated in.
>
> @is_mode_copy@
> @@
> drm_mode_copy(...)
> {
> ...
> }
>
> @depends on !is_mode_copy@
> struct drm_display_mode *mode;
> expression E, S;
> @@
> (
> - *mode = E
> + drm_mode_copy(mode, &E)
> |
> - memcpy(mode, E, S)
> + drm_mode_copy(mode, E)
> )
>
> @depends on !is_mode_copy@
> struct drm_display_mode mode;
> expression E;
> @@
> (
> - mode = E
> + drm_mode_copy(&mode, &E)
> |
> - memcpy(&mode, E, S)
> + drm_mode_copy(&mode, E)
> )
>
> @@
> struct drm_display_mode *mode;
> @@
> - &*mode
> + mode
>
> Cc: Alex Deucher <alexander.deucher@amd.com>
> Cc: amd-gfx@lists.freedesktop.org
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---
>  drivers/gpu/drm/radeon/radeon_connectors.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/radeon/radeon_connectors.c b/drivers/gpu/drm/radeon/radeon_connectors.c
> index a7925a8290b2..0cb1345c6ba4 100644
> --- a/drivers/gpu/drm/radeon/radeon_connectors.c
> +++ b/drivers/gpu/drm/radeon/radeon_connectors.c
> @@ -777,7 +777,7 @@ static void radeon_fixup_lvds_native_mode(struct drm_encoder *encoder,
>                 if (mode->type & DRM_MODE_TYPE_PREFERRED) {
>                         if (mode->hdisplay != native_mode->hdisplay ||
>                             mode->vdisplay != native_mode->vdisplay)
> -                               memcpy(native_mode, mode, sizeof(*mode));
> +                               drm_mode_copy(native_mode, mode);
>                 }
>         }
>
> @@ -786,7 +786,7 @@ static void radeon_fixup_lvds_native_mode(struct drm_encoder *encoder,
>                 list_for_each_entry_safe(mode, t, &connector->probed_modes, head) {
>                         if (mode->hdisplay == native_mode->hdisplay &&
>                             mode->vdisplay == native_mode->vdisplay) {
> -                               *native_mode = *mode;
> +                               drm_mode_copy(native_mode, mode);
>                                 drm_mode_set_crtcinfo(native_mode, CRTC_INTERLACE_HALVE_V);
>                                 DRM_DEBUG_KMS("Determined LVDS native mode details from EDID\n");
>                                 break;
> --
> 2.34.1
>

^ permalink raw reply	[flat|nested] 157+ messages in thread

* Re: [Intel-gfx] [PATCH 05/22] drm/radeon: Use drm_mode_copy()
@ 2022-03-15 18:49     ` Alex Deucher
  0 siblings, 0 replies; 157+ messages in thread
From: Alex Deucher @ 2022-03-15 18:49 UTC (permalink / raw)
  To: Ville Syrjala
  Cc: Alex Deucher, Intel Graphics Development, amd-gfx list,
	Maling list - DRI developers

Applied.  Thanks!

Alex

On Fri, Feb 18, 2022 at 5:04 AM Ville Syrjala
<ville.syrjala@linux.intel.com> wrote:
>
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
> struct drm_display_mode embeds a list head, so overwriting
> the full struct with another one will corrupt the list
> (if the destination mode is on a list). Use drm_mode_copy()
> instead which explicitly preserves the list head of
> the destination mode.
>
> Even if we know the destination mode is not on any list
> using drm_mode_copy() seems decent as it sets a good
> example. Bad examples of not using it might eventually
> get copied into code where preserving the list head
> actually matters.
>
> Obviously one case not covered here is when the mode
> itself is embedded in a larger structure and the whole
> structure is copied. But if we are careful when copying
> into modes embedded in structures I think we can be a
> little more reassured that bogus list heads haven't been
> propagated in.
>
> @is_mode_copy@
> @@
> drm_mode_copy(...)
> {
> ...
> }
>
> @depends on !is_mode_copy@
> struct drm_display_mode *mode;
> expression E, S;
> @@
> (
> - *mode = E
> + drm_mode_copy(mode, &E)
> |
> - memcpy(mode, E, S)
> + drm_mode_copy(mode, E)
> )
>
> @depends on !is_mode_copy@
> struct drm_display_mode mode;
> expression E;
> @@
> (
> - mode = E
> + drm_mode_copy(&mode, &E)
> |
> - memcpy(&mode, E, S)
> + drm_mode_copy(&mode, E)
> )
>
> @@
> struct drm_display_mode *mode;
> @@
> - &*mode
> + mode
>
> Cc: Alex Deucher <alexander.deucher@amd.com>
> Cc: amd-gfx@lists.freedesktop.org
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---
>  drivers/gpu/drm/radeon/radeon_connectors.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/radeon/radeon_connectors.c b/drivers/gpu/drm/radeon/radeon_connectors.c
> index a7925a8290b2..0cb1345c6ba4 100644
> --- a/drivers/gpu/drm/radeon/radeon_connectors.c
> +++ b/drivers/gpu/drm/radeon/radeon_connectors.c
> @@ -777,7 +777,7 @@ static void radeon_fixup_lvds_native_mode(struct drm_encoder *encoder,
>                 if (mode->type & DRM_MODE_TYPE_PREFERRED) {
>                         if (mode->hdisplay != native_mode->hdisplay ||
>                             mode->vdisplay != native_mode->vdisplay)
> -                               memcpy(native_mode, mode, sizeof(*mode));
> +                               drm_mode_copy(native_mode, mode);
>                 }
>         }
>
> @@ -786,7 +786,7 @@ static void radeon_fixup_lvds_native_mode(struct drm_encoder *encoder,
>                 list_for_each_entry_safe(mode, t, &connector->probed_modes, head) {
>                         if (mode->hdisplay == native_mode->hdisplay &&
>                             mode->vdisplay == native_mode->vdisplay) {
> -                               *native_mode = *mode;
> +                               drm_mode_copy(native_mode, mode);
>                                 drm_mode_set_crtcinfo(native_mode, CRTC_INTERLACE_HALVE_V);
>                                 DRM_DEBUG_KMS("Determined LVDS native mode details from EDID\n");
>                                 break;
> --
> 2.34.1
>

^ permalink raw reply	[flat|nested] 157+ messages in thread

* Re: [PATCH 04/22] drm/amdgpu: Use drm_mode_copy()
  2022-02-18 16:32     ` [Intel-gfx] " Harry Wentland
  (?)
@ 2022-03-15 18:50       ` Alex Deucher
  -1 siblings, 0 replies; 157+ messages in thread
From: Alex Deucher @ 2022-03-15 18:50 UTC (permalink / raw)
  To: Harry Wentland
  Cc: Leo Li, Intel Graphics Development, Rodrigo Siqueira,
	Maling list - DRI developers, amd-gfx list, Alex Deucher

Applied.  Thanks!

Alex

On Fri, Feb 18, 2022 at 11:32 AM Harry Wentland <harry.wentland@amd.com> wrote:
>
>
>
> On 2022-02-18 05:03, Ville Syrjala wrote:
> > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> >
> > struct drm_display_mode embeds a list head, so overwriting
> > the full struct with another one will corrupt the list
> > (if the destination mode is on a list). Use drm_mode_copy()
> > instead which explicitly preserves the list head of
> > the destination mode.
> >
> > Even if we know the destination mode is not on any list
> > using drm_mode_copy() seems decent as it sets a good
> > example. Bad examples of not using it might eventually
> > get copied into code where preserving the list head
> > actually matters.
> >
> > Obviously one case not covered here is when the mode
> > itself is embedded in a larger structure and the whole
> > structure is copied. But if we are careful when copying
> > into modes embedded in structures I think we can be a
> > little more reassured that bogus list heads haven't been
> > propagated in.
> >
> > @is_mode_copy@
> > @@
> > drm_mode_copy(...)
> > {
> > ...
> > }
> >
> > @depends on !is_mode_copy@
> > struct drm_display_mode *mode;
> > expression E, S;
> > @@
> > (
> > - *mode = E
> > + drm_mode_copy(mode, &E)
> > |
> > - memcpy(mode, E, S)
> > + drm_mode_copy(mode, E)
> > )
> >
> > @depends on !is_mode_copy@
> > struct drm_display_mode mode;
> > expression E;
> > @@
> > (
> > - mode = E
> > + drm_mode_copy(&mode, &E)
> > |
> > - memcpy(&mode, E, S)
> > + drm_mode_copy(&mode, E)
> > )
> >
> > @@
> > struct drm_display_mode *mode;
> > @@
> > - &*mode
> > + mode
> >
> > Cc: Alex Deucher <alexander.deucher@amd.com>
> > Cc: Harry Wentland <harry.wentland@amd.com>
> > Cc: Leo Li <sunpeng.li@amd.com>
> > Cc: Rodrigo Siqueira <Rodrigo.Siqueira@amd.com>
> > Cc: amd-gfx@lists.freedesktop.org
> > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
> Reviewed-by: Harry Wentland <harry.wentland@amd.com>
>
> Harry
>
> > ---
> >  drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c    | 4 ++--
> >  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 6 +++---
> >  2 files changed, 5 insertions(+), 5 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
> > index fa20261aa928..673078faa27a 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
> > @@ -626,7 +626,7 @@ amdgpu_connector_fixup_lcd_native_mode(struct drm_encoder *encoder,
> >               if (mode->type & DRM_MODE_TYPE_PREFERRED) {
> >                       if (mode->hdisplay != native_mode->hdisplay ||
> >                           mode->vdisplay != native_mode->vdisplay)
> > -                             memcpy(native_mode, mode, sizeof(*mode));
> > +                             drm_mode_copy(native_mode, mode);
> >               }
> >       }
> >
> > @@ -635,7 +635,7 @@ amdgpu_connector_fixup_lcd_native_mode(struct drm_encoder *encoder,
> >               list_for_each_entry_safe(mode, t, &connector->probed_modes, head) {
> >                       if (mode->hdisplay == native_mode->hdisplay &&
> >                           mode->vdisplay == native_mode->vdisplay) {
> > -                             *native_mode = *mode;
> > +                             drm_mode_copy(native_mode, mode);
> >                               drm_mode_set_crtcinfo(native_mode, CRTC_INTERLACE_HALVE_V);
> >                               DRM_DEBUG_KMS("Determined LVDS native mode details from EDID\n");
> >                               break;
> > diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> > index bd23c9e481eb..514280699ad5 100644
> > --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> > +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> > @@ -6318,7 +6318,7 @@ get_highest_refresh_rate_mode(struct amdgpu_dm_connector *aconnector,
> >               }
> >       }
> >
> > -     aconnector->freesync_vid_base = *m_pref;
> > +     drm_mode_copy(&aconnector->freesync_vid_base, m_pref);
> >       return m_pref;
> >  }
> >
> > @@ -6432,8 +6432,8 @@ create_stream_for_sink(struct amdgpu_dm_connector *aconnector,
> >               recalculate_timing = is_freesync_video_mode(&mode, aconnector);
> >               if (recalculate_timing) {
> >                       freesync_mode = get_highest_refresh_rate_mode(aconnector, false);
> > -                     saved_mode = mode;
> > -                     mode = *freesync_mode;
> > +                     drm_mode_copy(&saved_mode, &mode);
> > +                     drm_mode_copy(&mode, freesync_mode);
> >               } else {
> >                       decide_crtc_timing_for_drm_display_mode(
> >                               &mode, preferred_mode, scale);
>

^ permalink raw reply	[flat|nested] 157+ messages in thread

* Re: [Intel-gfx] [PATCH 04/22] drm/amdgpu: Use drm_mode_copy()
@ 2022-03-15 18:50       ` Alex Deucher
  0 siblings, 0 replies; 157+ messages in thread
From: Alex Deucher @ 2022-03-15 18:50 UTC (permalink / raw)
  To: Harry Wentland
  Cc: Leo Li, Intel Graphics Development, Rodrigo Siqueira,
	Maling list - DRI developers, amd-gfx list, Alex Deucher

Applied.  Thanks!

Alex

On Fri, Feb 18, 2022 at 11:32 AM Harry Wentland <harry.wentland@amd.com> wrote:
>
>
>
> On 2022-02-18 05:03, Ville Syrjala wrote:
> > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> >
> > struct drm_display_mode embeds a list head, so overwriting
> > the full struct with another one will corrupt the list
> > (if the destination mode is on a list). Use drm_mode_copy()
> > instead which explicitly preserves the list head of
> > the destination mode.
> >
> > Even if we know the destination mode is not on any list
> > using drm_mode_copy() seems decent as it sets a good
> > example. Bad examples of not using it might eventually
> > get copied into code where preserving the list head
> > actually matters.
> >
> > Obviously one case not covered here is when the mode
> > itself is embedded in a larger structure and the whole
> > structure is copied. But if we are careful when copying
> > into modes embedded in structures I think we can be a
> > little more reassured that bogus list heads haven't been
> > propagated in.
> >
> > @is_mode_copy@
> > @@
> > drm_mode_copy(...)
> > {
> > ...
> > }
> >
> > @depends on !is_mode_copy@
> > struct drm_display_mode *mode;
> > expression E, S;
> > @@
> > (
> > - *mode = E
> > + drm_mode_copy(mode, &E)
> > |
> > - memcpy(mode, E, S)
> > + drm_mode_copy(mode, E)
> > )
> >
> > @depends on !is_mode_copy@
> > struct drm_display_mode mode;
> > expression E;
> > @@
> > (
> > - mode = E
> > + drm_mode_copy(&mode, &E)
> > |
> > - memcpy(&mode, E, S)
> > + drm_mode_copy(&mode, E)
> > )
> >
> > @@
> > struct drm_display_mode *mode;
> > @@
> > - &*mode
> > + mode
> >
> > Cc: Alex Deucher <alexander.deucher@amd.com>
> > Cc: Harry Wentland <harry.wentland@amd.com>
> > Cc: Leo Li <sunpeng.li@amd.com>
> > Cc: Rodrigo Siqueira <Rodrigo.Siqueira@amd.com>
> > Cc: amd-gfx@lists.freedesktop.org
> > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
> Reviewed-by: Harry Wentland <harry.wentland@amd.com>
>
> Harry
>
> > ---
> >  drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c    | 4 ++--
> >  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 6 +++---
> >  2 files changed, 5 insertions(+), 5 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
> > index fa20261aa928..673078faa27a 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
> > @@ -626,7 +626,7 @@ amdgpu_connector_fixup_lcd_native_mode(struct drm_encoder *encoder,
> >               if (mode->type & DRM_MODE_TYPE_PREFERRED) {
> >                       if (mode->hdisplay != native_mode->hdisplay ||
> >                           mode->vdisplay != native_mode->vdisplay)
> > -                             memcpy(native_mode, mode, sizeof(*mode));
> > +                             drm_mode_copy(native_mode, mode);
> >               }
> >       }
> >
> > @@ -635,7 +635,7 @@ amdgpu_connector_fixup_lcd_native_mode(struct drm_encoder *encoder,
> >               list_for_each_entry_safe(mode, t, &connector->probed_modes, head) {
> >                       if (mode->hdisplay == native_mode->hdisplay &&
> >                           mode->vdisplay == native_mode->vdisplay) {
> > -                             *native_mode = *mode;
> > +                             drm_mode_copy(native_mode, mode);
> >                               drm_mode_set_crtcinfo(native_mode, CRTC_INTERLACE_HALVE_V);
> >                               DRM_DEBUG_KMS("Determined LVDS native mode details from EDID\n");
> >                               break;
> > diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> > index bd23c9e481eb..514280699ad5 100644
> > --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> > +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> > @@ -6318,7 +6318,7 @@ get_highest_refresh_rate_mode(struct amdgpu_dm_connector *aconnector,
> >               }
> >       }
> >
> > -     aconnector->freesync_vid_base = *m_pref;
> > +     drm_mode_copy(&aconnector->freesync_vid_base, m_pref);
> >       return m_pref;
> >  }
> >
> > @@ -6432,8 +6432,8 @@ create_stream_for_sink(struct amdgpu_dm_connector *aconnector,
> >               recalculate_timing = is_freesync_video_mode(&mode, aconnector);
> >               if (recalculate_timing) {
> >                       freesync_mode = get_highest_refresh_rate_mode(aconnector, false);
> > -                     saved_mode = mode;
> > -                     mode = *freesync_mode;
> > +                     drm_mode_copy(&saved_mode, &mode);
> > +                     drm_mode_copy(&mode, freesync_mode);
> >               } else {
> >                       decide_crtc_timing_for_drm_display_mode(
> >                               &mode, preferred_mode, scale);
>

^ permalink raw reply	[flat|nested] 157+ messages in thread

* Re: [PATCH 04/22] drm/amdgpu: Use drm_mode_copy()
@ 2022-03-15 18:50       ` Alex Deucher
  0 siblings, 0 replies; 157+ messages in thread
From: Alex Deucher @ 2022-03-15 18:50 UTC (permalink / raw)
  To: Harry Wentland
  Cc: Leo Li, Intel Graphics Development, Rodrigo Siqueira,
	Maling list - DRI developers, amd-gfx list, Alex Deucher,
	Ville Syrjala

Applied.  Thanks!

Alex

On Fri, Feb 18, 2022 at 11:32 AM Harry Wentland <harry.wentland@amd.com> wrote:
>
>
>
> On 2022-02-18 05:03, Ville Syrjala wrote:
> > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> >
> > struct drm_display_mode embeds a list head, so overwriting
> > the full struct with another one will corrupt the list
> > (if the destination mode is on a list). Use drm_mode_copy()
> > instead which explicitly preserves the list head of
> > the destination mode.
> >
> > Even if we know the destination mode is not on any list
> > using drm_mode_copy() seems decent as it sets a good
> > example. Bad examples of not using it might eventually
> > get copied into code where preserving the list head
> > actually matters.
> >
> > Obviously one case not covered here is when the mode
> > itself is embedded in a larger structure and the whole
> > structure is copied. But if we are careful when copying
> > into modes embedded in structures I think we can be a
> > little more reassured that bogus list heads haven't been
> > propagated in.
> >
> > @is_mode_copy@
> > @@
> > drm_mode_copy(...)
> > {
> > ...
> > }
> >
> > @depends on !is_mode_copy@
> > struct drm_display_mode *mode;
> > expression E, S;
> > @@
> > (
> > - *mode = E
> > + drm_mode_copy(mode, &E)
> > |
> > - memcpy(mode, E, S)
> > + drm_mode_copy(mode, E)
> > )
> >
> > @depends on !is_mode_copy@
> > struct drm_display_mode mode;
> > expression E;
> > @@
> > (
> > - mode = E
> > + drm_mode_copy(&mode, &E)
> > |
> > - memcpy(&mode, E, S)
> > + drm_mode_copy(&mode, E)
> > )
> >
> > @@
> > struct drm_display_mode *mode;
> > @@
> > - &*mode
> > + mode
> >
> > Cc: Alex Deucher <alexander.deucher@amd.com>
> > Cc: Harry Wentland <harry.wentland@amd.com>
> > Cc: Leo Li <sunpeng.li@amd.com>
> > Cc: Rodrigo Siqueira <Rodrigo.Siqueira@amd.com>
> > Cc: amd-gfx@lists.freedesktop.org
> > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
> Reviewed-by: Harry Wentland <harry.wentland@amd.com>
>
> Harry
>
> > ---
> >  drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c    | 4 ++--
> >  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 6 +++---
> >  2 files changed, 5 insertions(+), 5 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
> > index fa20261aa928..673078faa27a 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
> > @@ -626,7 +626,7 @@ amdgpu_connector_fixup_lcd_native_mode(struct drm_encoder *encoder,
> >               if (mode->type & DRM_MODE_TYPE_PREFERRED) {
> >                       if (mode->hdisplay != native_mode->hdisplay ||
> >                           mode->vdisplay != native_mode->vdisplay)
> > -                             memcpy(native_mode, mode, sizeof(*mode));
> > +                             drm_mode_copy(native_mode, mode);
> >               }
> >       }
> >
> > @@ -635,7 +635,7 @@ amdgpu_connector_fixup_lcd_native_mode(struct drm_encoder *encoder,
> >               list_for_each_entry_safe(mode, t, &connector->probed_modes, head) {
> >                       if (mode->hdisplay == native_mode->hdisplay &&
> >                           mode->vdisplay == native_mode->vdisplay) {
> > -                             *native_mode = *mode;
> > +                             drm_mode_copy(native_mode, mode);
> >                               drm_mode_set_crtcinfo(native_mode, CRTC_INTERLACE_HALVE_V);
> >                               DRM_DEBUG_KMS("Determined LVDS native mode details from EDID\n");
> >                               break;
> > diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> > index bd23c9e481eb..514280699ad5 100644
> > --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> > +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> > @@ -6318,7 +6318,7 @@ get_highest_refresh_rate_mode(struct amdgpu_dm_connector *aconnector,
> >               }
> >       }
> >
> > -     aconnector->freesync_vid_base = *m_pref;
> > +     drm_mode_copy(&aconnector->freesync_vid_base, m_pref);
> >       return m_pref;
> >  }
> >
> > @@ -6432,8 +6432,8 @@ create_stream_for_sink(struct amdgpu_dm_connector *aconnector,
> >               recalculate_timing = is_freesync_video_mode(&mode, aconnector);
> >               if (recalculate_timing) {
> >                       freesync_mode = get_highest_refresh_rate_mode(aconnector, false);
> > -                     saved_mode = mode;
> > -                     mode = *freesync_mode;
> > +                     drm_mode_copy(&saved_mode, &mode);
> > +                     drm_mode_copy(&mode, freesync_mode);
> >               } else {
> >                       decide_crtc_timing_for_drm_display_mode(
> >                               &mode, preferred_mode, scale);
>

^ permalink raw reply	[flat|nested] 157+ messages in thread

* Re: [PATCH 00/22] drm: Review of mode copies
  2022-03-14 22:11   ` Ville Syrjälä
                       ` (3 preceding siblings ...)
  (?)
@ 2022-03-15 18:52     ` Alex Deucher
  -1 siblings, 0 replies; 157+ messages in thread
From: Alex Deucher @ 2022-03-15 18:52 UTC (permalink / raw)
  To: Ville Syrjälä
  Cc: Maling list - DRI developers, Heiko Stübner, Emma Anholt,
	Neil Armstrong, Xinliang Liu, Thierry Reding, Jernej Skrabec,
	Andrzej Hajda, Sam Ravnborg, Rodrigo Siqueira, amd-gfx list,
	linux-rockchip, Xinwei Kong, Aurabindo Pillai, Chen Feng,
	Alain Volmat, Harry Wentland, Chun-Kuang Hu, Jonas Karlman,
	Leo Li, linux-arm-msm, Intel Graphics Development, Abhinav Kumar,
	Maxime Ripard, Nikola Cornij, John Stultz, Sean Paul,
	linux-arm-kernel, Tomi Valkeinen, Jyri Sarha, Sandy Huang,
	Robert Foss, Patrik Jakobsson, Rob Clark, Philipp Zabel,
	Alex Deucher, Tian Tao, freedreno, Laurent Pinchart

On Mon, Mar 14, 2022 at 6:12 PM Ville Syrjälä
<ville.syrjala@linux.intel.com> wrote:
>
> On Fri, Feb 18, 2022 at 12:03:41PM +0200, Ville Syrjala wrote:
> >   drm: Add drm_mode_init()
> >   drm/bridge: Use drm_mode_copy()
> >   drm/imx: Use drm_mode_duplicate()
> >   drm/panel: Use drm_mode_duplicate()
> >   drm/vc4: Use drm_mode_copy()
> These have been pushed to drm-misc-next.
>
> >   drm/amdgpu: Remove pointless on stack mode copies
> >   drm/amdgpu: Use drm_mode_init() for on-stack modes
> >   drm/amdgpu: Use drm_mode_copy()
> amdgpu ones are reviewed, but I'll leave them for the
> AMD folks to push to whichever tree they prefer.

I pulled patches 2, 4, 5 into my tree.  For 3, I'm happy to have it
land via drm-misc with the rest of the mode_init changes if you'd
prefer.

Alex


Alex

>
>
> The rest are still in need of review:
> >   drm/radeon: Use drm_mode_copy()
> >   drm/gma500: Use drm_mode_copy()
> >   drm/hisilicon: Use drm_mode_init() for on-stack modes
> >   drm/msm: Nuke weird on stack mode copy
> >   drm/msm: Use drm_mode_init() for on-stack modes
> >   drm/msm: Use drm_mode_copy()
> >   drm/mtk: Use drm_mode_init() for on-stack modes
> >   drm/rockchip: Use drm_mode_copy()
> >   drm/sti: Use drm_mode_copy()
> >   drm/tilcdc: Use drm_mode_copy()
> >   drm/i915: Use drm_mode_init() for on-stack modes
> >   drm/i915: Use drm_mode_copy()
> >   drm: Use drm_mode_init() for on-stack modes
> >   drm: Use drm_mode_copy()
>
> --
> Ville Syrjälä
> Intel

^ permalink raw reply	[flat|nested] 157+ messages in thread

* Re: [PATCH 00/22] drm: Review of mode copies
@ 2022-03-15 18:52     ` Alex Deucher
  0 siblings, 0 replies; 157+ messages in thread
From: Alex Deucher @ 2022-03-15 18:52 UTC (permalink / raw)
  To: Ville Syrjälä
  Cc: Maling list - DRI developers, Heiko Stübner, Emma Anholt,
	Neil Armstrong, Xinliang Liu, Thierry Reding, Jernej Skrabec,
	Andrzej Hajda, Sam Ravnborg, Rodrigo Siqueira, amd-gfx list,
	linux-rockchip, Xinwei Kong, Aurabindo Pillai, Chen Feng,
	Alain Volmat, Harry Wentland, Chun-Kuang Hu, Jonas Karlman,
	Leo Li, linux-arm-msm, Intel Graphics Development, Abhinav Kumar,
	Maxime Ripard, Nikola Cornij, John Stultz, Sean Paul,
	linux-arm-kernel, Tomi Valkeinen, Jyri Sarha, Sandy Huang,
	Robert Foss, Patrik Jakobsson, Rob Clark, Philipp Zabel,
	Alex Deucher, Tian Tao, freedreno, Laurent Pinchart

On Mon, Mar 14, 2022 at 6:12 PM Ville Syrjälä
<ville.syrjala@linux.intel.com> wrote:
>
> On Fri, Feb 18, 2022 at 12:03:41PM +0200, Ville Syrjala wrote:
> >   drm: Add drm_mode_init()
> >   drm/bridge: Use drm_mode_copy()
> >   drm/imx: Use drm_mode_duplicate()
> >   drm/panel: Use drm_mode_duplicate()
> >   drm/vc4: Use drm_mode_copy()
> These have been pushed to drm-misc-next.
>
> >   drm/amdgpu: Remove pointless on stack mode copies
> >   drm/amdgpu: Use drm_mode_init() for on-stack modes
> >   drm/amdgpu: Use drm_mode_copy()
> amdgpu ones are reviewed, but I'll leave them for the
> AMD folks to push to whichever tree they prefer.

I pulled patches 2, 4, 5 into my tree.  For 3, I'm happy to have it
land via drm-misc with the rest of the mode_init changes if you'd
prefer.

Alex


Alex

>
>
> The rest are still in need of review:
> >   drm/radeon: Use drm_mode_copy()
> >   drm/gma500: Use drm_mode_copy()
> >   drm/hisilicon: Use drm_mode_init() for on-stack modes
> >   drm/msm: Nuke weird on stack mode copy
> >   drm/msm: Use drm_mode_init() for on-stack modes
> >   drm/msm: Use drm_mode_copy()
> >   drm/mtk: Use drm_mode_init() for on-stack modes
> >   drm/rockchip: Use drm_mode_copy()
> >   drm/sti: Use drm_mode_copy()
> >   drm/tilcdc: Use drm_mode_copy()
> >   drm/i915: Use drm_mode_init() for on-stack modes
> >   drm/i915: Use drm_mode_copy()
> >   drm: Use drm_mode_init() for on-stack modes
> >   drm: Use drm_mode_copy()
>
> --
> Ville Syrjälä
> Intel

_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

^ permalink raw reply	[flat|nested] 157+ messages in thread

* Re: [PATCH 00/22] drm: Review of mode copies
@ 2022-03-15 18:52     ` Alex Deucher
  0 siblings, 0 replies; 157+ messages in thread
From: Alex Deucher @ 2022-03-15 18:52 UTC (permalink / raw)
  To: Ville Syrjälä
  Cc: Emma Anholt, Neil Armstrong, Xinliang Liu,
	Maling list - DRI developers, Thierry Reding, Jernej Skrabec,
	Andrzej Hajda, Sam Ravnborg, Rodrigo Siqueira, amd-gfx list,
	linux-rockchip, Xinwei Kong, Aurabindo Pillai, linux-arm-msm,
	Alain Volmat, Chun-Kuang Hu, Jonas Karlman, Leo Li, Chen Feng,
	Intel Graphics Development, Abhinav Kumar, Nikola Cornij,
	Sean Paul, linux-arm-kernel, Tomi Valkeinen, freedreno,
	Sandy Huang, Robert Foss, Alex Deucher, Tian Tao, Jyri Sarha,
	Laurent Pinchart

On Mon, Mar 14, 2022 at 6:12 PM Ville Syrjälä
<ville.syrjala@linux.intel.com> wrote:
>
> On Fri, Feb 18, 2022 at 12:03:41PM +0200, Ville Syrjala wrote:
> >   drm: Add drm_mode_init()
> >   drm/bridge: Use drm_mode_copy()
> >   drm/imx: Use drm_mode_duplicate()
> >   drm/panel: Use drm_mode_duplicate()
> >   drm/vc4: Use drm_mode_copy()
> These have been pushed to drm-misc-next.
>
> >   drm/amdgpu: Remove pointless on stack mode copies
> >   drm/amdgpu: Use drm_mode_init() for on-stack modes
> >   drm/amdgpu: Use drm_mode_copy()
> amdgpu ones are reviewed, but I'll leave them for the
> AMD folks to push to whichever tree they prefer.

I pulled patches 2, 4, 5 into my tree.  For 3, I'm happy to have it
land via drm-misc with the rest of the mode_init changes if you'd
prefer.

Alex


Alex

>
>
> The rest are still in need of review:
> >   drm/radeon: Use drm_mode_copy()
> >   drm/gma500: Use drm_mode_copy()
> >   drm/hisilicon: Use drm_mode_init() for on-stack modes
> >   drm/msm: Nuke weird on stack mode copy
> >   drm/msm: Use drm_mode_init() for on-stack modes
> >   drm/msm: Use drm_mode_copy()
> >   drm/mtk: Use drm_mode_init() for on-stack modes
> >   drm/rockchip: Use drm_mode_copy()
> >   drm/sti: Use drm_mode_copy()
> >   drm/tilcdc: Use drm_mode_copy()
> >   drm/i915: Use drm_mode_init() for on-stack modes
> >   drm/i915: Use drm_mode_copy()
> >   drm: Use drm_mode_init() for on-stack modes
> >   drm: Use drm_mode_copy()
>
> --
> Ville Syrjälä
> Intel

^ permalink raw reply	[flat|nested] 157+ messages in thread

* Re: [Intel-gfx] [PATCH 00/22] drm: Review of mode copies
@ 2022-03-15 18:52     ` Alex Deucher
  0 siblings, 0 replies; 157+ messages in thread
From: Alex Deucher @ 2022-03-15 18:52 UTC (permalink / raw)
  To: Ville Syrjälä
  Cc: Heiko Stübner, Emma Anholt, Neil Armstrong, Xinliang Liu,
	Maling list - DRI developers, Jernej Skrabec, Andrzej Hajda,
	Sam Ravnborg, Rodrigo Siqueira, amd-gfx list, linux-rockchip,
	Xinwei Kong, Aurabindo Pillai, linux-arm-msm, Alain Volmat,
	Harry Wentland, Chun-Kuang Hu, Jonas Karlman, Leo Li, Chen Feng,
	Intel Graphics Development, Abhinav Kumar, Maxime Ripard,
	Nikola Cornij, John Stultz, linux-arm-kernel, Tomi Valkeinen,
	freedreno, Sandy Huang, Robert Foss, Philipp Zabel, Alex Deucher,
	Tian Tao, Jyri Sarha, Laurent Pinchart

On Mon, Mar 14, 2022 at 6:12 PM Ville Syrjälä
<ville.syrjala@linux.intel.com> wrote:
>
> On Fri, Feb 18, 2022 at 12:03:41PM +0200, Ville Syrjala wrote:
> >   drm: Add drm_mode_init()
> >   drm/bridge: Use drm_mode_copy()
> >   drm/imx: Use drm_mode_duplicate()
> >   drm/panel: Use drm_mode_duplicate()
> >   drm/vc4: Use drm_mode_copy()
> These have been pushed to drm-misc-next.
>
> >   drm/amdgpu: Remove pointless on stack mode copies
> >   drm/amdgpu: Use drm_mode_init() for on-stack modes
> >   drm/amdgpu: Use drm_mode_copy()
> amdgpu ones are reviewed, but I'll leave them for the
> AMD folks to push to whichever tree they prefer.

I pulled patches 2, 4, 5 into my tree.  For 3, I'm happy to have it
land via drm-misc with the rest of the mode_init changes if you'd
prefer.

Alex


Alex

>
>
> The rest are still in need of review:
> >   drm/radeon: Use drm_mode_copy()
> >   drm/gma500: Use drm_mode_copy()
> >   drm/hisilicon: Use drm_mode_init() for on-stack modes
> >   drm/msm: Nuke weird on stack mode copy
> >   drm/msm: Use drm_mode_init() for on-stack modes
> >   drm/msm: Use drm_mode_copy()
> >   drm/mtk: Use drm_mode_init() for on-stack modes
> >   drm/rockchip: Use drm_mode_copy()
> >   drm/sti: Use drm_mode_copy()
> >   drm/tilcdc: Use drm_mode_copy()
> >   drm/i915: Use drm_mode_init() for on-stack modes
> >   drm/i915: Use drm_mode_copy()
> >   drm: Use drm_mode_init() for on-stack modes
> >   drm: Use drm_mode_copy()
>
> --
> Ville Syrjälä
> Intel

^ permalink raw reply	[flat|nested] 157+ messages in thread

* Re: [PATCH 00/22] drm: Review of mode copies
@ 2022-03-15 18:52     ` Alex Deucher
  0 siblings, 0 replies; 157+ messages in thread
From: Alex Deucher @ 2022-03-15 18:52 UTC (permalink / raw)
  To: Ville Syrjälä
  Cc: Heiko Stübner, Emma Anholt, Neil Armstrong, Xinliang Liu,
	Maling list - DRI developers, Thierry Reding, Jernej Skrabec,
	Andrzej Hajda, Sam Ravnborg, Rodrigo Siqueira, amd-gfx list,
	linux-rockchip, Xinwei Kong, Aurabindo Pillai, linux-arm-msm,
	Alain Volmat, Harry Wentland, Chun-Kuang Hu, Jonas Karlman,
	Leo Li, Chen Feng, Intel Graphics Development, Abhinav Kumar,
	Maxime Ripard, Nikola Cornij, John Stultz, Sean Paul,
	linux-arm-kernel, Tomi Valkeinen, freedreno, Sandy Huang,
	Robert Foss, Patrik Jakobsson, Rob Clark, Philipp Zabel,
	Alex Deucher, Tian Tao, Jyri Sarha, Laurent Pinchart

On Mon, Mar 14, 2022 at 6:12 PM Ville Syrjälä
<ville.syrjala@linux.intel.com> wrote:
>
> On Fri, Feb 18, 2022 at 12:03:41PM +0200, Ville Syrjala wrote:
> >   drm: Add drm_mode_init()
> >   drm/bridge: Use drm_mode_copy()
> >   drm/imx: Use drm_mode_duplicate()
> >   drm/panel: Use drm_mode_duplicate()
> >   drm/vc4: Use drm_mode_copy()
> These have been pushed to drm-misc-next.
>
> >   drm/amdgpu: Remove pointless on stack mode copies
> >   drm/amdgpu: Use drm_mode_init() for on-stack modes
> >   drm/amdgpu: Use drm_mode_copy()
> amdgpu ones are reviewed, but I'll leave them for the
> AMD folks to push to whichever tree they prefer.

I pulled patches 2, 4, 5 into my tree.  For 3, I'm happy to have it
land via drm-misc with the rest of the mode_init changes if you'd
prefer.

Alex


Alex

>
>
> The rest are still in need of review:
> >   drm/radeon: Use drm_mode_copy()
> >   drm/gma500: Use drm_mode_copy()
> >   drm/hisilicon: Use drm_mode_init() for on-stack modes
> >   drm/msm: Nuke weird on stack mode copy
> >   drm/msm: Use drm_mode_init() for on-stack modes
> >   drm/msm: Use drm_mode_copy()
> >   drm/mtk: Use drm_mode_init() for on-stack modes
> >   drm/rockchip: Use drm_mode_copy()
> >   drm/sti: Use drm_mode_copy()
> >   drm/tilcdc: Use drm_mode_copy()
> >   drm/i915: Use drm_mode_init() for on-stack modes
> >   drm/i915: Use drm_mode_copy()
> >   drm: Use drm_mode_init() for on-stack modes
> >   drm: Use drm_mode_copy()
>
> --
> Ville Syrjälä
> Intel

^ permalink raw reply	[flat|nested] 157+ messages in thread

* Re: [PATCH 00/22] drm: Review of mode copies
@ 2022-03-15 18:52     ` Alex Deucher
  0 siblings, 0 replies; 157+ messages in thread
From: Alex Deucher @ 2022-03-15 18:52 UTC (permalink / raw)
  To: Ville Syrjälä
  Cc: Maling list - DRI developers, Heiko Stübner, Emma Anholt,
	Neil Armstrong, Xinliang Liu, Thierry Reding, Jernej Skrabec,
	Andrzej Hajda, Sam Ravnborg, Rodrigo Siqueira, amd-gfx list,
	linux-rockchip, Xinwei Kong, Aurabindo Pillai, Chen Feng,
	Alain Volmat, Harry Wentland, Chun-Kuang Hu, Jonas Karlman,
	Leo Li, linux-arm-msm, Intel Graphics Development, Abhinav Kumar,
	Maxime Ripard, Nikola Cornij, John Stultz, Sean Paul,
	linux-arm-kernel, Tomi Valkeinen, Jyri Sarha, Sandy Huang,
	Robert Foss, Patrik Jakobsson, Rob Clark, Philipp Zabel,
	Alex Deucher, Tian Tao, freedreno, Laurent Pinchart

On Mon, Mar 14, 2022 at 6:12 PM Ville Syrjälä
<ville.syrjala@linux.intel.com> wrote:
>
> On Fri, Feb 18, 2022 at 12:03:41PM +0200, Ville Syrjala wrote:
> >   drm: Add drm_mode_init()
> >   drm/bridge: Use drm_mode_copy()
> >   drm/imx: Use drm_mode_duplicate()
> >   drm/panel: Use drm_mode_duplicate()
> >   drm/vc4: Use drm_mode_copy()
> These have been pushed to drm-misc-next.
>
> >   drm/amdgpu: Remove pointless on stack mode copies
> >   drm/amdgpu: Use drm_mode_init() for on-stack modes
> >   drm/amdgpu: Use drm_mode_copy()
> amdgpu ones are reviewed, but I'll leave them for the
> AMD folks to push to whichever tree they prefer.

I pulled patches 2, 4, 5 into my tree.  For 3, I'm happy to have it
land via drm-misc with the rest of the mode_init changes if you'd
prefer.

Alex


Alex

>
>
> The rest are still in need of review:
> >   drm/radeon: Use drm_mode_copy()
> >   drm/gma500: Use drm_mode_copy()
> >   drm/hisilicon: Use drm_mode_init() for on-stack modes
> >   drm/msm: Nuke weird on stack mode copy
> >   drm/msm: Use drm_mode_init() for on-stack modes
> >   drm/msm: Use drm_mode_copy()
> >   drm/mtk: Use drm_mode_init() for on-stack modes
> >   drm/rockchip: Use drm_mode_copy()
> >   drm/sti: Use drm_mode_copy()
> >   drm/tilcdc: Use drm_mode_copy()
> >   drm/i915: Use drm_mode_init() for on-stack modes
> >   drm/i915: Use drm_mode_copy()
> >   drm: Use drm_mode_init() for on-stack modes
> >   drm: Use drm_mode_copy()
>
> --
> Ville Syrjälä
> Intel

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 157+ messages in thread

* Re: [Intel-gfx] [PATCH 18/22] drm/i915: Use drm_mode_init() for on-stack modes
  2022-02-18 10:03   ` [Intel-gfx] " Ville Syrjala
  (?)
@ 2022-03-16  8:00   ` Jani Nikula
  2022-03-21 18:57       ` [cocci] " Ville Syrjälä
  -1 siblings, 1 reply; 157+ messages in thread
From: Jani Nikula @ 2022-03-16  8:00 UTC (permalink / raw)
  To: Ville Syrjala, dri-devel; +Cc: intel-gfx

On Fri, 18 Feb 2022, Ville Syrjala <ville.syrjala@linux.intel.com> wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
> Initialize on-stack modes with drm_mode_init() to guarantee
> no stack garbage in the list head, or that we aren't copying
> over another mode's list head.
>
> Based on the following cocci script, with manual fixups:
> @decl@
> identifier M;
> expression E;
> @@
> - struct drm_display_mode M = E;
> + struct drm_display_mode M;
>
> @@
> identifier decl.M;
> expression decl.E;
> statement S, S1;
> @@
> struct drm_display_mode M;
> ... when != S
> + drm_mode_init(&M, &E);
> +
> S1
>
> @@
> expression decl.E;
> @@
> - &*E
> + E
>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

I wonder if that cocci could be added to scripts/coccinelle or something
to detect anyone adding new ones?

Anyway,

Reviewed-by: Jani Nikula <jani.nikula@intel.com>


> ---
>  drivers/gpu/drm/i915/display/intel_display.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c
> index 740620ef07ad..74c5a99ab276 100644
> --- a/drivers/gpu/drm/i915/display/intel_display.c
> +++ b/drivers/gpu/drm/i915/display/intel_display.c
> @@ -6898,8 +6898,9 @@ intel_crtc_update_active_timings(const struct intel_crtc_state *crtc_state)
>  {
>  	struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
>  	struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
> -	struct drm_display_mode adjusted_mode =
> -		crtc_state->hw.adjusted_mode;
> +	struct drm_display_mode adjusted_mode;
> +
> +	drm_mode_init(&adjusted_mode, &crtc_state->hw.adjusted_mode);
>  
>  	if (crtc_state->vrr.enable) {
>  		adjusted_mode.crtc_vtotal = crtc_state->vrr.vmax;

-- 
Jani Nikula, Intel Open Source Graphics Center

^ permalink raw reply	[flat|nested] 157+ messages in thread

* Re: [Intel-gfx] [PATCH 19/22] drm/i915: Use drm_mode_copy()
  2022-02-18 10:04   ` [Intel-gfx] " Ville Syrjala
  (?)
@ 2022-03-16  8:04   ` Jani Nikula
  -1 siblings, 0 replies; 157+ messages in thread
From: Jani Nikula @ 2022-03-16  8:04 UTC (permalink / raw)
  To: Ville Syrjala, dri-devel; +Cc: intel-gfx

On Fri, 18 Feb 2022, Ville Syrjala <ville.syrjala@linux.intel.com> wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
> struct drm_display_mode embeds a list head, so overwriting
> the full struct with another one will corrupt the list
> (if the destination mode is on a list). Use drm_mode_copy()
> instead which explicitly preserves the list head of
> the destination mode.
>
> Even if we know the destination mode is not on any list
> using drm_mode_copy() seems decent as it sets a good
> example. Bad examples of not using it might eventually
> get copied into code where preserving the list head
> actually matters.
>
> Obviously one case not covered here is when the mode
> itself is embedded in a larger structure and the whole
> structure is copied. But if we are careful when copying
> into modes embedded in structures I think we can be a
> little more reassured that bogus list heads haven't been
> propagated in.
>
> @is_mode_copy@
> @@
> drm_mode_copy(...)
> {
> ...
> }
>
> @depends on !is_mode_copy@
> struct drm_display_mode *mode;
> expression E, S;
> @@
> (
> - *mode = E
> + drm_mode_copy(mode, &E)
> |
> - memcpy(mode, E, S)
> + drm_mode_copy(mode, E)
> )
>
> @depends on !is_mode_copy@
> struct drm_display_mode mode;
> expression E;
> @@
> (
> - mode = E
> + drm_mode_copy(&mode, &E)
> |
> - memcpy(&mode, E, S)
> + drm_mode_copy(&mode, E)
> )
>
> @@
> struct drm_display_mode *mode;
> @@
> - &*mode
> + mode
>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

Reviewed-by: Jani Nikula <jani.nikula@intel.com>


> ---
>  drivers/gpu/drm/i915/display/intel_display.c | 15 ++++++++++-----
>  1 file changed, 10 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c
> index 74c5a99ab276..661e36435793 100644
> --- a/drivers/gpu/drm/i915/display/intel_display.c
> +++ b/drivers/gpu/drm/i915/display/intel_display.c
> @@ -5506,8 +5506,10 @@ intel_crtc_copy_uapi_to_hw_state_modeset(struct intel_atomic_state *state,
>  
>  	crtc_state->hw.enable = crtc_state->uapi.enable;
>  	crtc_state->hw.active = crtc_state->uapi.active;
> -	crtc_state->hw.mode = crtc_state->uapi.mode;
> -	crtc_state->hw.adjusted_mode = crtc_state->uapi.adjusted_mode;
> +	drm_mode_copy(&crtc_state->hw.mode,
> +		      &crtc_state->uapi.mode);
> +	drm_mode_copy(&crtc_state->hw.adjusted_mode,
> +		      &crtc_state->uapi.adjusted_mode);
>  	crtc_state->hw.scaling_filter = crtc_state->uapi.scaling_filter;
>  
>  	intel_crtc_copy_uapi_to_hw_state_nomodeset(state, crtc);
> @@ -5584,9 +5586,12 @@ copy_bigjoiner_crtc_state_modeset(struct intel_atomic_state *state,
>  	memset(&slave_crtc_state->hw, 0, sizeof(slave_crtc_state->hw));
>  	slave_crtc_state->hw.enable = master_crtc_state->hw.enable;
>  	slave_crtc_state->hw.active = master_crtc_state->hw.active;
> -	slave_crtc_state->hw.mode = master_crtc_state->hw.mode;
> -	slave_crtc_state->hw.pipe_mode = master_crtc_state->hw.pipe_mode;
> -	slave_crtc_state->hw.adjusted_mode = master_crtc_state->hw.adjusted_mode;
> +	drm_mode_copy(&slave_crtc_state->hw.mode,
> +		      &master_crtc_state->hw.mode);
> +	drm_mode_copy(&slave_crtc_state->hw.pipe_mode,
> +		      &master_crtc_state->hw.pipe_mode);
> +	drm_mode_copy(&slave_crtc_state->hw.adjusted_mode,
> +		      &master_crtc_state->hw.adjusted_mode);
>  	slave_crtc_state->hw.scaling_filter = master_crtc_state->hw.scaling_filter;
>  
>  	copy_bigjoiner_crtc_state_nomodeset(state, slave_crtc);

-- 
Jani Nikula, Intel Open Source Graphics Center

^ permalink raw reply	[flat|nested] 157+ messages in thread

* Re: [PATCH 07/22] drm/gma500: Use drm_mode_copy()
  2022-02-18 10:03   ` [Intel-gfx] " Ville Syrjala
@ 2022-03-16 13:16     ` Patrik Jakobsson
  -1 siblings, 0 replies; 157+ messages in thread
From: Patrik Jakobsson @ 2022-03-16 13:16 UTC (permalink / raw)
  To: Ville Syrjala; +Cc: Intel Graphics Development, dri-devel

On Fri, Feb 18, 2022 at 11:04 AM Ville Syrjala
<ville.syrjala@linux.intel.com> wrote:
>
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
> struct drm_display_mode embeds a list head, so overwriting
> the full struct with another one will corrupt the list
> (if the destination mode is on a list). Use drm_mode_copy()
> instead which explicitly preserves the list head of
> the destination mode.
>
> Even if we know the destination mode is not on any list
> using drm_mode_copy() seems decent as it sets a good
> example. Bad examples of not using it might eventually
> get copied into code where preserving the list head
> actually matters.
>
> Obviously one case not covered here is when the mode
> itself is embedded in a larger structure and the whole
> structure is copied. But if we are careful when copying
> into modes embedded in structures I think we can be a
> little more reassured that bogus list heads haven't been
> propagated in.
>
> @is_mode_copy@
> @@
> drm_mode_copy(...)
> {
> ...
> }
>
> @depends on !is_mode_copy@
> struct drm_display_mode *mode;
> expression E, S;
> @@
> (
> - *mode = E
> + drm_mode_copy(mode, &E)
> |
> - memcpy(mode, E, S)
> + drm_mode_copy(mode, E)
> )
>
> @depends on !is_mode_copy@
> struct drm_display_mode mode;
> expression E;
> @@
> (
> - mode = E
> + drm_mode_copy(&mode, &E)
> |
> - memcpy(&mode, E, S)
> + drm_mode_copy(&mode, E)
> )
>
> @@
> struct drm_display_mode *mode;
> @@
> - &*mode
> + mode
>
> Cc: Patrik Jakobsson <patrik.r.jakobsson@gmail.com>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

Looks good. Thanks!
Acked-by: Patrik Jakobsson <patrik.r.jakobsson@gmail.com>

> ---
>  drivers/gpu/drm/gma500/oaktrail_crtc.c | 8 ++------
>  1 file changed, 2 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpu/drm/gma500/oaktrail_crtc.c b/drivers/gpu/drm/gma500/oaktrail_crtc.c
> index 36c7c2686c90..79fc602b35bc 100644
> --- a/drivers/gpu/drm/gma500/oaktrail_crtc.c
> +++ b/drivers/gpu/drm/gma500/oaktrail_crtc.c
> @@ -385,12 +385,8 @@ static int oaktrail_crtc_mode_set(struct drm_crtc *crtc,
>         if (!gma_power_begin(dev, true))
>                 return 0;
>
> -       memcpy(&gma_crtc->saved_mode,
> -               mode,
> -               sizeof(struct drm_display_mode));
> -       memcpy(&gma_crtc->saved_adjusted_mode,
> -               adjusted_mode,
> -               sizeof(struct drm_display_mode));
> +       drm_mode_copy(&gma_crtc->saved_mode, mode);
> +       drm_mode_copy(&gma_crtc->saved_adjusted_mode, adjusted_mode);
>
>         list_for_each_entry(connector, &mode_config->connector_list, head) {
>                 if (!connector->encoder || connector->encoder->crtc != crtc)
> --
> 2.34.1
>

^ permalink raw reply	[flat|nested] 157+ messages in thread

* Re: [Intel-gfx] [PATCH 07/22] drm/gma500: Use drm_mode_copy()
@ 2022-03-16 13:16     ` Patrik Jakobsson
  0 siblings, 0 replies; 157+ messages in thread
From: Patrik Jakobsson @ 2022-03-16 13:16 UTC (permalink / raw)
  To: Ville Syrjala; +Cc: Intel Graphics Development, dri-devel

On Fri, Feb 18, 2022 at 11:04 AM Ville Syrjala
<ville.syrjala@linux.intel.com> wrote:
>
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
> struct drm_display_mode embeds a list head, so overwriting
> the full struct with another one will corrupt the list
> (if the destination mode is on a list). Use drm_mode_copy()
> instead which explicitly preserves the list head of
> the destination mode.
>
> Even if we know the destination mode is not on any list
> using drm_mode_copy() seems decent as it sets a good
> example. Bad examples of not using it might eventually
> get copied into code where preserving the list head
> actually matters.
>
> Obviously one case not covered here is when the mode
> itself is embedded in a larger structure and the whole
> structure is copied. But if we are careful when copying
> into modes embedded in structures I think we can be a
> little more reassured that bogus list heads haven't been
> propagated in.
>
> @is_mode_copy@
> @@
> drm_mode_copy(...)
> {
> ...
> }
>
> @depends on !is_mode_copy@
> struct drm_display_mode *mode;
> expression E, S;
> @@
> (
> - *mode = E
> + drm_mode_copy(mode, &E)
> |
> - memcpy(mode, E, S)
> + drm_mode_copy(mode, E)
> )
>
> @depends on !is_mode_copy@
> struct drm_display_mode mode;
> expression E;
> @@
> (
> - mode = E
> + drm_mode_copy(&mode, &E)
> |
> - memcpy(&mode, E, S)
> + drm_mode_copy(&mode, E)
> )
>
> @@
> struct drm_display_mode *mode;
> @@
> - &*mode
> + mode
>
> Cc: Patrik Jakobsson <patrik.r.jakobsson@gmail.com>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

Looks good. Thanks!
Acked-by: Patrik Jakobsson <patrik.r.jakobsson@gmail.com>

> ---
>  drivers/gpu/drm/gma500/oaktrail_crtc.c | 8 ++------
>  1 file changed, 2 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpu/drm/gma500/oaktrail_crtc.c b/drivers/gpu/drm/gma500/oaktrail_crtc.c
> index 36c7c2686c90..79fc602b35bc 100644
> --- a/drivers/gpu/drm/gma500/oaktrail_crtc.c
> +++ b/drivers/gpu/drm/gma500/oaktrail_crtc.c
> @@ -385,12 +385,8 @@ static int oaktrail_crtc_mode_set(struct drm_crtc *crtc,
>         if (!gma_power_begin(dev, true))
>                 return 0;
>
> -       memcpy(&gma_crtc->saved_mode,
> -               mode,
> -               sizeof(struct drm_display_mode));
> -       memcpy(&gma_crtc->saved_adjusted_mode,
> -               adjusted_mode,
> -               sizeof(struct drm_display_mode));
> +       drm_mode_copy(&gma_crtc->saved_mode, mode);
> +       drm_mode_copy(&gma_crtc->saved_adjusted_mode, adjusted_mode);
>
>         list_for_each_entry(connector, &mode_config->connector_list, head) {
>                 if (!connector->encoder || connector->encoder->crtc != crtc)
> --
> 2.34.1
>

^ permalink raw reply	[flat|nested] 157+ messages in thread

* Re: [Intel-gfx] [PATCH 18/22] drm/i915: Use drm_mode_init() for on-stack modes
  2022-03-16  8:00   ` Jani Nikula
@ 2022-03-21 18:57       ` Ville Syrjälä
  0 siblings, 0 replies; 157+ messages in thread
From: Ville Syrjälä @ 2022-03-21 18:57 UTC (permalink / raw)
  To: Jani Nikula; +Cc: Julia Lawall, intel-gfx, Nicolas Palix, cocci, dri-devel

On Wed, Mar 16, 2022 at 10:00:06AM +0200, Jani Nikula wrote:
> On Fri, 18 Feb 2022, Ville Syrjala <ville.syrjala@linux.intel.com> wrote:
> > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> >
> > Initialize on-stack modes with drm_mode_init() to guarantee
> > no stack garbage in the list head, or that we aren't copying
> > over another mode's list head.
> >
> > Based on the following cocci script, with manual fixups:
> > @decl@
> > identifier M;
> > expression E;
> > @@
> > - struct drm_display_mode M = E;
> > + struct drm_display_mode M;
> >
> > @@
> > identifier decl.M;
> > expression decl.E;
> > statement S, S1;
> > @@
> > struct drm_display_mode M;
> > ... when != S
> > + drm_mode_init(&M, &E);
> > +
> > S1
> >
> > @@
> > expression decl.E;
> > @@
> > - &*E
> > + E
> >
> > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> I wonder if that cocci could be added to scripts/coccinelle or something
> to detect anyone adding new ones?

Maybe.

Julia & co, would you be open to having drm subsystem specific
coccinelle scripts? If so where should we put the?
scripts/coccinelle/drm perhaps?

-- 
Ville Syrjälä
Intel

^ permalink raw reply	[flat|nested] 157+ messages in thread

* Re: [cocci] [Intel-gfx] [PATCH 18/22] drm/i915: Use drm_mode_init() for on-stack modes
@ 2022-03-21 18:57       ` Ville Syrjälä
  0 siblings, 0 replies; 157+ messages in thread
From: Ville Syrjälä @ 2022-03-21 18:57 UTC (permalink / raw)
  To: Jani Nikula; +Cc: dri-devel, intel-gfx, Julia Lawall, Nicolas Palix, cocci

On Wed, Mar 16, 2022 at 10:00:06AM +0200, Jani Nikula wrote:
> On Fri, 18 Feb 2022, Ville Syrjala <ville.syrjala@linux.intel.com> wrote:
> > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> >
> > Initialize on-stack modes with drm_mode_init() to guarantee
> > no stack garbage in the list head, or that we aren't copying
> > over another mode's list head.
> >
> > Based on the following cocci script, with manual fixups:
> > @decl@
> > identifier M;
> > expression E;
> > @@
> > - struct drm_display_mode M = E;
> > + struct drm_display_mode M;
> >
> > @@
> > identifier decl.M;
> > expression decl.E;
> > statement S, S1;
> > @@
> > struct drm_display_mode M;
> > ... when != S
> > + drm_mode_init(&M, &E);
> > +
> > S1
> >
> > @@
> > expression decl.E;
> > @@
> > - &*E
> > + E
> >
> > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> I wonder if that cocci could be added to scripts/coccinelle or something
> to detect anyone adding new ones?

Maybe.

Julia & co, would you be open to having drm subsystem specific
coccinelle scripts? If so where should we put the?
scripts/coccinelle/drm perhaps?

-- 
Ville Syrjälä
Intel

^ permalink raw reply	[flat|nested] 157+ messages in thread

* Re: [cocci] [Intel-gfx] [PATCH 18/22] drm/i915: Use drm_mode_init() for on-stack modes
  2022-03-21 18:57       ` [cocci] " Ville Syrjälä
@ 2022-03-21 20:48         ` Julia Lawall
  -1 siblings, 0 replies; 157+ messages in thread
From: Julia Lawall @ 2022-03-21 20:48 UTC (permalink / raw)
  To: Ville Syrjälä
  Cc: Jani Nikula, dri-devel, intel-gfx, Nicolas Palix, cocci

[-- Attachment #1: Type: text/plain, Size: 1460 bytes --]



On Mon, 21 Mar 2022, Ville Syrjälä wrote:

> On Wed, Mar 16, 2022 at 10:00:06AM +0200, Jani Nikula wrote:
> > On Fri, 18 Feb 2022, Ville Syrjala <ville.syrjala@linux.intel.com> wrote:
> > > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > >
> > > Initialize on-stack modes with drm_mode_init() to guarantee
> > > no stack garbage in the list head, or that we aren't copying
> > > over another mode's list head.
> > >
> > > Based on the following cocci script, with manual fixups:
> > > @decl@
> > > identifier M;
> > > expression E;
> > > @@
> > > - struct drm_display_mode M = E;
> > > + struct drm_display_mode M;
> > >
> > > @@
> > > identifier decl.M;
> > > expression decl.E;
> > > statement S, S1;
> > > @@
> > > struct drm_display_mode M;
> > > ... when != S
> > > + drm_mode_init(&M, &E);
> > > +
> > > S1
> > >
> > > @@
> > > expression decl.E;
> > > @@
> > > - &*E
> > > + E
> > >
> > > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> >
> > I wonder if that cocci could be added to scripts/coccinelle or something
> > to detect anyone adding new ones?
>
> Maybe.
>
> Julia & co, would you be open to having drm subsystem specific
> coccinelle scripts? If so where should we put the?
> scripts/coccinelle/drm perhaps?

That would be fine.  It is possible to make a script only apply to a
specific directory, but I think that that is not necessary in this case,
since you mention types that are only relevant to drm code.

julia

^ permalink raw reply	[flat|nested] 157+ messages in thread

* Re: [Intel-gfx] [PATCH 18/22] drm/i915: Use drm_mode_init() for on-stack modes
@ 2022-03-21 20:48         ` Julia Lawall
  0 siblings, 0 replies; 157+ messages in thread
From: Julia Lawall @ 2022-03-21 20:48 UTC (permalink / raw)
  To: Ville Syrjälä; +Cc: intel-gfx, Nicolas Palix, dri-devel, cocci

[-- Attachment #1: Type: text/plain, Size: 1460 bytes --]



On Mon, 21 Mar 2022, Ville Syrjälä wrote:

> On Wed, Mar 16, 2022 at 10:00:06AM +0200, Jani Nikula wrote:
> > On Fri, 18 Feb 2022, Ville Syrjala <ville.syrjala@linux.intel.com> wrote:
> > > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > >
> > > Initialize on-stack modes with drm_mode_init() to guarantee
> > > no stack garbage in the list head, or that we aren't copying
> > > over another mode's list head.
> > >
> > > Based on the following cocci script, with manual fixups:
> > > @decl@
> > > identifier M;
> > > expression E;
> > > @@
> > > - struct drm_display_mode M = E;
> > > + struct drm_display_mode M;
> > >
> > > @@
> > > identifier decl.M;
> > > expression decl.E;
> > > statement S, S1;
> > > @@
> > > struct drm_display_mode M;
> > > ... when != S
> > > + drm_mode_init(&M, &E);
> > > +
> > > S1
> > >
> > > @@
> > > expression decl.E;
> > > @@
> > > - &*E
> > > + E
> > >
> > > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> >
> > I wonder if that cocci could be added to scripts/coccinelle or something
> > to detect anyone adding new ones?
>
> Maybe.
>
> Julia & co, would you be open to having drm subsystem specific
> coccinelle scripts? If so where should we put the?
> scripts/coccinelle/drm perhaps?

That would be fine.  It is possible to make a script only apply to a
specific directory, but I think that that is not necessary in this case,
since you mention types that are only relevant to drm code.

julia

^ permalink raw reply	[flat|nested] 157+ messages in thread

* Re: [PATCH 00/22] drm: Review of mode copies
  2022-03-15 18:52     ` Alex Deucher
                         ` (3 preceding siblings ...)
  (?)
@ 2022-03-21 22:37       ` Ville Syrjälä
  -1 siblings, 0 replies; 157+ messages in thread
From: Ville Syrjälä @ 2022-03-21 22:37 UTC (permalink / raw)
  To: Alex Deucher
  Cc: Emma Anholt, Neil Armstrong, Xinliang Liu,
	Maling list - DRI developers, Thierry Reding, Jernej Skrabec,
	Andrzej Hajda, Sam Ravnborg, Rodrigo Siqueira, amd-gfx list,
	linux-rockchip, Xinwei Kong, Aurabindo Pillai, linux-arm-msm,
	Alain Volmat, Chun-Kuang Hu, Jonas Karlman, Leo Li, Chen Feng,
	Intel Graphics Development, Abhinav Kumar, Nikola Cornij,
	Sean Paul, linux-arm-kernel, Tomi Valkeinen, freedreno,
	Sandy Huang, Robert Foss, Alex Deucher, Tian Tao, Jyri Sarha,
	Laurent Pinchart

On Tue, Mar 15, 2022 at 02:52:38PM -0400, Alex Deucher wrote:
> On Mon, Mar 14, 2022 at 6:12 PM Ville Syrjälä
> <ville.syrjala@linux.intel.com> wrote:
> >
> > On Fri, Feb 18, 2022 at 12:03:41PM +0200, Ville Syrjala wrote:
> > >   drm: Add drm_mode_init()
> > >   drm/bridge: Use drm_mode_copy()
> > >   drm/imx: Use drm_mode_duplicate()
> > >   drm/panel: Use drm_mode_duplicate()
> > >   drm/vc4: Use drm_mode_copy()
> > These have been pushed to drm-misc-next.
> >
> > >   drm/amdgpu: Remove pointless on stack mode copies
> > >   drm/amdgpu: Use drm_mode_init() for on-stack modes
> > >   drm/amdgpu: Use drm_mode_copy()
> > amdgpu ones are reviewed, but I'll leave them for the
> > AMD folks to push to whichever tree they prefer.
> 
> I pulled patches 2, 4, 5 into my tree.

Thanks.

> For 3, I'm happy to have it
> land via drm-misc with the rest of the mode_init changes if you'd
> prefer.

Either way works for me. I don't yet have reviews yet for
the other drivers, so I'll proably hold off for a bit more
at least. And the i915 patch I'll be merging via drm-intel.

> > >   drm/radeon: Use drm_mode_copy()
> > >   drm/gma500: Use drm_mode_copy()
> > >   drm/tilcdc: Use drm_mode_copy()
> > >   drm/i915: Use drm_mode_copy()

Those are now all in.

Which leaves us with these stragglers:
> > >   drm/hisilicon: Use drm_mode_init() for on-stack modes
> > >   drm/msm: Nuke weird on stack mode copy
> > >   drm/msm: Use drm_mode_init() for on-stack modes
> > >   drm/msm: Use drm_mode_copy()
> > >   drm/mtk: Use drm_mode_init() for on-stack modes
> > >   drm/rockchip: Use drm_mode_copy()
> > >   drm/sti: Use drm_mode_copy()
> > >   drm: Use drm_mode_init() for on-stack modes
> > >   drm: Use drm_mode_copy()

-- 
Ville Syrjälä
Intel

^ permalink raw reply	[flat|nested] 157+ messages in thread

* Re: [Intel-gfx] [PATCH 00/22] drm: Review of mode copies
@ 2022-03-21 22:37       ` Ville Syrjälä
  0 siblings, 0 replies; 157+ messages in thread
From: Ville Syrjälä @ 2022-03-21 22:37 UTC (permalink / raw)
  To: Alex Deucher
  Cc: Heiko Stübner, Emma Anholt, Neil Armstrong, Xinliang Liu,
	Maling list - DRI developers, Jernej Skrabec, Andrzej Hajda,
	Sam Ravnborg, Rodrigo Siqueira, amd-gfx list, linux-rockchip,
	Xinwei Kong, Aurabindo Pillai, linux-arm-msm, Alain Volmat,
	Harry Wentland, Chun-Kuang Hu, Jonas Karlman, Leo Li, Chen Feng,
	Intel Graphics Development, Abhinav Kumar, Maxime Ripard,
	Nikola Cornij, John Stultz, linux-arm-kernel, Tomi Valkeinen,
	freedreno, Sandy Huang, Robert Foss, Philipp Zabel, Alex Deucher,
	Tian Tao, Jyri Sarha, Laurent Pinchart

On Tue, Mar 15, 2022 at 02:52:38PM -0400, Alex Deucher wrote:
> On Mon, Mar 14, 2022 at 6:12 PM Ville Syrjälä
> <ville.syrjala@linux.intel.com> wrote:
> >
> > On Fri, Feb 18, 2022 at 12:03:41PM +0200, Ville Syrjala wrote:
> > >   drm: Add drm_mode_init()
> > >   drm/bridge: Use drm_mode_copy()
> > >   drm/imx: Use drm_mode_duplicate()
> > >   drm/panel: Use drm_mode_duplicate()
> > >   drm/vc4: Use drm_mode_copy()
> > These have been pushed to drm-misc-next.
> >
> > >   drm/amdgpu: Remove pointless on stack mode copies
> > >   drm/amdgpu: Use drm_mode_init() for on-stack modes
> > >   drm/amdgpu: Use drm_mode_copy()
> > amdgpu ones are reviewed, but I'll leave them for the
> > AMD folks to push to whichever tree they prefer.
> 
> I pulled patches 2, 4, 5 into my tree.

Thanks.

> For 3, I'm happy to have it
> land via drm-misc with the rest of the mode_init changes if you'd
> prefer.

Either way works for me. I don't yet have reviews yet for
the other drivers, so I'll proably hold off for a bit more
at least. And the i915 patch I'll be merging via drm-intel.

> > >   drm/radeon: Use drm_mode_copy()
> > >   drm/gma500: Use drm_mode_copy()
> > >   drm/tilcdc: Use drm_mode_copy()
> > >   drm/i915: Use drm_mode_copy()

Those are now all in.

Which leaves us with these stragglers:
> > >   drm/hisilicon: Use drm_mode_init() for on-stack modes
> > >   drm/msm: Nuke weird on stack mode copy
> > >   drm/msm: Use drm_mode_init() for on-stack modes
> > >   drm/msm: Use drm_mode_copy()
> > >   drm/mtk: Use drm_mode_init() for on-stack modes
> > >   drm/rockchip: Use drm_mode_copy()
> > >   drm/sti: Use drm_mode_copy()
> > >   drm: Use drm_mode_init() for on-stack modes
> > >   drm: Use drm_mode_copy()

-- 
Ville Syrjälä
Intel

^ permalink raw reply	[flat|nested] 157+ messages in thread

* Re: [PATCH 00/22] drm: Review of mode copies
@ 2022-03-21 22:37       ` Ville Syrjälä
  0 siblings, 0 replies; 157+ messages in thread
From: Ville Syrjälä @ 2022-03-21 22:37 UTC (permalink / raw)
  To: Alex Deucher
  Cc: Heiko Stübner, Emma Anholt, Neil Armstrong, Xinliang Liu,
	Maling list - DRI developers, Thierry Reding, Jernej Skrabec,
	Andrzej Hajda, Sam Ravnborg, Rodrigo Siqueira, amd-gfx list,
	linux-rockchip, Xinwei Kong, Aurabindo Pillai, linux-arm-msm,
	Alain Volmat, Harry Wentland, Chun-Kuang Hu, Jonas Karlman,
	Leo Li, Chen Feng, Intel Graphics Development, Abhinav Kumar,
	Maxime Ripard, Nikola Cornij, John Stultz, Sean Paul,
	linux-arm-kernel, Tomi Valkeinen, freedreno, Sandy Huang,
	Robert Foss, Patrik Jakobsson, Rob Clark, Philipp Zabel,
	Alex Deucher, Tian Tao, Jyri Sarha, Laurent Pinchart

On Tue, Mar 15, 2022 at 02:52:38PM -0400, Alex Deucher wrote:
> On Mon, Mar 14, 2022 at 6:12 PM Ville Syrjälä
> <ville.syrjala@linux.intel.com> wrote:
> >
> > On Fri, Feb 18, 2022 at 12:03:41PM +0200, Ville Syrjala wrote:
> > >   drm: Add drm_mode_init()
> > >   drm/bridge: Use drm_mode_copy()
> > >   drm/imx: Use drm_mode_duplicate()
> > >   drm/panel: Use drm_mode_duplicate()
> > >   drm/vc4: Use drm_mode_copy()
> > These have been pushed to drm-misc-next.
> >
> > >   drm/amdgpu: Remove pointless on stack mode copies
> > >   drm/amdgpu: Use drm_mode_init() for on-stack modes
> > >   drm/amdgpu: Use drm_mode_copy()
> > amdgpu ones are reviewed, but I'll leave them for the
> > AMD folks to push to whichever tree they prefer.
> 
> I pulled patches 2, 4, 5 into my tree.

Thanks.

> For 3, I'm happy to have it
> land via drm-misc with the rest of the mode_init changes if you'd
> prefer.

Either way works for me. I don't yet have reviews yet for
the other drivers, so I'll proably hold off for a bit more
at least. And the i915 patch I'll be merging via drm-intel.

> > >   drm/radeon: Use drm_mode_copy()
> > >   drm/gma500: Use drm_mode_copy()
> > >   drm/tilcdc: Use drm_mode_copy()
> > >   drm/i915: Use drm_mode_copy()

Those are now all in.

Which leaves us with these stragglers:
> > >   drm/hisilicon: Use drm_mode_init() for on-stack modes
> > >   drm/msm: Nuke weird on stack mode copy
> > >   drm/msm: Use drm_mode_init() for on-stack modes
> > >   drm/msm: Use drm_mode_copy()
> > >   drm/mtk: Use drm_mode_init() for on-stack modes
> > >   drm/rockchip: Use drm_mode_copy()
> > >   drm/sti: Use drm_mode_copy()
> > >   drm: Use drm_mode_init() for on-stack modes
> > >   drm: Use drm_mode_copy()

-- 
Ville Syrjälä
Intel

^ permalink raw reply	[flat|nested] 157+ messages in thread

* Re: [PATCH 00/22] drm: Review of mode copies
@ 2022-03-21 22:37       ` Ville Syrjälä
  0 siblings, 0 replies; 157+ messages in thread
From: Ville Syrjälä @ 2022-03-21 22:37 UTC (permalink / raw)
  To: Alex Deucher
  Cc: Maling list - DRI developers, Heiko Stübner, Emma Anholt,
	Neil Armstrong, Xinliang Liu, Thierry Reding, Jernej Skrabec,
	Andrzej Hajda, Sam Ravnborg, Rodrigo Siqueira, amd-gfx list,
	linux-rockchip, Xinwei Kong, Aurabindo Pillai, Chen Feng,
	Alain Volmat, Harry Wentland, Chun-Kuang Hu, Jonas Karlman,
	Leo Li, linux-arm-msm, Intel Graphics Development, Abhinav Kumar,
	Maxime Ripard, Nikola Cornij, John Stultz, Sean Paul,
	linux-arm-kernel, Tomi Valkeinen, Jyri Sarha, Sandy Huang,
	Robert Foss, Patrik Jakobsson, Rob Clark, Philipp Zabel,
	Alex Deucher, Tian Tao, freedreno, Laurent Pinchart

On Tue, Mar 15, 2022 at 02:52:38PM -0400, Alex Deucher wrote:
> On Mon, Mar 14, 2022 at 6:12 PM Ville Syrjälä
> <ville.syrjala@linux.intel.com> wrote:
> >
> > On Fri, Feb 18, 2022 at 12:03:41PM +0200, Ville Syrjala wrote:
> > >   drm: Add drm_mode_init()
> > >   drm/bridge: Use drm_mode_copy()
> > >   drm/imx: Use drm_mode_duplicate()
> > >   drm/panel: Use drm_mode_duplicate()
> > >   drm/vc4: Use drm_mode_copy()
> > These have been pushed to drm-misc-next.
> >
> > >   drm/amdgpu: Remove pointless on stack mode copies
> > >   drm/amdgpu: Use drm_mode_init() for on-stack modes
> > >   drm/amdgpu: Use drm_mode_copy()
> > amdgpu ones are reviewed, but I'll leave them for the
> > AMD folks to push to whichever tree they prefer.
> 
> I pulled patches 2, 4, 5 into my tree.

Thanks.

> For 3, I'm happy to have it
> land via drm-misc with the rest of the mode_init changes if you'd
> prefer.

Either way works for me. I don't yet have reviews yet for
the other drivers, so I'll proably hold off for a bit more
at least. And the i915 patch I'll be merging via drm-intel.

> > >   drm/radeon: Use drm_mode_copy()
> > >   drm/gma500: Use drm_mode_copy()
> > >   drm/tilcdc: Use drm_mode_copy()
> > >   drm/i915: Use drm_mode_copy()

Those are now all in.

Which leaves us with these stragglers:
> > >   drm/hisilicon: Use drm_mode_init() for on-stack modes
> > >   drm/msm: Nuke weird on stack mode copy
> > >   drm/msm: Use drm_mode_init() for on-stack modes
> > >   drm/msm: Use drm_mode_copy()
> > >   drm/mtk: Use drm_mode_init() for on-stack modes
> > >   drm/rockchip: Use drm_mode_copy()
> > >   drm/sti: Use drm_mode_copy()
> > >   drm: Use drm_mode_init() for on-stack modes
> > >   drm: Use drm_mode_copy()

-- 
Ville Syrjälä
Intel

_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

^ permalink raw reply	[flat|nested] 157+ messages in thread

* Re: [PATCH 00/22] drm: Review of mode copies
@ 2022-03-21 22:37       ` Ville Syrjälä
  0 siblings, 0 replies; 157+ messages in thread
From: Ville Syrjälä @ 2022-03-21 22:37 UTC (permalink / raw)
  To: Alex Deucher
  Cc: Maling list - DRI developers, Heiko Stübner, Emma Anholt,
	Neil Armstrong, Xinliang Liu, Thierry Reding, Jernej Skrabec,
	Andrzej Hajda, Sam Ravnborg, Rodrigo Siqueira, amd-gfx list,
	linux-rockchip, Xinwei Kong, Aurabindo Pillai, Chen Feng,
	Alain Volmat, Harry Wentland, Chun-Kuang Hu, Jonas Karlman,
	Leo Li, linux-arm-msm, Intel Graphics Development, Abhinav Kumar,
	Maxime Ripard, Nikola Cornij, John Stultz, Sean Paul,
	linux-arm-kernel, Tomi Valkeinen, Jyri Sarha, Sandy Huang,
	Robert Foss, Patrik Jakobsson, Rob Clark, Philipp Zabel,
	Alex Deucher, Tian Tao, freedreno, Laurent Pinchart

On Tue, Mar 15, 2022 at 02:52:38PM -0400, Alex Deucher wrote:
> On Mon, Mar 14, 2022 at 6:12 PM Ville Syrjälä
> <ville.syrjala@linux.intel.com> wrote:
> >
> > On Fri, Feb 18, 2022 at 12:03:41PM +0200, Ville Syrjala wrote:
> > >   drm: Add drm_mode_init()
> > >   drm/bridge: Use drm_mode_copy()
> > >   drm/imx: Use drm_mode_duplicate()
> > >   drm/panel: Use drm_mode_duplicate()
> > >   drm/vc4: Use drm_mode_copy()
> > These have been pushed to drm-misc-next.
> >
> > >   drm/amdgpu: Remove pointless on stack mode copies
> > >   drm/amdgpu: Use drm_mode_init() for on-stack modes
> > >   drm/amdgpu: Use drm_mode_copy()
> > amdgpu ones are reviewed, but I'll leave them for the
> > AMD folks to push to whichever tree they prefer.
> 
> I pulled patches 2, 4, 5 into my tree.

Thanks.

> For 3, I'm happy to have it
> land via drm-misc with the rest of the mode_init changes if you'd
> prefer.

Either way works for me. I don't yet have reviews yet for
the other drivers, so I'll proably hold off for a bit more
at least. And the i915 patch I'll be merging via drm-intel.

> > >   drm/radeon: Use drm_mode_copy()
> > >   drm/gma500: Use drm_mode_copy()
> > >   drm/tilcdc: Use drm_mode_copy()
> > >   drm/i915: Use drm_mode_copy()

Those are now all in.

Which leaves us with these stragglers:
> > >   drm/hisilicon: Use drm_mode_init() for on-stack modes
> > >   drm/msm: Nuke weird on stack mode copy
> > >   drm/msm: Use drm_mode_init() for on-stack modes
> > >   drm/msm: Use drm_mode_copy()
> > >   drm/mtk: Use drm_mode_init() for on-stack modes
> > >   drm/rockchip: Use drm_mode_copy()
> > >   drm/sti: Use drm_mode_copy()
> > >   drm: Use drm_mode_init() for on-stack modes
> > >   drm: Use drm_mode_copy()

-- 
Ville Syrjälä
Intel

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 157+ messages in thread

* Re: [PATCH 00/22] drm: Review of mode copies
@ 2022-03-21 22:37       ` Ville Syrjälä
  0 siblings, 0 replies; 157+ messages in thread
From: Ville Syrjälä @ 2022-03-21 22:37 UTC (permalink / raw)
  To: Alex Deucher
  Cc: Maling list - DRI developers, Heiko Stübner, Emma Anholt,
	Neil Armstrong, Xinliang Liu, Thierry Reding, Jernej Skrabec,
	Andrzej Hajda, Sam Ravnborg, Rodrigo Siqueira, amd-gfx list,
	linux-rockchip, Xinwei Kong, Aurabindo Pillai, Chen Feng,
	Alain Volmat, Harry Wentland, Chun-Kuang Hu, Jonas Karlman,
	Leo Li, linux-arm-msm, Intel Graphics Development, Abhinav Kumar,
	Maxime Ripard, Nikola Cornij, John Stultz, Sean Paul,
	linux-arm-kernel, Tomi Valkeinen, Jyri Sarha, Sandy Huang,
	Robert Foss, Patrik Jakobsson, Rob Clark, Philipp Zabel,
	Alex Deucher, Tian Tao, freedreno, Laurent Pinchart

On Tue, Mar 15, 2022 at 02:52:38PM -0400, Alex Deucher wrote:
> On Mon, Mar 14, 2022 at 6:12 PM Ville Syrjälä
> <ville.syrjala@linux.intel.com> wrote:
> >
> > On Fri, Feb 18, 2022 at 12:03:41PM +0200, Ville Syrjala wrote:
> > >   drm: Add drm_mode_init()
> > >   drm/bridge: Use drm_mode_copy()
> > >   drm/imx: Use drm_mode_duplicate()
> > >   drm/panel: Use drm_mode_duplicate()
> > >   drm/vc4: Use drm_mode_copy()
> > These have been pushed to drm-misc-next.
> >
> > >   drm/amdgpu: Remove pointless on stack mode copies
> > >   drm/amdgpu: Use drm_mode_init() for on-stack modes
> > >   drm/amdgpu: Use drm_mode_copy()
> > amdgpu ones are reviewed, but I'll leave them for the
> > AMD folks to push to whichever tree they prefer.
> 
> I pulled patches 2, 4, 5 into my tree.

Thanks.

> For 3, I'm happy to have it
> land via drm-misc with the rest of the mode_init changes if you'd
> prefer.

Either way works for me. I don't yet have reviews yet for
the other drivers, so I'll proably hold off for a bit more
at least. And the i915 patch I'll be merging via drm-intel.

> > >   drm/radeon: Use drm_mode_copy()
> > >   drm/gma500: Use drm_mode_copy()
> > >   drm/tilcdc: Use drm_mode_copy()
> > >   drm/i915: Use drm_mode_copy()

Those are now all in.

Which leaves us with these stragglers:
> > >   drm/hisilicon: Use drm_mode_init() for on-stack modes
> > >   drm/msm: Nuke weird on stack mode copy
> > >   drm/msm: Use drm_mode_init() for on-stack modes
> > >   drm/msm: Use drm_mode_copy()
> > >   drm/mtk: Use drm_mode_init() for on-stack modes
> > >   drm/rockchip: Use drm_mode_copy()
> > >   drm/sti: Use drm_mode_copy()
> > >   drm: Use drm_mode_init() for on-stack modes
> > >   drm: Use drm_mode_copy()

-- 
Ville Syrjälä
Intel

^ permalink raw reply	[flat|nested] 157+ messages in thread

* Re: [PATCH 21/22] drm: Use drm_mode_init() for on-stack modes
  2022-02-18 10:04   ` [Intel-gfx] " Ville Syrjala
@ 2022-03-22 11:10     ` Andrzej Hajda
  -1 siblings, 0 replies; 157+ messages in thread
From: Andrzej Hajda @ 2022-03-22 11:10 UTC (permalink / raw)
  To: Ville Syrjala, dri-devel; +Cc: intel-gfx

On 18.02.2022 11:04, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> Initialize on-stack modes with drm_mode_init() to guarantee
> no stack garbage in the list head, or that we aren't copying
> over another mode's list head.
> 
> Based on the following cocci script, with manual fixups:
> @decl@
> identifier M;
> expression E;
> @@
> - struct drm_display_mode M = E;
> + struct drm_display_mode M;
> 
> @@
> identifier decl.M;
> expression decl.E;
> statement S, S1;
> @@
> struct drm_display_mode M;
> ... when != S
> + drm_mode_init(&M, &E);
> +
> S1
> 
> @@
> expression decl.E;
> @@
> - &*E
> + E
> 
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---


Reviewed-by: Andrzej Hajda <andrzej.hajda@intel.com>

Regards
Andrzej

^ permalink raw reply	[flat|nested] 157+ messages in thread

* Re: [Intel-gfx] [PATCH 21/22] drm: Use drm_mode_init() for on-stack modes
@ 2022-03-22 11:10     ` Andrzej Hajda
  0 siblings, 0 replies; 157+ messages in thread
From: Andrzej Hajda @ 2022-03-22 11:10 UTC (permalink / raw)
  To: Ville Syrjala, dri-devel; +Cc: intel-gfx

On 18.02.2022 11:04, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> Initialize on-stack modes with drm_mode_init() to guarantee
> no stack garbage in the list head, or that we aren't copying
> over another mode's list head.
> 
> Based on the following cocci script, with manual fixups:
> @decl@
> identifier M;
> expression E;
> @@
> - struct drm_display_mode M = E;
> + struct drm_display_mode M;
> 
> @@
> identifier decl.M;
> expression decl.E;
> statement S, S1;
> @@
> struct drm_display_mode M;
> ... when != S
> + drm_mode_init(&M, &E);
> +
> S1
> 
> @@
> expression decl.E;
> @@
> - &*E
> + E
> 
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---


Reviewed-by: Andrzej Hajda <andrzej.hajda@intel.com>

Regards
Andrzej

^ permalink raw reply	[flat|nested] 157+ messages in thread

* Re: [PATCH 22/22] drm: Use drm_mode_copy()
  2022-02-18 10:04   ` [Intel-gfx] " Ville Syrjala
@ 2022-03-22 11:19     ` Andrzej Hajda
  -1 siblings, 0 replies; 157+ messages in thread
From: Andrzej Hajda @ 2022-03-22 11:19 UTC (permalink / raw)
  To: Ville Syrjala, dri-devel; +Cc: intel-gfx

On 18.02.2022 11:04, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> struct drm_display_mode embeds a list head, so overwriting
> the full struct with another one will corrupt the list
> (if the destination mode is on a list). Use drm_mode_copy()
> instead which explicitly preserves the list head of
> the destination mode.
> 
> Even if we know the destination mode is not on any list
> using drm_mode_copy() seems decent as it sets a good
> example. Bad examples of not using it might eventually
> get copied into code where preserving the list head
> actually matters.
> 
> Obviously one case not covered here is when the mode
> itself is embedded in a larger structure and the whole
> structure is copied. But if we are careful when copying
> into modes embedded in structures I think we can be a
> little more reassured that bogus list heads haven't been
> propagated in.
> 
> @is_mode_copy@
> @@
> drm_mode_copy(...)
> {
> ...
> }
> 
> @depends on !is_mode_copy@
> struct drm_display_mode *mode;
> expression E, S;
> @@
> (
> - *mode = E
> + drm_mode_copy(mode, &E)
> |
> - memcpy(mode, E, S)
> + drm_mode_copy(mode, E)
> )
> 
> @depends on !is_mode_copy@
> struct drm_display_mode mode;
> expression E;
> @@
> (
> - mode = E
> + drm_mode_copy(&mode, &E)
> |
> - memcpy(&mode, E, S)
> + drm_mode_copy(&mode, E)
> )
> 
> @@
> struct drm_display_mode *mode;
> @@
> - &*mode
> + mode
> 
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---

Reviewed-by: Andrzej Hajda <andrzej.hajda@intel.com>

Regards
Andrzej

^ permalink raw reply	[flat|nested] 157+ messages in thread

* Re: [Intel-gfx] [PATCH 22/22] drm: Use drm_mode_copy()
@ 2022-03-22 11:19     ` Andrzej Hajda
  0 siblings, 0 replies; 157+ messages in thread
From: Andrzej Hajda @ 2022-03-22 11:19 UTC (permalink / raw)
  To: Ville Syrjala, dri-devel; +Cc: intel-gfx

On 18.02.2022 11:04, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> struct drm_display_mode embeds a list head, so overwriting
> the full struct with another one will corrupt the list
> (if the destination mode is on a list). Use drm_mode_copy()
> instead which explicitly preserves the list head of
> the destination mode.
> 
> Even if we know the destination mode is not on any list
> using drm_mode_copy() seems decent as it sets a good
> example. Bad examples of not using it might eventually
> get copied into code where preserving the list head
> actually matters.
> 
> Obviously one case not covered here is when the mode
> itself is embedded in a larger structure and the whole
> structure is copied. But if we are careful when copying
> into modes embedded in structures I think we can be a
> little more reassured that bogus list heads haven't been
> propagated in.
> 
> @is_mode_copy@
> @@
> drm_mode_copy(...)
> {
> ...
> }
> 
> @depends on !is_mode_copy@
> struct drm_display_mode *mode;
> expression E, S;
> @@
> (
> - *mode = E
> + drm_mode_copy(mode, &E)
> |
> - memcpy(mode, E, S)
> + drm_mode_copy(mode, E)
> )
> 
> @depends on !is_mode_copy@
> struct drm_display_mode mode;
> expression E;
> @@
> (
> - mode = E
> + drm_mode_copy(&mode, &E)
> |
> - memcpy(&mode, E, S)
> + drm_mode_copy(&mode, E)
> )
> 
> @@
> struct drm_display_mode *mode;
> @@
> - &*mode
> + mode
> 
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---

Reviewed-by: Andrzej Hajda <andrzej.hajda@intel.com>

Regards
Andrzej

^ permalink raw reply	[flat|nested] 157+ messages in thread

* Re: [PATCH 11/22] drm/msm: Use drm_mode_init() for on-stack modes
  2022-02-18 10:03   ` Ville Syrjala
  (?)
@ 2022-03-23 10:11     ` Dmitry Baryshkov
  -1 siblings, 0 replies; 157+ messages in thread
From: Dmitry Baryshkov @ 2022-03-23 10:11 UTC (permalink / raw)
  To: Ville Syrjala, dri-devel
  Cc: intel-gfx, Rob Clark, Sean Paul, Abhinav Kumar, linux-arm-msm, freedreno

On 18/02/2022 13:03, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> Initialize on-stack modes with drm_mode_init() to guarantee
> no stack garbage in the list head, or that we aren't copying
> over another mode's list head.
> 
> Based on the following cocci script, with manual fixups:
> @decl@
> identifier M;
> expression E;
> @@
> - struct drm_display_mode M = E;
> + struct drm_display_mode M;
> 
> @@
> identifier decl.M;
> expression decl.E;
> statement S, S1;
> @@
> struct drm_display_mode M;
> ... when != S
> + drm_mode_init(&M, &E);
> +
> S1
> 
> @@
> expression decl.E;
> @@
> - &*E
> + E
> 
> Cc: Rob Clark <robdclark@gmail.com>
> Cc: Sean Paul <sean@poorly.run>
> Cc: Abhinav Kumar <quic_abhinavk@quicinc.com>
> Cc: linux-arm-msm@vger.kernel.org
> Cc: freedreno@lists.freedesktop.org
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>

> ---

-- 
With best wishes
Dmitry

^ permalink raw reply	[flat|nested] 157+ messages in thread

* Re: [PATCH 11/22] drm/msm: Use drm_mode_init() for on-stack modes
@ 2022-03-23 10:11     ` Dmitry Baryshkov
  0 siblings, 0 replies; 157+ messages in thread
From: Dmitry Baryshkov @ 2022-03-23 10:11 UTC (permalink / raw)
  To: Ville Syrjala, dri-devel
  Cc: Sean Paul, linux-arm-msm, intel-gfx, Abhinav Kumar, freedreno

On 18/02/2022 13:03, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> Initialize on-stack modes with drm_mode_init() to guarantee
> no stack garbage in the list head, or that we aren't copying
> over another mode's list head.
> 
> Based on the following cocci script, with manual fixups:
> @decl@
> identifier M;
> expression E;
> @@
> - struct drm_display_mode M = E;
> + struct drm_display_mode M;
> 
> @@
> identifier decl.M;
> expression decl.E;
> statement S, S1;
> @@
> struct drm_display_mode M;
> ... when != S
> + drm_mode_init(&M, &E);
> +
> S1
> 
> @@
> expression decl.E;
> @@
> - &*E
> + E
> 
> Cc: Rob Clark <robdclark@gmail.com>
> Cc: Sean Paul <sean@poorly.run>
> Cc: Abhinav Kumar <quic_abhinavk@quicinc.com>
> Cc: linux-arm-msm@vger.kernel.org
> Cc: freedreno@lists.freedesktop.org
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>

> ---

-- 
With best wishes
Dmitry

^ permalink raw reply	[flat|nested] 157+ messages in thread

* Re: [Intel-gfx] [PATCH 11/22] drm/msm: Use drm_mode_init() for on-stack modes
@ 2022-03-23 10:11     ` Dmitry Baryshkov
  0 siblings, 0 replies; 157+ messages in thread
From: Dmitry Baryshkov @ 2022-03-23 10:11 UTC (permalink / raw)
  To: Ville Syrjala, dri-devel
  Cc: linux-arm-msm, intel-gfx, Abhinav Kumar, freedreno

On 18/02/2022 13:03, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> Initialize on-stack modes with drm_mode_init() to guarantee
> no stack garbage in the list head, or that we aren't copying
> over another mode's list head.
> 
> Based on the following cocci script, with manual fixups:
> @decl@
> identifier M;
> expression E;
> @@
> - struct drm_display_mode M = E;
> + struct drm_display_mode M;
> 
> @@
> identifier decl.M;
> expression decl.E;
> statement S, S1;
> @@
> struct drm_display_mode M;
> ... when != S
> + drm_mode_init(&M, &E);
> +
> S1
> 
> @@
> expression decl.E;
> @@
> - &*E
> + E
> 
> Cc: Rob Clark <robdclark@gmail.com>
> Cc: Sean Paul <sean@poorly.run>
> Cc: Abhinav Kumar <quic_abhinavk@quicinc.com>
> Cc: linux-arm-msm@vger.kernel.org
> Cc: freedreno@lists.freedesktop.org
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>

> ---

-- 
With best wishes
Dmitry

^ permalink raw reply	[flat|nested] 157+ messages in thread

* Re: [PATCH 12/22] drm/msm: Use drm_mode_copy()
  2022-02-18 10:03   ` Ville Syrjala
  (?)
@ 2022-03-23 10:12     ` Dmitry Baryshkov
  -1 siblings, 0 replies; 157+ messages in thread
From: Dmitry Baryshkov @ 2022-03-23 10:12 UTC (permalink / raw)
  To: Ville Syrjala, dri-devel
  Cc: intel-gfx, Rob Clark, Sean Paul, Abhinav Kumar, linux-arm-msm, freedreno

On 18/02/2022 13:03, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> struct drm_display_mode embeds a list head, so overwriting
> the full struct with another one will corrupt the list
> (if the destination mode is on a list). Use drm_mode_copy()
> instead which explicitly preserves the list head of
> the destination mode.
> 
> Even if we know the destination mode is not on any list
> using drm_mode_copy() seems decent as it sets a good
> example. Bad examples of not using it might eventually
> get copied into code where preserving the list head
> actually matters.
> 
> Obviously one case not covered here is when the mode
> itself is embedded in a larger structure and the whole
> structure is copied. But if we are careful when copying
> into modes embedded in structures I think we can be a
> little more reassured that bogus list heads haven't been
> propagated in.
> 
> @is_mode_copy@
> @@
> drm_mode_copy(...)
> {
> ...
> }
> 
> @depends on !is_mode_copy@
> struct drm_display_mode *mode;
> expression E, S;
> @@
> (
> - *mode = E
> + drm_mode_copy(mode, &E)
> |
> - memcpy(mode, E, S)
> + drm_mode_copy(mode, E)
> )
> 
> @depends on !is_mode_copy@
> struct drm_display_mode mode;
> expression E;
> @@
> (
> - mode = E
> + drm_mode_copy(&mode, &E)
> |
> - memcpy(&mode, E, S)
> + drm_mode_copy(&mode, E)
> )
> 
> @@
> struct drm_display_mode *mode;
> @@
> - &*mode
> + mode
> 
> Cc: Rob Clark <robdclark@gmail.com>
> Cc: Sean Paul <sean@poorly.run>
> Cc: Abhinav Kumar <quic_abhinavk@quicinc.com>
> Cc: linux-arm-msm@vger.kernel.org
> Cc: freedreno@lists.freedesktop.org
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>

> ---


-- 
With best wishes
Dmitry

^ permalink raw reply	[flat|nested] 157+ messages in thread

* Re: [PATCH 12/22] drm/msm: Use drm_mode_copy()
@ 2022-03-23 10:12     ` Dmitry Baryshkov
  0 siblings, 0 replies; 157+ messages in thread
From: Dmitry Baryshkov @ 2022-03-23 10:12 UTC (permalink / raw)
  To: Ville Syrjala, dri-devel
  Cc: Sean Paul, linux-arm-msm, intel-gfx, Abhinav Kumar, freedreno

On 18/02/2022 13:03, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> struct drm_display_mode embeds a list head, so overwriting
> the full struct with another one will corrupt the list
> (if the destination mode is on a list). Use drm_mode_copy()
> instead which explicitly preserves the list head of
> the destination mode.
> 
> Even if we know the destination mode is not on any list
> using drm_mode_copy() seems decent as it sets a good
> example. Bad examples of not using it might eventually
> get copied into code where preserving the list head
> actually matters.
> 
> Obviously one case not covered here is when the mode
> itself is embedded in a larger structure and the whole
> structure is copied. But if we are careful when copying
> into modes embedded in structures I think we can be a
> little more reassured that bogus list heads haven't been
> propagated in.
> 
> @is_mode_copy@
> @@
> drm_mode_copy(...)
> {
> ...
> }
> 
> @depends on !is_mode_copy@
> struct drm_display_mode *mode;
> expression E, S;
> @@
> (
> - *mode = E
> + drm_mode_copy(mode, &E)
> |
> - memcpy(mode, E, S)
> + drm_mode_copy(mode, E)
> )
> 
> @depends on !is_mode_copy@
> struct drm_display_mode mode;
> expression E;
> @@
> (
> - mode = E
> + drm_mode_copy(&mode, &E)
> |
> - memcpy(&mode, E, S)
> + drm_mode_copy(&mode, E)
> )
> 
> @@
> struct drm_display_mode *mode;
> @@
> - &*mode
> + mode
> 
> Cc: Rob Clark <robdclark@gmail.com>
> Cc: Sean Paul <sean@poorly.run>
> Cc: Abhinav Kumar <quic_abhinavk@quicinc.com>
> Cc: linux-arm-msm@vger.kernel.org
> Cc: freedreno@lists.freedesktop.org
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>

> ---


-- 
With best wishes
Dmitry

^ permalink raw reply	[flat|nested] 157+ messages in thread

* Re: [Intel-gfx] [PATCH 12/22] drm/msm: Use drm_mode_copy()
@ 2022-03-23 10:12     ` Dmitry Baryshkov
  0 siblings, 0 replies; 157+ messages in thread
From: Dmitry Baryshkov @ 2022-03-23 10:12 UTC (permalink / raw)
  To: Ville Syrjala, dri-devel
  Cc: linux-arm-msm, intel-gfx, Abhinav Kumar, freedreno

On 18/02/2022 13:03, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> struct drm_display_mode embeds a list head, so overwriting
> the full struct with another one will corrupt the list
> (if the destination mode is on a list). Use drm_mode_copy()
> instead which explicitly preserves the list head of
> the destination mode.
> 
> Even if we know the destination mode is not on any list
> using drm_mode_copy() seems decent as it sets a good
> example. Bad examples of not using it might eventually
> get copied into code where preserving the list head
> actually matters.
> 
> Obviously one case not covered here is when the mode
> itself is embedded in a larger structure and the whole
> structure is copied. But if we are careful when copying
> into modes embedded in structures I think we can be a
> little more reassured that bogus list heads haven't been
> propagated in.
> 
> @is_mode_copy@
> @@
> drm_mode_copy(...)
> {
> ...
> }
> 
> @depends on !is_mode_copy@
> struct drm_display_mode *mode;
> expression E, S;
> @@
> (
> - *mode = E
> + drm_mode_copy(mode, &E)
> |
> - memcpy(mode, E, S)
> + drm_mode_copy(mode, E)
> )
> 
> @depends on !is_mode_copy@
> struct drm_display_mode mode;
> expression E;
> @@
> (
> - mode = E
> + drm_mode_copy(&mode, &E)
> |
> - memcpy(&mode, E, S)
> + drm_mode_copy(&mode, E)
> )
> 
> @@
> struct drm_display_mode *mode;
> @@
> - &*mode
> + mode
> 
> Cc: Rob Clark <robdclark@gmail.com>
> Cc: Sean Paul <sean@poorly.run>
> Cc: Abhinav Kumar <quic_abhinavk@quicinc.com>
> Cc: linux-arm-msm@vger.kernel.org
> Cc: freedreno@lists.freedesktop.org
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>

> ---


-- 
With best wishes
Dmitry

^ permalink raw reply	[flat|nested] 157+ messages in thread

* Re: [PATCH 10/22] drm/msm: Nuke weird on stack mode copy
  2022-02-18 10:03   ` Ville Syrjala
  (?)
@ 2022-03-23 10:19     ` Dmitry Baryshkov
  -1 siblings, 0 replies; 157+ messages in thread
From: Dmitry Baryshkov @ 2022-03-23 10:19 UTC (permalink / raw)
  To: Ville Syrjala, dri-devel
  Cc: intel-gfx, Rob Clark, Sean Paul, Abhinav Kumar, linux-arm-msm, freedreno

On 18/02/2022 13:03, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> This on stack middle man mode looks entirely pointless.
> Just duplicate the original mode directly.
> 
> Cc: Rob Clark <robdclark@gmail.com>
> Cc: Sean Paul <sean@poorly.run>
> Cc: Abhinav Kumar <quic_abhinavk@quicinc.com>
> Cc: linux-arm-msm@vger.kernel.org
> Cc: freedreno@lists.freedesktop.org
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

I took a glance at the surrounding piece of code.
The dp_connector_get_modes() calls dp_display_get_modes() in attempt to 
fill the dp_mode argument. However the dp_display_get_modes() function 
just calls dp_panel_get_modes(), which does not touch dp_mode argument 
since the commit ab205927592b ("drm/msm/dp: remove mode hard-coding in 
case of DP CTS") dating September 2020. I think we can drop this piece 
of code completely.

> ---
>   drivers/gpu/drm/msm/dp/dp_drm.c | 10 ++++------
>   1 file changed, 4 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/gpu/drm/msm/dp/dp_drm.c b/drivers/gpu/drm/msm/dp/dp_drm.c
> index d4d360d19eba..09188d02aa1e 100644
> --- a/drivers/gpu/drm/msm/dp/dp_drm.c
> +++ b/drivers/gpu/drm/msm/dp/dp_drm.c
> @@ -56,7 +56,7 @@ static int dp_connector_get_modes(struct drm_connector *connector)
>   	int rc = 0;
>   	struct msm_dp *dp;
>   	struct dp_display_mode *dp_mode = NULL;
> -	struct drm_display_mode *m, drm_mode;
> +	struct drm_display_mode *m;
>   
>   	if (!connector)
>   		return 0;
> @@ -82,13 +82,11 @@ static int dp_connector_get_modes(struct drm_connector *connector)
>   			return rc;
>   		}
>   		if (dp_mode->drm_mode.clock) { /* valid DP mode */
> -			memset(&drm_mode, 0x0, sizeof(drm_mode));
> -			drm_mode_copy(&drm_mode, &dp_mode->drm_mode);
> -			m = drm_mode_duplicate(connector->dev, &drm_mode);
> +			m = drm_mode_duplicate(connector->dev, &dp_mode->drm_mode);
>   			if (!m) {
>   				DRM_ERROR("failed to add mode %ux%u\n",
> -				       drm_mode.hdisplay,
> -				       drm_mode.vdisplay);
> +					  dp_mode->drm_mode.hdisplay,
> +					  dp_mode->drm_mode.vdisplay);
>   				kfree(dp_mode);
>   				return 0;
>   			}


-- 
With best wishes
Dmitry

^ permalink raw reply	[flat|nested] 157+ messages in thread

* Re: [PATCH 10/22] drm/msm: Nuke weird on stack mode copy
@ 2022-03-23 10:19     ` Dmitry Baryshkov
  0 siblings, 0 replies; 157+ messages in thread
From: Dmitry Baryshkov @ 2022-03-23 10:19 UTC (permalink / raw)
  To: Ville Syrjala, dri-devel
  Cc: Sean Paul, linux-arm-msm, intel-gfx, Abhinav Kumar, freedreno

On 18/02/2022 13:03, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> This on stack middle man mode looks entirely pointless.
> Just duplicate the original mode directly.
> 
> Cc: Rob Clark <robdclark@gmail.com>
> Cc: Sean Paul <sean@poorly.run>
> Cc: Abhinav Kumar <quic_abhinavk@quicinc.com>
> Cc: linux-arm-msm@vger.kernel.org
> Cc: freedreno@lists.freedesktop.org
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

I took a glance at the surrounding piece of code.
The dp_connector_get_modes() calls dp_display_get_modes() in attempt to 
fill the dp_mode argument. However the dp_display_get_modes() function 
just calls dp_panel_get_modes(), which does not touch dp_mode argument 
since the commit ab205927592b ("drm/msm/dp: remove mode hard-coding in 
case of DP CTS") dating September 2020. I think we can drop this piece 
of code completely.

> ---
>   drivers/gpu/drm/msm/dp/dp_drm.c | 10 ++++------
>   1 file changed, 4 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/gpu/drm/msm/dp/dp_drm.c b/drivers/gpu/drm/msm/dp/dp_drm.c
> index d4d360d19eba..09188d02aa1e 100644
> --- a/drivers/gpu/drm/msm/dp/dp_drm.c
> +++ b/drivers/gpu/drm/msm/dp/dp_drm.c
> @@ -56,7 +56,7 @@ static int dp_connector_get_modes(struct drm_connector *connector)
>   	int rc = 0;
>   	struct msm_dp *dp;
>   	struct dp_display_mode *dp_mode = NULL;
> -	struct drm_display_mode *m, drm_mode;
> +	struct drm_display_mode *m;
>   
>   	if (!connector)
>   		return 0;
> @@ -82,13 +82,11 @@ static int dp_connector_get_modes(struct drm_connector *connector)
>   			return rc;
>   		}
>   		if (dp_mode->drm_mode.clock) { /* valid DP mode */
> -			memset(&drm_mode, 0x0, sizeof(drm_mode));
> -			drm_mode_copy(&drm_mode, &dp_mode->drm_mode);
> -			m = drm_mode_duplicate(connector->dev, &drm_mode);
> +			m = drm_mode_duplicate(connector->dev, &dp_mode->drm_mode);
>   			if (!m) {
>   				DRM_ERROR("failed to add mode %ux%u\n",
> -				       drm_mode.hdisplay,
> -				       drm_mode.vdisplay);
> +					  dp_mode->drm_mode.hdisplay,
> +					  dp_mode->drm_mode.vdisplay);
>   				kfree(dp_mode);
>   				return 0;
>   			}


-- 
With best wishes
Dmitry

^ permalink raw reply	[flat|nested] 157+ messages in thread

* Re: [Intel-gfx] [PATCH 10/22] drm/msm: Nuke weird on stack mode copy
@ 2022-03-23 10:19     ` Dmitry Baryshkov
  0 siblings, 0 replies; 157+ messages in thread
From: Dmitry Baryshkov @ 2022-03-23 10:19 UTC (permalink / raw)
  To: Ville Syrjala, dri-devel
  Cc: linux-arm-msm, intel-gfx, Abhinav Kumar, freedreno

On 18/02/2022 13:03, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> This on stack middle man mode looks entirely pointless.
> Just duplicate the original mode directly.
> 
> Cc: Rob Clark <robdclark@gmail.com>
> Cc: Sean Paul <sean@poorly.run>
> Cc: Abhinav Kumar <quic_abhinavk@quicinc.com>
> Cc: linux-arm-msm@vger.kernel.org
> Cc: freedreno@lists.freedesktop.org
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

I took a glance at the surrounding piece of code.
The dp_connector_get_modes() calls dp_display_get_modes() in attempt to 
fill the dp_mode argument. However the dp_display_get_modes() function 
just calls dp_panel_get_modes(), which does not touch dp_mode argument 
since the commit ab205927592b ("drm/msm/dp: remove mode hard-coding in 
case of DP CTS") dating September 2020. I think we can drop this piece 
of code completely.

> ---
>   drivers/gpu/drm/msm/dp/dp_drm.c | 10 ++++------
>   1 file changed, 4 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/gpu/drm/msm/dp/dp_drm.c b/drivers/gpu/drm/msm/dp/dp_drm.c
> index d4d360d19eba..09188d02aa1e 100644
> --- a/drivers/gpu/drm/msm/dp/dp_drm.c
> +++ b/drivers/gpu/drm/msm/dp/dp_drm.c
> @@ -56,7 +56,7 @@ static int dp_connector_get_modes(struct drm_connector *connector)
>   	int rc = 0;
>   	struct msm_dp *dp;
>   	struct dp_display_mode *dp_mode = NULL;
> -	struct drm_display_mode *m, drm_mode;
> +	struct drm_display_mode *m;
>   
>   	if (!connector)
>   		return 0;
> @@ -82,13 +82,11 @@ static int dp_connector_get_modes(struct drm_connector *connector)
>   			return rc;
>   		}
>   		if (dp_mode->drm_mode.clock) { /* valid DP mode */
> -			memset(&drm_mode, 0x0, sizeof(drm_mode));
> -			drm_mode_copy(&drm_mode, &dp_mode->drm_mode);
> -			m = drm_mode_duplicate(connector->dev, &drm_mode);
> +			m = drm_mode_duplicate(connector->dev, &dp_mode->drm_mode);
>   			if (!m) {
>   				DRM_ERROR("failed to add mode %ux%u\n",
> -				       drm_mode.hdisplay,
> -				       drm_mode.vdisplay);
> +					  dp_mode->drm_mode.hdisplay,
> +					  dp_mode->drm_mode.vdisplay);
>   				kfree(dp_mode);
>   				return 0;
>   			}


-- 
With best wishes
Dmitry

^ permalink raw reply	[flat|nested] 157+ messages in thread

* Re: [PATCH 00/22] drm: Review of mode copies
  2022-03-21 22:37       ` [Intel-gfx] " Ville Syrjälä
                           ` (3 preceding siblings ...)
  (?)
@ 2022-03-23 10:39         ` Dmitry Baryshkov
  -1 siblings, 0 replies; 157+ messages in thread
From: Dmitry Baryshkov @ 2022-03-23 10:39 UTC (permalink / raw)
  To: Ville Syrjälä, Alex Deucher
  Cc: Maling list - DRI developers, Heiko Stübner, Emma Anholt,
	Neil Armstrong, Xinliang Liu, Thierry Reding, Jernej Skrabec,
	Andrzej Hajda, Sam Ravnborg, Rodrigo Siqueira, amd-gfx list,
	linux-rockchip, Xinwei Kong, Aurabindo Pillai, Chen Feng,
	Alain Volmat, Harry Wentland, Chun-Kuang Hu, Jonas Karlman,
	Leo Li, linux-arm-msm, Intel Graphics Development, Abhinav Kumar,
	Maxime Ripard, Nikola Cornij, John Stultz, Sean Paul,
	linux-arm-kernel, Tomi Valkeinen, Jyri Sarha, Sandy Huang,
	Robert Foss, Patrik Jakobsson, Rob Clark, Philipp Zabel,
	Alex Deucher, Tian Tao, freedreno, Laurent Pinchart

On 22/03/2022 01:37, Ville Syrjälä wrote:
> On Tue, Mar 15, 2022 at 02:52:38PM -0400, Alex Deucher wrote:
>> On Mon, Mar 14, 2022 at 6:12 PM Ville Syrjälä
>> <ville.syrjala@linux.intel.com> wrote:
>>>
>>> On Fri, Feb 18, 2022 at 12:03:41PM +0200, Ville Syrjala wrote:
>>>>    drm: Add drm_mode_init()
>>>>    drm/bridge: Use drm_mode_copy()
>>>>    drm/imx: Use drm_mode_duplicate()
>>>>    drm/panel: Use drm_mode_duplicate()
>>>>    drm/vc4: Use drm_mode_copy()
>>> These have been pushed to drm-misc-next.
>>>
>>>>    drm/amdgpu: Remove pointless on stack mode copies
>>>>    drm/amdgpu: Use drm_mode_init() for on-stack modes
>>>>    drm/amdgpu: Use drm_mode_copy()
>>> amdgpu ones are reviewed, but I'll leave them for the
>>> AMD folks to push to whichever tree they prefer.
>>
>> I pulled patches 2, 4, 5 into my tree.
> 
> Thanks.
> 
>> For 3, I'm happy to have it
>> land via drm-misc with the rest of the mode_init changes if you'd
>> prefer.
> 
> Either way works for me. I don't yet have reviews yet for
> the other drivers, so I'll proably hold off for a bit more
> at least. And the i915 patch I'll be merging via drm-intel.
> 
>>>>    drm/radeon: Use drm_mode_copy()
>>>>    drm/gma500: Use drm_mode_copy()
>>>>    drm/tilcdc: Use drm_mode_copy()
>>>>    drm/i915: Use drm_mode_copy()
> 
> Those are now all in.
> 
> Which leaves us with these stragglers:
>>>>    drm/hisilicon: Use drm_mode_init() for on-stack modes

>>>>    drm/msm: Nuke weird on stack mode copy
>>>>    drm/msm: Use drm_mode_init() for on-stack modes
>>>>    drm/msm: Use drm_mode_copy()

These three patches went beneath my radar for some reason.

I have just sent a replacement for the first patch ([1]). Other two 
patches can be pulled in msm/msm-next (or msm/msm-fixes) during the next 
development cycle if that works for you.

[1] https://patchwork.freedesktop.org/series/101682/

>>>>    drm/mtk: Use drm_mode_init() for on-stack modes
>>>>    drm/rockchip: Use drm_mode_copy()
>>>>    drm/sti: Use drm_mode_copy()
>>>>    drm: Use drm_mode_init() for on-stack modes
>>>>    drm: Use drm_mode_copy()
> 


-- 
With best wishes
Dmitry

^ permalink raw reply	[flat|nested] 157+ messages in thread

* Re: [PATCH 00/22] drm: Review of mode copies
@ 2022-03-23 10:39         ` Dmitry Baryshkov
  0 siblings, 0 replies; 157+ messages in thread
From: Dmitry Baryshkov @ 2022-03-23 10:39 UTC (permalink / raw)
  To: Ville Syrjälä, Alex Deucher
  Cc: Maling list - DRI developers, Heiko Stübner, Emma Anholt,
	Neil Armstrong, Xinliang Liu, Thierry Reding, Jernej Skrabec,
	Andrzej Hajda, Sam Ravnborg, Rodrigo Siqueira, amd-gfx list,
	linux-rockchip, Xinwei Kong, Aurabindo Pillai, Chen Feng,
	Alain Volmat, Harry Wentland, Chun-Kuang Hu, Jonas Karlman,
	Leo Li, linux-arm-msm, Intel Graphics Development, Abhinav Kumar,
	Maxime Ripard, Nikola Cornij, John Stultz, Sean Paul,
	linux-arm-kernel, Tomi Valkeinen, Jyri Sarha, Sandy Huang,
	Robert Foss, Patrik Jakobsson, Rob Clark, Philipp Zabel,
	Alex Deucher, Tian Tao, freedreno, Laurent Pinchart

On 22/03/2022 01:37, Ville Syrjälä wrote:
> On Tue, Mar 15, 2022 at 02:52:38PM -0400, Alex Deucher wrote:
>> On Mon, Mar 14, 2022 at 6:12 PM Ville Syrjälä
>> <ville.syrjala@linux.intel.com> wrote:
>>>
>>> On Fri, Feb 18, 2022 at 12:03:41PM +0200, Ville Syrjala wrote:
>>>>    drm: Add drm_mode_init()
>>>>    drm/bridge: Use drm_mode_copy()
>>>>    drm/imx: Use drm_mode_duplicate()
>>>>    drm/panel: Use drm_mode_duplicate()
>>>>    drm/vc4: Use drm_mode_copy()
>>> These have been pushed to drm-misc-next.
>>>
>>>>    drm/amdgpu: Remove pointless on stack mode copies
>>>>    drm/amdgpu: Use drm_mode_init() for on-stack modes
>>>>    drm/amdgpu: Use drm_mode_copy()
>>> amdgpu ones are reviewed, but I'll leave them for the
>>> AMD folks to push to whichever tree they prefer.
>>
>> I pulled patches 2, 4, 5 into my tree.
> 
> Thanks.
> 
>> For 3, I'm happy to have it
>> land via drm-misc with the rest of the mode_init changes if you'd
>> prefer.
> 
> Either way works for me. I don't yet have reviews yet for
> the other drivers, so I'll proably hold off for a bit more
> at least. And the i915 patch I'll be merging via drm-intel.
> 
>>>>    drm/radeon: Use drm_mode_copy()
>>>>    drm/gma500: Use drm_mode_copy()
>>>>    drm/tilcdc: Use drm_mode_copy()
>>>>    drm/i915: Use drm_mode_copy()
> 
> Those are now all in.
> 
> Which leaves us with these stragglers:
>>>>    drm/hisilicon: Use drm_mode_init() for on-stack modes

>>>>    drm/msm: Nuke weird on stack mode copy
>>>>    drm/msm: Use drm_mode_init() for on-stack modes
>>>>    drm/msm: Use drm_mode_copy()

These three patches went beneath my radar for some reason.

I have just sent a replacement for the first patch ([1]). Other two 
patches can be pulled in msm/msm-next (or msm/msm-fixes) during the next 
development cycle if that works for you.

[1] https://patchwork.freedesktop.org/series/101682/

>>>>    drm/mtk: Use drm_mode_init() for on-stack modes
>>>>    drm/rockchip: Use drm_mode_copy()
>>>>    drm/sti: Use drm_mode_copy()
>>>>    drm: Use drm_mode_init() for on-stack modes
>>>>    drm: Use drm_mode_copy()
> 


-- 
With best wishes
Dmitry

_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

^ permalink raw reply	[flat|nested] 157+ messages in thread

* Re: [PATCH 00/22] drm: Review of mode copies
@ 2022-03-23 10:39         ` Dmitry Baryshkov
  0 siblings, 0 replies; 157+ messages in thread
From: Dmitry Baryshkov @ 2022-03-23 10:39 UTC (permalink / raw)
  To: Ville Syrjälä, Alex Deucher
  Cc: Emma Anholt, Neil Armstrong, Xinliang Liu,
	Maling list - DRI developers, Thierry Reding, Jernej Skrabec,
	Andrzej Hajda, Sam Ravnborg, Rodrigo Siqueira, amd-gfx list,
	linux-rockchip, Xinwei Kong, Aurabindo Pillai, linux-arm-msm,
	Alain Volmat, Chun-Kuang Hu, Jonas Karlman, Leo Li, Chen Feng,
	Intel Graphics Development, Abhinav Kumar, Nikola Cornij,
	Sean Paul, linux-arm-kernel, Tomi Valkeinen, freedreno,
	Sandy Huang, Robert Foss, Alex Deucher, Tian Tao, Jyri Sarha,
	Laurent Pinchart

On 22/03/2022 01:37, Ville Syrjälä wrote:
> On Tue, Mar 15, 2022 at 02:52:38PM -0400, Alex Deucher wrote:
>> On Mon, Mar 14, 2022 at 6:12 PM Ville Syrjälä
>> <ville.syrjala@linux.intel.com> wrote:
>>>
>>> On Fri, Feb 18, 2022 at 12:03:41PM +0200, Ville Syrjala wrote:
>>>>    drm: Add drm_mode_init()
>>>>    drm/bridge: Use drm_mode_copy()
>>>>    drm/imx: Use drm_mode_duplicate()
>>>>    drm/panel: Use drm_mode_duplicate()
>>>>    drm/vc4: Use drm_mode_copy()
>>> These have been pushed to drm-misc-next.
>>>
>>>>    drm/amdgpu: Remove pointless on stack mode copies
>>>>    drm/amdgpu: Use drm_mode_init() for on-stack modes
>>>>    drm/amdgpu: Use drm_mode_copy()
>>> amdgpu ones are reviewed, but I'll leave them for the
>>> AMD folks to push to whichever tree they prefer.
>>
>> I pulled patches 2, 4, 5 into my tree.
> 
> Thanks.
> 
>> For 3, I'm happy to have it
>> land via drm-misc with the rest of the mode_init changes if you'd
>> prefer.
> 
> Either way works for me. I don't yet have reviews yet for
> the other drivers, so I'll proably hold off for a bit more
> at least. And the i915 patch I'll be merging via drm-intel.
> 
>>>>    drm/radeon: Use drm_mode_copy()
>>>>    drm/gma500: Use drm_mode_copy()
>>>>    drm/tilcdc: Use drm_mode_copy()
>>>>    drm/i915: Use drm_mode_copy()
> 
> Those are now all in.
> 
> Which leaves us with these stragglers:
>>>>    drm/hisilicon: Use drm_mode_init() for on-stack modes

>>>>    drm/msm: Nuke weird on stack mode copy
>>>>    drm/msm: Use drm_mode_init() for on-stack modes
>>>>    drm/msm: Use drm_mode_copy()

These three patches went beneath my radar for some reason.

I have just sent a replacement for the first patch ([1]). Other two 
patches can be pulled in msm/msm-next (or msm/msm-fixes) during the next 
development cycle if that works for you.

[1] https://patchwork.freedesktop.org/series/101682/

>>>>    drm/mtk: Use drm_mode_init() for on-stack modes
>>>>    drm/rockchip: Use drm_mode_copy()
>>>>    drm/sti: Use drm_mode_copy()
>>>>    drm: Use drm_mode_init() for on-stack modes
>>>>    drm: Use drm_mode_copy()
> 


-- 
With best wishes
Dmitry

^ permalink raw reply	[flat|nested] 157+ messages in thread

* Re: [PATCH 00/22] drm: Review of mode copies
@ 2022-03-23 10:39         ` Dmitry Baryshkov
  0 siblings, 0 replies; 157+ messages in thread
From: Dmitry Baryshkov @ 2022-03-23 10:39 UTC (permalink / raw)
  To: Ville Syrjälä, Alex Deucher
  Cc: Maling list - DRI developers, Heiko Stübner, Emma Anholt,
	Neil Armstrong, Xinliang Liu, Thierry Reding, Jernej Skrabec,
	Andrzej Hajda, Sam Ravnborg, Rodrigo Siqueira, amd-gfx list,
	linux-rockchip, Xinwei Kong, Aurabindo Pillai, Chen Feng,
	Alain Volmat, Harry Wentland, Chun-Kuang Hu, Jonas Karlman,
	Leo Li, linux-arm-msm, Intel Graphics Development, Abhinav Kumar,
	Maxime Ripard, Nikola Cornij, John Stultz, Sean Paul,
	linux-arm-kernel, Tomi Valkeinen, Jyri Sarha, Sandy Huang,
	Robert Foss, Patrik Jakobsson, Rob Clark, Philipp Zabel,
	Alex Deucher, Tian Tao, freedreno, Laurent Pinchart

On 22/03/2022 01:37, Ville Syrjälä wrote:
> On Tue, Mar 15, 2022 at 02:52:38PM -0400, Alex Deucher wrote:
>> On Mon, Mar 14, 2022 at 6:12 PM Ville Syrjälä
>> <ville.syrjala@linux.intel.com> wrote:
>>>
>>> On Fri, Feb 18, 2022 at 12:03:41PM +0200, Ville Syrjala wrote:
>>>>    drm: Add drm_mode_init()
>>>>    drm/bridge: Use drm_mode_copy()
>>>>    drm/imx: Use drm_mode_duplicate()
>>>>    drm/panel: Use drm_mode_duplicate()
>>>>    drm/vc4: Use drm_mode_copy()
>>> These have been pushed to drm-misc-next.
>>>
>>>>    drm/amdgpu: Remove pointless on stack mode copies
>>>>    drm/amdgpu: Use drm_mode_init() for on-stack modes
>>>>    drm/amdgpu: Use drm_mode_copy()
>>> amdgpu ones are reviewed, but I'll leave them for the
>>> AMD folks to push to whichever tree they prefer.
>>
>> I pulled patches 2, 4, 5 into my tree.
> 
> Thanks.
> 
>> For 3, I'm happy to have it
>> land via drm-misc with the rest of the mode_init changes if you'd
>> prefer.
> 
> Either way works for me. I don't yet have reviews yet for
> the other drivers, so I'll proably hold off for a bit more
> at least. And the i915 patch I'll be merging via drm-intel.
> 
>>>>    drm/radeon: Use drm_mode_copy()
>>>>    drm/gma500: Use drm_mode_copy()
>>>>    drm/tilcdc: Use drm_mode_copy()
>>>>    drm/i915: Use drm_mode_copy()
> 
> Those are now all in.
> 
> Which leaves us with these stragglers:
>>>>    drm/hisilicon: Use drm_mode_init() for on-stack modes

>>>>    drm/msm: Nuke weird on stack mode copy
>>>>    drm/msm: Use drm_mode_init() for on-stack modes
>>>>    drm/msm: Use drm_mode_copy()

These three patches went beneath my radar for some reason.

I have just sent a replacement for the first patch ([1]). Other two 
patches can be pulled in msm/msm-next (or msm/msm-fixes) during the next 
development cycle if that works for you.

[1] https://patchwork.freedesktop.org/series/101682/

>>>>    drm/mtk: Use drm_mode_init() for on-stack modes
>>>>    drm/rockchip: Use drm_mode_copy()
>>>>    drm/sti: Use drm_mode_copy()
>>>>    drm: Use drm_mode_init() for on-stack modes
>>>>    drm: Use drm_mode_copy()
> 


-- 
With best wishes
Dmitry

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 157+ messages in thread

* Re: [PATCH 00/22] drm: Review of mode copies
@ 2022-03-23 10:39         ` Dmitry Baryshkov
  0 siblings, 0 replies; 157+ messages in thread
From: Dmitry Baryshkov @ 2022-03-23 10:39 UTC (permalink / raw)
  To: Ville Syrjälä, Alex Deucher
  Cc: Heiko Stübner, Emma Anholt, Neil Armstrong, Xinliang Liu,
	Maling list - DRI developers, Thierry Reding, Jernej Skrabec,
	Andrzej Hajda, Sam Ravnborg, Rodrigo Siqueira, amd-gfx list,
	linux-rockchip, Xinwei Kong, Aurabindo Pillai, linux-arm-msm,
	Alain Volmat, Harry Wentland, Chun-Kuang Hu, Jonas Karlman,
	Leo Li, Chen Feng, Intel Graphics Development, Abhinav Kumar,
	Maxime Ripard, Nikola Cornij, John Stultz, Sean Paul,
	linux-arm-kernel, Tomi Valkeinen, freedreno, Sandy Huang,
	Robert Foss, Patrik Jakobsson, Rob Clark, Philipp Zabel,
	Alex Deucher, Tian Tao, Jyri Sarha, Laurent Pinchart

On 22/03/2022 01:37, Ville Syrjälä wrote:
> On Tue, Mar 15, 2022 at 02:52:38PM -0400, Alex Deucher wrote:
>> On Mon, Mar 14, 2022 at 6:12 PM Ville Syrjälä
>> <ville.syrjala@linux.intel.com> wrote:
>>>
>>> On Fri, Feb 18, 2022 at 12:03:41PM +0200, Ville Syrjala wrote:
>>>>    drm: Add drm_mode_init()
>>>>    drm/bridge: Use drm_mode_copy()
>>>>    drm/imx: Use drm_mode_duplicate()
>>>>    drm/panel: Use drm_mode_duplicate()
>>>>    drm/vc4: Use drm_mode_copy()
>>> These have been pushed to drm-misc-next.
>>>
>>>>    drm/amdgpu: Remove pointless on stack mode copies
>>>>    drm/amdgpu: Use drm_mode_init() for on-stack modes
>>>>    drm/amdgpu: Use drm_mode_copy()
>>> amdgpu ones are reviewed, but I'll leave them for the
>>> AMD folks to push to whichever tree they prefer.
>>
>> I pulled patches 2, 4, 5 into my tree.
> 
> Thanks.
> 
>> For 3, I'm happy to have it
>> land via drm-misc with the rest of the mode_init changes if you'd
>> prefer.
> 
> Either way works for me. I don't yet have reviews yet for
> the other drivers, so I'll proably hold off for a bit more
> at least. And the i915 patch I'll be merging via drm-intel.
> 
>>>>    drm/radeon: Use drm_mode_copy()
>>>>    drm/gma500: Use drm_mode_copy()
>>>>    drm/tilcdc: Use drm_mode_copy()
>>>>    drm/i915: Use drm_mode_copy()
> 
> Those are now all in.
> 
> Which leaves us with these stragglers:
>>>>    drm/hisilicon: Use drm_mode_init() for on-stack modes

>>>>    drm/msm: Nuke weird on stack mode copy
>>>>    drm/msm: Use drm_mode_init() for on-stack modes
>>>>    drm/msm: Use drm_mode_copy()

These three patches went beneath my radar for some reason.

I have just sent a replacement for the first patch ([1]). Other two 
patches can be pulled in msm/msm-next (or msm/msm-fixes) during the next 
development cycle if that works for you.

[1] https://patchwork.freedesktop.org/series/101682/

>>>>    drm/mtk: Use drm_mode_init() for on-stack modes
>>>>    drm/rockchip: Use drm_mode_copy()
>>>>    drm/sti: Use drm_mode_copy()
>>>>    drm: Use drm_mode_init() for on-stack modes
>>>>    drm: Use drm_mode_copy()
> 


-- 
With best wishes
Dmitry

^ permalink raw reply	[flat|nested] 157+ messages in thread

* Re: [Intel-gfx] [PATCH 00/22] drm: Review of mode copies
@ 2022-03-23 10:39         ` Dmitry Baryshkov
  0 siblings, 0 replies; 157+ messages in thread
From: Dmitry Baryshkov @ 2022-03-23 10:39 UTC (permalink / raw)
  To: Ville Syrjälä, Alex Deucher
  Cc: Heiko Stübner, Emma Anholt, Neil Armstrong, Xinliang Liu,
	Maling list - DRI developers, Jernej Skrabec, Andrzej Hajda,
	Sam Ravnborg, Rodrigo Siqueira, amd-gfx list, linux-rockchip,
	Xinwei Kong, Aurabindo Pillai, linux-arm-msm, Alain Volmat,
	Harry Wentland, Chun-Kuang Hu, Jonas Karlman, Leo Li, Chen Feng,
	Intel Graphics Development, Abhinav Kumar, Maxime Ripard,
	Nikola Cornij, John Stultz, linux-arm-kernel, Tomi Valkeinen,
	freedreno, Sandy Huang, Robert Foss, Philipp Zabel, Alex Deucher,
	Tian Tao, Jyri Sarha, Laurent Pinchart

On 22/03/2022 01:37, Ville Syrjälä wrote:
> On Tue, Mar 15, 2022 at 02:52:38PM -0400, Alex Deucher wrote:
>> On Mon, Mar 14, 2022 at 6:12 PM Ville Syrjälä
>> <ville.syrjala@linux.intel.com> wrote:
>>>
>>> On Fri, Feb 18, 2022 at 12:03:41PM +0200, Ville Syrjala wrote:
>>>>    drm: Add drm_mode_init()
>>>>    drm/bridge: Use drm_mode_copy()
>>>>    drm/imx: Use drm_mode_duplicate()
>>>>    drm/panel: Use drm_mode_duplicate()
>>>>    drm/vc4: Use drm_mode_copy()
>>> These have been pushed to drm-misc-next.
>>>
>>>>    drm/amdgpu: Remove pointless on stack mode copies
>>>>    drm/amdgpu: Use drm_mode_init() for on-stack modes
>>>>    drm/amdgpu: Use drm_mode_copy()
>>> amdgpu ones are reviewed, but I'll leave them for the
>>> AMD folks to push to whichever tree they prefer.
>>
>> I pulled patches 2, 4, 5 into my tree.
> 
> Thanks.
> 
>> For 3, I'm happy to have it
>> land via drm-misc with the rest of the mode_init changes if you'd
>> prefer.
> 
> Either way works for me. I don't yet have reviews yet for
> the other drivers, so I'll proably hold off for a bit more
> at least. And the i915 patch I'll be merging via drm-intel.
> 
>>>>    drm/radeon: Use drm_mode_copy()
>>>>    drm/gma500: Use drm_mode_copy()
>>>>    drm/tilcdc: Use drm_mode_copy()
>>>>    drm/i915: Use drm_mode_copy()
> 
> Those are now all in.
> 
> Which leaves us with these stragglers:
>>>>    drm/hisilicon: Use drm_mode_init() for on-stack modes

>>>>    drm/msm: Nuke weird on stack mode copy
>>>>    drm/msm: Use drm_mode_init() for on-stack modes
>>>>    drm/msm: Use drm_mode_copy()

These three patches went beneath my radar for some reason.

I have just sent a replacement for the first patch ([1]). Other two 
patches can be pulled in msm/msm-next (or msm/msm-fixes) during the next 
development cycle if that works for you.

[1] https://patchwork.freedesktop.org/series/101682/

>>>>    drm/mtk: Use drm_mode_init() for on-stack modes
>>>>    drm/rockchip: Use drm_mode_copy()
>>>>    drm/sti: Use drm_mode_copy()
>>>>    drm: Use drm_mode_init() for on-stack modes
>>>>    drm: Use drm_mode_copy()
> 


-- 
With best wishes
Dmitry

^ permalink raw reply	[flat|nested] 157+ messages in thread

* Re: [PATCH 00/22] drm: Review of mode copies
  2022-03-23 10:39         ` Dmitry Baryshkov
                             ` (3 preceding siblings ...)
  (?)
@ 2022-03-23 15:10           ` Ville Syrjälä
  -1 siblings, 0 replies; 157+ messages in thread
From: Ville Syrjälä @ 2022-03-23 15:10 UTC (permalink / raw)
  To: Dmitry Baryshkov
  Cc: Alex Deucher, Maling list - DRI developers, Heiko Stübner,
	Emma Anholt, Neil Armstrong, Xinliang Liu, Thierry Reding,
	Jernej Skrabec, Andrzej Hajda, Sam Ravnborg, Rodrigo Siqueira,
	amd-gfx list, linux-rockchip, Xinwei Kong, Aurabindo Pillai,
	Chen Feng, Alain Volmat, Harry Wentland, Chun-Kuang Hu,
	Jonas Karlman, Leo Li, linux-arm-msm, Intel Graphics Development,
	Abhinav Kumar, Maxime Ripard, Nikola Cornij, John Stultz,
	Sean Paul, linux-arm-kernel, Tomi Valkeinen, Jyri Sarha,
	Sandy Huang, Robert Foss, Patrik Jakobsson, Rob Clark,
	Philipp Zabel, Alex Deucher, Tian Tao, freedreno,
	Laurent Pinchart

On Wed, Mar 23, 2022 at 01:39:44PM +0300, Dmitry Baryshkov wrote:
> On 22/03/2022 01:37, Ville Syrjälä wrote:
> > On Tue, Mar 15, 2022 at 02:52:38PM -0400, Alex Deucher wrote:
> >> On Mon, Mar 14, 2022 at 6:12 PM Ville Syrjälä
> >> <ville.syrjala@linux.intel.com> wrote:
> >>>
> >>> On Fri, Feb 18, 2022 at 12:03:41PM +0200, Ville Syrjala wrote:
> >>>>    drm: Add drm_mode_init()
> >>>>    drm/bridge: Use drm_mode_copy()
> >>>>    drm/imx: Use drm_mode_duplicate()
> >>>>    drm/panel: Use drm_mode_duplicate()
> >>>>    drm/vc4: Use drm_mode_copy()
> >>> These have been pushed to drm-misc-next.
> >>>
> >>>>    drm/amdgpu: Remove pointless on stack mode copies
> >>>>    drm/amdgpu: Use drm_mode_init() for on-stack modes
> >>>>    drm/amdgpu: Use drm_mode_copy()
> >>> amdgpu ones are reviewed, but I'll leave them for the
> >>> AMD folks to push to whichever tree they prefer.
> >>
> >> I pulled patches 2, 4, 5 into my tree.
> > 
> > Thanks.
> > 
> >> For 3, I'm happy to have it
> >> land via drm-misc with the rest of the mode_init changes if you'd
> >> prefer.
> > 
> > Either way works for me. I don't yet have reviews yet for
> > the other drivers, so I'll proably hold off for a bit more
> > at least. And the i915 patch I'll be merging via drm-intel.
> > 
> >>>>    drm/radeon: Use drm_mode_copy()
> >>>>    drm/gma500: Use drm_mode_copy()
> >>>>    drm/tilcdc: Use drm_mode_copy()
> >>>>    drm/i915: Use drm_mode_copy()
> > 
> > Those are now all in.
> > 
> > Which leaves us with these stragglers:
> >>>>    drm/hisilicon: Use drm_mode_init() for on-stack modes
> 
> >>>>    drm/msm: Nuke weird on stack mode copy
> >>>>    drm/msm: Use drm_mode_init() for on-stack modes
> >>>>    drm/msm: Use drm_mode_copy()
> 
> These three patches went beneath my radar for some reason.
> 
> I have just sent a replacement for the first patch ([1]). Other two 
> patches can be pulled in msm/msm-next (or msm/msm-fixes) during the next 
> development cycle if that works for you.

That'll do fine for me. Thanks.

> 
> [1] https://patchwork.freedesktop.org/series/101682/
> 
> >>>>    drm/mtk: Use drm_mode_init() for on-stack modes
> >>>>    drm/rockchip: Use drm_mode_copy()
> >>>>    drm/sti: Use drm_mode_copy()
> >>>>    drm: Use drm_mode_init() for on-stack modes
> >>>>    drm: Use drm_mode_copy()
> > 
> 
> 
> -- 
> With best wishes
> Dmitry

-- 
Ville Syrjälä
Intel

^ permalink raw reply	[flat|nested] 157+ messages in thread

* Re: [PATCH 00/22] drm: Review of mode copies
@ 2022-03-23 15:10           ` Ville Syrjälä
  0 siblings, 0 replies; 157+ messages in thread
From: Ville Syrjälä @ 2022-03-23 15:10 UTC (permalink / raw)
  To: Dmitry Baryshkov
  Cc: Emma Anholt, Neil Armstrong, Xinliang Liu,
	Maling list - DRI developers, Thierry Reding, Jernej Skrabec,
	Andrzej Hajda, Sam Ravnborg, Rodrigo Siqueira, amd-gfx list,
	linux-rockchip, Xinwei Kong, Aurabindo Pillai, linux-arm-msm,
	Alain Volmat, Chun-Kuang Hu, Jonas Karlman, Leo Li, Chen Feng,
	Intel Graphics Development, Abhinav Kumar, Nikola Cornij,
	Alex Deucher, Sean Paul, linux-arm-kernel, Tomi Valkeinen,
	freedreno, Sandy Huang, Robert Foss, Tian Tao, Jyri Sarha,
	Laurent Pinchart

On Wed, Mar 23, 2022 at 01:39:44PM +0300, Dmitry Baryshkov wrote:
> On 22/03/2022 01:37, Ville Syrjälä wrote:
> > On Tue, Mar 15, 2022 at 02:52:38PM -0400, Alex Deucher wrote:
> >> On Mon, Mar 14, 2022 at 6:12 PM Ville Syrjälä
> >> <ville.syrjala@linux.intel.com> wrote:
> >>>
> >>> On Fri, Feb 18, 2022 at 12:03:41PM +0200, Ville Syrjala wrote:
> >>>>    drm: Add drm_mode_init()
> >>>>    drm/bridge: Use drm_mode_copy()
> >>>>    drm/imx: Use drm_mode_duplicate()
> >>>>    drm/panel: Use drm_mode_duplicate()
> >>>>    drm/vc4: Use drm_mode_copy()
> >>> These have been pushed to drm-misc-next.
> >>>
> >>>>    drm/amdgpu: Remove pointless on stack mode copies
> >>>>    drm/amdgpu: Use drm_mode_init() for on-stack modes
> >>>>    drm/amdgpu: Use drm_mode_copy()
> >>> amdgpu ones are reviewed, but I'll leave them for the
> >>> AMD folks to push to whichever tree they prefer.
> >>
> >> I pulled patches 2, 4, 5 into my tree.
> > 
> > Thanks.
> > 
> >> For 3, I'm happy to have it
> >> land via drm-misc with the rest of the mode_init changes if you'd
> >> prefer.
> > 
> > Either way works for me. I don't yet have reviews yet for
> > the other drivers, so I'll proably hold off for a bit more
> > at least. And the i915 patch I'll be merging via drm-intel.
> > 
> >>>>    drm/radeon: Use drm_mode_copy()
> >>>>    drm/gma500: Use drm_mode_copy()
> >>>>    drm/tilcdc: Use drm_mode_copy()
> >>>>    drm/i915: Use drm_mode_copy()
> > 
> > Those are now all in.
> > 
> > Which leaves us with these stragglers:
> >>>>    drm/hisilicon: Use drm_mode_init() for on-stack modes
> 
> >>>>    drm/msm: Nuke weird on stack mode copy
> >>>>    drm/msm: Use drm_mode_init() for on-stack modes
> >>>>    drm/msm: Use drm_mode_copy()
> 
> These three patches went beneath my radar for some reason.
> 
> I have just sent a replacement for the first patch ([1]). Other two 
> patches can be pulled in msm/msm-next (or msm/msm-fixes) during the next 
> development cycle if that works for you.

That'll do fine for me. Thanks.

> 
> [1] https://patchwork.freedesktop.org/series/101682/
> 
> >>>>    drm/mtk: Use drm_mode_init() for on-stack modes
> >>>>    drm/rockchip: Use drm_mode_copy()
> >>>>    drm/sti: Use drm_mode_copy()
> >>>>    drm: Use drm_mode_init() for on-stack modes
> >>>>    drm: Use drm_mode_copy()
> > 
> 
> 
> -- 
> With best wishes
> Dmitry

-- 
Ville Syrjälä
Intel

^ permalink raw reply	[flat|nested] 157+ messages in thread

* Re: [Intel-gfx] [PATCH 00/22] drm: Review of mode copies
@ 2022-03-23 15:10           ` Ville Syrjälä
  0 siblings, 0 replies; 157+ messages in thread
From: Ville Syrjälä @ 2022-03-23 15:10 UTC (permalink / raw)
  To: Dmitry Baryshkov
  Cc: Heiko Stübner, Emma Anholt, Neil Armstrong, Xinliang Liu,
	Maling list - DRI developers, Jernej Skrabec, Andrzej Hajda,
	Sam Ravnborg, Rodrigo Siqueira, amd-gfx list, linux-rockchip,
	Xinwei Kong, Aurabindo Pillai, linux-arm-msm, Alain Volmat,
	Harry Wentland, Chun-Kuang Hu, Jonas Karlman, Leo Li, Chen Feng,
	Intel Graphics Development, Abhinav Kumar, Maxime Ripard,
	Nikola Cornij, Alex Deucher, John Stultz, linux-arm-kernel,
	Tomi Valkeinen, freedreno, Sandy Huang, Robert Foss,
	Philipp Zabel, Alex Deucher, Tian Tao, Jyri Sarha,
	Laurent Pinchart

On Wed, Mar 23, 2022 at 01:39:44PM +0300, Dmitry Baryshkov wrote:
> On 22/03/2022 01:37, Ville Syrjälä wrote:
> > On Tue, Mar 15, 2022 at 02:52:38PM -0400, Alex Deucher wrote:
> >> On Mon, Mar 14, 2022 at 6:12 PM Ville Syrjälä
> >> <ville.syrjala@linux.intel.com> wrote:
> >>>
> >>> On Fri, Feb 18, 2022 at 12:03:41PM +0200, Ville Syrjala wrote:
> >>>>    drm: Add drm_mode_init()
> >>>>    drm/bridge: Use drm_mode_copy()
> >>>>    drm/imx: Use drm_mode_duplicate()
> >>>>    drm/panel: Use drm_mode_duplicate()
> >>>>    drm/vc4: Use drm_mode_copy()
> >>> These have been pushed to drm-misc-next.
> >>>
> >>>>    drm/amdgpu: Remove pointless on stack mode copies
> >>>>    drm/amdgpu: Use drm_mode_init() for on-stack modes
> >>>>    drm/amdgpu: Use drm_mode_copy()
> >>> amdgpu ones are reviewed, but I'll leave them for the
> >>> AMD folks to push to whichever tree they prefer.
> >>
> >> I pulled patches 2, 4, 5 into my tree.
> > 
> > Thanks.
> > 
> >> For 3, I'm happy to have it
> >> land via drm-misc with the rest of the mode_init changes if you'd
> >> prefer.
> > 
> > Either way works for me. I don't yet have reviews yet for
> > the other drivers, so I'll proably hold off for a bit more
> > at least. And the i915 patch I'll be merging via drm-intel.
> > 
> >>>>    drm/radeon: Use drm_mode_copy()
> >>>>    drm/gma500: Use drm_mode_copy()
> >>>>    drm/tilcdc: Use drm_mode_copy()
> >>>>    drm/i915: Use drm_mode_copy()
> > 
> > Those are now all in.
> > 
> > Which leaves us with these stragglers:
> >>>>    drm/hisilicon: Use drm_mode_init() for on-stack modes
> 
> >>>>    drm/msm: Nuke weird on stack mode copy
> >>>>    drm/msm: Use drm_mode_init() for on-stack modes
> >>>>    drm/msm: Use drm_mode_copy()
> 
> These three patches went beneath my radar for some reason.
> 
> I have just sent a replacement for the first patch ([1]). Other two 
> patches can be pulled in msm/msm-next (or msm/msm-fixes) during the next 
> development cycle if that works for you.

That'll do fine for me. Thanks.

> 
> [1] https://patchwork.freedesktop.org/series/101682/
> 
> >>>>    drm/mtk: Use drm_mode_init() for on-stack modes
> >>>>    drm/rockchip: Use drm_mode_copy()
> >>>>    drm/sti: Use drm_mode_copy()
> >>>>    drm: Use drm_mode_init() for on-stack modes
> >>>>    drm: Use drm_mode_copy()
> > 
> 
> 
> -- 
> With best wishes
> Dmitry

-- 
Ville Syrjälä
Intel

^ permalink raw reply	[flat|nested] 157+ messages in thread

* Re: [PATCH 00/22] drm: Review of mode copies
@ 2022-03-23 15:10           ` Ville Syrjälä
  0 siblings, 0 replies; 157+ messages in thread
From: Ville Syrjälä @ 2022-03-23 15:10 UTC (permalink / raw)
  To: Dmitry Baryshkov
  Cc: Heiko Stübner, Emma Anholt, Neil Armstrong, Xinliang Liu,
	Maling list - DRI developers, Thierry Reding, Jernej Skrabec,
	Andrzej Hajda, Sam Ravnborg, Rodrigo Siqueira, amd-gfx list,
	linux-rockchip, Xinwei Kong, Aurabindo Pillai, linux-arm-msm,
	Alain Volmat, Harry Wentland, Chun-Kuang Hu, Jonas Karlman,
	Leo Li, Chen Feng, Intel Graphics Development, Abhinav Kumar,
	Maxime Ripard, Nikola Cornij, Alex Deucher, John Stultz,
	Sean Paul, linux-arm-kernel, Tomi Valkeinen, freedreno,
	Sandy Huang, Robert Foss, Patrik Jakobsson, Rob Clark,
	Philipp Zabel, Alex Deucher, Tian Tao, Jyri Sarha,
	Laurent Pinchart

On Wed, Mar 23, 2022 at 01:39:44PM +0300, Dmitry Baryshkov wrote:
> On 22/03/2022 01:37, Ville Syrjälä wrote:
> > On Tue, Mar 15, 2022 at 02:52:38PM -0400, Alex Deucher wrote:
> >> On Mon, Mar 14, 2022 at 6:12 PM Ville Syrjälä
> >> <ville.syrjala@linux.intel.com> wrote:
> >>>
> >>> On Fri, Feb 18, 2022 at 12:03:41PM +0200, Ville Syrjala wrote:
> >>>>    drm: Add drm_mode_init()
> >>>>    drm/bridge: Use drm_mode_copy()
> >>>>    drm/imx: Use drm_mode_duplicate()
> >>>>    drm/panel: Use drm_mode_duplicate()
> >>>>    drm/vc4: Use drm_mode_copy()
> >>> These have been pushed to drm-misc-next.
> >>>
> >>>>    drm/amdgpu: Remove pointless on stack mode copies
> >>>>    drm/amdgpu: Use drm_mode_init() for on-stack modes
> >>>>    drm/amdgpu: Use drm_mode_copy()
> >>> amdgpu ones are reviewed, but I'll leave them for the
> >>> AMD folks to push to whichever tree they prefer.
> >>
> >> I pulled patches 2, 4, 5 into my tree.
> > 
> > Thanks.
> > 
> >> For 3, I'm happy to have it
> >> land via drm-misc with the rest of the mode_init changes if you'd
> >> prefer.
> > 
> > Either way works for me. I don't yet have reviews yet for
> > the other drivers, so I'll proably hold off for a bit more
> > at least. And the i915 patch I'll be merging via drm-intel.
> > 
> >>>>    drm/radeon: Use drm_mode_copy()
> >>>>    drm/gma500: Use drm_mode_copy()
> >>>>    drm/tilcdc: Use drm_mode_copy()
> >>>>    drm/i915: Use drm_mode_copy()
> > 
> > Those are now all in.
> > 
> > Which leaves us with these stragglers:
> >>>>    drm/hisilicon: Use drm_mode_init() for on-stack modes
> 
> >>>>    drm/msm: Nuke weird on stack mode copy
> >>>>    drm/msm: Use drm_mode_init() for on-stack modes
> >>>>    drm/msm: Use drm_mode_copy()
> 
> These three patches went beneath my radar for some reason.
> 
> I have just sent a replacement for the first patch ([1]). Other two 
> patches can be pulled in msm/msm-next (or msm/msm-fixes) during the next 
> development cycle if that works for you.

That'll do fine for me. Thanks.

> 
> [1] https://patchwork.freedesktop.org/series/101682/
> 
> >>>>    drm/mtk: Use drm_mode_init() for on-stack modes
> >>>>    drm/rockchip: Use drm_mode_copy()
> >>>>    drm/sti: Use drm_mode_copy()
> >>>>    drm: Use drm_mode_init() for on-stack modes
> >>>>    drm: Use drm_mode_copy()
> > 
> 
> 
> -- 
> With best wishes
> Dmitry

-- 
Ville Syrjälä
Intel

^ permalink raw reply	[flat|nested] 157+ messages in thread

* Re: [PATCH 00/22] drm: Review of mode copies
@ 2022-03-23 15:10           ` Ville Syrjälä
  0 siblings, 0 replies; 157+ messages in thread
From: Ville Syrjälä @ 2022-03-23 15:10 UTC (permalink / raw)
  To: Dmitry Baryshkov
  Cc: Alex Deucher, Maling list - DRI developers, Heiko Stübner,
	Emma Anholt, Neil Armstrong, Xinliang Liu, Thierry Reding,
	Jernej Skrabec, Andrzej Hajda, Sam Ravnborg, Rodrigo Siqueira,
	amd-gfx list, linux-rockchip, Xinwei Kong, Aurabindo Pillai,
	Chen Feng, Alain Volmat, Harry Wentland, Chun-Kuang Hu,
	Jonas Karlman, Leo Li, linux-arm-msm, Intel Graphics Development,
	Abhinav Kumar, Maxime Ripard, Nikola Cornij, John Stultz,
	Sean Paul, linux-arm-kernel, Tomi Valkeinen, Jyri Sarha,
	Sandy Huang, Robert Foss, Patrik Jakobsson, Rob Clark,
	Philipp Zabel, Alex Deucher, Tian Tao, freedreno,
	Laurent Pinchart

On Wed, Mar 23, 2022 at 01:39:44PM +0300, Dmitry Baryshkov wrote:
> On 22/03/2022 01:37, Ville Syrjälä wrote:
> > On Tue, Mar 15, 2022 at 02:52:38PM -0400, Alex Deucher wrote:
> >> On Mon, Mar 14, 2022 at 6:12 PM Ville Syrjälä
> >> <ville.syrjala@linux.intel.com> wrote:
> >>>
> >>> On Fri, Feb 18, 2022 at 12:03:41PM +0200, Ville Syrjala wrote:
> >>>>    drm: Add drm_mode_init()
> >>>>    drm/bridge: Use drm_mode_copy()
> >>>>    drm/imx: Use drm_mode_duplicate()
> >>>>    drm/panel: Use drm_mode_duplicate()
> >>>>    drm/vc4: Use drm_mode_copy()
> >>> These have been pushed to drm-misc-next.
> >>>
> >>>>    drm/amdgpu: Remove pointless on stack mode copies
> >>>>    drm/amdgpu: Use drm_mode_init() for on-stack modes
> >>>>    drm/amdgpu: Use drm_mode_copy()
> >>> amdgpu ones are reviewed, but I'll leave them for the
> >>> AMD folks to push to whichever tree they prefer.
> >>
> >> I pulled patches 2, 4, 5 into my tree.
> > 
> > Thanks.
> > 
> >> For 3, I'm happy to have it
> >> land via drm-misc with the rest of the mode_init changes if you'd
> >> prefer.
> > 
> > Either way works for me. I don't yet have reviews yet for
> > the other drivers, so I'll proably hold off for a bit more
> > at least. And the i915 patch I'll be merging via drm-intel.
> > 
> >>>>    drm/radeon: Use drm_mode_copy()
> >>>>    drm/gma500: Use drm_mode_copy()
> >>>>    drm/tilcdc: Use drm_mode_copy()
> >>>>    drm/i915: Use drm_mode_copy()
> > 
> > Those are now all in.
> > 
> > Which leaves us with these stragglers:
> >>>>    drm/hisilicon: Use drm_mode_init() for on-stack modes
> 
> >>>>    drm/msm: Nuke weird on stack mode copy
> >>>>    drm/msm: Use drm_mode_init() for on-stack modes
> >>>>    drm/msm: Use drm_mode_copy()
> 
> These three patches went beneath my radar for some reason.
> 
> I have just sent a replacement for the first patch ([1]). Other two 
> patches can be pulled in msm/msm-next (or msm/msm-fixes) during the next 
> development cycle if that works for you.

That'll do fine for me. Thanks.

> 
> [1] https://patchwork.freedesktop.org/series/101682/
> 
> >>>>    drm/mtk: Use drm_mode_init() for on-stack modes
> >>>>    drm/rockchip: Use drm_mode_copy()
> >>>>    drm/sti: Use drm_mode_copy()
> >>>>    drm: Use drm_mode_init() for on-stack modes
> >>>>    drm: Use drm_mode_copy()
> > 
> 
> 
> -- 
> With best wishes
> Dmitry

-- 
Ville Syrjälä
Intel

_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

^ permalink raw reply	[flat|nested] 157+ messages in thread

* Re: [PATCH 00/22] drm: Review of mode copies
@ 2022-03-23 15:10           ` Ville Syrjälä
  0 siblings, 0 replies; 157+ messages in thread
From: Ville Syrjälä @ 2022-03-23 15:10 UTC (permalink / raw)
  To: Dmitry Baryshkov
  Cc: Alex Deucher, Maling list - DRI developers, Heiko Stübner,
	Emma Anholt, Neil Armstrong, Xinliang Liu, Thierry Reding,
	Jernej Skrabec, Andrzej Hajda, Sam Ravnborg, Rodrigo Siqueira,
	amd-gfx list, linux-rockchip, Xinwei Kong, Aurabindo Pillai,
	Chen Feng, Alain Volmat, Harry Wentland, Chun-Kuang Hu,
	Jonas Karlman, Leo Li, linux-arm-msm, Intel Graphics Development,
	Abhinav Kumar, Maxime Ripard, Nikola Cornij, John Stultz,
	Sean Paul, linux-arm-kernel, Tomi Valkeinen, Jyri Sarha,
	Sandy Huang, Robert Foss, Patrik Jakobsson, Rob Clark,
	Philipp Zabel, Alex Deucher, Tian Tao, freedreno,
	Laurent Pinchart

On Wed, Mar 23, 2022 at 01:39:44PM +0300, Dmitry Baryshkov wrote:
> On 22/03/2022 01:37, Ville Syrjälä wrote:
> > On Tue, Mar 15, 2022 at 02:52:38PM -0400, Alex Deucher wrote:
> >> On Mon, Mar 14, 2022 at 6:12 PM Ville Syrjälä
> >> <ville.syrjala@linux.intel.com> wrote:
> >>>
> >>> On Fri, Feb 18, 2022 at 12:03:41PM +0200, Ville Syrjala wrote:
> >>>>    drm: Add drm_mode_init()
> >>>>    drm/bridge: Use drm_mode_copy()
> >>>>    drm/imx: Use drm_mode_duplicate()
> >>>>    drm/panel: Use drm_mode_duplicate()
> >>>>    drm/vc4: Use drm_mode_copy()
> >>> These have been pushed to drm-misc-next.
> >>>
> >>>>    drm/amdgpu: Remove pointless on stack mode copies
> >>>>    drm/amdgpu: Use drm_mode_init() for on-stack modes
> >>>>    drm/amdgpu: Use drm_mode_copy()
> >>> amdgpu ones are reviewed, but I'll leave them for the
> >>> AMD folks to push to whichever tree they prefer.
> >>
> >> I pulled patches 2, 4, 5 into my tree.
> > 
> > Thanks.
> > 
> >> For 3, I'm happy to have it
> >> land via drm-misc with the rest of the mode_init changes if you'd
> >> prefer.
> > 
> > Either way works for me. I don't yet have reviews yet for
> > the other drivers, so I'll proably hold off for a bit more
> > at least. And the i915 patch I'll be merging via drm-intel.
> > 
> >>>>    drm/radeon: Use drm_mode_copy()
> >>>>    drm/gma500: Use drm_mode_copy()
> >>>>    drm/tilcdc: Use drm_mode_copy()
> >>>>    drm/i915: Use drm_mode_copy()
> > 
> > Those are now all in.
> > 
> > Which leaves us with these stragglers:
> >>>>    drm/hisilicon: Use drm_mode_init() for on-stack modes
> 
> >>>>    drm/msm: Nuke weird on stack mode copy
> >>>>    drm/msm: Use drm_mode_init() for on-stack modes
> >>>>    drm/msm: Use drm_mode_copy()
> 
> These three patches went beneath my radar for some reason.
> 
> I have just sent a replacement for the first patch ([1]). Other two 
> patches can be pulled in msm/msm-next (or msm/msm-fixes) during the next 
> development cycle if that works for you.

That'll do fine for me. Thanks.

> 
> [1] https://patchwork.freedesktop.org/series/101682/
> 
> >>>>    drm/mtk: Use drm_mode_init() for on-stack modes
> >>>>    drm/rockchip: Use drm_mode_copy()
> >>>>    drm/sti: Use drm_mode_copy()
> >>>>    drm: Use drm_mode_init() for on-stack modes
> >>>>    drm: Use drm_mode_copy()
> > 
> 
> 
> -- 
> With best wishes
> Dmitry

-- 
Ville Syrjälä
Intel

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 157+ messages in thread

* Re: [PATCH 11/22] drm/msm: Use drm_mode_init() for on-stack modes
  2022-02-18 10:03   ` Ville Syrjala
  (?)
@ 2022-03-23 20:04     ` Abhinav Kumar
  -1 siblings, 0 replies; 157+ messages in thread
From: Abhinav Kumar @ 2022-03-23 20:04 UTC (permalink / raw)
  To: Ville Syrjala, dri-devel
  Cc: intel-gfx, Rob Clark, Sean Paul, linux-arm-msm, freedreno



On 2/18/2022 2:03 AM, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> Initialize on-stack modes with drm_mode_init() to guarantee
> no stack garbage in the list head, or that we aren't copying
> over another mode's list head.
> 
> Based on the following cocci script, with manual fixups:
> @decl@
> identifier M;
> expression E;
> @@
> - struct drm_display_mode M = E;
> + struct drm_display_mode M;
> 
> @@
> identifier decl.M;
> expression decl.E;
> statement S, S1;
> @@
> struct drm_display_mode M;
> ... when != S
> + drm_mode_init(&M, &E);
> +
> S1
> 
> @@
> expression decl.E;
> @@
> - &*E
> + E
> 
> Cc: Rob Clark <robdclark@gmail.com>
> Cc: Sean Paul <sean@poorly.run>
> Cc: Abhinav Kumar <quic_abhinavk@quicinc.com>
> Cc: linux-arm-msm@vger.kernel.org
> Cc: freedreno@lists.freedesktop.org
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Abhinav Kumar <quic_abhinavk@quicinc.com>
> ---
>   drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c | 7 +++++--
>   1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c
> index ddd9d89cd456..e7813c6f7bd9 100644
> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c
> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c
> @@ -248,12 +248,13 @@ static void dpu_encoder_phys_vid_setup_timing_engine(
>   	unsigned long lock_flags;
>   	struct dpu_hw_intf_cfg intf_cfg = { 0 };
>   
> +	drm_mode_init(&mode, &phys_enc->cached_mode);
> +
>   	if (!phys_enc->hw_ctl->ops.setup_intf_cfg) {
>   		DPU_ERROR("invalid encoder %d\n", phys_enc != NULL);
>   		return;
>   	}
>   
> -	mode = phys_enc->cached_mode;
>   	if (!phys_enc->hw_intf->ops.setup_timing_gen) {
>   		DPU_ERROR("timing engine setup is not supported\n");
>   		return;
> @@ -652,7 +653,9 @@ static int dpu_encoder_phys_vid_get_frame_count(
>   {
>   	struct intf_status s = {0};
>   	u32 fetch_start = 0;
> -	struct drm_display_mode mode = phys_enc->cached_mode;
> +	struct drm_display_mode mode;
> +
> +	drm_mode_init(&mode, &phys_enc->cached_mode);
>   
>   	if (!dpu_encoder_phys_vid_is_master(phys_enc))
>   		return -EINVAL;

^ permalink raw reply	[flat|nested] 157+ messages in thread

* Re: [PATCH 11/22] drm/msm: Use drm_mode_init() for on-stack modes
@ 2022-03-23 20:04     ` Abhinav Kumar
  0 siblings, 0 replies; 157+ messages in thread
From: Abhinav Kumar @ 2022-03-23 20:04 UTC (permalink / raw)
  To: Ville Syrjala, dri-devel; +Cc: linux-arm-msm, intel-gfx, freedreno, Sean Paul



On 2/18/2022 2:03 AM, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> Initialize on-stack modes with drm_mode_init() to guarantee
> no stack garbage in the list head, or that we aren't copying
> over another mode's list head.
> 
> Based on the following cocci script, with manual fixups:
> @decl@
> identifier M;
> expression E;
> @@
> - struct drm_display_mode M = E;
> + struct drm_display_mode M;
> 
> @@
> identifier decl.M;
> expression decl.E;
> statement S, S1;
> @@
> struct drm_display_mode M;
> ... when != S
> + drm_mode_init(&M, &E);
> +
> S1
> 
> @@
> expression decl.E;
> @@
> - &*E
> + E
> 
> Cc: Rob Clark <robdclark@gmail.com>
> Cc: Sean Paul <sean@poorly.run>
> Cc: Abhinav Kumar <quic_abhinavk@quicinc.com>
> Cc: linux-arm-msm@vger.kernel.org
> Cc: freedreno@lists.freedesktop.org
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Abhinav Kumar <quic_abhinavk@quicinc.com>
> ---
>   drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c | 7 +++++--
>   1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c
> index ddd9d89cd456..e7813c6f7bd9 100644
> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c
> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c
> @@ -248,12 +248,13 @@ static void dpu_encoder_phys_vid_setup_timing_engine(
>   	unsigned long lock_flags;
>   	struct dpu_hw_intf_cfg intf_cfg = { 0 };
>   
> +	drm_mode_init(&mode, &phys_enc->cached_mode);
> +
>   	if (!phys_enc->hw_ctl->ops.setup_intf_cfg) {
>   		DPU_ERROR("invalid encoder %d\n", phys_enc != NULL);
>   		return;
>   	}
>   
> -	mode = phys_enc->cached_mode;
>   	if (!phys_enc->hw_intf->ops.setup_timing_gen) {
>   		DPU_ERROR("timing engine setup is not supported\n");
>   		return;
> @@ -652,7 +653,9 @@ static int dpu_encoder_phys_vid_get_frame_count(
>   {
>   	struct intf_status s = {0};
>   	u32 fetch_start = 0;
> -	struct drm_display_mode mode = phys_enc->cached_mode;
> +	struct drm_display_mode mode;
> +
> +	drm_mode_init(&mode, &phys_enc->cached_mode);
>   
>   	if (!dpu_encoder_phys_vid_is_master(phys_enc))
>   		return -EINVAL;

^ permalink raw reply	[flat|nested] 157+ messages in thread

* Re: [Intel-gfx] [PATCH 11/22] drm/msm: Use drm_mode_init() for on-stack modes
@ 2022-03-23 20:04     ` Abhinav Kumar
  0 siblings, 0 replies; 157+ messages in thread
From: Abhinav Kumar @ 2022-03-23 20:04 UTC (permalink / raw)
  To: Ville Syrjala, dri-devel; +Cc: linux-arm-msm, intel-gfx, freedreno



On 2/18/2022 2:03 AM, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> Initialize on-stack modes with drm_mode_init() to guarantee
> no stack garbage in the list head, or that we aren't copying
> over another mode's list head.
> 
> Based on the following cocci script, with manual fixups:
> @decl@
> identifier M;
> expression E;
> @@
> - struct drm_display_mode M = E;
> + struct drm_display_mode M;
> 
> @@
> identifier decl.M;
> expression decl.E;
> statement S, S1;
> @@
> struct drm_display_mode M;
> ... when != S
> + drm_mode_init(&M, &E);
> +
> S1
> 
> @@
> expression decl.E;
> @@
> - &*E
> + E
> 
> Cc: Rob Clark <robdclark@gmail.com>
> Cc: Sean Paul <sean@poorly.run>
> Cc: Abhinav Kumar <quic_abhinavk@quicinc.com>
> Cc: linux-arm-msm@vger.kernel.org
> Cc: freedreno@lists.freedesktop.org
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Abhinav Kumar <quic_abhinavk@quicinc.com>
> ---
>   drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c | 7 +++++--
>   1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c
> index ddd9d89cd456..e7813c6f7bd9 100644
> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c
> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c
> @@ -248,12 +248,13 @@ static void dpu_encoder_phys_vid_setup_timing_engine(
>   	unsigned long lock_flags;
>   	struct dpu_hw_intf_cfg intf_cfg = { 0 };
>   
> +	drm_mode_init(&mode, &phys_enc->cached_mode);
> +
>   	if (!phys_enc->hw_ctl->ops.setup_intf_cfg) {
>   		DPU_ERROR("invalid encoder %d\n", phys_enc != NULL);
>   		return;
>   	}
>   
> -	mode = phys_enc->cached_mode;
>   	if (!phys_enc->hw_intf->ops.setup_timing_gen) {
>   		DPU_ERROR("timing engine setup is not supported\n");
>   		return;
> @@ -652,7 +653,9 @@ static int dpu_encoder_phys_vid_get_frame_count(
>   {
>   	struct intf_status s = {0};
>   	u32 fetch_start = 0;
> -	struct drm_display_mode mode = phys_enc->cached_mode;
> +	struct drm_display_mode mode;
> +
> +	drm_mode_init(&mode, &phys_enc->cached_mode);
>   
>   	if (!dpu_encoder_phys_vid_is_master(phys_enc))
>   		return -EINVAL;

^ permalink raw reply	[flat|nested] 157+ messages in thread

* Re: [PATCH 12/22] drm/msm: Use drm_mode_copy()
  2022-02-18 10:03   ` Ville Syrjala
  (?)
@ 2022-03-23 20:09     ` Abhinav Kumar
  -1 siblings, 0 replies; 157+ messages in thread
From: Abhinav Kumar @ 2022-03-23 20:09 UTC (permalink / raw)
  To: Ville Syrjala, dri-devel
  Cc: intel-gfx, Rob Clark, Sean Paul, linux-arm-msm, freedreno



On 2/18/2022 2:03 AM, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> struct drm_display_mode embeds a list head, so overwriting
> the full struct with another one will corrupt the list
> (if the destination mode is on a list). Use drm_mode_copy()
> instead which explicitly preserves the list head of
> the destination mode.
> 
> Even if we know the destination mode is not on any list
> using drm_mode_copy() seems decent as it sets a good
> example. Bad examples of not using it might eventually
> get copied into code where preserving the list head
> actually matters.
> 
> Obviously one case not covered here is when the mode
> itself is embedded in a larger structure and the whole
> structure is copied. But if we are careful when copying
> into modes embedded in structures I think we can be a
> little more reassured that bogus list heads haven't been
> propagated in.
> 
> @is_mode_copy@
> @@
> drm_mode_copy(...)
> {
> ...
> }
> 
> @depends on !is_mode_copy@
> struct drm_display_mode *mode;
> expression E, S;
> @@
> (
> - *mode = E
> + drm_mode_copy(mode, &E)
> |
> - memcpy(mode, E, S)
> + drm_mode_copy(mode, E)
> )
> 
> @depends on !is_mode_copy@
> struct drm_display_mode mode;
> expression E;
> @@
> (
> - mode = E
> + drm_mode_copy(&mode, &E)
> |
> - memcpy(&mode, E, S)
> + drm_mode_copy(&mode, E)
> )
> 
> @@
> struct drm_display_mode *mode;
> @@
> - &*mode
> + mode
> 
> Cc: Rob Clark <robdclark@gmail.com>
> Cc: Sean Paul <sean@poorly.run>
> Cc: Abhinav Kumar <quic_abhinavk@quicinc.com>
> Cc: linux-arm-msm@vger.kernel.org
> Cc: freedreno@lists.freedesktop.org
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Abhinav Kumar <quic_abhinavk@quicinc.com>
> ---
>   drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_cmd.c | 2 +-
>   drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c | 2 +-
>   drivers/gpu/drm/msm/dp/dp_display.c                  | 2 +-
>   3 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_cmd.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_cmd.c
> index 34a6940d12c5..57592052af23 100644
> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_cmd.c
> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_cmd.c
> @@ -157,7 +157,7 @@ static void dpu_encoder_phys_cmd_mode_set(
>   		DPU_ERROR("invalid args\n");
>   		return;
>   	}
> -	phys_enc->cached_mode = *adj_mode;
> +	drm_mode_copy(&phys_enc->cached_mode, adj_mode);
>   	DPU_DEBUG_CMDENC(cmd_enc, "caching mode:\n");
>   	drm_mode_debug_printmodeline(adj_mode);
>   
> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c
> index e7813c6f7bd9..d5deca07b65a 100644
> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c
> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c
> @@ -370,7 +370,7 @@ static void dpu_encoder_phys_vid_mode_set(
>   	struct dpu_encoder_irq *irq;
>   
>   	if (adj_mode) {
> -		phys_enc->cached_mode = *adj_mode;
> +		drm_mode_copy(&phys_enc->cached_mode, adj_mode);
>   		drm_mode_debug_printmodeline(adj_mode);
>   		DPU_DEBUG_VIDENC(phys_enc, "caching mode:\n");
>   	}
> diff --git a/drivers/gpu/drm/msm/dp/dp_display.c b/drivers/gpu/drm/msm/dp/dp_display.c
> index 7cc4d21f2091..2ed6028ca8d6 100644
> --- a/drivers/gpu/drm/msm/dp/dp_display.c
> +++ b/drivers/gpu/drm/msm/dp/dp_display.c
> @@ -825,7 +825,7 @@ static int dp_display_set_mode(struct msm_dp *dp_display,
>   
>   	dp = container_of(dp_display, struct dp_display_private, dp_display);
>   
> -	dp->panel->dp_mode.drm_mode = mode->drm_mode;
> +	drm_mode_copy(&dp->panel->dp_mode.drm_mode, &mode->drm_mode);
>   	dp->panel->dp_mode.bpp = mode->bpp;
>   	dp->panel->dp_mode.capabilities = mode->capabilities;
>   	dp_panel_init_panel_info(dp->panel);

^ permalink raw reply	[flat|nested] 157+ messages in thread

* Re: [PATCH 12/22] drm/msm: Use drm_mode_copy()
@ 2022-03-23 20:09     ` Abhinav Kumar
  0 siblings, 0 replies; 157+ messages in thread
From: Abhinav Kumar @ 2022-03-23 20:09 UTC (permalink / raw)
  To: Ville Syrjala, dri-devel; +Cc: linux-arm-msm, intel-gfx, freedreno, Sean Paul



On 2/18/2022 2:03 AM, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> struct drm_display_mode embeds a list head, so overwriting
> the full struct with another one will corrupt the list
> (if the destination mode is on a list). Use drm_mode_copy()
> instead which explicitly preserves the list head of
> the destination mode.
> 
> Even if we know the destination mode is not on any list
> using drm_mode_copy() seems decent as it sets a good
> example. Bad examples of not using it might eventually
> get copied into code where preserving the list head
> actually matters.
> 
> Obviously one case not covered here is when the mode
> itself is embedded in a larger structure and the whole
> structure is copied. But if we are careful when copying
> into modes embedded in structures I think we can be a
> little more reassured that bogus list heads haven't been
> propagated in.
> 
> @is_mode_copy@
> @@
> drm_mode_copy(...)
> {
> ...
> }
> 
> @depends on !is_mode_copy@
> struct drm_display_mode *mode;
> expression E, S;
> @@
> (
> - *mode = E
> + drm_mode_copy(mode, &E)
> |
> - memcpy(mode, E, S)
> + drm_mode_copy(mode, E)
> )
> 
> @depends on !is_mode_copy@
> struct drm_display_mode mode;
> expression E;
> @@
> (
> - mode = E
> + drm_mode_copy(&mode, &E)
> |
> - memcpy(&mode, E, S)
> + drm_mode_copy(&mode, E)
> )
> 
> @@
> struct drm_display_mode *mode;
> @@
> - &*mode
> + mode
> 
> Cc: Rob Clark <robdclark@gmail.com>
> Cc: Sean Paul <sean@poorly.run>
> Cc: Abhinav Kumar <quic_abhinavk@quicinc.com>
> Cc: linux-arm-msm@vger.kernel.org
> Cc: freedreno@lists.freedesktop.org
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Abhinav Kumar <quic_abhinavk@quicinc.com>
> ---
>   drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_cmd.c | 2 +-
>   drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c | 2 +-
>   drivers/gpu/drm/msm/dp/dp_display.c                  | 2 +-
>   3 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_cmd.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_cmd.c
> index 34a6940d12c5..57592052af23 100644
> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_cmd.c
> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_cmd.c
> @@ -157,7 +157,7 @@ static void dpu_encoder_phys_cmd_mode_set(
>   		DPU_ERROR("invalid args\n");
>   		return;
>   	}
> -	phys_enc->cached_mode = *adj_mode;
> +	drm_mode_copy(&phys_enc->cached_mode, adj_mode);
>   	DPU_DEBUG_CMDENC(cmd_enc, "caching mode:\n");
>   	drm_mode_debug_printmodeline(adj_mode);
>   
> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c
> index e7813c6f7bd9..d5deca07b65a 100644
> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c
> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c
> @@ -370,7 +370,7 @@ static void dpu_encoder_phys_vid_mode_set(
>   	struct dpu_encoder_irq *irq;
>   
>   	if (adj_mode) {
> -		phys_enc->cached_mode = *adj_mode;
> +		drm_mode_copy(&phys_enc->cached_mode, adj_mode);
>   		drm_mode_debug_printmodeline(adj_mode);
>   		DPU_DEBUG_VIDENC(phys_enc, "caching mode:\n");
>   	}
> diff --git a/drivers/gpu/drm/msm/dp/dp_display.c b/drivers/gpu/drm/msm/dp/dp_display.c
> index 7cc4d21f2091..2ed6028ca8d6 100644
> --- a/drivers/gpu/drm/msm/dp/dp_display.c
> +++ b/drivers/gpu/drm/msm/dp/dp_display.c
> @@ -825,7 +825,7 @@ static int dp_display_set_mode(struct msm_dp *dp_display,
>   
>   	dp = container_of(dp_display, struct dp_display_private, dp_display);
>   
> -	dp->panel->dp_mode.drm_mode = mode->drm_mode;
> +	drm_mode_copy(&dp->panel->dp_mode.drm_mode, &mode->drm_mode);
>   	dp->panel->dp_mode.bpp = mode->bpp;
>   	dp->panel->dp_mode.capabilities = mode->capabilities;
>   	dp_panel_init_panel_info(dp->panel);

^ permalink raw reply	[flat|nested] 157+ messages in thread

* Re: [Intel-gfx] [PATCH 12/22] drm/msm: Use drm_mode_copy()
@ 2022-03-23 20:09     ` Abhinav Kumar
  0 siblings, 0 replies; 157+ messages in thread
From: Abhinav Kumar @ 2022-03-23 20:09 UTC (permalink / raw)
  To: Ville Syrjala, dri-devel; +Cc: linux-arm-msm, intel-gfx, freedreno



On 2/18/2022 2:03 AM, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> struct drm_display_mode embeds a list head, so overwriting
> the full struct with another one will corrupt the list
> (if the destination mode is on a list). Use drm_mode_copy()
> instead which explicitly preserves the list head of
> the destination mode.
> 
> Even if we know the destination mode is not on any list
> using drm_mode_copy() seems decent as it sets a good
> example. Bad examples of not using it might eventually
> get copied into code where preserving the list head
> actually matters.
> 
> Obviously one case not covered here is when the mode
> itself is embedded in a larger structure and the whole
> structure is copied. But if we are careful when copying
> into modes embedded in structures I think we can be a
> little more reassured that bogus list heads haven't been
> propagated in.
> 
> @is_mode_copy@
> @@
> drm_mode_copy(...)
> {
> ...
> }
> 
> @depends on !is_mode_copy@
> struct drm_display_mode *mode;
> expression E, S;
> @@
> (
> - *mode = E
> + drm_mode_copy(mode, &E)
> |
> - memcpy(mode, E, S)
> + drm_mode_copy(mode, E)
> )
> 
> @depends on !is_mode_copy@
> struct drm_display_mode mode;
> expression E;
> @@
> (
> - mode = E
> + drm_mode_copy(&mode, &E)
> |
> - memcpy(&mode, E, S)
> + drm_mode_copy(&mode, E)
> )
> 
> @@
> struct drm_display_mode *mode;
> @@
> - &*mode
> + mode
> 
> Cc: Rob Clark <robdclark@gmail.com>
> Cc: Sean Paul <sean@poorly.run>
> Cc: Abhinav Kumar <quic_abhinavk@quicinc.com>
> Cc: linux-arm-msm@vger.kernel.org
> Cc: freedreno@lists.freedesktop.org
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Abhinav Kumar <quic_abhinavk@quicinc.com>
> ---
>   drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_cmd.c | 2 +-
>   drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c | 2 +-
>   drivers/gpu/drm/msm/dp/dp_display.c                  | 2 +-
>   3 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_cmd.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_cmd.c
> index 34a6940d12c5..57592052af23 100644
> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_cmd.c
> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_cmd.c
> @@ -157,7 +157,7 @@ static void dpu_encoder_phys_cmd_mode_set(
>   		DPU_ERROR("invalid args\n");
>   		return;
>   	}
> -	phys_enc->cached_mode = *adj_mode;
> +	drm_mode_copy(&phys_enc->cached_mode, adj_mode);
>   	DPU_DEBUG_CMDENC(cmd_enc, "caching mode:\n");
>   	drm_mode_debug_printmodeline(adj_mode);
>   
> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c
> index e7813c6f7bd9..d5deca07b65a 100644
> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c
> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c
> @@ -370,7 +370,7 @@ static void dpu_encoder_phys_vid_mode_set(
>   	struct dpu_encoder_irq *irq;
>   
>   	if (adj_mode) {
> -		phys_enc->cached_mode = *adj_mode;
> +		drm_mode_copy(&phys_enc->cached_mode, adj_mode);
>   		drm_mode_debug_printmodeline(adj_mode);
>   		DPU_DEBUG_VIDENC(phys_enc, "caching mode:\n");
>   	}
> diff --git a/drivers/gpu/drm/msm/dp/dp_display.c b/drivers/gpu/drm/msm/dp/dp_display.c
> index 7cc4d21f2091..2ed6028ca8d6 100644
> --- a/drivers/gpu/drm/msm/dp/dp_display.c
> +++ b/drivers/gpu/drm/msm/dp/dp_display.c
> @@ -825,7 +825,7 @@ static int dp_display_set_mode(struct msm_dp *dp_display,
>   
>   	dp = container_of(dp_display, struct dp_display_private, dp_display);
>   
> -	dp->panel->dp_mode.drm_mode = mode->drm_mode;
> +	drm_mode_copy(&dp->panel->dp_mode.drm_mode, &mode->drm_mode);
>   	dp->panel->dp_mode.bpp = mode->bpp;
>   	dp->panel->dp_mode.capabilities = mode->capabilities;
>   	dp_panel_init_panel_info(dp->panel);

^ permalink raw reply	[flat|nested] 157+ messages in thread

* Re: [PATCH 00/22] drm: Review of mode copies
  2022-03-23 10:39         ` Dmitry Baryshkov
                             ` (2 preceding siblings ...)
  (?)
@ 2022-03-23 20:50           ` Abhinav Kumar
  -1 siblings, 0 replies; 157+ messages in thread
From: Abhinav Kumar @ 2022-03-23 20:50 UTC (permalink / raw)
  To: Dmitry Baryshkov, Ville Syrjälä, Alex Deucher
  Cc: Emma Anholt, Neil Armstrong, Xinliang Liu,
	Maling list - DRI developers, Thierry Reding, Jernej Skrabec,
	Andrzej Hajda, Sam Ravnborg, Rodrigo Siqueira, amd-gfx list,
	linux-rockchip, Xinwei Kong, Aurabindo Pillai, linux-arm-msm,
	Alain Volmat, Chun-Kuang Hu, Jonas Karlman, Leo Li, Chen Feng,
	Intel Graphics Development, Nikola Cornij, Sean Paul,
	linux-arm-kernel, Tomi Valkeinen, freedreno, Sandy Huang,
	Robert Foss, Alex Deucher, Tian Tao, Jyri Sarha,
	Laurent Pinchart



On 3/23/2022 3:39 AM, Dmitry Baryshkov wrote:
> On 22/03/2022 01:37, Ville Syrjälä wrote:
>> On Tue, Mar 15, 2022 at 02:52:38PM -0400, Alex Deucher wrote:
>>> On Mon, Mar 14, 2022 at 6:12 PM Ville Syrjälä
>>> <ville.syrjala@linux.intel.com> wrote:
>>>>
>>>> On Fri, Feb 18, 2022 at 12:03:41PM +0200, Ville Syrjala wrote:
>>>>>    drm: Add drm_mode_init()
>>>>>    drm/bridge: Use drm_mode_copy()
>>>>>    drm/imx: Use drm_mode_duplicate()
>>>>>    drm/panel: Use drm_mode_duplicate()
>>>>>    drm/vc4: Use drm_mode_copy()
>>>> These have been pushed to drm-misc-next.
>>>>
>>>>>    drm/amdgpu: Remove pointless on stack mode copies
>>>>>    drm/amdgpu: Use drm_mode_init() for on-stack modes
>>>>>    drm/amdgpu: Use drm_mode_copy()
>>>> amdgpu ones are reviewed, but I'll leave them for the
>>>> AMD folks to push to whichever tree they prefer.
>>>
>>> I pulled patches 2, 4, 5 into my tree.
>>
>> Thanks.
>>
>>> For 3, I'm happy to have it
>>> land via drm-misc with the rest of the mode_init changes if you'd
>>> prefer.
>>
>> Either way works for me. I don't yet have reviews yet for
>> the other drivers, so I'll proably hold off for a bit more
>> at least. And the i915 patch I'll be merging via drm-intel.
>>
>>>>>    drm/radeon: Use drm_mode_copy()
>>>>>    drm/gma500: Use drm_mode_copy()
>>>>>    drm/tilcdc: Use drm_mode_copy()
>>>>>    drm/i915: Use drm_mode_copy()
>>
>> Those are now all in.
>>
>> Which leaves us with these stragglers:
>>>>>    drm/hisilicon: Use drm_mode_init() for on-stack modes
> 
>>>>>    drm/msm: Nuke weird on stack mode copy
>>>>>    drm/msm: Use drm_mode_init() for on-stack modes
>>>>>    drm/msm: Use drm_mode_copy()
> 
> These three patches went beneath my radar for some reason.
> 
> I have just sent a replacement for the first patch ([1]). Other two 
> patches can be pulled in msm/msm-next (or msm/msm-fixes) during the next 
> development cycle if that works for you.
> 
> [1] https://patchwork.freedesktop.org/series/101682/

Agree with this approach.

We can replace the first patch with 
https://patchwork.freedesktop.org/series/101682/.

Thanks

Abhinav

> 
>>>>>    drm/mtk: Use drm_mode_init() for on-stack modes
>>>>>    drm/rockchip: Use drm_mode_copy()
>>>>>    drm/sti: Use drm_mode_copy()
>>>>>    drm: Use drm_mode_init() for on-stack modes
>>>>>    drm: Use drm_mode_copy()
>>
> 
> 

^ permalink raw reply	[flat|nested] 157+ messages in thread

* Re: [PATCH 00/22] drm: Review of mode copies
@ 2022-03-23 20:50           ` Abhinav Kumar
  0 siblings, 0 replies; 157+ messages in thread
From: Abhinav Kumar @ 2022-03-23 20:50 UTC (permalink / raw)
  To: Dmitry Baryshkov, Ville Syrjälä, Alex Deucher
  Cc: Emma Anholt, Neil Armstrong, Xinliang Liu,
	Maling list - DRI developers, Thierry Reding, Jernej Skrabec,
	Andrzej Hajda, Sam Ravnborg, Rodrigo Siqueira, amd-gfx list,
	linux-rockchip, Xinwei Kong, Aurabindo Pillai, linux-arm-msm,
	Alain Volmat, Chun-Kuang Hu, Jonas Karlman, Leo Li, Chen Feng,
	Intel Graphics Development, Nikola Cornij, Sean Paul,
	linux-arm-kernel, Tomi Valkeinen, freedreno, Sandy Huang,
	Robert Foss, Alex Deucher, Tian Tao, Jyri Sarha,
	Laurent Pinchart



On 3/23/2022 3:39 AM, Dmitry Baryshkov wrote:
> On 22/03/2022 01:37, Ville Syrjälä wrote:
>> On Tue, Mar 15, 2022 at 02:52:38PM -0400, Alex Deucher wrote:
>>> On Mon, Mar 14, 2022 at 6:12 PM Ville Syrjälä
>>> <ville.syrjala@linux.intel.com> wrote:
>>>>
>>>> On Fri, Feb 18, 2022 at 12:03:41PM +0200, Ville Syrjala wrote:
>>>>>    drm: Add drm_mode_init()
>>>>>    drm/bridge: Use drm_mode_copy()
>>>>>    drm/imx: Use drm_mode_duplicate()
>>>>>    drm/panel: Use drm_mode_duplicate()
>>>>>    drm/vc4: Use drm_mode_copy()
>>>> These have been pushed to drm-misc-next.
>>>>
>>>>>    drm/amdgpu: Remove pointless on stack mode copies
>>>>>    drm/amdgpu: Use drm_mode_init() for on-stack modes
>>>>>    drm/amdgpu: Use drm_mode_copy()
>>>> amdgpu ones are reviewed, but I'll leave them for the
>>>> AMD folks to push to whichever tree they prefer.
>>>
>>> I pulled patches 2, 4, 5 into my tree.
>>
>> Thanks.
>>
>>> For 3, I'm happy to have it
>>> land via drm-misc with the rest of the mode_init changes if you'd
>>> prefer.
>>
>> Either way works for me. I don't yet have reviews yet for
>> the other drivers, so I'll proably hold off for a bit more
>> at least. And the i915 patch I'll be merging via drm-intel.
>>
>>>>>    drm/radeon: Use drm_mode_copy()
>>>>>    drm/gma500: Use drm_mode_copy()
>>>>>    drm/tilcdc: Use drm_mode_copy()
>>>>>    drm/i915: Use drm_mode_copy()
>>
>> Those are now all in.
>>
>> Which leaves us with these stragglers:
>>>>>    drm/hisilicon: Use drm_mode_init() for on-stack modes
> 
>>>>>    drm/msm: Nuke weird on stack mode copy
>>>>>    drm/msm: Use drm_mode_init() for on-stack modes
>>>>>    drm/msm: Use drm_mode_copy()
> 
> These three patches went beneath my radar for some reason.
> 
> I have just sent a replacement for the first patch ([1]). Other two 
> patches can be pulled in msm/msm-next (or msm/msm-fixes) during the next 
> development cycle if that works for you.
> 
> [1] https://patchwork.freedesktop.org/series/101682/

Agree with this approach.

We can replace the first patch with 
https://patchwork.freedesktop.org/series/101682/.

Thanks

Abhinav

> 
>>>>>    drm/mtk: Use drm_mode_init() for on-stack modes
>>>>>    drm/rockchip: Use drm_mode_copy()
>>>>>    drm/sti: Use drm_mode_copy()
>>>>>    drm: Use drm_mode_init() for on-stack modes
>>>>>    drm: Use drm_mode_copy()
>>
> 
> 

_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

^ permalink raw reply	[flat|nested] 157+ messages in thread

* Re: [PATCH 00/22] drm: Review of mode copies
@ 2022-03-23 20:50           ` Abhinav Kumar
  0 siblings, 0 replies; 157+ messages in thread
From: Abhinav Kumar @ 2022-03-23 20:50 UTC (permalink / raw)
  To: Dmitry Baryshkov, Ville Syrjälä, Alex Deucher
  Cc: Emma Anholt, Neil Armstrong, Xinliang Liu,
	Maling list - DRI developers, Thierry Reding, Jernej Skrabec,
	Andrzej Hajda, Sam Ravnborg, Rodrigo Siqueira, amd-gfx list,
	linux-rockchip, Xinwei Kong, Aurabindo Pillai, Chen Feng,
	Alain Volmat, Chun-Kuang Hu, Jonas Karlman, Leo Li,
	linux-arm-msm, Intel Graphics Development, Nikola Cornij,
	Sean Paul, linux-arm-kernel, Tomi Valkeinen, Jyri Sarha,
	Sandy Huang, Robert Foss, Alex Deucher, Tian Tao, freedreno,
	Laurent Pinchart



On 3/23/2022 3:39 AM, Dmitry Baryshkov wrote:
> On 22/03/2022 01:37, Ville Syrjälä wrote:
>> On Tue, Mar 15, 2022 at 02:52:38PM -0400, Alex Deucher wrote:
>>> On Mon, Mar 14, 2022 at 6:12 PM Ville Syrjälä
>>> <ville.syrjala@linux.intel.com> wrote:
>>>>
>>>> On Fri, Feb 18, 2022 at 12:03:41PM +0200, Ville Syrjala wrote:
>>>>>    drm: Add drm_mode_init()
>>>>>    drm/bridge: Use drm_mode_copy()
>>>>>    drm/imx: Use drm_mode_duplicate()
>>>>>    drm/panel: Use drm_mode_duplicate()
>>>>>    drm/vc4: Use drm_mode_copy()
>>>> These have been pushed to drm-misc-next.
>>>>
>>>>>    drm/amdgpu: Remove pointless on stack mode copies
>>>>>    drm/amdgpu: Use drm_mode_init() for on-stack modes
>>>>>    drm/amdgpu: Use drm_mode_copy()
>>>> amdgpu ones are reviewed, but I'll leave them for the
>>>> AMD folks to push to whichever tree they prefer.
>>>
>>> I pulled patches 2, 4, 5 into my tree.
>>
>> Thanks.
>>
>>> For 3, I'm happy to have it
>>> land via drm-misc with the rest of the mode_init changes if you'd
>>> prefer.
>>
>> Either way works for me. I don't yet have reviews yet for
>> the other drivers, so I'll proably hold off for a bit more
>> at least. And the i915 patch I'll be merging via drm-intel.
>>
>>>>>    drm/radeon: Use drm_mode_copy()
>>>>>    drm/gma500: Use drm_mode_copy()
>>>>>    drm/tilcdc: Use drm_mode_copy()
>>>>>    drm/i915: Use drm_mode_copy()
>>
>> Those are now all in.
>>
>> Which leaves us with these stragglers:
>>>>>    drm/hisilicon: Use drm_mode_init() for on-stack modes
> 
>>>>>    drm/msm: Nuke weird on stack mode copy
>>>>>    drm/msm: Use drm_mode_init() for on-stack modes
>>>>>    drm/msm: Use drm_mode_copy()
> 
> These three patches went beneath my radar for some reason.
> 
> I have just sent a replacement for the first patch ([1]). Other two 
> patches can be pulled in msm/msm-next (or msm/msm-fixes) during the next 
> development cycle if that works for you.
> 
> [1] https://patchwork.freedesktop.org/series/101682/

Agree with this approach.

We can replace the first patch with 
https://patchwork.freedesktop.org/series/101682/.

Thanks

Abhinav

> 
>>>>>    drm/mtk: Use drm_mode_init() for on-stack modes
>>>>>    drm/rockchip: Use drm_mode_copy()
>>>>>    drm/sti: Use drm_mode_copy()
>>>>>    drm: Use drm_mode_init() for on-stack modes
>>>>>    drm: Use drm_mode_copy()
>>
> 
> 

^ permalink raw reply	[flat|nested] 157+ messages in thread

* Re: [Intel-gfx] [PATCH 00/22] drm: Review of mode copies
@ 2022-03-23 20:50           ` Abhinav Kumar
  0 siblings, 0 replies; 157+ messages in thread
From: Abhinav Kumar @ 2022-03-23 20:50 UTC (permalink / raw)
  To: Dmitry Baryshkov, Ville Syrjälä, Alex Deucher
  Cc: Emma Anholt, Neil Armstrong, Xinliang Liu,
	Maling list - DRI developers, Jernej Skrabec, Andrzej Hajda,
	Sam Ravnborg, Rodrigo Siqueira, amd-gfx list, linux-rockchip,
	Xinwei Kong, Aurabindo Pillai, Chen Feng, Alain Volmat,
	Chun-Kuang Hu, Jonas Karlman, Leo Li, linux-arm-msm,
	Intel Graphics Development, Nikola Cornij, linux-arm-kernel,
	Tomi Valkeinen, Jyri Sarha, Sandy Huang, Robert Foss,
	Alex Deucher, Tian Tao, freedreno, Laurent Pinchart



On 3/23/2022 3:39 AM, Dmitry Baryshkov wrote:
> On 22/03/2022 01:37, Ville Syrjälä wrote:
>> On Tue, Mar 15, 2022 at 02:52:38PM -0400, Alex Deucher wrote:
>>> On Mon, Mar 14, 2022 at 6:12 PM Ville Syrjälä
>>> <ville.syrjala@linux.intel.com> wrote:
>>>>
>>>> On Fri, Feb 18, 2022 at 12:03:41PM +0200, Ville Syrjala wrote:
>>>>>    drm: Add drm_mode_init()
>>>>>    drm/bridge: Use drm_mode_copy()
>>>>>    drm/imx: Use drm_mode_duplicate()
>>>>>    drm/panel: Use drm_mode_duplicate()
>>>>>    drm/vc4: Use drm_mode_copy()
>>>> These have been pushed to drm-misc-next.
>>>>
>>>>>    drm/amdgpu: Remove pointless on stack mode copies
>>>>>    drm/amdgpu: Use drm_mode_init() for on-stack modes
>>>>>    drm/amdgpu: Use drm_mode_copy()
>>>> amdgpu ones are reviewed, but I'll leave them for the
>>>> AMD folks to push to whichever tree they prefer.
>>>
>>> I pulled patches 2, 4, 5 into my tree.
>>
>> Thanks.
>>
>>> For 3, I'm happy to have it
>>> land via drm-misc with the rest of the mode_init changes if you'd
>>> prefer.
>>
>> Either way works for me. I don't yet have reviews yet for
>> the other drivers, so I'll proably hold off for a bit more
>> at least. And the i915 patch I'll be merging via drm-intel.
>>
>>>>>    drm/radeon: Use drm_mode_copy()
>>>>>    drm/gma500: Use drm_mode_copy()
>>>>>    drm/tilcdc: Use drm_mode_copy()
>>>>>    drm/i915: Use drm_mode_copy()
>>
>> Those are now all in.
>>
>> Which leaves us with these stragglers:
>>>>>    drm/hisilicon: Use drm_mode_init() for on-stack modes
> 
>>>>>    drm/msm: Nuke weird on stack mode copy
>>>>>    drm/msm: Use drm_mode_init() for on-stack modes
>>>>>    drm/msm: Use drm_mode_copy()
> 
> These three patches went beneath my radar for some reason.
> 
> I have just sent a replacement for the first patch ([1]). Other two 
> patches can be pulled in msm/msm-next (or msm/msm-fixes) during the next 
> development cycle if that works for you.
> 
> [1] https://patchwork.freedesktop.org/series/101682/

Agree with this approach.

We can replace the first patch with 
https://patchwork.freedesktop.org/series/101682/.

Thanks

Abhinav

> 
>>>>>    drm/mtk: Use drm_mode_init() for on-stack modes
>>>>>    drm/rockchip: Use drm_mode_copy()
>>>>>    drm/sti: Use drm_mode_copy()
>>>>>    drm: Use drm_mode_init() for on-stack modes
>>>>>    drm: Use drm_mode_copy()
>>
> 
> 

^ permalink raw reply	[flat|nested] 157+ messages in thread

* Re: [PATCH 00/22] drm: Review of mode copies
@ 2022-03-23 20:50           ` Abhinav Kumar
  0 siblings, 0 replies; 157+ messages in thread
From: Abhinav Kumar @ 2022-03-23 20:50 UTC (permalink / raw)
  To: Dmitry Baryshkov, Ville Syrjälä, Alex Deucher
  Cc: Emma Anholt, Neil Armstrong, Xinliang Liu,
	Maling list - DRI developers, Thierry Reding, Jernej Skrabec,
	Andrzej Hajda, Sam Ravnborg, Rodrigo Siqueira, amd-gfx list,
	linux-rockchip, Xinwei Kong, Aurabindo Pillai, linux-arm-msm,
	Alain Volmat, Chun-Kuang Hu, Jonas Karlman, Leo Li, Chen Feng,
	Intel Graphics Development, Nikola Cornij, Sean Paul,
	linux-arm-kernel, Tomi Valkeinen, freedreno, Sandy Huang,
	Robert Foss, Alex Deucher, Tian Tao, Jyri Sarha,
	Laurent Pinchart



On 3/23/2022 3:39 AM, Dmitry Baryshkov wrote:
> On 22/03/2022 01:37, Ville Syrjälä wrote:
>> On Tue, Mar 15, 2022 at 02:52:38PM -0400, Alex Deucher wrote:
>>> On Mon, Mar 14, 2022 at 6:12 PM Ville Syrjälä
>>> <ville.syrjala@linux.intel.com> wrote:
>>>>
>>>> On Fri, Feb 18, 2022 at 12:03:41PM +0200, Ville Syrjala wrote:
>>>>>    drm: Add drm_mode_init()
>>>>>    drm/bridge: Use drm_mode_copy()
>>>>>    drm/imx: Use drm_mode_duplicate()
>>>>>    drm/panel: Use drm_mode_duplicate()
>>>>>    drm/vc4: Use drm_mode_copy()
>>>> These have been pushed to drm-misc-next.
>>>>
>>>>>    drm/amdgpu: Remove pointless on stack mode copies
>>>>>    drm/amdgpu: Use drm_mode_init() for on-stack modes
>>>>>    drm/amdgpu: Use drm_mode_copy()
>>>> amdgpu ones are reviewed, but I'll leave them for the
>>>> AMD folks to push to whichever tree they prefer.
>>>
>>> I pulled patches 2, 4, 5 into my tree.
>>
>> Thanks.
>>
>>> For 3, I'm happy to have it
>>> land via drm-misc with the rest of the mode_init changes if you'd
>>> prefer.
>>
>> Either way works for me. I don't yet have reviews yet for
>> the other drivers, so I'll proably hold off for a bit more
>> at least. And the i915 patch I'll be merging via drm-intel.
>>
>>>>>    drm/radeon: Use drm_mode_copy()
>>>>>    drm/gma500: Use drm_mode_copy()
>>>>>    drm/tilcdc: Use drm_mode_copy()
>>>>>    drm/i915: Use drm_mode_copy()
>>
>> Those are now all in.
>>
>> Which leaves us with these stragglers:
>>>>>    drm/hisilicon: Use drm_mode_init() for on-stack modes
> 
>>>>>    drm/msm: Nuke weird on stack mode copy
>>>>>    drm/msm: Use drm_mode_init() for on-stack modes
>>>>>    drm/msm: Use drm_mode_copy()
> 
> These three patches went beneath my radar for some reason.
> 
> I have just sent a replacement for the first patch ([1]). Other two 
> patches can be pulled in msm/msm-next (or msm/msm-fixes) during the next 
> development cycle if that works for you.
> 
> [1] https://patchwork.freedesktop.org/series/101682/

Agree with this approach.

We can replace the first patch with 
https://patchwork.freedesktop.org/series/101682/.

Thanks

Abhinav

> 
>>>>>    drm/mtk: Use drm_mode_init() for on-stack modes
>>>>>    drm/rockchip: Use drm_mode_copy()
>>>>>    drm/sti: Use drm_mode_copy()
>>>>>    drm: Use drm_mode_init() for on-stack modes
>>>>>    drm: Use drm_mode_copy()
>>
> 
> 

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 157+ messages in thread

end of thread, other threads:[~2022-03-23 20:52 UTC | newest]

Thread overview: 157+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-18 10:03 [PATCH 00/22] drm: Review of mode copies Ville Syrjala
2022-02-18 10:03 ` Ville Syrjala
2022-02-18 10:03 ` Ville Syrjala
2022-02-18 10:03 ` [Intel-gfx] " Ville Syrjala
2022-02-18 10:03 ` Ville Syrjala
2022-02-18 10:03 ` Ville Syrjala
2022-02-18 10:03 ` [PATCH 01/22] drm: Add drm_mode_init() Ville Syrjala
2022-02-18 10:03   ` [Intel-gfx] " Ville Syrjala
2022-02-18 11:22   ` Andrzej Hajda
2022-02-18 11:22     ` [Intel-gfx] " Andrzej Hajda
2022-02-18 11:56     ` Ville Syrjälä
2022-02-18 11:56       ` [Intel-gfx] " Ville Syrjälä
2022-02-18 12:23       ` Andrzej Hajda
2022-02-18 12:23         ` [Intel-gfx] " Andrzej Hajda
2022-02-18 16:34   ` Harry Wentland
2022-02-18 16:34     ` [Intel-gfx] " Harry Wentland
2022-02-18 10:03 ` [PATCH 02/22] drm/amdgpu: Remove pointless on stack mode copies Ville Syrjala
2022-02-18 10:03   ` Ville Syrjala
2022-02-18 10:03   ` [Intel-gfx] " Ville Syrjala
2022-02-18 16:28   ` Harry Wentland
2022-02-18 16:28     ` [Intel-gfx] " Harry Wentland
2022-03-15 15:57     ` Alex Deucher
2022-03-15 15:57       ` Alex Deucher
2022-03-15 15:57       ` [Intel-gfx] " Alex Deucher
2022-02-18 10:03 ` [PATCH 03/22] drm/amdgpu: Use drm_mode_init() for on-stack modes Ville Syrjala
2022-02-18 10:03   ` Ville Syrjala
2022-02-18 10:03   ` [Intel-gfx] " Ville Syrjala
2022-02-18 16:30   ` Harry Wentland
2022-02-18 16:30     ` [Intel-gfx] " Harry Wentland
2022-02-18 10:03 ` [PATCH 04/22] drm/amdgpu: Use drm_mode_copy() Ville Syrjala
2022-02-18 10:03   ` Ville Syrjala
2022-02-18 10:03   ` [Intel-gfx] " Ville Syrjala
2022-02-18 16:32   ` Harry Wentland
2022-02-18 16:32     ` [Intel-gfx] " Harry Wentland
2022-03-15 18:50     ` Alex Deucher
2022-03-15 18:50       ` Alex Deucher
2022-03-15 18:50       ` [Intel-gfx] " Alex Deucher
2022-02-18 10:03 ` [PATCH 05/22] drm/radeon: " Ville Syrjala
2022-02-18 10:03   ` [Intel-gfx] " Ville Syrjala
2022-03-15 18:49   ` Alex Deucher
2022-03-15 18:49     ` [Intel-gfx] " Alex Deucher
2022-02-18 10:03 ` [PATCH 06/22] drm/bridge: " Ville Syrjala
2022-02-18 10:03   ` [Intel-gfx] " Ville Syrjala
2022-02-18 11:25   ` Andrzej Hajda
2022-02-18 11:25     ` [Intel-gfx] " Andrzej Hajda
2022-02-18 17:47   ` Laurent Pinchart
2022-02-18 17:47     ` [Intel-gfx] " Laurent Pinchart
2022-02-18 10:03 ` [PATCH 07/22] drm/gma500: " Ville Syrjala
2022-02-18 10:03   ` [Intel-gfx] " Ville Syrjala
2022-03-16 13:16   ` Patrik Jakobsson
2022-03-16 13:16     ` [Intel-gfx] " Patrik Jakobsson
2022-02-18 10:03 ` [PATCH 08/22] drm/hisilicon: Use drm_mode_init() for on-stack modes Ville Syrjala
2022-02-18 10:03   ` [Intel-gfx] " Ville Syrjala
2022-02-18 10:03 ` [PATCH 09/22] drm/imx: Use drm_mode_duplicate() Ville Syrjala
2022-02-18 10:03   ` [Intel-gfx] " Ville Syrjala
2022-02-18 11:42   ` Philipp Zabel
2022-02-18 11:42     ` [Intel-gfx] " Philipp Zabel
2022-02-18 10:03 ` [PATCH 10/22] drm/msm: Nuke weird on stack mode copy Ville Syrjala
2022-02-18 10:03   ` [Intel-gfx] " Ville Syrjala
2022-02-18 10:03   ` Ville Syrjala
2022-03-23 10:19   ` Dmitry Baryshkov
2022-03-23 10:19     ` [Intel-gfx] " Dmitry Baryshkov
2022-03-23 10:19     ` Dmitry Baryshkov
2022-02-18 10:03 ` [PATCH 11/22] drm/msm: Use drm_mode_init() for on-stack modes Ville Syrjala
2022-02-18 10:03   ` [Intel-gfx] " Ville Syrjala
2022-02-18 10:03   ` Ville Syrjala
2022-03-23 10:11   ` Dmitry Baryshkov
2022-03-23 10:11     ` [Intel-gfx] " Dmitry Baryshkov
2022-03-23 10:11     ` Dmitry Baryshkov
2022-03-23 20:04   ` Abhinav Kumar
2022-03-23 20:04     ` [Intel-gfx] " Abhinav Kumar
2022-03-23 20:04     ` Abhinav Kumar
2022-02-18 10:03 ` [PATCH 12/22] drm/msm: Use drm_mode_copy() Ville Syrjala
2022-02-18 10:03   ` [Intel-gfx] " Ville Syrjala
2022-02-18 10:03   ` Ville Syrjala
2022-03-23 10:12   ` Dmitry Baryshkov
2022-03-23 10:12     ` [Intel-gfx] " Dmitry Baryshkov
2022-03-23 10:12     ` Dmitry Baryshkov
2022-03-23 20:09   ` Abhinav Kumar
2022-03-23 20:09     ` [Intel-gfx] " Abhinav Kumar
2022-03-23 20:09     ` Abhinav Kumar
2022-02-18 10:03 ` [PATCH 13/22] drm/mtk: Use drm_mode_init() for on-stack modes Ville Syrjala
2022-02-18 10:03   ` [Intel-gfx] " Ville Syrjala
2022-02-18 10:03 ` [PATCH 14/22] drm/rockchip: Use drm_mode_copy() Ville Syrjala
2022-02-18 10:03   ` Ville Syrjala
2022-02-18 10:03   ` Ville Syrjala
2022-02-18 10:03   ` [Intel-gfx] " Ville Syrjala
2022-02-18 10:03 ` [PATCH 15/22] drm/sti: " Ville Syrjala
2022-02-18 10:03   ` [Intel-gfx] " Ville Syrjala
2022-02-18 10:03 ` [PATCH 16/22] drm/tilcdc: " Ville Syrjala
2022-02-18 10:03   ` [Intel-gfx] " Ville Syrjala
2022-03-15  4:54   ` Tomi Valkeinen
2022-03-15  4:54     ` [Intel-gfx] " Tomi Valkeinen
2022-02-18 10:03 ` [Intel-gfx] [PATCH 17/22] drm/vc4: " Ville Syrjala
2022-02-18 10:03   ` Ville Syrjala
2022-02-21 10:13   ` (subset) [Intel-gfx] " Maxime Ripard
2022-02-21 10:13     ` [Intel-gfx] (subset) " Maxime Ripard
2022-02-18 10:03 ` [PATCH 18/22] drm/i915: Use drm_mode_init() for on-stack modes Ville Syrjala
2022-02-18 10:03   ` [Intel-gfx] " Ville Syrjala
2022-03-16  8:00   ` Jani Nikula
2022-03-21 18:57     ` Ville Syrjälä
2022-03-21 18:57       ` [cocci] " Ville Syrjälä
2022-03-21 20:48       ` Julia Lawall
2022-03-21 20:48         ` Julia Lawall
2022-02-18 10:04 ` [PATCH 19/22] drm/i915: Use drm_mode_copy() Ville Syrjala
2022-02-18 10:04   ` [Intel-gfx] " Ville Syrjala
2022-03-16  8:04   ` Jani Nikula
2022-02-18 10:04 ` [PATCH 20/22] drm/panel: Use drm_mode_duplicate() Ville Syrjala
2022-02-18 10:04   ` [Intel-gfx] " Ville Syrjala
2022-02-18 11:51   ` Sam Ravnborg
2022-02-18 11:51     ` [Intel-gfx] " Sam Ravnborg
2022-02-18 10:04 ` [PATCH 21/22] drm: Use drm_mode_init() for on-stack modes Ville Syrjala
2022-02-18 10:04   ` [Intel-gfx] " Ville Syrjala
2022-03-22 11:10   ` Andrzej Hajda
2022-03-22 11:10     ` [Intel-gfx] " Andrzej Hajda
2022-02-18 10:04 ` [PATCH 22/22] drm: Use drm_mode_copy() Ville Syrjala
2022-02-18 10:04   ` [Intel-gfx] " Ville Syrjala
2022-03-22 11:19   ` Andrzej Hajda
2022-03-22 11:19     ` [Intel-gfx] " Andrzej Hajda
2022-02-18 13:43 ` [Intel-gfx] ✗ Fi.CI.SPARSE: warning for drm: Review of mode copies Patchwork
2022-02-18 14:16 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2022-02-19  5:06 ` [Intel-gfx] ✗ Fi.CI.IGT: failure " Patchwork
2022-03-14 22:11 ` [PATCH 00/22] " Ville Syrjälä
2022-03-14 22:11   ` Ville Syrjälä
2022-03-14 22:11   ` Ville Syrjälä
2022-03-14 22:11   ` [Intel-gfx] " Ville Syrjälä
2022-03-14 22:11   ` Ville Syrjälä
2022-03-14 22:11   ` Ville Syrjälä
2022-03-15 18:52   ` Alex Deucher
2022-03-15 18:52     ` Alex Deucher
2022-03-15 18:52     ` Alex Deucher
2022-03-15 18:52     ` [Intel-gfx] " Alex Deucher
2022-03-15 18:52     ` Alex Deucher
2022-03-15 18:52     ` Alex Deucher
2022-03-21 22:37     ` Ville Syrjälä
2022-03-21 22:37       ` Ville Syrjälä
2022-03-21 22:37       ` Ville Syrjälä
2022-03-21 22:37       ` Ville Syrjälä
2022-03-21 22:37       ` Ville Syrjälä
2022-03-21 22:37       ` [Intel-gfx] " Ville Syrjälä
2022-03-23 10:39       ` Dmitry Baryshkov
2022-03-23 10:39         ` [Intel-gfx] " Dmitry Baryshkov
2022-03-23 10:39         ` Dmitry Baryshkov
2022-03-23 10:39         ` Dmitry Baryshkov
2022-03-23 10:39         ` Dmitry Baryshkov
2022-03-23 10:39         ` Dmitry Baryshkov
2022-03-23 15:10         ` Ville Syrjälä
2022-03-23 15:10           ` Ville Syrjälä
2022-03-23 15:10           ` Ville Syrjälä
2022-03-23 15:10           ` Ville Syrjälä
2022-03-23 15:10           ` [Intel-gfx] " Ville Syrjälä
2022-03-23 15:10           ` Ville Syrjälä
2022-03-23 20:50         ` Abhinav Kumar
2022-03-23 20:50           ` Abhinav Kumar
2022-03-23 20:50           ` [Intel-gfx] " Abhinav Kumar
2022-03-23 20:50           ` Abhinav Kumar
2022-03-23 20:50           ` Abhinav Kumar

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.