[bug report] drm/vc4: Add CTM support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Stefan Schake,

Commit 766cc6b1f7fc ("drm/vc4: Add CTM support") from Apr 20, 2018
(linux-next), leads to the following Smatch static checker warning:

	drivers/gpu/drm/vc4/vc4_kms.c:555 vc4_ctm_atomic_check()
	warn: reusing outside iterator: 'i'

drivers/gpu/drm/vc4/vc4_kms.c
    504 static int
    505 vc4_ctm_atomic_check(struct drm_device *dev, struct drm_atomic_state *state)
    506 {
    507         struct vc4_dev *vc4 = to_vc4_dev(dev);
    508         struct vc4_ctm_state *ctm_state = NULL;
    509         struct drm_crtc *crtc;
    510         struct drm_crtc_state *old_crtc_state, *new_crtc_state;
    511         struct drm_color_ctm *ctm;
    512         int i;
    513 
    514         for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
    515                 /* CTM is being disabled. */
    516                 if (!new_crtc_state->ctm && old_crtc_state->ctm) {
    517                         ctm_state = vc4_get_ctm_state(state, &vc4->ctm_manager);
    518                         if (IS_ERR(ctm_state))
    519                                 return PTR_ERR(ctm_state);
    520                         ctm_state->fifo = 0;
    521                 }
    522         }
    523 
    524         for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
                                                                                           ^
This loops from zero to state->dev->mode_config.num_crtc - 1.

    525                 if (new_crtc_state->ctm == old_crtc_state->ctm)
    526                         continue;
    527 
    528                 if (!ctm_state) {
    529                         ctm_state = vc4_get_ctm_state(state, &vc4->ctm_manager);
    530                         if (IS_ERR(ctm_state))
    531                                 return PTR_ERR(ctm_state);
    532                 }
    533 
    534                 /* CTM is being enabled or the matrix changed. */
    535                 if (new_crtc_state->ctm) {
    536                         struct vc4_crtc_state *vc4_crtc_state =
    537                                 to_vc4_crtc_state(new_crtc_state);
    538 
    539                         /* fifo is 1-based since 0 disables CTM. */
    540                         int fifo = vc4_crtc_state->assigned_channel + 1;
    541 
    542                         /* Check userland isn't trying to turn on CTM for more
    543                          * than one CRTC at a time.
    544                          */
    545                         if (ctm_state->fifo && ctm_state->fifo != fifo) {
    546                                 DRM_DEBUG_DRIVER("Too many CTM configured\n");
    547                                 return -EINVAL;
    548                         }
    549 
    550                         /* Check we can approximate the specified CTM.
    551                          * We disallow scalars |c| > 1.0 since the HW has
    552                          * no integer bits.
    553                          */
    554                         ctm = new_crtc_state->ctm->data;
--> 555                         for (i = 0; i < ARRAY_SIZE(ctm->matrix); i++) {
                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This uses the same iterator and restarts the loop.

    556                                 u64 val = ctm->matrix[i];
    557 
    558                                 val &= ~BIT_ULL(63);
    559                                 if (val > BIT_ULL(32))
    560                                         return -EINVAL;
    561                         }
    562 
    563                         ctm_state->fifo = fifo;
    564                         ctm_state->ctm = ctm;
    565                 }
    566         }
    567 
    568         return 0;
    569 }

regards,
dan carpenter



[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux