From patchwork Mon Mar 22 16:02:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 406166 Delivered-To: patch@linaro.org Received: by 2002:a17:906:5290:0:0:0:0 with SMTP id c16csp1348550ejm; Mon, 22 Mar 2021 09:05:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx8zUjMiCM+nAIQ1PuvzcsZogeLTL4xtyRYQqfLxOfzrnF0hI3OwGSqJ21QXhIEuoam6s0z X-Received: by 2002:a62:4c1:0:b029:1ee:70e1:75c1 with SMTP id 184-20020a6204c10000b02901ee70e175c1mr602017pfe.23.1616429134971; Mon, 22 Mar 2021 09:05:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616429134; cv=none; d=google.com; s=arc-20160816; b=TxFtzK55qiUQ1AKwy0a0rB1rqcJBRO3SzZwp2TMZ90prTUPmKlexHK9EMsNvZPHCf5 4iIUFit1atz3H1R/pCjfU0qqNx/FIGKQVoRjsYbvPO27J2Tgllyby/iz9EJXOejBc07t gIYcSeu1pJF71G2If4JZ19bn3xBailpxA9YvOuZHPt0SFScPEQx3EoeUYoSSUsXb00fO E6nezVNY6YwO+97hdIOIhjan9oqD96zNx7fQ51nYCJlqWEPyf7Fr9BnOzMvygW7ntBvA L6iEVy0w8iXAErfrC1VGM9uzUy2Ax9HNqvrWXAQiPOgjBxTUauvv2n2Yn/2+2INMD8i0 hGTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:mime-version:references:in-reply-to:message-id:date :subject:to:from:dkim-signature:delivered-to; bh=tHTEUdB1pUN2gsdd0T3EHGf2YiuQXrzy8nalwlY+pOU=; b=fhrw4iMQW6jEa5Q1zNyRcdhhFxuXVqVU0ZhdAcracNEZeCNC1xZi27JitTxxCp6kZ1 zDWu/rRFuHqWtPrtsJ9+OIW3O3b49SjIPV6JBTtoFGMA7mfa6aJGAT29zBlbyqqQ9EPp TkXkPk6ME9xCdthpddd+kVXvyLAzdjaAp1O1HtlavrIP3zcOWPSz5SjqlTTPhUGoOwAn 7Jdja2Ymn1Km8BssGXJv/MWMUpNEtuzGTCp+iFYhW/8htfYLVrNYVF3rMUkJKYULORcy tWwXlaudaYx2kHF3mbb8nKDXTJMWiM48Tq8MOdZot4sJGngWKbKJVbJcMfZPXOqW7XwI J1pQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@kernel.org header.s=k20201202 header.b=YmX1KQkI; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTPS id t14si14901202pgv.180.2021.03.22.09.05.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Mar 2021 09:05:34 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) client-ip=131.252.210.177; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@kernel.org header.s=k20201202 header.b=YmX1KQkI; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D10076E508; Mon, 22 Mar 2021 16:05:33 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by gabe.freedesktop.org (Postfix) with ESMTPS id B37206E508; Mon, 22 Mar 2021 16:05:32 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id 9E526619B3; Mon, 22 Mar 2021 16:05:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1616429130; bh=Cz6Ib/Jy2MCBRG3RkrW7YxIgzj/6kEv+v4DuuyruVdM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YmX1KQkIWDTM9oL9SIaizhQuXBgId2TgjaOHRvpRa8ujB1Hj1aOwCgrCrMNJVi2gq P8VgokfOwAmfnYZLX1rsRk4pLvkeDX2bspNuX1VYi25/JXoxXtnn7F2MgFWC0FsAFu N+uQuJ3Me21QeU0KrCs4aFbaBIGeJwlctHwPj1pA51MBMY2ra+UvbFh+zl+P+BsSj9 1ElKemq6Wxa1TUdo/FGf/LywTMYZxZt3573Q+qI3GKdCXVd48krzSZHquQETNI++01 tCB8r6B7NO2iohCFFlGopnfYJGFYOD5rOpt+nJhCejnPW+cx72ztkTHm7tbHkrEoPf S1/KeKBMSo8Ag== From: Arnd Bergmann To: linux-kernel@vger.kernel.org, Martin Sebor , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , David Airlie , Daniel Vetter Subject: [PATCH 10/11] drm/i915: avoid stringop-overread warning on pri_latency Date: Mon, 22 Mar 2021 17:02:48 +0100 Message-Id: <20210322160253.4032422-11-arnd@kernel.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210322160253.4032422-1-arnd@kernel.org> References: <20210322160253.4032422-1-arnd@kernel.org> MIME-Version: 1.0 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: dri-devel@lists.freedesktop.org, Chris Wilson , linux-scsi@vger.kernel.org, x86@kernel.org, James Smart , tboot-devel@lists.sourceforge.net, Kalle Valo , ath11k@lists.infradead.org, Serge Hallyn , Arnd Bergmann , "James E.J. Bottomley" , Ning Sun , Anders Larsen , =?utf-8?q?Jos=C3=A9_Roberto_de_Souza?= , cgroups@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Aditya Swarup , netdev@vger.kernel.org, linux-wireless@vger.kernel.org, linux-security-module@vger.kernel.org, Tejun Heo , Simon Kelley , intel-gfx@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Arnd Bergmann gcc-11 warns about what appears to be an out-of-range array access: In function ‘snb_wm_latency_quirk’, inlined from ‘ilk_setup_wm_latency’ at drivers/gpu/drm/i915/intel_pm.c:3108:3: drivers/gpu/drm/i915/intel_pm.c:3057:9: error: ‘intel_print_wm_latency’ reading 16 bytes from a region of size 10 [-Werror=stringop-overread] 3057 | intel_print_wm_latency(dev_priv, "Primary", dev_priv->wm.pri_latency); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/gpu/drm/i915/intel_pm.c: In function ‘ilk_setup_wm_latency’: drivers/gpu/drm/i915/intel_pm.c:3057:9: note: referencing argument 3 of type ‘const u16 *’ {aka ‘const short unsigned int *’} drivers/gpu/drm/i915/intel_pm.c:2994:13: note: in a call to function ‘intel_print_wm_latency’ 2994 | static void intel_print_wm_latency(struct drm_i915_private *dev_priv, | ^~~~~~~~~~~~~~~~~~~~~~ My guess is that this code is actually safe because the size of the array depends on the hardware generation, and the function checks for that, but at the same time I would not expect the compiler to work it out correctly, and the code seems a little fragile with regards to future changes. Simply increasing the size of the array should help. Signed-off-by: Arnd Bergmann Reviewed-by: Jani Nikula --- drivers/gpu/drm/i915/i915_drv.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index 26d69d06aa6d..3567602e0a35 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -1095,11 +1095,11 @@ struct drm_i915_private { * in 0.5us units for WM1+. */ /* primary */ - u16 pri_latency[5]; + u16 pri_latency[8]; /* sprite */ - u16 spr_latency[5]; + u16 spr_latency[8]; /* cursor */ - u16 cur_latency[5]; + u16 cur_latency[8]; /* * Raw watermark memory latency values * for SKL for all 8 levels