From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7DE65C433DF for ; Wed, 29 Jul 2020 21:34:30 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 46BAD206D7 for ; Wed, 29 Jul 2020 21:34:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=ffwll.ch header.i=@ffwll.ch header.b="PkcX/+Sx" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 46BAD206D7 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ffwll.ch Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9AA3E6E2E5; Wed, 29 Jul 2020 21:34:29 +0000 (UTC) Received: from mail-oo1-xc44.google.com (mail-oo1-xc44.google.com [IPv6:2607:f8b0:4864:20::c44]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7CCD76E2E5 for ; Wed, 29 Jul 2020 21:34:28 +0000 (UTC) Received: by mail-oo1-xc44.google.com with SMTP id a9so4822308oof.12 for ; Wed, 29 Jul 2020 14:34:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=z/TZdLxklOCKkN8i4+cSEsg+b7HbOT6N2Tke9Pj7LUU=; b=PkcX/+SxrLF58QXjfWe1NYIIvmeMaLZQYiqX7/9QHwYsHPk3fl0Hsu7IADIZ99KP+/ EJ0eVf+kh6w3Jmuqj48hqHHp0xRmJrH7LpiOuu1C0RZ/rnMCjdPFlQB3qV4QdNfsKFI/ OcrqGWzp3r3usyCM4fykQg+yd+NbItUQXQoRo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=z/TZdLxklOCKkN8i4+cSEsg+b7HbOT6N2Tke9Pj7LUU=; b=DF5kW6JRi3e3tOiX+dWRvmTlvG8FzTcGIzsyUAkQqyi6Otwf6/IRFfKfHkoEhfqptk ZqHiI9tyJUbu0nRIUIL8IwQ8yJ/xA1oZdypO+my/S2hZSfFzK53JTiWbnaexQMKQiku+ WpP+4U7knrwpQ/DPeDGBVahXN/JTcRNy45l9uPsmVD1Zu57QGMHhQKVFi++vazpHIX+D 2nCoqVEcwMS6AOBv1w7lwdv7HzIw7GWEixMiWWa+pF3oY4DvcNy1o3AOWDhB3oVUpEf0 4OHuF8dRpJ11oWg+/C7qXVXTAGIwCe54//FnkmrYDY1xuFQCx8hxXTE+Z7QkkrSJi2XK BE2w== X-Gm-Message-State: AOAM530pZCCGQMZdtWiT1/Bvn9gOmM7PHkqL8GmCFeM+5ZKaORpQjQYg LPZor5kh+YcYjhg9N2TWAM/E1BFDB9lLg1BejoYYTA== X-Google-Smtp-Source: ABdhPJz6pC1tXOpsIpPdanfPHNgJKYuJ24mheM1Ripgovr1LROfuOCg8D4UZcSeWreJVM/O85k/+pohT+por/StU1Es= X-Received: by 2002:a4a:b6c5:: with SMTP id w5mr152969ooo.89.1596058467438; Wed, 29 Jul 2020 14:34:27 -0700 (PDT) MIME-Version: 1.0 References: <1596046674-29155-1-git-send-email-hyun.kwon@xilinx.com> In-Reply-To: <1596046674-29155-1-git-send-email-hyun.kwon@xilinx.com> From: Daniel Vetter Date: Wed, 29 Jul 2020 23:34:16 +0200 Message-ID: Subject: Re: [PATCH 1/1] drm: xlnx: zynqmp: Stop the loop at lowest link rate without check To: Hyun Kwon X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Dan Carpenter , Laurent Pinchart , dri-devel Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" On Wed, Jul 29, 2020 at 8:21 PM Hyun Kwon wrote: > > The loop should exit at the lowest link rate, so break the loop > at the lowest link rate without check. The check is always true > because lowest link rate is smaller than current one and maximum > of current display. Otherwise, it may be seen as the loop can > potentially result in negative array offset. > > The patch d76271d22694: "drm: xlnx: DRM/KMS driver for Xilinx ZynqMP > DisplayPort Subsystem" from Jul 7, 2018, leads to the following > static checker warning: > > drivers/gpu/drm/xlnx/zynqmp_dp.c:594 zynqmp_dp_mode_configure() > error: iterator underflow 'bws' (-1)-2 > > Reported-by: Dan Carpenter > Signed-off-by: Hyun Kwon > --- > drivers/gpu/drm/xlnx/zynqmp_dp.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/xlnx/zynqmp_dp.c b/drivers/gpu/drm/xlnx/zynqmp_dp.c > index b735072..1be2b19 100644 > --- a/drivers/gpu/drm/xlnx/zynqmp_dp.c > +++ b/drivers/gpu/drm/xlnx/zynqmp_dp.c > @@ -579,7 +579,7 @@ static int zynqmp_dp_mode_configure(struct zynqmp_dp *dp, int pclock, > return -EINVAL; > } > > - for (i = ARRAY_SIZE(bws) - 1; i >= 0; i--) { > + for (i = ARRAY_SIZE(bws) - 1; i > 0; i--) { But now we don't go through the lowest element anymore, which also looks wrong. Or I'm blind. I think the problem is later on that we should bail out of the loop on the last iteration (when i == 0) before we decrement, since otherwise we then look at bws[-1] in the next loop, which is clearly wrong. I guess your code results in the same, but it's very confusing logic for me ... -Daniel > if (current_bw && bws[i] >= current_bw) > continue; > > -- > 2.7.4 > > _______________________________________________ > 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