* [bug report] drm/ingenic: Add support for the IPU
@ 2020-07-20 7:22 dan.carpenter
2020-07-20 7:24 ` Dan Carpenter
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: dan.carpenter @ 2020-07-20 7:22 UTC (permalink / raw)
To: paul; +Cc: dri-devel
Hello Paul Cercueil,
The patch fc1acf317b01: "drm/ingenic: Add support for the IPU" from
Jul 16, 2020, leads to the following static checker warning:
drivers/gpu/drm/ingenic/ingenic-drm-drv.c:232 ingenic_drm_crtc_atomic_check()
error: potentially dereferencing uninitialized 'ipu_state'.
drivers/gpu/drm/ingenic/ingenic-drm-drv.c
197 static int ingenic_drm_crtc_atomic_check(struct drm_crtc *crtc,
198 struct drm_crtc_state *state)
199 {
200 struct ingenic_drm *priv = drm_crtc_get_priv(crtc);
201 struct drm_plane_state *f1_state, *f0_state, *ipu_state;
202 long rate;
203
204 if (!drm_atomic_crtc_needs_modeset(state))
205 return 0;
206
207 if (state->mode.hdisplay > priv->soc_info->max_width ||
208 state->mode.vdisplay > priv->soc_info->max_height)
209 return -EINVAL;
210
211 rate = clk_round_rate(priv->pix_clk,
212 state->adjusted_mode.clock * 1000);
213 if (rate < 0)
214 return rate;
215
216 if (priv->soc_info->has_osd) {
217 f1_state = drm_atomic_get_plane_state(state->state, &priv->f1);
218 f0_state = drm_atomic_get_plane_state(state->state, &priv->f0);
219
220 if (IS_ENABLED(CONFIG_DRM_INGENIC_IPU) && priv->ipu_plane) {
Do we need to check both the CONFIG and the priv->ipu_plane or would it
be sufficient to just check if (priv->ipu_plane) {?
221 ipu_state = drm_atomic_get_plane_state(state->state, priv->ipu_plane);
222
223 /* IPU and F1 planes cannot be enabled at the same time. */
224 if (f1_state->fb && ipu_state->fb) {
225 dev_dbg(priv->dev, "Cannot enable both F1 and IPU\n");
226 return -EINVAL;
227 }
228 }
229
230 /* If all the planes are disabled, we won't get a VBLANK IRQ */
231 priv->no_vblank = !f1_state->fb && !f0_state->fb &&
232 !(priv->ipu_plane && ipu_state->fb);
^^^^^^^^^^^^^^^
Because here we're only checking "priv->ipu_plane".
233 }
234
235 return 0;
236 }
regards,
dan carpenter
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [bug report] drm/ingenic: Add support for the IPU
2020-07-20 7:22 [bug report] drm/ingenic: Add support for the IPU dan.carpenter
@ 2020-07-20 7:24 ` Dan Carpenter
2020-07-20 7:44 ` Daniel Vetter
2020-07-20 10:27 ` Paul Cercueil
2 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2020-07-20 7:24 UTC (permalink / raw)
To: paul; +Cc: dri-devel
On Mon, Jul 20, 2020 at 10:22:37AM +0300, dan.carpenter@oracle.com wrote:
> Hello Paul Cercueil,
>
> The patch fc1acf317b01: "drm/ingenic: Add support for the IPU" from
> Jul 16, 2020, leads to the following static checker warning:
>
> drivers/gpu/drm/ingenic/ingenic-drm-drv.c:232 ingenic_drm_crtc_atomic_check()
> error: potentially dereferencing uninitialized 'ipu_state'.
>
> drivers/gpu/drm/ingenic/ingenic-drm-drv.c
> 197 static int ingenic_drm_crtc_atomic_check(struct drm_crtc *crtc,
> 198 struct drm_crtc_state *state)
> 199 {
> 200 struct ingenic_drm *priv = drm_crtc_get_priv(crtc);
> 201 struct drm_plane_state *f1_state, *f0_state, *ipu_state;
> 202 long rate;
> 203
> 204 if (!drm_atomic_crtc_needs_modeset(state))
> 205 return 0;
> 206
> 207 if (state->mode.hdisplay > priv->soc_info->max_width ||
> 208 state->mode.vdisplay > priv->soc_info->max_height)
> 209 return -EINVAL;
> 210
> 211 rate = clk_round_rate(priv->pix_clk,
> 212 state->adjusted_mode.clock * 1000);
> 213 if (rate < 0)
> 214 return rate;
> 215
> 216 if (priv->soc_info->has_osd) {
> 217 f1_state = drm_atomic_get_plane_state(state->state, &priv->f1);
> 218 f0_state = drm_atomic_get_plane_state(state->state, &priv->f0);
drivers/gpu/drm/ingenic/ingenic-drm-drv.c:224 ingenic_drm_crtc_atomic_check() error: 'f1_state' dereferencing possible ERR_PTR()
drivers/gpu/drm/ingenic/ingenic-drm-drv.c:224 ingenic_drm_crtc_atomic_check() error: 'ipu_state' dereferencing possible ERR_PTR()
drivers/gpu/drm/ingenic/ingenic-drm-drv.c:231 ingenic_drm_crtc_atomic_check() error: 'f1_state' dereferencing possible ERR_PTR()
drivers/gpu/drm/ingenic/ingenic-drm-drv.c:231 ingenic_drm_crtc_atomic_check() error: 'f0_state' dereferencing possible ERR_PTR()
drivers/gpu/drm/ingenic/ingenic-drm-drv.c:232 ingenic_drm_crtc_atomic_check() error: 'ipu_state' dereferencing possible ERR_PTR()
Also Smatch complains that these need error checking.
regards,
dan carpenter
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [bug report] drm/ingenic: Add support for the IPU
2020-07-20 7:22 [bug report] drm/ingenic: Add support for the IPU dan.carpenter
2020-07-20 7:24 ` Dan Carpenter
@ 2020-07-20 7:44 ` Daniel Vetter
2020-07-20 10:27 ` Paul Cercueil
2 siblings, 0 replies; 4+ messages in thread
From: Daniel Vetter @ 2020-07-20 7:44 UTC (permalink / raw)
To: dan.carpenter; +Cc: paul, dri-devel
On Mon, Jul 20, 2020 at 10:22:37AM +0300, dan.carpenter@oracle.com wrote:
> Hello Paul Cercueil,
>
> The patch fc1acf317b01: "drm/ingenic: Add support for the IPU" from
> Jul 16, 2020, leads to the following static checker warning:
>
> drivers/gpu/drm/ingenic/ingenic-drm-drv.c:232 ingenic_drm_crtc_atomic_check()
> error: potentially dereferencing uninitialized 'ipu_state'.
>
> drivers/gpu/drm/ingenic/ingenic-drm-drv.c
> 197 static int ingenic_drm_crtc_atomic_check(struct drm_crtc *crtc,
> 198 struct drm_crtc_state *state)
> 199 {
> 200 struct ingenic_drm *priv = drm_crtc_get_priv(crtc);
> 201 struct drm_plane_state *f1_state, *f0_state, *ipu_state;
> 202 long rate;
> 203
> 204 if (!drm_atomic_crtc_needs_modeset(state))
> 205 return 0;
> 206
> 207 if (state->mode.hdisplay > priv->soc_info->max_width ||
> 208 state->mode.vdisplay > priv->soc_info->max_height)
> 209 return -EINVAL;
Random entirely unrelated drive-through comment: These mode checks should
be in crtc_helper_funcs->mode_valid so that they're shared between the
atomic_check and output probe paths.
But preexisting issues, just something that would be nice to rectify.
Cheers, Daniel
> 210
> 211 rate = clk_round_rate(priv->pix_clk,
> 212 state->adjusted_mode.clock * 1000);
> 213 if (rate < 0)
> 214 return rate;
> 215
> 216 if (priv->soc_info->has_osd) {
> 217 f1_state = drm_atomic_get_plane_state(state->state, &priv->f1);
> 218 f0_state = drm_atomic_get_plane_state(state->state, &priv->f0);
> 219
> 220 if (IS_ENABLED(CONFIG_DRM_INGENIC_IPU) && priv->ipu_plane) {
>
> Do we need to check both the CONFIG and the priv->ipu_plane or would it
> be sufficient to just check if (priv->ipu_plane) {?
>
> 221 ipu_state = drm_atomic_get_plane_state(state->state, priv->ipu_plane);
> 222
> 223 /* IPU and F1 planes cannot be enabled at the same time. */
> 224 if (f1_state->fb && ipu_state->fb) {
> 225 dev_dbg(priv->dev, "Cannot enable both F1 and IPU\n");
> 226 return -EINVAL;
> 227 }
> 228 }
> 229
> 230 /* If all the planes are disabled, we won't get a VBLANK IRQ */
> 231 priv->no_vblank = !f1_state->fb && !f0_state->fb &&
> 232 !(priv->ipu_plane && ipu_state->fb);
> ^^^^^^^^^^^^^^^
> Because here we're only checking "priv->ipu_plane".
>
> 233 }
> 234
> 235 return 0;
> 236 }
>
> regards,
> dan carpenter
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [bug report] drm/ingenic: Add support for the IPU
2020-07-20 7:22 [bug report] drm/ingenic: Add support for the IPU dan.carpenter
2020-07-20 7:24 ` Dan Carpenter
2020-07-20 7:44 ` Daniel Vetter
@ 2020-07-20 10:27 ` Paul Cercueil
2 siblings, 0 replies; 4+ messages in thread
From: Paul Cercueil @ 2020-07-20 10:27 UTC (permalink / raw)
To: dan.carpenter; +Cc: dri-devel
Hi Dan,
Le lun. 20 juil. 2020 à 10:22, dan.carpenter@oracle.com a écrit :
> Hello Paul Cercueil,
>
> The patch fc1acf317b01: "drm/ingenic: Add support for the IPU" from
> Jul 16, 2020, leads to the following static checker warning:
>
> drivers/gpu/drm/ingenic/ingenic-drm-drv.c:232
> ingenic_drm_crtc_atomic_check()
> error: potentially dereferencing uninitialized 'ipu_state'.
I fixed it yesterday, commit 40a55dc13e9d in drm-misc-next.
> drivers/gpu/drm/ingenic/ingenic-drm-drv.c
> 197 static int ingenic_drm_crtc_atomic_check(struct drm_crtc
> *crtc,
> 198 struct
> drm_crtc_state *state)
> 199 {
> 200 struct ingenic_drm *priv = drm_crtc_get_priv(crtc);
> 201 struct drm_plane_state *f1_state, *f0_state,
> *ipu_state;
> 202 long rate;
> 203
> 204 if (!drm_atomic_crtc_needs_modeset(state))
> 205 return 0;
> 206
> 207 if (state->mode.hdisplay > priv->soc_info->max_width
> ||
> 208 state->mode.vdisplay > priv->soc_info->max_height)
> 209 return -EINVAL;
> 210
> 211 rate = clk_round_rate(priv->pix_clk,
> 212 state->adjusted_mode.clock *
> 1000);
> 213 if (rate < 0)
> 214 return rate;
> 215
> 216 if (priv->soc_info->has_osd) {
> 217 f1_state =
> drm_atomic_get_plane_state(state->state, &priv->f1);
> 218 f0_state =
> drm_atomic_get_plane_state(state->state, &priv->f0);
> 219
> 220 if (IS_ENABLED(CONFIG_DRM_INGENIC_IPU) &&
> priv->ipu_plane) {
>
> Do we need to check both the CONFIG and the priv->ipu_plane or would
> it
> be sufficient to just check if (priv->ipu_plane) {?
It would be enough, yes.
Cheers,
-Paul
> 221 ipu_state =
> drm_atomic_get_plane_state(state->state, priv->ipu_plane);
> 222
> 223 /* IPU and F1 planes cannot be
> enabled at the same time. */
> 224 if (f1_state->fb && ipu_state->fb) {
> 225 dev_dbg(priv->dev, "Cannot
> enable both F1 and IPU\n");
> 226 return -EINVAL;
> 227 }
> 228 }
> 229
> 230 /* If all the planes are disabled, we won't
> get a VBLANK IRQ */
> 231 priv->no_vblank = !f1_state->fb &&
> !f0_state->fb &&
> 232 !(priv->ipu_plane &&
> ipu_state->fb);
> ^^^^^^^^^^^^^^^
> Because here we're only checking "priv->ipu_plane".
>
> 233 }
> 234
> 235 return 0;
> 236 }
>
> regards,
> dan carpenter
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-07-21 8:18 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-20 7:22 [bug report] drm/ingenic: Add support for the IPU dan.carpenter
2020-07-20 7:24 ` Dan Carpenter
2020-07-20 7:44 ` Daniel Vetter
2020-07-20 10:27 ` Paul Cercueil
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.