From patchwork Mon Oct 30 01:28:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Airlie X-Patchwork-Id: 13439955 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 48AA6C4167D for ; Mon, 30 Oct 2023 01:35:08 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5C37E10E1F7; Mon, 30 Oct 2023 01:35:07 +0000 (UTC) X-Greylist: delayed 401 seconds by postgrey-1.36 at gabe; Mon, 30 Oct 2023 01:35:04 UTC Received: from us-smtp-delivery-44.mimecast.com (us-smtp-delivery-44.mimecast.com [205.139.111.44]) by gabe.freedesktop.org (Postfix) with ESMTPS id 94BCE10E1F6 for ; Mon, 30 Oct 2023 01:35:04 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-433-_0nseZbpMru7Y0OBKPpVGQ-1; Sun, 29 Oct 2023 21:28:17 -0400 X-MC-Unique: _0nseZbpMru7Y0OBKPpVGQ-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 027181C05149; Mon, 30 Oct 2023 01:28:17 +0000 (UTC) Received: from dreadlord.redhat.com (unknown [10.64.136.133]) by smtp.corp.redhat.com (Postfix) with ESMTP id 03120492BE0; Mon, 30 Oct 2023 01:28:15 +0000 (UTC) From: Dave Airlie To: dri-devel@lists.freedesktop.org Subject: [PATCH 1/2] nouveau: fix r535 build on 32-bit arm. Date: Mon, 30 Oct 2023 11:28:12 +1000 Message-ID: <20231030012814.1208972-1-airlied@gmail.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: gmail.com 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: nouveau@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Dave Airlie This needs the proper division macros. Signed-off-by: Dave Airlie Reviewed-by: Danilo Krummrich --- drivers/gpu/drm/nouveau/nvkm/engine/fifo/r535.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/r535.c b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/r535.c index 14a67cf96204..0f9b8087d5e6 100644 --- a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/r535.c +++ b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/r535.c @@ -267,7 +267,7 @@ r535_chan_id_get_locked(struct nvkm_chan *chan, struct nvkm_memory *muserd, u64 return -EINVAL; } - chid = ouserd / chan->func->userd->size; + chid = div_u64(ouserd, chan->func->userd->size); list_for_each_entry(userd, &fifo->userd.list, head) { if (userd->mem == muserd) { From patchwork Mon Oct 30 01:28:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Airlie X-Patchwork-Id: 13439954 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id A0285C4332F for ; Mon, 30 Oct 2023 01:34:54 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5A44910E068; Mon, 30 Oct 2023 01:34:50 +0000 (UTC) X-Greylist: delayed 378 seconds by postgrey-1.36 at gabe; Mon, 30 Oct 2023 01:34:47 UTC Received: from us-smtp-delivery-44.mimecast.com (unknown [207.211.30.44]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4AEB910E068 for ; Mon, 30 Oct 2023 01:34:47 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-508-Xy9NjHctMKqDh59Y5P5M3w-1; Sun, 29 Oct 2023 21:28:18 -0400 X-MC-Unique: Xy9NjHctMKqDh59Y5P5M3w-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7771C3827965; Mon, 30 Oct 2023 01:28:18 +0000 (UTC) Received: from dreadlord.redhat.com (unknown [10.64.136.133]) by smtp.corp.redhat.com (Postfix) with ESMTP id 788EC492BE0; Mon, 30 Oct 2023 01:28:17 +0000 (UTC) From: Dave Airlie To: dri-devel@lists.freedesktop.org Subject: [PATCH 2/2] nouveau/disp: fix post-gsp build on 32-bit arm. Date: Mon, 30 Oct 2023 11:28:13 +1000 Message-ID: <20231030012814.1208972-2-airlied@gmail.com> In-Reply-To: <20231030012814.1208972-1-airlied@gmail.com> References: <20231030012814.1208972-1-airlied@gmail.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: gmail.com 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: nouveau@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Dave Airlie This converts a bunch of divides into the proper macros. Signed-off-by: Dave Airlie Reviewed-by: Danilo Krummrich --- drivers/gpu/drm/nouveau/dispnv50/disp.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/nouveau/dispnv50/disp.c b/drivers/gpu/drm/nouveau/dispnv50/disp.c index d2be40337b92..7840b6428afb 100644 --- a/drivers/gpu/drm/nouveau/dispnv50/disp.c +++ b/drivers/gpu/drm/nouveau/dispnv50/disp.c @@ -1644,7 +1644,7 @@ nv50_sor_dp_watermark_sst(struct nouveau_encoder *outp, // 0 active symbols. This may cause HW hang. Bug 200379426 // if ((bEnableDsc) && - ((pixelClockHz * depth) < ((8 * minRate * outp->dp.link_nr * DSC_FACTOR) / 64))) + ((pixelClockHz * depth) < div_u64(8 * minRate * outp->dp.link_nr * DSC_FACTOR, 64))) { return false; } @@ -1654,20 +1654,20 @@ nv50_sor_dp_watermark_sst(struct nouveau_encoder *outp, // For auto mode the watermark calculation does not need to track accumulated error the // formulas for manual mode will not work. So below calculation was extracted from the DTB. // - ratioF = ((u64)pixelClockHz * depth * PrecisionFactor) / DSC_FACTOR; + ratioF = div_u64((u64)pixelClockHz * depth * PrecisionFactor, DSC_FACTOR); - ratioF /= 8 * (u64) minRate * outp->dp.link_nr; + ratioF = div_u64(ratioF, 8 * (u64) minRate * outp->dp.link_nr); if (PrecisionFactor < ratioF) // Assert if we will end up with a negative number in below return false; - watermarkF = ratioF * tuSize * (PrecisionFactor - ratioF) / PrecisionFactor; - waterMark = (unsigned)(watermarkAdjust + ((2 * (depth * PrecisionFactor / (8 * numLanesPerLink * DSC_FACTOR)) + watermarkF) / PrecisionFactor)); + watermarkF = div_u64(ratioF * tuSize * (PrecisionFactor - ratioF), PrecisionFactor); + waterMark = (unsigned)(watermarkAdjust + (div_u64(2 * div_u64(depth * PrecisionFactor, 8 * numLanesPerLink * DSC_FACTOR) + watermarkF, PrecisionFactor))); // // Bounds check the watermark // - numSymbolsPerLine = (surfaceWidth * depth) / (8 * outp->dp.link_nr * DSC_FACTOR); + numSymbolsPerLine = div_u64(surfaceWidth * depth, 8 * outp->dp.link_nr * DSC_FACTOR); if (WARN_ON(waterMark > 39 || waterMark > numSymbolsPerLine)) return false; @@ -1688,11 +1688,13 @@ nv50_sor_dp_watermark_sst(struct nouveau_encoder *outp, surfaceWidthPerLink = surfaceWidth; //Extra bits sent due to pixel steering - PixelSteeringBits = (surfaceWidthPerLink % numLanesPerLink) ? (((numLanesPerLink - surfaceWidthPerLink % numLanesPerLink) * depth) / DSC_FACTOR) : 0; + u32 remain; + div_u64_rem(surfaceWidthPerLink, numLanesPerLink, &remain); + PixelSteeringBits = remain ? div_u64((numLanesPerLink - remain) * depth, DSC_FACTOR) : 0; BlankingBits += PixelSteeringBits; - NumBlankingLinkClocks = (u64)BlankingBits * PrecisionFactor / (8 * numLanesPerLink); - MinHBlank = (u32)(NumBlankingLinkClocks * pixelClockHz/ minRate / PrecisionFactor); + NumBlankingLinkClocks = div_u64((u64)BlankingBits * PrecisionFactor, (8 * numLanesPerLink)); + MinHBlank = (u32)(div_u64(div_u64(NumBlankingLinkClocks * pixelClockHz, minRate), PrecisionFactor)); MinHBlank += 12; if (WARN_ON(MinHBlank > rasterWidth - surfaceWidth)) @@ -1703,7 +1705,7 @@ nv50_sor_dp_watermark_sst(struct nouveau_encoder *outp, return false; - hblank_symbols = (s32)(((u64)(rasterWidth - surfaceWidth - MinHBlank) * minRate) / pixelClockHz); + hblank_symbols = (s32)(div_u64((u64)(rasterWidth - surfaceWidth - MinHBlank) * minRate, pixelClockHz)); //reduce HBlank Symbols to account for secondary data packet hblank_symbols -= 1; //Stuffer latency to send BS @@ -1722,7 +1724,7 @@ nv50_sor_dp_watermark_sst(struct nouveau_encoder *outp, } else { - vblank_symbols = (s32)(((u64)(surfaceWidth - 40) * minRate) / pixelClockHz) - 1; + vblank_symbols = (s32)((div_u64((u64)(surfaceWidth - 40) * minRate, pixelClockHz))) - 1; vblank_symbols -= numLanesPerLink == 1 ? 39 : numLanesPerLink == 2 ? 21 : 12; }