Skip to contentSkip to conversation

drm: include: fix W=1 warnings in struct drm_dsc_config

PATCH In review Benjamin Gaignard 6 participants 16 messages Sep 9, 2019 – Oct 8, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm: include: fix W=1 warnings in struct drm_dsc_config

Change scale_increment_interval and nfl_bpg_offset fields to u32 to avoid W=1 warnings because we are testing them against 65535.

---
 include/drm/drm_dsc.h | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
include/drm/drm_dsc.h +4 -2
index 887954cbfc60..e495024e901c 100644
@@ -207,11 +207,13 @@ struct drm_dsc_config {
 	 * Number of group times between incrementing the scale factor value
 	 * used at the beginning of a slice.
 	 */
-	u16 scale_increment_interval;
+	u32 scale_increment_interval;
+
 	/**
 	 * @nfl_bpg_offset: Non first line BPG offset to be used
 	 */
-	u16 nfl_bpg_offset;
+
+	u32 nfl_bpg_offset;
 	/**
 	 * @slice_bpg_offset: BPG offset used to enforce slice bit
 	 */
Signature · 1 line
2.15.0
#1 lore raw

PATCH 1/1 drm: atomic helper: fix W=1 warnings

Fix warnings with W=1.
Few for_each macro set variables that are never used later. Prevent warning by marking these variables as __maybe_unused.

---
 drivers/gpu/drm/drm_atomic_helper.c | 36 ++++++++++++++++++------------------
 1 file changed, 18 insertions(+), 18 deletions(-)
drivers/gpu/drm/drm_atomic_helper.c +18 -18
index aa16ea17ff9b..b69d17b0b9bd 100644
@@ -262,7 +262,7 @@ steal_encoder(struct drm_atomic_state *state,
 	      struct drm_encoder *encoder)
 {
 	struct drm_crtc_state *crtc_state;
-	struct drm_connector *connector;
+	struct drm_connector __maybe_unused *connector;
 	struct drm_connector_state *old_connector_state, *new_connector_state;
 	int i;
 
@@ -412,7 +412,7 @@ mode_fixup(struct drm_atomic_state *state)
 {
 	struct drm_crtc *crtc;
 	struct drm_crtc_state *new_crtc_state;
-	struct drm_connector *connector;
+	struct drm_connector __maybe_unused *connector;
 	struct drm_connector_state *new_conn_state;
 	int i;
 	int ret;
@@ -608,7 +608,7 @@ drm_atomic_helper_check_modeset(struct drm_device *dev,
 {
 	struct drm_crtc *crtc;
 	struct drm_crtc_state *old_crtc_state, *new_crtc_state;
-	struct drm_connector *connector;
+	struct drm_connector __maybe_unused *connector;
 	struct drm_connector_state *old_connector_state, *new_connector_state;
 	int i, ret;
 	unsigned connectors_mask = 0;
@@ -984,7 +984,7 @@ crtc_needs_disable(struct drm_crtc_state *old_state,
 static void
 disable_outputs(struct drm_device *dev, struct drm_atomic_state *old_state)
 {
-	struct drm_connector *connector;
+	struct drm_connector __maybe_unused *connector;
 	struct drm_connector_state *old_conn_state, *new_conn_state;
 	struct drm_crtc *crtc;
 	struct drm_crtc_state *old_crtc_state, *new_crtc_state;
@@ -1173,7 +1173,7 @@ crtc_set_mode(struct drm_device *dev, struct drm_atomic_state *old_state)
 {
 	struct drm_crtc *crtc;
 	struct drm_crtc_state *new_crtc_state;
-	struct drm_connector *connector;
+	struct drm_connector __maybe_unused *connector;
 	struct drm_connector_state *new_conn_state;
 	int i;
 
@@ -1294,7 +1294,7 @@ void drm_atomic_helper_commit_modeset_enables(struct drm_device *dev,
 	struct drm_crtc *crtc;
 	struct drm_crtc_state *old_crtc_state;
 	struct drm_crtc_state *new_crtc_state;
-	struct drm_connector *connector;
+	struct drm_connector __maybe_unused *connector;
 	struct drm_connector_state *new_conn_state;
 	int i;
 
@@ -1384,7 +1384,7 @@ int drm_atomic_helper_wait_for_fences(struct drm_device *dev,
 				      struct drm_atomic_state *state,
 				      bool pre_swap)
 {
-	struct drm_plane *plane;
+	struct drm_plane __maybe_unused *plane;
 	struct drm_plane_state *new_plane_state;
 	int i, ret;
 
@@ -1431,7 +1431,7 @@ drm_atomic_helper_wait_for_vblanks(struct drm_device *dev,
 		struct drm_atomic_state *old_state)
 {
 	struct drm_crtc *crtc;
-	struct drm_crtc_state *old_crtc_state, *new_crtc_state;
+	struct drm_crtc_state __maybe_unused *old_crtc_state, *new_crtc_state;
 	int i, ret;
 	unsigned crtc_mask = 0;
 
@@ -1621,7 +1621,7 @@ static void commit_work(struct work_struct *work)
 int drm_atomic_helper_async_check(struct drm_device *dev,
 				   struct drm_atomic_state *state)
 {
-	struct drm_crtc *crtc;
+	struct drm_crtc __maybe_unused *crtc;
 	struct drm_crtc_state *crtc_state;
 	struct drm_plane *plane = NULL;
 	struct drm_plane_state *old_plane_state = NULL;
@@ -1982,9 +1982,9 @@ int drm_atomic_helper_setup_commit(struct drm_atomic_state *state,
 {
 	struct drm_crtc *crtc;
 	struct drm_crtc_state *old_crtc_state, *new_crtc_state;
-	struct drm_connector *conn;
+	struct drm_connector __maybe_unused *conn;
 	struct drm_connector_state *old_conn_state, *new_conn_state;
-	struct drm_plane *plane;
+	struct drm_plane __maybe_unused *plane;
 	struct drm_plane_state *old_plane_state, *new_plane_state;
 	struct drm_crtc_commit *commit;
 	int i, ret;
@@ -2214,7 +2214,7 @@ EXPORT_SYMBOL(drm_atomic_helper_fake_vblank);
  */
 void drm_atomic_helper_commit_hw_done(struct drm_atomic_state *old_state)
 {
-	struct drm_crtc *crtc;
+	struct drm_crtc __maybe_unused *crtc;
 	struct drm_crtc_state *old_crtc_state, *new_crtc_state;
 	struct drm_crtc_commit *commit;
 	int i;
@@ -2300,7 +2300,7 @@ EXPORT_SYMBOL(drm_atomic_helper_commit_cleanup_done);
 int drm_atomic_helper_prepare_planes(struct drm_device *dev,
 				     struct drm_atomic_state *state)
 {
-	struct drm_connector *connector;
+	struct drm_connector __maybe_unused *connector;
 	struct drm_connector_state *new_conn_state;
 	struct drm_plane *plane;
 	struct drm_plane_state *new_plane_state;
@@ -2953,9 +2953,9 @@ int drm_atomic_helper_disable_all(struct drm_device *dev,
 {
 	struct drm_atomic_state *state;
 	struct drm_connector_state *conn_state;
-	struct drm_connector *conn;
+	struct drm_connector __maybe_unused *conn;
 	struct drm_plane_state *plane_state;
-	struct drm_plane *plane;
+	struct drm_plane __maybe_unused *plane;
 	struct drm_crtc_state *crtc_state;
 	struct drm_crtc *crtc;
 	int ret, i;
@@ -3199,11 +3199,11 @@ int drm_atomic_helper_commit_duplicated_state(struct drm_atomic_state *state,
 {
 	int i, ret;
 	struct drm_plane *plane;
-	struct drm_plane_state *new_plane_state;
+	struct drm_plane_state __maybe_unused *new_plane_state;
 	struct drm_connector *connector;
-	struct drm_connector_state *new_conn_state;
+	struct drm_connector_state __maybe_unused *new_conn_state;
 	struct drm_crtc *crtc;
-	struct drm_crtc_state *new_crtc_state;
+	struct drm_crtc_state __maybe_unused *new_crtc_state;
 
 	state->acquire_ctx = ctx;
 
Signature · 1 line
2.15.0
#2 lore raw

Re: [PATCH] drm: atomic helper: fix W=1 warnings

Quoted 5 lines · Benjamin Gaignard

Fix warnings with W=1.
Few for_each macro set variables that are never used later. Prevent warning by marking these variables as __maybe_unused.

A little up on this one because it may exist others ways to fix these warnings. Get feedback on this path could give the direction for similar ones in drm.

Thanks,
Benjamin

Quoted 148 lines
---
 drivers/gpu/drm/drm_atomic_helper.c | 36 ++++++++++++++++++------------------
 1 file changed, 18 insertions(+), 18 deletions(-)
drivers/gpu/drm/drm_atomic_helper.c +18 -19
index aa16ea17ff9b..b69d17b0b9bd 100644
@@ -262,7 +262,7 @@ steal_encoder(struct drm_atomic_state *state,
              struct drm_encoder *encoder)
 {
        struct drm_crtc_state *crtc_state;
-       struct drm_connector *connector;
+       struct drm_connector __maybe_unused *connector;
        struct drm_connector_state *old_connector_state, *new_connector_state;
        int i;
 
@@ -412,7 +412,7 @@ mode_fixup(struct drm_atomic_state *state)
 {
        struct drm_crtc *crtc;
        struct drm_crtc_state *new_crtc_state;
-       struct drm_connector *connector;
+       struct drm_connector __maybe_unused *connector;
        struct drm_connector_state *new_conn_state;
        int i;
        int ret;
@@ -608,7 +608,7 @@ drm_atomic_helper_check_modeset(struct drm_device *dev,
 {
        struct drm_crtc *crtc;
        struct drm_crtc_state *old_crtc_state, *new_crtc_state;
-       struct drm_connector *connector;
+       struct drm_connector __maybe_unused *connector;
        struct drm_connector_state *old_connector_state, *new_connector_state;
        int i, ret;
        unsigned connectors_mask = 0;
@@ -984,7 +984,7 @@ crtc_needs_disable(struct drm_crtc_state *old_state,
 static void
 disable_outputs(struct drm_device *dev, struct drm_atomic_state *old_state)
 {
-       struct drm_connector *connector;
+       struct drm_connector __maybe_unused *connector;
        struct drm_connector_state *old_conn_state, *new_conn_state;
        struct drm_crtc *crtc;
        struct drm_crtc_state *old_crtc_state, *new_crtc_state;
@@ -1173,7 +1173,7 @@ crtc_set_mode(struct drm_device *dev, struct drm_atomic_state *old_state)
 {
        struct drm_crtc *crtc;
        struct drm_crtc_state *new_crtc_state;
-       struct drm_connector *connector;
+       struct drm_connector __maybe_unused *connector;
        struct drm_connector_state *new_conn_state;
        int i;
 
@@ -1294,7 +1294,7 @@ void drm_atomic_helper_commit_modeset_enables(struct drm_device *dev,
        struct drm_crtc *crtc;
        struct drm_crtc_state *old_crtc_state;
        struct drm_crtc_state *new_crtc_state;
-       struct drm_connector *connector;
+       struct drm_connector __maybe_unused *connector;
        struct drm_connector_state *new_conn_state;
        int i;
 
@@ -1384,7 +1384,7 @@ int drm_atomic_helper_wait_for_fences(struct drm_device *dev,
                                      struct drm_atomic_state *state,
                                      bool pre_swap)
 {
-       struct drm_plane *plane;
+       struct drm_plane __maybe_unused *plane;
        struct drm_plane_state *new_plane_state;
        int i, ret;
 
@@ -1431,7 +1431,7 @@ drm_atomic_helper_wait_for_vblanks(struct drm_device *dev,
                struct drm_atomic_state *old_state)
 {
        struct drm_crtc *crtc;
-       struct drm_crtc_state *old_crtc_state, *new_crtc_state;
+       struct drm_crtc_state __maybe_unused *old_crtc_state, *new_crtc_state;
        int i, ret;
        unsigned crtc_mask = 0;
 
@@ -1621,7 +1621,7 @@ static void commit_work(struct work_struct *work)
 int drm_atomic_helper_async_check(struct drm_device *dev,
                                   struct drm_atomic_state *state)
 {
-       struct drm_crtc *crtc;
+       struct drm_crtc __maybe_unused *crtc;
        struct drm_crtc_state *crtc_state;
        struct drm_plane *plane = NULL;
        struct drm_plane_state *old_plane_state = NULL;
@@ -1982,9 +1982,9 @@ int drm_atomic_helper_setup_commit(struct drm_atomic_state *state,
 {
        struct drm_crtc *crtc;
        struct drm_crtc_state *old_crtc_state, *new_crtc_state;
-       struct drm_connector *conn;
+       struct drm_connector __maybe_unused *conn;
        struct drm_connector_state *old_conn_state, *new_conn_state;
-       struct drm_plane *plane;
+       struct drm_plane __maybe_unused *plane;
        struct drm_plane_state *old_plane_state, *new_plane_state;
        struct drm_crtc_commit *commit;
        int i, ret;
@@ -2214,7 +2214,7 @@ EXPORT_SYMBOL(drm_atomic_helper_fake_vblank);
  */
 void drm_atomic_helper_commit_hw_done(struct drm_atomic_state *old_state)
 {
-       struct drm_crtc *crtc;
+       struct drm_crtc __maybe_unused *crtc;
        struct drm_crtc_state *old_crtc_state, *new_crtc_state;
        struct drm_crtc_commit *commit;
        int i;
@@ -2300,7 +2300,7 @@ EXPORT_SYMBOL(drm_atomic_helper_commit_cleanup_done);
 int drm_atomic_helper_prepare_planes(struct drm_device *dev,
                                     struct drm_atomic_state *state)
 {
-       struct drm_connector *connector;
+       struct drm_connector __maybe_unused *connector;
        struct drm_connector_state *new_conn_state;
        struct drm_plane *plane;
        struct drm_plane_state *new_plane_state;
@@ -2953,9 +2953,9 @@ int drm_atomic_helper_disable_all(struct drm_device *dev,
 {
        struct drm_atomic_state *state;
        struct drm_connector_state *conn_state;
-       struct drm_connector *conn;
+       struct drm_connector __maybe_unused *conn;
        struct drm_plane_state *plane_state;
-       struct drm_plane *plane;
+       struct drm_plane __maybe_unused *plane;
        struct drm_crtc_state *crtc_state;
        struct drm_crtc *crtc;
        int ret, i;
@@ -3199,11 +3199,11 @@ int drm_atomic_helper_commit_duplicated_state(struct drm_atomic_state *state,
 {
        int i, ret;
        struct drm_plane *plane;
-       struct drm_plane_state *new_plane_state;
+       struct drm_plane_state __maybe_unused *new_plane_state;
        struct drm_connector *connector;
-       struct drm_connector_state *new_conn_state;
+       struct drm_connector_state __maybe_unused *new_conn_state;
        struct drm_crtc *crtc;
-       struct drm_crtc_state *new_crtc_state;
+       struct drm_crtc_state __maybe_unused *new_crtc_state;
 
        state->acquire_ctx = ctx;
 
--
Quoted 2 lines

2.15.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#3 lore raw

Re: [PATCH] drm: atomic helper: fix W=1 warnings

Quoted 9 lines · Benjamin Gaignard
Quoted 5 lines · Benjamin Gaignard

Fix warnings with W=1.
Few for_each macro set variables that are never used later. Prevent warning by marking these variables as __maybe_unused.

Gentle Ping

benjamin

Quoted 156 lines

A little up on this one because it may exist others ways to fix these warnings. Get feedback on this path could give the direction for similar ones in drm.

Thanks,
Benjamin

Quoted 150 lines
---
 drivers/gpu/drm/drm_atomic_helper.c | 36 ++++++++++++++++++------------------
 1 file changed, 18 insertions(+), 18 deletions(-)
drivers/gpu/drm/drm_atomic_helper.c +18 -19
index aa16ea17ff9b..b69d17b0b9bd 100644
@@ -262,7 +262,7 @@ steal_encoder(struct drm_atomic_state *state,
              struct drm_encoder *encoder)
 {
        struct drm_crtc_state *crtc_state;
-       struct drm_connector *connector;
+       struct drm_connector __maybe_unused *connector;
        struct drm_connector_state *old_connector_state, *new_connector_state;
        int i;
 
@@ -412,7 +412,7 @@ mode_fixup(struct drm_atomic_state *state)
 {
        struct drm_crtc *crtc;
        struct drm_crtc_state *new_crtc_state;
-       struct drm_connector *connector;
+       struct drm_connector __maybe_unused *connector;
        struct drm_connector_state *new_conn_state;
        int i;
        int ret;
@@ -608,7 +608,7 @@ drm_atomic_helper_check_modeset(struct drm_device *dev,
 {
        struct drm_crtc *crtc;
        struct drm_crtc_state *old_crtc_state, *new_crtc_state;
-       struct drm_connector *connector;
+       struct drm_connector __maybe_unused *connector;
        struct drm_connector_state *old_connector_state, *new_connector_state;
        int i, ret;
        unsigned connectors_mask = 0;
@@ -984,7 +984,7 @@ crtc_needs_disable(struct drm_crtc_state *old_state,
 static void
 disable_outputs(struct drm_device *dev, struct drm_atomic_state *old_state)
 {
-       struct drm_connector *connector;
+       struct drm_connector __maybe_unused *connector;
        struct drm_connector_state *old_conn_state, *new_conn_state;
        struct drm_crtc *crtc;
        struct drm_crtc_state *old_crtc_state, *new_crtc_state;
@@ -1173,7 +1173,7 @@ crtc_set_mode(struct drm_device *dev, struct drm_atomic_state *old_state)
 {
        struct drm_crtc *crtc;
        struct drm_crtc_state *new_crtc_state;
-       struct drm_connector *connector;
+       struct drm_connector __maybe_unused *connector;
        struct drm_connector_state *new_conn_state;
        int i;
 
@@ -1294,7 +1294,7 @@ void drm_atomic_helper_commit_modeset_enables(struct drm_device *dev,
        struct drm_crtc *crtc;
        struct drm_crtc_state *old_crtc_state;
        struct drm_crtc_state *new_crtc_state;
-       struct drm_connector *connector;
+       struct drm_connector __maybe_unused *connector;
        struct drm_connector_state *new_conn_state;
        int i;
 
@@ -1384,7 +1384,7 @@ int drm_atomic_helper_wait_for_fences(struct drm_device *dev,
                                      struct drm_atomic_state *state,
                                      bool pre_swap)
 {
-       struct drm_plane *plane;
+       struct drm_plane __maybe_unused *plane;
        struct drm_plane_state *new_plane_state;
        int i, ret;
 
@@ -1431,7 +1431,7 @@ drm_atomic_helper_wait_for_vblanks(struct drm_device *dev,
                struct drm_atomic_state *old_state)
 {
        struct drm_crtc *crtc;
-       struct drm_crtc_state *old_crtc_state, *new_crtc_state;
+       struct drm_crtc_state __maybe_unused *old_crtc_state, *new_crtc_state;
        int i, ret;
        unsigned crtc_mask = 0;
 
@@ -1621,7 +1621,7 @@ static void commit_work(struct work_struct *work)
 int drm_atomic_helper_async_check(struct drm_device *dev,
                                   struct drm_atomic_state *state)
 {
-       struct drm_crtc *crtc;
+       struct drm_crtc __maybe_unused *crtc;
        struct drm_crtc_state *crtc_state;
        struct drm_plane *plane = NULL;
        struct drm_plane_state *old_plane_state = NULL;
@@ -1982,9 +1982,9 @@ int drm_atomic_helper_setup_commit(struct drm_atomic_state *state,
 {
        struct drm_crtc *crtc;
        struct drm_crtc_state *old_crtc_state, *new_crtc_state;
-       struct drm_connector *conn;
+       struct drm_connector __maybe_unused *conn;
        struct drm_connector_state *old_conn_state, *new_conn_state;
-       struct drm_plane *plane;
+       struct drm_plane __maybe_unused *plane;
        struct drm_plane_state *old_plane_state, *new_plane_state;
        struct drm_crtc_commit *commit;
        int i, ret;
@@ -2214,7 +2214,7 @@ EXPORT_SYMBOL(drm_atomic_helper_fake_vblank);
  */
 void drm_atomic_helper_commit_hw_done(struct drm_atomic_state *old_state)
 {
-       struct drm_crtc *crtc;
+       struct drm_crtc __maybe_unused *crtc;
        struct drm_crtc_state *old_crtc_state, *new_crtc_state;
        struct drm_crtc_commit *commit;
        int i;
@@ -2300,7 +2300,7 @@ EXPORT_SYMBOL(drm_atomic_helper_commit_cleanup_done);
 int drm_atomic_helper_prepare_planes(struct drm_device *dev,
                                     struct drm_atomic_state *state)
 {
-       struct drm_connector *connector;
+       struct drm_connector __maybe_unused *connector;
        struct drm_connector_state *new_conn_state;
        struct drm_plane *plane;
        struct drm_plane_state *new_plane_state;
@@ -2953,9 +2953,9 @@ int drm_atomic_helper_disable_all(struct drm_device *dev,
 {
        struct drm_atomic_state *state;
        struct drm_connector_state *conn_state;
-       struct drm_connector *conn;
+       struct drm_connector __maybe_unused *conn;
        struct drm_plane_state *plane_state;
-       struct drm_plane *plane;
+       struct drm_plane __maybe_unused *plane;
        struct drm_crtc_state *crtc_state;
        struct drm_crtc *crtc;
        int ret, i;
@@ -3199,11 +3199,11 @@ int drm_atomic_helper_commit_duplicated_state(struct drm_atomic_state *state,
 {
        int i, ret;
        struct drm_plane *plane;
-       struct drm_plane_state *new_plane_state;
+       struct drm_plane_state __maybe_unused *new_plane_state;
        struct drm_connector *connector;
-       struct drm_connector_state *new_conn_state;
+       struct drm_connector_state __maybe_unused *new_conn_state;
        struct drm_crtc *crtc;
-       struct drm_crtc_state *new_crtc_state;
+       struct drm_crtc_state __maybe_unused *new_crtc_state;
 
        state->acquire_ctx = ctx;
 
--

2.15.0

#4 lore raw

Re: [PATCH] drm: atomic helper: fix W=1 warnings

In reply to Benjamin Gaignard
Quoted 14 lines · Benjamin Gaignard

Fix warnings with W=1.
Few for_each macro set variables that are never used later. Prevent warning by marking these variables as __maybe_unused.

---
 drivers/gpu/drm/drm_atomic_helper.c | 36 ++++++++++++++++++------------------
 1 file changed, 18 insertions(+), 18 deletions(-)
drivers/gpu/drm/drm_atomic_helper.c +0 -0
index aa16ea17ff9b..b69d17b0b9bd 100644

drivers/gpu/drm/drm_atomic_helper.c steal_encoder(struct drm_atomic_state *state, · line 265

Quoted 5 lines
drivers/gpu/drm/drm_atomic_helper.c +1 -1
@@ -262,7 +262,7 @@ steal_encoder(struct drm_atomic_state *state,
 	      struct drm_encoder *encoder)
 {
 	struct drm_crtc_state *crtc_state;
-	struct drm_connector *connector;
+	struct drm_connector __maybe_unused *connector;

Rather ugly. IMO would be nicer if we could hide something inside the iterator macros to suppress the warning.

Quoted 139 lines
drivers/gpu/drm/drm_atomic_helper.c +17 -17
 	struct drm_connector_state *old_connector_state, *new_connector_state;
 	int i;
 
@@ -412,7 +412,7 @@ mode_fixup(struct drm_atomic_state *state)
 {
 	struct drm_crtc *crtc;
 	struct drm_crtc_state *new_crtc_state;
-	struct drm_connector *connector;
+	struct drm_connector __maybe_unused *connector;
 	struct drm_connector_state *new_conn_state;
 	int i;
 	int ret;
@@ -608,7 +608,7 @@ drm_atomic_helper_check_modeset(struct drm_device *dev,
 {
 	struct drm_crtc *crtc;
 	struct drm_crtc_state *old_crtc_state, *new_crtc_state;
-	struct drm_connector *connector;
+	struct drm_connector __maybe_unused *connector;
 	struct drm_connector_state *old_connector_state, *new_connector_state;
 	int i, ret;
 	unsigned connectors_mask = 0;
@@ -984,7 +984,7 @@ crtc_needs_disable(struct drm_crtc_state *old_state,
 static void
 disable_outputs(struct drm_device *dev, struct drm_atomic_state *old_state)
 {
-	struct drm_connector *connector;
+	struct drm_connector __maybe_unused *connector;
 	struct drm_connector_state *old_conn_state, *new_conn_state;
 	struct drm_crtc *crtc;
 	struct drm_crtc_state *old_crtc_state, *new_crtc_state;
@@ -1173,7 +1173,7 @@ crtc_set_mode(struct drm_device *dev, struct drm_atomic_state *old_state)
 {
 	struct drm_crtc *crtc;
 	struct drm_crtc_state *new_crtc_state;
-	struct drm_connector *connector;
+	struct drm_connector __maybe_unused *connector;
 	struct drm_connector_state *new_conn_state;
 	int i;
 
@@ -1294,7 +1294,7 @@ void drm_atomic_helper_commit_modeset_enables(struct drm_device *dev,
 	struct drm_crtc *crtc;
 	struct drm_crtc_state *old_crtc_state;
 	struct drm_crtc_state *new_crtc_state;
-	struct drm_connector *connector;
+	struct drm_connector __maybe_unused *connector;
 	struct drm_connector_state *new_conn_state;
 	int i;
 
@@ -1384,7 +1384,7 @@ int drm_atomic_helper_wait_for_fences(struct drm_device *dev,
 				      struct drm_atomic_state *state,
 				      bool pre_swap)
 {
-	struct drm_plane *plane;
+	struct drm_plane __maybe_unused *plane;
 	struct drm_plane_state *new_plane_state;
 	int i, ret;
 
@@ -1431,7 +1431,7 @@ drm_atomic_helper_wait_for_vblanks(struct drm_device *dev,
 		struct drm_atomic_state *old_state)
 {
 	struct drm_crtc *crtc;
-	struct drm_crtc_state *old_crtc_state, *new_crtc_state;
+	struct drm_crtc_state __maybe_unused *old_crtc_state, *new_crtc_state;
 	int i, ret;
 	unsigned crtc_mask = 0;
 
@@ -1621,7 +1621,7 @@ static void commit_work(struct work_struct *work)
 int drm_atomic_helper_async_check(struct drm_device *dev,
 				   struct drm_atomic_state *state)
 {
-	struct drm_crtc *crtc;
+	struct drm_crtc __maybe_unused *crtc;
 	struct drm_crtc_state *crtc_state;
 	struct drm_plane *plane = NULL;
 	struct drm_plane_state *old_plane_state = NULL;
@@ -1982,9 +1982,9 @@ int drm_atomic_helper_setup_commit(struct drm_atomic_state *state,
 {
 	struct drm_crtc *crtc;
 	struct drm_crtc_state *old_crtc_state, *new_crtc_state;
-	struct drm_connector *conn;
+	struct drm_connector __maybe_unused *conn;
 	struct drm_connector_state *old_conn_state, *new_conn_state;
-	struct drm_plane *plane;
+	struct drm_plane __maybe_unused *plane;
 	struct drm_plane_state *old_plane_state, *new_plane_state;
 	struct drm_crtc_commit *commit;
 	int i, ret;
@@ -2214,7 +2214,7 @@ EXPORT_SYMBOL(drm_atomic_helper_fake_vblank);
  */
 void drm_atomic_helper_commit_hw_done(struct drm_atomic_state *old_state)
 {
-	struct drm_crtc *crtc;
+	struct drm_crtc __maybe_unused *crtc;
 	struct drm_crtc_state *old_crtc_state, *new_crtc_state;
 	struct drm_crtc_commit *commit;
 	int i;
@@ -2300,7 +2300,7 @@ EXPORT_SYMBOL(drm_atomic_helper_commit_cleanup_done);
 int drm_atomic_helper_prepare_planes(struct drm_device *dev,
 				     struct drm_atomic_state *state)
 {
-	struct drm_connector *connector;
+	struct drm_connector __maybe_unused *connector;
 	struct drm_connector_state *new_conn_state;
 	struct drm_plane *plane;
 	struct drm_plane_state *new_plane_state;
@@ -2953,9 +2953,9 @@ int drm_atomic_helper_disable_all(struct drm_device *dev,
 {
 	struct drm_atomic_state *state;
 	struct drm_connector_state *conn_state;
-	struct drm_connector *conn;
+	struct drm_connector __maybe_unused *conn;
 	struct drm_plane_state *plane_state;
-	struct drm_plane *plane;
+	struct drm_plane __maybe_unused *plane;
 	struct drm_crtc_state *crtc_state;
 	struct drm_crtc *crtc;
 	int ret, i;
@@ -3199,11 +3199,11 @@ int drm_atomic_helper_commit_duplicated_state(struct drm_atomic_state *state,
 {
 	int i, ret;
 	struct drm_plane *plane;
-	struct drm_plane_state *new_plane_state;
+	struct drm_plane_state __maybe_unused *new_plane_state;
 	struct drm_connector *connector;
-	struct drm_connector_state *new_conn_state;
+	struct drm_connector_state __maybe_unused *new_conn_state;
 	struct drm_crtc *crtc;
-	struct drm_crtc_state *new_crtc_state;
+	struct drm_crtc_state __maybe_unused *new_crtc_state;
 
 	state->acquire_ctx = ctx;
 
Signature · 6 lines
2.15.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 2 lines
Ville Syrjälä
Intel
#5 lore raw

Re: [PATCH] drm: atomic helper: fix W=1 warnings

Quoted 11 lines · Ville Syrjälä
Quoted 9 lines · Benjamin Gaignard

Fix warnings with W=1.
Few for_each macro set variables that are never used later. Prevent warning by marking these variables as __maybe_unused.

---
 drivers/gpu/drm/drm_atomic_helper.c | 36 ++++++++++++++++++------------------
 1 file changed, 18 insertions(+), 18 deletions(-)
Quoted 13 lines

drivers/gpu/drm/drm_atomic_helper.c steal_encoder(struct drm_atomic_state *state, · line 265

Quoted 10 lines
drivers/gpu/drm/drm_atomic_helper.c +1 -1
index aa16ea17ff9b..b69d17b0b9bd 100644
@@ -262,7 +262,7 @@ steal_encoder(struct drm_atomic_state *state,
            struct drm_encoder *encoder)
 {
      struct drm_crtc_state *crtc_state;
-     struct drm_connector *connector;
+     struct drm_connector __maybe_unused *connector;

Rather ugly. IMO would be nicer if we could hide something inside the iterator macros to suppress the warning.

Ok but how ?
connector is assigned in the macros but not used later and we can't set "__maybe_unused"
in the macro.
Does another keyword exist for that ?

Quoted 144 lines
Quoted 136 lines
drivers/gpu/drm/drm_atomic_helper.c +17 -18
      struct drm_connector_state *old_connector_state, *new_connector_state;
      int i;
 
@@ -412,7 +412,7 @@ mode_fixup(struct drm_atomic_state *state)
 {
      struct drm_crtc *crtc;
      struct drm_crtc_state *new_crtc_state;
-     struct drm_connector *connector;
+     struct drm_connector __maybe_unused *connector;
      struct drm_connector_state *new_conn_state;
      int i;
      int ret;
@@ -608,7 +608,7 @@ drm_atomic_helper_check_modeset(struct drm_device *dev,
 {
      struct drm_crtc *crtc;
      struct drm_crtc_state *old_crtc_state, *new_crtc_state;
-     struct drm_connector *connector;
+     struct drm_connector __maybe_unused *connector;
      struct drm_connector_state *old_connector_state, *new_connector_state;
      int i, ret;
      unsigned connectors_mask = 0;
@@ -984,7 +984,7 @@ crtc_needs_disable(struct drm_crtc_state *old_state,
 static void
 disable_outputs(struct drm_device *dev, struct drm_atomic_state *old_state)
 {
-     struct drm_connector *connector;
+     struct drm_connector __maybe_unused *connector;
      struct drm_connector_state *old_conn_state, *new_conn_state;
      struct drm_crtc *crtc;
      struct drm_crtc_state *old_crtc_state, *new_crtc_state;
@@ -1173,7 +1173,7 @@ crtc_set_mode(struct drm_device *dev, struct drm_atomic_state *old_state)
 {
      struct drm_crtc *crtc;
      struct drm_crtc_state *new_crtc_state;
-     struct drm_connector *connector;
+     struct drm_connector __maybe_unused *connector;
      struct drm_connector_state *new_conn_state;
      int i;
 
@@ -1294,7 +1294,7 @@ void drm_atomic_helper_commit_modeset_enables(struct drm_device *dev,
      struct drm_crtc *crtc;
      struct drm_crtc_state *old_crtc_state;
      struct drm_crtc_state *new_crtc_state;
-     struct drm_connector *connector;
+     struct drm_connector __maybe_unused *connector;
      struct drm_connector_state *new_conn_state;
      int i;
 
@@ -1384,7 +1384,7 @@ int drm_atomic_helper_wait_for_fences(struct drm_device *dev,
                                    struct drm_atomic_state *state,
                                    bool pre_swap)
 {
-     struct drm_plane *plane;
+     struct drm_plane __maybe_unused *plane;
      struct drm_plane_state *new_plane_state;
      int i, ret;
 
@@ -1431,7 +1431,7 @@ drm_atomic_helper_wait_for_vblanks(struct drm_device *dev,
              struct drm_atomic_state *old_state)
 {
      struct drm_crtc *crtc;
-     struct drm_crtc_state *old_crtc_state, *new_crtc_state;
+     struct drm_crtc_state __maybe_unused *old_crtc_state, *new_crtc_state;
      int i, ret;
      unsigned crtc_mask = 0;
 
@@ -1621,7 +1621,7 @@ static void commit_work(struct work_struct *work)
 int drm_atomic_helper_async_check(struct drm_device *dev,
                                 struct drm_atomic_state *state)
 {
-     struct drm_crtc *crtc;
+     struct drm_crtc __maybe_unused *crtc;
      struct drm_crtc_state *crtc_state;
      struct drm_plane *plane = NULL;
      struct drm_plane_state *old_plane_state = NULL;
@@ -1982,9 +1982,9 @@ int drm_atomic_helper_setup_commit(struct drm_atomic_state *state,
 {
      struct drm_crtc *crtc;
      struct drm_crtc_state *old_crtc_state, *new_crtc_state;
-     struct drm_connector *conn;
+     struct drm_connector __maybe_unused *conn;
      struct drm_connector_state *old_conn_state, *new_conn_state;
-     struct drm_plane *plane;
+     struct drm_plane __maybe_unused *plane;
      struct drm_plane_state *old_plane_state, *new_plane_state;
      struct drm_crtc_commit *commit;
      int i, ret;
@@ -2214,7 +2214,7 @@ EXPORT_SYMBOL(drm_atomic_helper_fake_vblank);
  */
 void drm_atomic_helper_commit_hw_done(struct drm_atomic_state *old_state)
 {
-     struct drm_crtc *crtc;
+     struct drm_crtc __maybe_unused *crtc;
      struct drm_crtc_state *old_crtc_state, *new_crtc_state;
      struct drm_crtc_commit *commit;
      int i;
@@ -2300,7 +2300,7 @@ EXPORT_SYMBOL(drm_atomic_helper_commit_cleanup_done);
 int drm_atomic_helper_prepare_planes(struct drm_device *dev,
                                   struct drm_atomic_state *state)
 {
-     struct drm_connector *connector;
+     struct drm_connector __maybe_unused *connector;
      struct drm_connector_state *new_conn_state;
      struct drm_plane *plane;
      struct drm_plane_state *new_plane_state;
@@ -2953,9 +2953,9 @@ int drm_atomic_helper_disable_all(struct drm_device *dev,
 {
      struct drm_atomic_state *state;
      struct drm_connector_state *conn_state;
-     struct drm_connector *conn;
+     struct drm_connector __maybe_unused *conn;
      struct drm_plane_state *plane_state;
-     struct drm_plane *plane;
+     struct drm_plane __maybe_unused *plane;
      struct drm_crtc_state *crtc_state;
      struct drm_crtc *crtc;
      int ret, i;
@@ -3199,11 +3199,11 @@ int drm_atomic_helper_commit_duplicated_state(struct drm_atomic_state *state,
 {
      int i, ret;
      struct drm_plane *plane;
-     struct drm_plane_state *new_plane_state;
+     struct drm_plane_state __maybe_unused *new_plane_state;
      struct drm_connector *connector;
-     struct drm_connector_state *new_conn_state;
+     struct drm_connector_state __maybe_unused *new_conn_state;
      struct drm_crtc *crtc;
-     struct drm_crtc_state *new_crtc_state;
+     struct drm_crtc_state __maybe_unused *new_crtc_state;
 
      state->acquire_ctx = ctx;
 
--

2.15.0

Quoted 4 lines

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

--
Ville Syrjälä
Intel

#6 lore raw

Re: [PATCH] drm: atomic helper: fix W=1 warnings

Quoted 27 lines · Benjamin Gaignard
Quoted 11 lines · Ville Syrjälä
Quoted 9 lines · Benjamin Gaignard

Fix warnings with W=1.
Few for_each macro set variables that are never used later. Prevent warning by marking these variables as __maybe_unused.

---
 drivers/gpu/drm/drm_atomic_helper.c | 36 ++++++++++++++++++------------------
 1 file changed, 18 insertions(+), 18 deletions(-)
Quoted 13 lines

drivers/gpu/drm/drm_atomic_helper.c steal_encoder(struct drm_atomic_state *state, · line 265

Quoted 10 lines
drivers/gpu/drm/drm_atomic_helper.c +1 -1
index aa16ea17ff9b..b69d17b0b9bd 100644
@@ -262,7 +262,7 @@ steal_encoder(struct drm_atomic_state *state,
            struct drm_encoder *encoder)
 {
      struct drm_crtc_state *crtc_state;
-     struct drm_connector *connector;
+     struct drm_connector __maybe_unused *connector;

Rather ugly. IMO would be nicer if we could hide something inside the iterator macros to suppress the warning.

Quoted 5 lines

Ok but how ?
connector is assigned in the macros but not used later and we can't set "__maybe_unused"
in the macro.
Does another keyword exist for that ?

Stick a (void)(connector) into the macro?

Another (arguably cleaner) idea would be to remove the connector/crtc/plane argument from the iterators entirely since it's redundant, and instead just extract it from the appropriate new/old state as needed.

We could then also add a for_each_connector_in_state()/etc. which omit s the state arguments and just has the connector argument, for cases where you don't care about the states when iterating.

Quoted 145 lines
Quoted 145 lines
Quoted 137 lines
drivers/gpu/drm/drm_atomic_helper.c +17 -18
      struct drm_connector_state *old_connector_state, *new_connector_state;
      int i;
 
@@ -412,7 +412,7 @@ mode_fixup(struct drm_atomic_state *state)
 {
      struct drm_crtc *crtc;
      struct drm_crtc_state *new_crtc_state;
-     struct drm_connector *connector;
+     struct drm_connector __maybe_unused *connector;
      struct drm_connector_state *new_conn_state;
      int i;
      int ret;
@@ -608,7 +608,7 @@ drm_atomic_helper_check_modeset(struct drm_device *dev,
 {
      struct drm_crtc *crtc;
      struct drm_crtc_state *old_crtc_state, *new_crtc_state;
-     struct drm_connector *connector;
+     struct drm_connector __maybe_unused *connector;
      struct drm_connector_state *old_connector_state, *new_connector_state;
      int i, ret;
      unsigned connectors_mask = 0;
@@ -984,7 +984,7 @@ crtc_needs_disable(struct drm_crtc_state *old_state,
 static void
 disable_outputs(struct drm_device *dev, struct drm_atomic_state *old_state)
 {
-     struct drm_connector *connector;
+     struct drm_connector __maybe_unused *connector;
      struct drm_connector_state *old_conn_state, *new_conn_state;
      struct drm_crtc *crtc;
      struct drm_crtc_state *old_crtc_state, *new_crtc_state;
@@ -1173,7 +1173,7 @@ crtc_set_mode(struct drm_device *dev, struct drm_atomic_state *old_state)
 {
      struct drm_crtc *crtc;
      struct drm_crtc_state *new_crtc_state;
-     struct drm_connector *connector;
+     struct drm_connector __maybe_unused *connector;
      struct drm_connector_state *new_conn_state;
      int i;
 
@@ -1294,7 +1294,7 @@ void drm_atomic_helper_commit_modeset_enables(struct drm_device *dev,
      struct drm_crtc *crtc;
      struct drm_crtc_state *old_crtc_state;
      struct drm_crtc_state *new_crtc_state;
-     struct drm_connector *connector;
+     struct drm_connector __maybe_unused *connector;
      struct drm_connector_state *new_conn_state;
      int i;
 
@@ -1384,7 +1384,7 @@ int drm_atomic_helper_wait_for_fences(struct drm_device *dev,
                                    struct drm_atomic_state *state,
                                    bool pre_swap)
 {
-     struct drm_plane *plane;
+     struct drm_plane __maybe_unused *plane;
      struct drm_plane_state *new_plane_state;
      int i, ret;
 
@@ -1431,7 +1431,7 @@ drm_atomic_helper_wait_for_vblanks(struct drm_device *dev,
              struct drm_atomic_state *old_state)
 {
      struct drm_crtc *crtc;
-     struct drm_crtc_state *old_crtc_state, *new_crtc_state;
+     struct drm_crtc_state __maybe_unused *old_crtc_state, *new_crtc_state;
      int i, ret;
      unsigned crtc_mask = 0;
 
@@ -1621,7 +1621,7 @@ static void commit_work(struct work_struct *work)
 int drm_atomic_helper_async_check(struct drm_device *dev,
                                 struct drm_atomic_state *state)
 {
-     struct drm_crtc *crtc;
+     struct drm_crtc __maybe_unused *crtc;
      struct drm_crtc_state *crtc_state;
      struct drm_plane *plane = NULL;
      struct drm_plane_state *old_plane_state = NULL;
@@ -1982,9 +1982,9 @@ int drm_atomic_helper_setup_commit(struct drm_atomic_state *state,
 {
      struct drm_crtc *crtc;
      struct drm_crtc_state *old_crtc_state, *new_crtc_state;
-     struct drm_connector *conn;
+     struct drm_connector __maybe_unused *conn;
      struct drm_connector_state *old_conn_state, *new_conn_state;
-     struct drm_plane *plane;
+     struct drm_plane __maybe_unused *plane;
      struct drm_plane_state *old_plane_state, *new_plane_state;
      struct drm_crtc_commit *commit;
      int i, ret;
@@ -2214,7 +2214,7 @@ EXPORT_SYMBOL(drm_atomic_helper_fake_vblank);
  */
 void drm_atomic_helper_commit_hw_done(struct drm_atomic_state *old_state)
 {
-     struct drm_crtc *crtc;
+     struct drm_crtc __maybe_unused *crtc;
      struct drm_crtc_state *old_crtc_state, *new_crtc_state;
      struct drm_crtc_commit *commit;
      int i;
@@ -2300,7 +2300,7 @@ EXPORT_SYMBOL(drm_atomic_helper_commit_cleanup_done);
 int drm_atomic_helper_prepare_planes(struct drm_device *dev,
                                   struct drm_atomic_state *state)
 {
-     struct drm_connector *connector;
+     struct drm_connector __maybe_unused *connector;
      struct drm_connector_state *new_conn_state;
      struct drm_plane *plane;
      struct drm_plane_state *new_plane_state;
@@ -2953,9 +2953,9 @@ int drm_atomic_helper_disable_all(struct drm_device *dev,
 {
      struct drm_atomic_state *state;
      struct drm_connector_state *conn_state;
-     struct drm_connector *conn;
+     struct drm_connector __maybe_unused *conn;
      struct drm_plane_state *plane_state;
-     struct drm_plane *plane;
+     struct drm_plane __maybe_unused *plane;
      struct drm_crtc_state *crtc_state;
      struct drm_crtc *crtc;
      int ret, i;
@@ -3199,11 +3199,11 @@ int drm_atomic_helper_commit_duplicated_state(struct drm_atomic_state *state,
 {
      int i, ret;
      struct drm_plane *plane;
-     struct drm_plane_state *new_plane_state;
+     struct drm_plane_state __maybe_unused *new_plane_state;
      struct drm_connector *connector;
-     struct drm_connector_state *new_conn_state;
+     struct drm_connector_state __maybe_unused *new_conn_state;
      struct drm_crtc *crtc;
-     struct drm_crtc_state *new_crtc_state;
+     struct drm_crtc_state __maybe_unused *new_crtc_state;
 
      state->acquire_ctx = ctx;
 
--

2.15.0

Quoted 4 lines

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

--
Ville Syrjälä
Intel

Signature · 2 lines
Ville Syrjälä
Intel
#7 lore raw

Re: [PATCH] drm: atomic helper: fix W=1 warnings

Quoted 29 lines · Ville Syrjälä
Quoted 27 lines · Benjamin Gaignard
Quoted 24 lines · Ville Syrjälä
Quoted 14 lines · Benjamin Gaignard

Fix warnings with W=1.
Few for_each macro set variables that are never used later. Prevent warning by marking these variables as __maybe_unused.

---
 drivers/gpu/drm/drm_atomic_helper.c | 36 ++++++++++++++++++------------------
 1 file changed, 18 insertions(+), 18 deletions(-)
drivers/gpu/drm/drm_atomic_helper.c +0 -0
index aa16ea17ff9b..b69d17b0b9bd 100644

drivers/gpu/drm/drm_atomic_helper.c steal_encoder(struct drm_atomic_state *state, · line 265

Quoted 5 lines
drivers/gpu/drm/drm_atomic_helper.c +1 -1
@@ -262,7 +262,7 @@ steal_encoder(struct drm_atomic_state *state,
            struct drm_encoder *encoder)
 {
      struct drm_crtc_state *crtc_state;
-     struct drm_connector *connector;
+     struct drm_connector __maybe_unused *connector;

Rather ugly. IMO would be nicer if we could hide something inside the iterator macros to suppress the warning.

Quoted 7 lines
Quoted 5 lines

Ok but how ?
connector is assigned in the macros but not used later and we can't set "__maybe_unused"
in the macro.
Does another keyword exist for that ?

Stick a (void)(connector) into the macro?

That could work but it will look strange inside the macro.

Quoted 8 lines

Another (arguably cleaner) idea would be to remove the connector/crtc/plane argument from the iterators entirely since it's redundant, and instead just extract it from the appropriate new/old state as needed.

We could then also add a for_each_connector_in_state()/etc. which omit s the state arguments and just has the connector argument, for cases where you don't care about the states when iterating.

That may lead to get a macro for each possible combination of used variables.

Quoted 147 lines
Quoted 138 lines
Quoted 138 lines
Quoted 138 lines
drivers/gpu/drm/drm_atomic_helper.c +17 -18
      struct drm_connector_state *old_connector_state, *new_connector_state;
      int i;
 
@@ -412,7 +412,7 @@ mode_fixup(struct drm_atomic_state *state)
 {
      struct drm_crtc *crtc;
      struct drm_crtc_state *new_crtc_state;
-     struct drm_connector *connector;
+     struct drm_connector __maybe_unused *connector;
      struct drm_connector_state *new_conn_state;
      int i;
      int ret;
@@ -608,7 +608,7 @@ drm_atomic_helper_check_modeset(struct drm_device *dev,
 {
      struct drm_crtc *crtc;
      struct drm_crtc_state *old_crtc_state, *new_crtc_state;
-     struct drm_connector *connector;
+     struct drm_connector __maybe_unused *connector;
      struct drm_connector_state *old_connector_state, *new_connector_state;
      int i, ret;
      unsigned connectors_mask = 0;
@@ -984,7 +984,7 @@ crtc_needs_disable(struct drm_crtc_state *old_state,
 static void
 disable_outputs(struct drm_device *dev, struct drm_atomic_state *old_state)
 {
-     struct drm_connector *connector;
+     struct drm_connector __maybe_unused *connector;
      struct drm_connector_state *old_conn_state, *new_conn_state;
      struct drm_crtc *crtc;
      struct drm_crtc_state *old_crtc_state, *new_crtc_state;
@@ -1173,7 +1173,7 @@ crtc_set_mode(struct drm_device *dev, struct drm_atomic_state *old_state)
 {
      struct drm_crtc *crtc;
      struct drm_crtc_state *new_crtc_state;
-     struct drm_connector *connector;
+     struct drm_connector __maybe_unused *connector;
      struct drm_connector_state *new_conn_state;
      int i;
 
@@ -1294,7 +1294,7 @@ void drm_atomic_helper_commit_modeset_enables(struct drm_device *dev,
      struct drm_crtc *crtc;
      struct drm_crtc_state *old_crtc_state;
      struct drm_crtc_state *new_crtc_state;
-     struct drm_connector *connector;
+     struct drm_connector __maybe_unused *connector;
      struct drm_connector_state *new_conn_state;
      int i;
 
@@ -1384,7 +1384,7 @@ int drm_atomic_helper_wait_for_fences(struct drm_device *dev,
                                    struct drm_atomic_state *state,
                                    bool pre_swap)
 {
-     struct drm_plane *plane;
+     struct drm_plane __maybe_unused *plane;
      struct drm_plane_state *new_plane_state;
      int i, ret;
 
@@ -1431,7 +1431,7 @@ drm_atomic_helper_wait_for_vblanks(struct drm_device *dev,
              struct drm_atomic_state *old_state)
 {
      struct drm_crtc *crtc;
-     struct drm_crtc_state *old_crtc_state, *new_crtc_state;
+     struct drm_crtc_state __maybe_unused *old_crtc_state, *new_crtc_state;
      int i, ret;
      unsigned crtc_mask = 0;
 
@@ -1621,7 +1621,7 @@ static void commit_work(struct work_struct *work)
 int drm_atomic_helper_async_check(struct drm_device *dev,
                                 struct drm_atomic_state *state)
 {
-     struct drm_crtc *crtc;
+     struct drm_crtc __maybe_unused *crtc;
      struct drm_crtc_state *crtc_state;
      struct drm_plane *plane = NULL;
      struct drm_plane_state *old_plane_state = NULL;
@@ -1982,9 +1982,9 @@ int drm_atomic_helper_setup_commit(struct drm_atomic_state *state,
 {
      struct drm_crtc *crtc;
      struct drm_crtc_state *old_crtc_state, *new_crtc_state;
-     struct drm_connector *conn;
+     struct drm_connector __maybe_unused *conn;
      struct drm_connector_state *old_conn_state, *new_conn_state;
-     struct drm_plane *plane;
+     struct drm_plane __maybe_unused *plane;
      struct drm_plane_state *old_plane_state, *new_plane_state;
      struct drm_crtc_commit *commit;
      int i, ret;
@@ -2214,7 +2214,7 @@ EXPORT_SYMBOL(drm_atomic_helper_fake_vblank);
  */
 void drm_atomic_helper_commit_hw_done(struct drm_atomic_state *old_state)
 {
-     struct drm_crtc *crtc;
+     struct drm_crtc __maybe_unused *crtc;
      struct drm_crtc_state *old_crtc_state, *new_crtc_state;
      struct drm_crtc_commit *commit;
      int i;
@@ -2300,7 +2300,7 @@ EXPORT_SYMBOL(drm_atomic_helper_commit_cleanup_done);
 int drm_atomic_helper_prepare_planes(struct drm_device *dev,
                                   struct drm_atomic_state *state)
 {
-     struct drm_connector *connector;
+     struct drm_connector __maybe_unused *connector;
      struct drm_connector_state *new_conn_state;
      struct drm_plane *plane;
      struct drm_plane_state *new_plane_state;
@@ -2953,9 +2953,9 @@ int drm_atomic_helper_disable_all(struct drm_device *dev,
 {
      struct drm_atomic_state *state;
      struct drm_connector_state *conn_state;
-     struct drm_connector *conn;
+     struct drm_connector __maybe_unused *conn;
      struct drm_plane_state *plane_state;
-     struct drm_plane *plane;
+     struct drm_plane __maybe_unused *plane;
      struct drm_crtc_state *crtc_state;
      struct drm_crtc *crtc;
      int ret, i;
@@ -3199,11 +3199,11 @@ int drm_atomic_helper_commit_duplicated_state(struct drm_atomic_state *state,
 {
      int i, ret;
      struct drm_plane *plane;
-     struct drm_plane_state *new_plane_state;
+     struct drm_plane_state __maybe_unused *new_plane_state;
      struct drm_connector *connector;
-     struct drm_connector_state *new_conn_state;
+     struct drm_connector_state __maybe_unused *new_conn_state;
      struct drm_crtc *crtc;
-     struct drm_crtc_state *new_crtc_state;
+     struct drm_crtc_state __maybe_unused *new_crtc_state;
 
      state->acquire_ctx = ctx;
 
--

2.15.0

Quoted 8 lines
Quoted 8 lines
Quoted 4 lines

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

--
Ville Syrjälä
Intel

Quoted 3 lines

--
Ville Syrjälä
Intel

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#8 lore raw

Re: [PATCH] drm: atomic helper: fix W=1 warnings

Quoted 46 lines · Benjamin Gaignard
Quoted 29 lines · Ville Syrjälä
Quoted 27 lines · Benjamin Gaignard
Quoted 24 lines · Ville Syrjälä
Quoted 14 lines · Benjamin Gaignard

Fix warnings with W=1.
Few for_each macro set variables that are never used later. Prevent warning by marking these variables as __maybe_unused.

---
 drivers/gpu/drm/drm_atomic_helper.c | 36 ++++++++++++++++++------------------
 1 file changed, 18 insertions(+), 18 deletions(-)
drivers/gpu/drm/drm_atomic_helper.c +0 -0
index aa16ea17ff9b..b69d17b0b9bd 100644

drivers/gpu/drm/drm_atomic_helper.c steal_encoder(struct drm_atomic_state *state, · line 265

Quoted 5 lines
drivers/gpu/drm/drm_atomic_helper.c +1 -1
@@ -262,7 +262,7 @@ steal_encoder(struct drm_atomic_state *state,
            struct drm_encoder *encoder)
 {
      struct drm_crtc_state *crtc_state;
-     struct drm_connector *connector;
+     struct drm_connector __maybe_unused *connector;

Rather ugly. IMO would be nicer if we could hide something inside the iterator macros to suppress the warning.

Quoted 7 lines
Quoted 5 lines

Ok but how ?
connector is assigned in the macros but not used later and we can't set "__maybe_unused"
in the macro.
Does another keyword exist for that ?

Stick a (void)(connector) into the macro?

That could work but it will look strange inside the macro.

Quoted 5 lines

Another (arguably cleaner) idea would be to remove the connector/crtc/plane argument from the iterators entirely since it's redundant, and instead just extract it from the appropriate new/old state as needed.

Quoted 5 lines
Quoted 3 lines

We could then also add a for_each_connector_in_state()/etc. which omit s the state arguments and just has the connector argument, for cases where you don't care about the states when iterating.

That may lead to get a macro for each possible combination of used variables.

We already have new/old/oldnew, so would "just" add one more.

Quoted 151 lines
Quoted 151 lines
Quoted 139 lines
Quoted 139 lines
Quoted 139 lines
drivers/gpu/drm/drm_atomic_helper.c +17 -18
      struct drm_connector_state *old_connector_state, *new_connector_state;
      int i;
 
@@ -412,7 +412,7 @@ mode_fixup(struct drm_atomic_state *state)
 {
      struct drm_crtc *crtc;
      struct drm_crtc_state *new_crtc_state;
-     struct drm_connector *connector;
+     struct drm_connector __maybe_unused *connector;
      struct drm_connector_state *new_conn_state;
      int i;
      int ret;
@@ -608,7 +608,7 @@ drm_atomic_helper_check_modeset(struct drm_device *dev,
 {
      struct drm_crtc *crtc;
      struct drm_crtc_state *old_crtc_state, *new_crtc_state;
-     struct drm_connector *connector;
+     struct drm_connector __maybe_unused *connector;
      struct drm_connector_state *old_connector_state, *new_connector_state;
      int i, ret;
      unsigned connectors_mask = 0;
@@ -984,7 +984,7 @@ crtc_needs_disable(struct drm_crtc_state *old_state,
 static void
 disable_outputs(struct drm_device *dev, struct drm_atomic_state *old_state)
 {
-     struct drm_connector *connector;
+     struct drm_connector __maybe_unused *connector;
      struct drm_connector_state *old_conn_state, *new_conn_state;
      struct drm_crtc *crtc;
      struct drm_crtc_state *old_crtc_state, *new_crtc_state;
@@ -1173,7 +1173,7 @@ crtc_set_mode(struct drm_device *dev, struct drm_atomic_state *old_state)
 {
      struct drm_crtc *crtc;
      struct drm_crtc_state *new_crtc_state;
-     struct drm_connector *connector;
+     struct drm_connector __maybe_unused *connector;
      struct drm_connector_state *new_conn_state;
      int i;
 
@@ -1294,7 +1294,7 @@ void drm_atomic_helper_commit_modeset_enables(struct drm_device *dev,
      struct drm_crtc *crtc;
      struct drm_crtc_state *old_crtc_state;
      struct drm_crtc_state *new_crtc_state;
-     struct drm_connector *connector;
+     struct drm_connector __maybe_unused *connector;
      struct drm_connector_state *new_conn_state;
      int i;
 
@@ -1384,7 +1384,7 @@ int drm_atomic_helper_wait_for_fences(struct drm_device *dev,
                                    struct drm_atomic_state *state,
                                    bool pre_swap)
 {
-     struct drm_plane *plane;
+     struct drm_plane __maybe_unused *plane;
      struct drm_plane_state *new_plane_state;
      int i, ret;
 
@@ -1431,7 +1431,7 @@ drm_atomic_helper_wait_for_vblanks(struct drm_device *dev,
              struct drm_atomic_state *old_state)
 {
      struct drm_crtc *crtc;
-     struct drm_crtc_state *old_crtc_state, *new_crtc_state;
+     struct drm_crtc_state __maybe_unused *old_crtc_state, *new_crtc_state;
      int i, ret;
      unsigned crtc_mask = 0;
 
@@ -1621,7 +1621,7 @@ static void commit_work(struct work_struct *work)
 int drm_atomic_helper_async_check(struct drm_device *dev,
                                 struct drm_atomic_state *state)
 {
-     struct drm_crtc *crtc;
+     struct drm_crtc __maybe_unused *crtc;
      struct drm_crtc_state *crtc_state;
      struct drm_plane *plane = NULL;
      struct drm_plane_state *old_plane_state = NULL;
@@ -1982,9 +1982,9 @@ int drm_atomic_helper_setup_commit(struct drm_atomic_state *state,
 {
      struct drm_crtc *crtc;
      struct drm_crtc_state *old_crtc_state, *new_crtc_state;
-     struct drm_connector *conn;
+     struct drm_connector __maybe_unused *conn;
      struct drm_connector_state *old_conn_state, *new_conn_state;
-     struct drm_plane *plane;
+     struct drm_plane __maybe_unused *plane;
      struct drm_plane_state *old_plane_state, *new_plane_state;
      struct drm_crtc_commit *commit;
      int i, ret;
@@ -2214,7 +2214,7 @@ EXPORT_SYMBOL(drm_atomic_helper_fake_vblank);
  */
 void drm_atomic_helper_commit_hw_done(struct drm_atomic_state *old_state)
 {
-     struct drm_crtc *crtc;
+     struct drm_crtc __maybe_unused *crtc;
      struct drm_crtc_state *old_crtc_state, *new_crtc_state;
      struct drm_crtc_commit *commit;
      int i;
@@ -2300,7 +2300,7 @@ EXPORT_SYMBOL(drm_atomic_helper_commit_cleanup_done);
 int drm_atomic_helper_prepare_planes(struct drm_device *dev,
                                   struct drm_atomic_state *state)
 {
-     struct drm_connector *connector;
+     struct drm_connector __maybe_unused *connector;
      struct drm_connector_state *new_conn_state;
      struct drm_plane *plane;
      struct drm_plane_state *new_plane_state;
@@ -2953,9 +2953,9 @@ int drm_atomic_helper_disable_all(struct drm_device *dev,
 {
      struct drm_atomic_state *state;
      struct drm_connector_state *conn_state;
-     struct drm_connector *conn;
+     struct drm_connector __maybe_unused *conn;
      struct drm_plane_state *plane_state;
-     struct drm_plane *plane;
+     struct drm_plane __maybe_unused *plane;
      struct drm_crtc_state *crtc_state;
      struct drm_crtc *crtc;
      int ret, i;
@@ -3199,11 +3199,11 @@ int drm_atomic_helper_commit_duplicated_state(struct drm_atomic_state *state,
 {
      int i, ret;
      struct drm_plane *plane;
-     struct drm_plane_state *new_plane_state;
+     struct drm_plane_state __maybe_unused *new_plane_state;
      struct drm_connector *connector;
-     struct drm_connector_state *new_conn_state;
+     struct drm_connector_state __maybe_unused *new_conn_state;
      struct drm_crtc *crtc;
-     struct drm_crtc_state *new_crtc_state;
+     struct drm_crtc_state __maybe_unused *new_crtc_state;
 
      state->acquire_ctx = ctx;
 
--

2.15.0

Quoted 8 lines
Quoted 8 lines
Quoted 4 lines

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

--
Ville Syrjälä
Intel

--
Ville Syrjälä
Intel

Signature · 6 lines
Ville Syrjälä
Intel
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#9 lore raw

Re: [PATCH] drm: atomic helper: fix W=1 warnings

Quoted 48 lines · Ville Syrjälä
Quoted 46 lines · Benjamin Gaignard
Quoted 29 lines · Ville Syrjälä
Quoted 27 lines · Benjamin Gaignard
Quoted 24 lines · Ville Syrjälä
Quoted 14 lines · Benjamin Gaignard

Fix warnings with W=1.
Few for_each macro set variables that are never used later. Prevent warning by marking these variables as __maybe_unused.

---
 drivers/gpu/drm/drm_atomic_helper.c | 36 ++++++++++++++++++------------------
 1 file changed, 18 insertions(+), 18 deletions(-)
drivers/gpu/drm/drm_atomic_helper.c +0 -0
index aa16ea17ff9b..b69d17b0b9bd 100644

drivers/gpu/drm/drm_atomic_helper.c steal_encoder(struct drm_atomic_state *state, · line 265

Quoted 5 lines
drivers/gpu/drm/drm_atomic_helper.c +1 -1
@@ -262,7 +262,7 @@ steal_encoder(struct drm_atomic_state *state,
            struct drm_encoder *encoder)
 {
      struct drm_crtc_state *crtc_state;
-     struct drm_connector *connector;
+     struct drm_connector __maybe_unused *connector;

Rather ugly. IMO would be nicer if we could hide something inside the iterator macros to suppress the warning.

Quoted 7 lines
Quoted 5 lines

Ok but how ?
connector is assigned in the macros but not used later and we can't set "__maybe_unused"
in the macro.
Does another keyword exist for that ?

Stick a (void)(connector) into the macro?

That could work but it will look strange inside the macro.

Quoted 5 lines

Another (arguably cleaner) idea would be to remove the connector/crtc/plane argument from the iterators entirely since it's redundant, and instead just extract it from the appropriate new/old state as needed.

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

We could then also add a for_each_connector_in_state()/etc. which omit s the state arguments and just has the connector argument, for cases where you don't care about the states when iterating.

That may lead to get a macro for each possible combination of used variables.

We already have new/old/oldnew, so would "just" add one more.

Not just one, it will be one each new/old/oldnew macro to be able to distinguish when connector is used or not.
And it will be the same for the for_each macros...

Quoted 156 lines
Quoted 149 lines
Quoted 149 lines
Quoted 148 lines
Quoted 148 lines
Quoted 140 lines
drivers/gpu/drm/drm_atomic_helper.c +17 -18
      struct drm_connector_state *old_connector_state, *new_connector_state;
      int i;
 
@@ -412,7 +412,7 @@ mode_fixup(struct drm_atomic_state *state)
 {
      struct drm_crtc *crtc;
      struct drm_crtc_state *new_crtc_state;
-     struct drm_connector *connector;
+     struct drm_connector __maybe_unused *connector;
      struct drm_connector_state *new_conn_state;
      int i;
      int ret;
@@ -608,7 +608,7 @@ drm_atomic_helper_check_modeset(struct drm_device *dev,
 {
      struct drm_crtc *crtc;
      struct drm_crtc_state *old_crtc_state, *new_crtc_state;
-     struct drm_connector *connector;
+     struct drm_connector __maybe_unused *connector;
      struct drm_connector_state *old_connector_state, *new_connector_state;
      int i, ret;
      unsigned connectors_mask = 0;
@@ -984,7 +984,7 @@ crtc_needs_disable(struct drm_crtc_state *old_state,
 static void
 disable_outputs(struct drm_device *dev, struct drm_atomic_state *old_state)
 {
-     struct drm_connector *connector;
+     struct drm_connector __maybe_unused *connector;
      struct drm_connector_state *old_conn_state, *new_conn_state;
      struct drm_crtc *crtc;
      struct drm_crtc_state *old_crtc_state, *new_crtc_state;
@@ -1173,7 +1173,7 @@ crtc_set_mode(struct drm_device *dev, struct drm_atomic_state *old_state)
 {
      struct drm_crtc *crtc;
      struct drm_crtc_state *new_crtc_state;
-     struct drm_connector *connector;
+     struct drm_connector __maybe_unused *connector;
      struct drm_connector_state *new_conn_state;
      int i;
 
@@ -1294,7 +1294,7 @@ void drm_atomic_helper_commit_modeset_enables(struct drm_device *dev,
      struct drm_crtc *crtc;
      struct drm_crtc_state *old_crtc_state;
      struct drm_crtc_state *new_crtc_state;
-     struct drm_connector *connector;
+     struct drm_connector __maybe_unused *connector;
      struct drm_connector_state *new_conn_state;
      int i;
 
@@ -1384,7 +1384,7 @@ int drm_atomic_helper_wait_for_fences(struct drm_device *dev,
                                    struct drm_atomic_state *state,
                                    bool pre_swap)
 {
-     struct drm_plane *plane;
+     struct drm_plane __maybe_unused *plane;
      struct drm_plane_state *new_plane_state;
      int i, ret;
 
@@ -1431,7 +1431,7 @@ drm_atomic_helper_wait_for_vblanks(struct drm_device *dev,
              struct drm_atomic_state *old_state)
 {
      struct drm_crtc *crtc;
-     struct drm_crtc_state *old_crtc_state, *new_crtc_state;
+     struct drm_crtc_state __maybe_unused *old_crtc_state, *new_crtc_state;
      int i, ret;
      unsigned crtc_mask = 0;
 
@@ -1621,7 +1621,7 @@ static void commit_work(struct work_struct *work)
 int drm_atomic_helper_async_check(struct drm_device *dev,
                                 struct drm_atomic_state *state)
 {
-     struct drm_crtc *crtc;
+     struct drm_crtc __maybe_unused *crtc;
      struct drm_crtc_state *crtc_state;
      struct drm_plane *plane = NULL;
      struct drm_plane_state *old_plane_state = NULL;
@@ -1982,9 +1982,9 @@ int drm_atomic_helper_setup_commit(struct drm_atomic_state *state,
 {
      struct drm_crtc *crtc;
      struct drm_crtc_state *old_crtc_state, *new_crtc_state;
-     struct drm_connector *conn;
+     struct drm_connector __maybe_unused *conn;
      struct drm_connector_state *old_conn_state, *new_conn_state;
-     struct drm_plane *plane;
+     struct drm_plane __maybe_unused *plane;
      struct drm_plane_state *old_plane_state, *new_plane_state;
      struct drm_crtc_commit *commit;
      int i, ret;
@@ -2214,7 +2214,7 @@ EXPORT_SYMBOL(drm_atomic_helper_fake_vblank);
  */
 void drm_atomic_helper_commit_hw_done(struct drm_atomic_state *old_state)
 {
-     struct drm_crtc *crtc;
+     struct drm_crtc __maybe_unused *crtc;
      struct drm_crtc_state *old_crtc_state, *new_crtc_state;
      struct drm_crtc_commit *commit;
      int i;
@@ -2300,7 +2300,7 @@ EXPORT_SYMBOL(drm_atomic_helper_commit_cleanup_done);
 int drm_atomic_helper_prepare_planes(struct drm_device *dev,
                                   struct drm_atomic_state *state)
 {
-     struct drm_connector *connector;
+     struct drm_connector __maybe_unused *connector;
      struct drm_connector_state *new_conn_state;
      struct drm_plane *plane;
      struct drm_plane_state *new_plane_state;
@@ -2953,9 +2953,9 @@ int drm_atomic_helper_disable_all(struct drm_device *dev,
 {
      struct drm_atomic_state *state;
      struct drm_connector_state *conn_state;
-     struct drm_connector *conn;
+     struct drm_connector __maybe_unused *conn;
      struct drm_plane_state *plane_state;
-     struct drm_plane *plane;
+     struct drm_plane __maybe_unused *plane;
      struct drm_crtc_state *crtc_state;
      struct drm_crtc *crtc;
      int ret, i;
@@ -3199,11 +3199,11 @@ int drm_atomic_helper_commit_duplicated_state(struct drm_atomic_state *state,
 {
      int i, ret;
      struct drm_plane *plane;
-     struct drm_plane_state *new_plane_state;
+     struct drm_plane_state __maybe_unused *new_plane_state;
      struct drm_connector *connector;
-     struct drm_connector_state *new_conn_state;
+     struct drm_connector_state __maybe_unused *new_conn_state;
      struct drm_crtc *crtc;
-     struct drm_crtc_state *new_crtc_state;
+     struct drm_crtc_state __maybe_unused *new_crtc_state;
 
      state->acquire_ctx = ctx;
 
--

2.15.0

Quoted 4 lines

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

--
Ville Syrjälä
Intel

Quoted 3 lines
Quoted 3 lines

--
Ville Syrjälä
Intel

--
Ville Syrjälä
Intel

#10 lore raw

Re: [PATCH] drm: atomic helper: fix W=1 warnings

Quoted 54 lines · Benjamin Gaignard
Quoted 52 lines · Ville Syrjälä
Quoted 50 lines · Benjamin Gaignard
Quoted 29 lines · Ville Syrjälä
Quoted 27 lines · Benjamin Gaignard
Quoted 24 lines · Ville Syrjälä
Quoted 14 lines · Benjamin Gaignard

Fix warnings with W=1.
Few for_each macro set variables that are never used later. Prevent warning by marking these variables as __maybe_unused.

---
 drivers/gpu/drm/drm_atomic_helper.c | 36 ++++++++++++++++++------------------
 1 file changed, 18 insertions(+), 18 deletions(-)
drivers/gpu/drm/drm_atomic_helper.c +0 -0
index aa16ea17ff9b..b69d17b0b9bd 100644

drivers/gpu/drm/drm_atomic_helper.c steal_encoder(struct drm_atomic_state *state, · line 265

Quoted 5 lines
drivers/gpu/drm/drm_atomic_helper.c +1 -1
@@ -262,7 +262,7 @@ steal_encoder(struct drm_atomic_state *state,
            struct drm_encoder *encoder)
 {
      struct drm_crtc_state *crtc_state;
-     struct drm_connector *connector;
+     struct drm_connector __maybe_unused *connector;

Rather ugly. IMO would be nicer if we could hide something inside the iterator macros to suppress the warning.

Quoted 7 lines
Quoted 5 lines

Ok but how ?
connector is assigned in the macros but not used later and we can't set "__maybe_unused"
in the macro.
Does another keyword exist for that ?

Stick a (void)(connector) into the macro?

That could work but it will look strange inside the macro.

Quoted 8 lines

Another (arguably cleaner) idea would be to remove the connector/crtc/plane argument from the iterators entirely since it's redundant, and instead just extract it from the appropriate new/old state as needed.

We could then also add a for_each_connector_in_state()/etc. which omit s the state arguments and just has the connector argument, for cases where you don't care about the states when iterating.

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

That may lead to get a macro for each possible combination of used variables.

We already have new/old/oldnew, so would "just" add one more.

Not just one, it will be one each new/old/oldnew macro to be able to distinguish when connector is used or not.

What I'm suggesting is this:
for_each_connector_in_state(state, connector, i) for_each_old_connector_in_state(state, old_conn_state, i) for_each_new_connector_in_state(state, new_conn_state, i) for_each_oldnew_connector_in_state(state, old_conn_state, new_conn_state, i)

So only four in total for each object type, instead of the current three.

Signature · 2 lines
Ville Syrjälä
Intel
#11 lore raw

Re: [PATCH] drm: atomic helper: fix W=1 warnings

Quoted 50 lines · Ville Syrjälä
Quoted 42 lines · Benjamin Gaignard
Quoted 40 lines · Ville Syrjälä
Quoted 39 lines · Benjamin Gaignard
Quoted 25 lines · Ville Syrjälä
Quoted 24 lines · Benjamin Gaignard
Quoted 22 lines · Ville Syrjälä
Quoted 14 lines · Benjamin Gaignard

Fix warnings with W=1.
Few for_each macro set variables that are never used later. Prevent warning by marking these variables as __maybe_unused.

---
  drivers/gpu/drm/drm_atomic_helper.c | 36 ++++++++++++++++++------------------
  1 file changed, 18 insertions(+), 18 deletions(-)
drivers/gpu/drm/drm_atomic_helper.c +0 -0
index aa16ea17ff9b..b69d17b0b9bd 100644

drivers/gpu/drm/drm_atomic_helper.c steal_encoder(struct drm_atomic_state *state, · line 265

Quoted 5 lines
drivers/gpu/drm/drm_atomic_helper.c +1 -1
@@ -262,7 +262,7 @@ steal_encoder(struct drm_atomic_state *state,
             struct drm_encoder *encoder)
  {
       struct drm_crtc_state *crtc_state;
-     struct drm_connector *connector;
+     struct drm_connector __maybe_unused *connector;

Rather ugly. IMO would be nicer if we could hide something inside the iterator macros to suppress the warning.

Quoted 6 lines
Quoted 5 lines

Ok but how ?
connector is assigned in the macros but not used later and we can't set "__maybe_unused"
in the macro.
Does another keyword exist for that ?

Stick a (void)(connector) into the macro?

That could work but it will look strange inside the macro.

Quoted 4 lines

Another (arguably cleaner) idea would be to remove the connector/crtc/plane argument from the iterators entirely since it's redundant, and instead just extract it from the appropriate new/old state as needed.

Quoted 7 lines
Quoted 5 lines
Quoted 4 lines
Quoted 3 lines

We could then also add a for_each_connector_in_state()/etc. which omit s the state arguments and just has the connector argument, for cases where you don't care about the states when iterating.

That may lead to get a macro for each possible combination of used variables.

We already have new/old/oldnew, so would "just" add one more.

Not just one, it will be one each new/old/oldnew macro to be able to distinguish when connector is used or not.

Quoted 8 lines

What I'm suggesting is this:
for_each_connector_in_state(state, connector, i) for_each_old_connector_in_state(state, old_conn_state, i) for_each_new_connector_in_state(state, new_conn_state, i) for_each_oldnew_connector_in_state(state, old_conn_state, new_conn_state, i)

So only four in total for each object type, instead of the current three.

You are missing these cases: old and connector, new and connector,

old and new and connector are needed together.

Quoted 1 line
#12 lore raw

Re: [PATCH] drm: atomic helper: fix W=1 warnings

Quoted 58 lines · Benjamin GAIGNARD
Quoted 56 lines · Ville Syrjälä
Quoted 42 lines · Benjamin Gaignard
Quoted 40 lines · Ville Syrjälä
Quoted 39 lines · Benjamin Gaignard
Quoted 25 lines · Ville Syrjälä
Quoted 24 lines · Benjamin Gaignard
Quoted 22 lines · Ville Syrjälä
Quoted 14 lines · Benjamin Gaignard

Fix warnings with W=1.
Few for_each macro set variables that are never used later. Prevent warning by marking these variables as __maybe_unused.

---
  drivers/gpu/drm/drm_atomic_helper.c | 36 ++++++++++++++++++------------------
  1 file changed, 18 insertions(+), 18 deletions(-)
drivers/gpu/drm/drm_atomic_helper.c +0 -0
index aa16ea17ff9b..b69d17b0b9bd 100644

drivers/gpu/drm/drm_atomic_helper.c steal_encoder(struct drm_atomic_state *state, · line 265

Quoted 5 lines
drivers/gpu/drm/drm_atomic_helper.c +1 -1
@@ -262,7 +262,7 @@ steal_encoder(struct drm_atomic_state *state,
             struct drm_encoder *encoder)
  {
       struct drm_crtc_state *crtc_state;
-     struct drm_connector *connector;
+     struct drm_connector __maybe_unused *connector;

Rather ugly. IMO would be nicer if we could hide something inside the iterator macros to suppress the warning.

Quoted 6 lines
Quoted 5 lines

Ok but how ?
connector is assigned in the macros but not used later and we can't set "__maybe_unused"
in the macro.
Does another keyword exist for that ?

Stick a (void)(connector) into the macro?

That could work but it will look strange inside the macro.

Quoted 4 lines

Another (arguably cleaner) idea would be to remove the connector/crtc/plane argument from the iterators entirely since it's redundant, and instead just extract it from the appropriate new/old state as needed.

Quoted 7 lines
Quoted 5 lines
Quoted 4 lines
Quoted 3 lines

We could then also add a for_each_connector_in_state()/etc. which omit s the state arguments and just has the connector argument, for cases where you don't care about the states when iterating.

That may lead to get a macro for each possible combination of used variables.

We already have new/old/oldnew, so would "just" add one more.

Not just one, it will be one each new/old/oldnew macro to be able to distinguish when connector is used or not.

What I'm suggesting is this:
for_each_connector_in_state(state, connector, i) for_each_old_connector_in_state(state, old_conn_state, i) for_each_new_connector_in_state(state, new_conn_state, i) for_each_oldnew_connector_in_state(state, old_conn_state, new_conn_state, i)

Quoted 6 lines
Quoted 2 lines

So only four in total for each object type, instead of the current three.

You are missing these cases: old and connector, new and connector,

old and new and connector are needed together.

No, that's redundant. You can always get the connector from old/new_conn_state->connector if you need it.

Signature · 2 lines
Ville Syrjälä
Intel
#13 lore raw

Re: [PATCH] drm: atomic helper: fix W=1 warnings

In reply to Benjamin Gaignard
Quoted 37 lines · Benjamin Gaignard
Quoted 35 lines · Ville Syrjälä
Quoted 32 lines · Benjamin Gaignard
Quoted 11 lines · Ville Syrjälä
Quoted 9 lines · Benjamin Gaignard

Fix warnings with W=1.
Few for_each macro set variables that are never used later. Prevent warning by marking these variables as __maybe_unused.

---
 drivers/gpu/drm/drm_atomic_helper.c | 36 ++++++++++++++++++------------------
 1 file changed, 18 insertions(+), 18 deletions(-)
Quoted 13 lines

drivers/gpu/drm/drm_atomic_helper.c steal_encoder(struct drm_atomic_state *state, · line 265

Quoted 10 lines
drivers/gpu/drm/drm_atomic_helper.c +1 -1
index aa16ea17ff9b..b69d17b0b9bd 100644
@@ -262,7 +262,7 @@ steal_encoder(struct drm_atomic_state *state,
            struct drm_encoder *encoder)
 {
      struct drm_crtc_state *crtc_state;
-     struct drm_connector *connector;
+     struct drm_connector __maybe_unused *connector;

Rather ugly. IMO would be nicer if we could hide something inside the iterator macros to suppress the warning.

Ok but how ?
connector is assigned in the macros but not used later and we can't set "__maybe_unused"
in the macro.
Does another keyword exist for that ?

Quoted 3 lines
Quoted 1 line

Stick a (void)(connector) into the macro?

That could work but it will look strange inside the macro.

If this works I think it's fine, maybe together with a FIXME or so ... At least as an interim solution. Much better than sprinkling all the maybe_unused annotations around like in this patch.
-Daniel

Quoted 162 lines
Quoted 9 lines

Another (arguably cleaner) idea would be to remove the connector/crtc/plane argument from the iterators entirely since it's redundant, and instead just extract it from the appropriate new/old state as needed.

We could then also add a for_each_connector_in_state()/etc. which omit s the state arguments and just has the connector argument, for cases where you don't care about the states when iterating.

That may lead to get a macro for each possible combination of used variables.

Quoted 150 lines
Quoted 138 lines
Quoted 138 lines
Quoted 138 lines
drivers/gpu/drm/drm_atomic_helper.c +17 -18
      struct drm_connector_state *old_connector_state, *new_connector_state;
      int i;
 
@@ -412,7 +412,7 @@ mode_fixup(struct drm_atomic_state *state)
 {
      struct drm_crtc *crtc;
      struct drm_crtc_state *new_crtc_state;
-     struct drm_connector *connector;
+     struct drm_connector __maybe_unused *connector;
      struct drm_connector_state *new_conn_state;
      int i;
      int ret;
@@ -608,7 +608,7 @@ drm_atomic_helper_check_modeset(struct drm_device *dev,
 {
      struct drm_crtc *crtc;
      struct drm_crtc_state *old_crtc_state, *new_crtc_state;
-     struct drm_connector *connector;
+     struct drm_connector __maybe_unused *connector;
      struct drm_connector_state *old_connector_state, *new_connector_state;
      int i, ret;
      unsigned connectors_mask = 0;
@@ -984,7 +984,7 @@ crtc_needs_disable(struct drm_crtc_state *old_state,
 static void
 disable_outputs(struct drm_device *dev, struct drm_atomic_state *old_state)
 {
-     struct drm_connector *connector;
+     struct drm_connector __maybe_unused *connector;
      struct drm_connector_state *old_conn_state, *new_conn_state;
      struct drm_crtc *crtc;
      struct drm_crtc_state *old_crtc_state, *new_crtc_state;
@@ -1173,7 +1173,7 @@ crtc_set_mode(struct drm_device *dev, struct drm_atomic_state *old_state)
 {
      struct drm_crtc *crtc;
      struct drm_crtc_state *new_crtc_state;
-     struct drm_connector *connector;
+     struct drm_connector __maybe_unused *connector;
      struct drm_connector_state *new_conn_state;
      int i;
 
@@ -1294,7 +1294,7 @@ void drm_atomic_helper_commit_modeset_enables(struct drm_device *dev,
      struct drm_crtc *crtc;
      struct drm_crtc_state *old_crtc_state;
      struct drm_crtc_state *new_crtc_state;
-     struct drm_connector *connector;
+     struct drm_connector __maybe_unused *connector;
      struct drm_connector_state *new_conn_state;
      int i;
 
@@ -1384,7 +1384,7 @@ int drm_atomic_helper_wait_for_fences(struct drm_device *dev,
                                    struct drm_atomic_state *state,
                                    bool pre_swap)
 {
-     struct drm_plane *plane;
+     struct drm_plane __maybe_unused *plane;
      struct drm_plane_state *new_plane_state;
      int i, ret;
 
@@ -1431,7 +1431,7 @@ drm_atomic_helper_wait_for_vblanks(struct drm_device *dev,
              struct drm_atomic_state *old_state)
 {
      struct drm_crtc *crtc;
-     struct drm_crtc_state *old_crtc_state, *new_crtc_state;
+     struct drm_crtc_state __maybe_unused *old_crtc_state, *new_crtc_state;
      int i, ret;
      unsigned crtc_mask = 0;
 
@@ -1621,7 +1621,7 @@ static void commit_work(struct work_struct *work)
 int drm_atomic_helper_async_check(struct drm_device *dev,
                                 struct drm_atomic_state *state)
 {
-     struct drm_crtc *crtc;
+     struct drm_crtc __maybe_unused *crtc;
      struct drm_crtc_state *crtc_state;
      struct drm_plane *plane = NULL;
      struct drm_plane_state *old_plane_state = NULL;
@@ -1982,9 +1982,9 @@ int drm_atomic_helper_setup_commit(struct drm_atomic_state *state,
 {
      struct drm_crtc *crtc;
      struct drm_crtc_state *old_crtc_state, *new_crtc_state;
-     struct drm_connector *conn;
+     struct drm_connector __maybe_unused *conn;
      struct drm_connector_state *old_conn_state, *new_conn_state;
-     struct drm_plane *plane;
+     struct drm_plane __maybe_unused *plane;
      struct drm_plane_state *old_plane_state, *new_plane_state;
      struct drm_crtc_commit *commit;
      int i, ret;
@@ -2214,7 +2214,7 @@ EXPORT_SYMBOL(drm_atomic_helper_fake_vblank);
  */
 void drm_atomic_helper_commit_hw_done(struct drm_atomic_state *old_state)
 {
-     struct drm_crtc *crtc;
+     struct drm_crtc __maybe_unused *crtc;
      struct drm_crtc_state *old_crtc_state, *new_crtc_state;
      struct drm_crtc_commit *commit;
      int i;
@@ -2300,7 +2300,7 @@ EXPORT_SYMBOL(drm_atomic_helper_commit_cleanup_done);
 int drm_atomic_helper_prepare_planes(struct drm_device *dev,
                                   struct drm_atomic_state *state)
 {
-     struct drm_connector *connector;
+     struct drm_connector __maybe_unused *connector;
      struct drm_connector_state *new_conn_state;
      struct drm_plane *plane;
      struct drm_plane_state *new_plane_state;
@@ -2953,9 +2953,9 @@ int drm_atomic_helper_disable_all(struct drm_device *dev,
 {
      struct drm_atomic_state *state;
      struct drm_connector_state *conn_state;
-     struct drm_connector *conn;
+     struct drm_connector __maybe_unused *conn;
      struct drm_plane_state *plane_state;
-     struct drm_plane *plane;
+     struct drm_plane __maybe_unused *plane;
      struct drm_crtc_state *crtc_state;
      struct drm_crtc *crtc;
      int ret, i;
@@ -3199,11 +3199,11 @@ int drm_atomic_helper_commit_duplicated_state(struct drm_atomic_state *state,
 {
      int i, ret;
      struct drm_plane *plane;
-     struct drm_plane_state *new_plane_state;
+     struct drm_plane_state __maybe_unused *new_plane_state;
      struct drm_connector *connector;
-     struct drm_connector_state *new_conn_state;
+     struct drm_connector_state __maybe_unused *new_conn_state;
      struct drm_crtc *crtc;
-     struct drm_crtc_state *new_crtc_state;
+     struct drm_crtc_state __maybe_unused *new_crtc_state;
 
      state->acquire_ctx = ctx;
 
--

2.15.0

Quoted 8 lines
Quoted 8 lines
Quoted 4 lines

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

--
Ville Syrjälä
Intel

--
Ville Syrjälä
Intel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#14 lore raw
In reply to Benjamin Gaignard

+Manasi, Gaurav

Quoted 14 lines · Benjamin Gaignard

Change scale_increment_interval and nfl_bpg_offset fields to u32 to avoid W=1 warnings because we are testing them against 65535.

---
  include/drm/drm_dsc.h | 6 ++++--
  1 file changed, 4 insertions(+), 2 deletions(-)
include/drm/drm_dsc.h +0 -0
index 887954cbfc60..e495024e901c 100644

include/drm/drm_dsc.h struct drm_dsc_config { · line 210

Quoted 5 lines
include/drm/drm_dsc.h +1 -1
@@ -207,11 +207,13 @@ struct drm_dsc_config {
  	 * Number of group times between incrementing the scale factor value
  	 * used at the beginning of a slice.
  	 */
-	u16 scale_increment_interval;
+	u32 scale_increment_interval;

The DSC spec defines both as u16. I think the check in drm_dsc.c is useless and should be dropped.

Harry

Quoted 11 lines
include/drm/drm_dsc.h +3 -1
+
  	/**
  	 * @nfl_bpg_offset: Non first line BPG offset to be used
  	 */
-	u16 nfl_bpg_offset;
+
+	u32 nfl_bpg_offset;
  	/**
  	 * @slice_bpg_offset: BPG offset used to enforce slice bit
  	 */
#15 lore raw
Quoted 12 lines · Harry Wentland

+Manasi, Gaurav

Quoted 9 lines · Benjamin Gaignard

Change scale_increment_interval and nfl_bpg_offset fields to u32 to avoid W=1 warnings because we are testing them against 65535.

---
  include/drm/drm_dsc.h | 6 ++++--
  1 file changed, 4 insertions(+), 2 deletions(-)
Quoted 14 lines

include/drm/drm_dsc.h struct drm_dsc_config { · line 210

Quoted 10 lines
include/drm/drm_dsc.h +1 -1
index 887954cbfc60..e495024e901c 100644
@@ -207,11 +207,13 @@ struct drm_dsc_config {
  	 * Number of group times between incrementing the scale factor value
  	 * used at the beginning of a slice.
  	 */
-	u16 scale_increment_interval;
+	u32 scale_increment_interval;

The DSC spec defines both as u16. I think the check in drm_dsc.c is useless and should be dropped.

I agree with Harry here, all these variables should match the number of bits in the spec, increasing them to u32 allows more values which violates the DSC spec.

It should stay u16

Manasi

Quoted 17 lines

Harry

include/drm/drm_dsc.h struct drm_dsc_config { · line 219

Quoted 11 lines
include/drm/drm_dsc.h +3 -1
+
  	/**
  	 * @nfl_bpg_offset: Non first line BPG offset to be used
  	 */
-	u16 nfl_bpg_offset;
+
+	u32 nfl_bpg_offset;
  	/**
  	 * @slice_bpg_offset: BPG offset used to enforce slice bit
  	 */

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel