From patchwork Tue Nov 24 07:39:28 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen-Yu Tsai X-Patchwork-Id: 522 Return-Path: X-Original-To: noreply@patchwork.local Delivered-To: noreply@patchwork.local Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mxe881.netcup.net (Postfix) with ESMTPS id 107C81C87CD for ; Tue, 24 Nov 2026 08:41:00 +0100 (CET) Authentication-Results: mxe881; dkim=pass header.d=chromium.org; spf=pass (sender IP is 172.234.253.10) smtp.mailfrom=linux-sunxi+bounces-28077-noreply=patchwork.local@lists.linux.dev smtp.helo=sea.lore.kernel.org Received-SPF: pass (mxe881: domain of lists.linux.dev designates 172.234.253.10 as permitted sender) client-ip=172.234.253.10; envelope-from=linux-sunxi+bounces-28077-noreply=patchwork.local@lists.linux.dev; helo=sea.lore.kernel.org; Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id BB28C28B60 for ; Tue, 24 Nov 2026 07:40:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1795506055; b=1fqZqTUKT9M12ZIBDCPSld4q65aOROT0+xFa0Qle8C90NdWGgYDDs2MGousCDO3Nr8uc FYhYMsAPlUWgG9h6V8Ji3dodkUokJ9CeNE8smZ9QLa6UiTx71anpJ8w5/NzPMYYbS7Rvx 0KVo0IoggOG5VvwAabMl7+E46fJoTLiV5qv0PDDrYU4GiwPS3Ev+Us9bNVie5lqCdeKAQ obVc8VMcrhGzIwk7GHSKcByLGJ1Ipo0Fp9FTCPRkN3mLQc7E9Tj0gfzrSQ9DU1fY8pDQt BZWvcs3Zszvg2Q+jZCaAXOoSyjT3cK6EvreqcBf2ARNAZbSoXHvQnbyQ7dFewcyIk5w== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795506055; h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature: X-Google-DKIM-Signature:X-Forwarded-Encrypted:X-Gm-Message-State: X-Gm-Gg:X-Received:Received:From:To:Cc:Subject:Date:Message-ID: X-Mailer:X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe: List-Unsubscribe:List-Owner:Precedence:MIME-Version: Content-Transfer-Encoding; bh=yq9KtC/Vr6jX4nQrqLEI9ETBwLEZhdEPTg6w69t4M3Q=; b=trgUL4QzSjyEi0IQdjWCrYogFF3swhVNeOqvaxbMLhuVq0lXxEZe/SLDKkdihBMLcXfY 9zztgWOGGK4BvCleRGX/NO4RmZAKltgR3X3OuJEhYwFPuETAWrS8sx7+I8dEHVfcDG6l1 lPahMw3/e7Gg/p48t5n09cqd/RO4Mc5Noi5cGYPkqQo5Svp5y2Zxgk8OQIMB7g1WXJE7h zu0Y9N9/HSQkjj9H866QcZJCG8tHxUPVEnKN+H/bth2LJccd/+dIOsL1q0fxIAMfxrAN2 49MWIgHbGOaasM8FZgvK1n8TZr0/s6lmY3sqjeB8RfOxV6roT8YpG/502yDc+FY9Ixw== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=irIQYn8I; dmarc=pass header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 80D91606A331; Tue, 24 Nov 2026 07:40:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=irIQYn8I X-Original-To: linux-sunxi@lists.linux.dev Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.216.47 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795506055; b=2ccJLKoeziMysvLS+Chzk51vOgNlaLVUcXMNm3iPBgHJBYX7CPv7Lhitu0KwN1jzeyd0 RsHEfNIQGj2j+4P4BMHe9HmzA4w0WFOlq7hvbVGbOa4FIhS/HTrRrqsDPO3usGu7z688O 4iUbLUPJ/fIh+3Q38V7lX6v+4bHVTjzs1PVyp/ns9eePs/X05t2T1yS3AejFXKv9FOB8Y wUtG1sRaSvgiFbqS5qKaYaWTaJcrScod7njLnjRV7b+syBzXBiT7Lh1Wyy9JZPA5sY4PE 5+cIakqIZkPK70sPfbouCe4ZktNmWqimh3g2HqMtagnqYqOP4wLdQmK0a5ZtXI3jV1w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795506055; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:MIME-Version: Content-Transfer-Encoding; bh=yq9KtC/Vr6jX4nQrqLEI9ETBwLEZhdEPTg6w69t4M3Q=; b=blOwP0U9tfdVrErmd3Q2PBMENGgMl9qMjoNYb4iwdjRklGKUM5zHAugLVQJS8hIUp+v5 1dcXG8BWXVDaOddmyi71+krTyfg0+REHkMyuOshOobqKo/EQtpIlRUZ7e7QgHDu9Viyvw Ek8ctmSrZ6Fdy2JTNl3PTSEK2nO9g/YZSsTcXFX/Z2hFcWrDYrLpPQfrZjKmiE0a1saJL PKs2I8H+Tx3FOHkHmbsLu9xcoGZPWo+S1B20svGIDg5XNGmAIU1Ihyt+hxPD5mAEGYSI7 D6eG+Xlkx6oEwVaa07a1N5MfVGzG+R5g4GbQlAa6n+lFu9dU/5A45wqWuqxtTRMFKgg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=irIQYn8I; arc=none smtp.remote-ip=209.85.216.47 Received: from mail-pj1-f47.google.com (mail-pj1-f47.google.com [209.85.216.47]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5BE20606A321 for ; Tue, 24 Nov 2026 07:40:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 5BE20606A321 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-pj1-f47.google.com with SMTP id 98e67ed59e1d1-3b08cf16decso2441752a91.0 for ; Mon, 23 Nov 2026 23:40:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1795506054; x=1796110854; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=yq9KtC/Vr6jX4nQrqLEI9ETBwLEZhdEPTg6w69t4M3Q=; b=irIQYn8IHaHV3ZhOkzpXNyvE7Yf4yoUelb9AvSpWnCuCVa7B0o8wX6CTkkOvA9yguJ ywmHrCCrZe+QORLvOS1EU1gs5t3Z7aawcm4L0S7w/1uYvWJvipv7nA1p2dCrcMTs9Sou 58y9dwtICmZ1WR2CjsV/aIXUVFIDR72WufNL4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795506054; x=1796110854; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=yq9KtC/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Gn7dpHf0cHHFUjZd X84iB4wjLRX0etwsIy5tzJEaAm6OTAL+N5osm2Bq6uHCFGuSWsIwBWAavkl+rioSuJRfdrhS5go CkJ3ztILymhohShX4qXqT/vjD2M6adHvAKk4hM5H94l8X7V97LlRJd3rzILm9rKJPb3tkt+o+pW xwS58mPlaeRB9/tIDhTXhLOSdufaberW5qkwP1toa/fl/utpzToHfwg67KEz X-Received: by 2002:a17:90b:5289:b0:3b3:8094:321d with SMTP id 98e67ed59e1d1-3b41c9080bamr13617140a91.32.1795506053661; Mon, 23 Nov 2026 23:40:53 -0800 (PST) Received: from localhost ([2a00:79e0:203d:7:8f32:8910:4727:ea03]) by smtp.gmail.com with UTF8SMTPSA id 41be03b00d2f7-cde84cd5ed8sm3771777a12.10.2026.11.23.23.40.50 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 23 Nov 2026 23:40:53 -0800 (PST) From: Chen-Yu Tsai To: Liu Ying , Laurentiu Palcu , Lucas Stach , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann Cc: Chen-Yu Tsai , David Airlie , Simona Vetter , linux-sunxi@lists.linux.dev, imx@lists.linux.dev, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH RFT v3 0/5] drm: Add and use drm_fb_dma_get_gem_clipped_addr() helper Date: Tue, 24 Nov 2026 15:39:28 +0800 Message-ID: <20261124074041.115251-1-wenst@chromium.org> X-Mailer: git-send-email 2.56.1.809.ga0b61035b5-goog X-Mailing-List: linux-sunxi@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 X-Rspamd-Server: rspamd-worker-8404 X-Spamd-Result: default: False [4.31 / 15.00]; RBL_SENDERSCORE(2.00)[172.234.253.10:from]; MID_CONTAINS_FROM(1.00)[]; DMARC_POLICY_SOFTFAIL(1.00)[chromium.org : SPF not aligned (relaxed), No valid DKIM,none]; R_MISSING_CHARSET(0.50)[]; MAILLIST(-0.18)[generic]; MIME_GOOD(-0.10)[text/plain]; BAD_REP_POLICIES(0.10)[]; HAS_LIST_UNSUB(-0.01)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[sea.lore.kernel.org:helo,sea.lore.kernel.org:rdns]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_TWELVE(0.00)[17]; FREEMAIL_CC(0.00)[chromium.org,gmail.com,ffwll.ch,lists.linux.dev,lists.freedesktop.org,lists.infradead.org,vger.kernel.org]; RCVD_COUNT_FIVE(0.00)[6]; FROM_NEQ_ENVFROM(0.00)[wenst@chromium.org,linux-sunxi@lists.linux.dev]; ARC_ALLOW(0.00)[subspace.kernel.org:s=arc20261015:i=2]; R_SPF_ALLOW(0.00)[+ip4:172.234.253.10]; TO_DN_SOME(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a00:79e0:203d:7:8f32:8910:4727:ea03:received,209.85.216.47:received,100.77.114.92:received]; FORGED_SENDER_MAILLIST(0.00)[]; FORGED_RECIPIENTS_MAILLIST(0.00)[]; RCVD_TLS_LAST(0.00)[]; MIME_TRACE(0.00)[0:+]; TAGGED_FROM(0.00)[bounces-28077-noreply=patchwork.local]; ASN(0.00)[asn:63949, ipnet:172.234.224.0/19, country:SG]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[172.234.253.10:from] X-Rspamd-Queue-Id: 107C81C87CD X-MORS-Enabled: yes X-MORS-DOMAIN: patchwork.local X-MORS-HOSTING: hosting172546 X-MORS-USER: hosting172546 X-getmail-retrieved-from-mailbox: INBOX Hi, This is v3 of my drm_fb_dma_get_gem_clipped_addr() series. Changes since v2: - Change drm_framebuffer_get_block_offset() offset variable and return type to u64, and use mul_u32_u32() to avoid 32-bit overflow (Thomas) Changes since v1: - Add and use new drm_framebuffer_get_block_offset() helper (Thomas) This series adds a helper to retrieve the buffer starting address of a "clipped" framebuffer. This contrasts with drm_fb_dma_get_gem_addr(), which gives the address of the full buffer. Some drivers program their hardware with clipped dimensions, so they should be using the clipped buffer address as well, unless the hardware can advance the scanout directly. (Side note: many drivers still use the non-clipped dimensions.) While at it, also pull out the offset calculation of drm_fb_dma_get_gem_addr() into a separate helper in drm_framebuffer.[ch], thereby separating responsibilities. The sun4i driver was recently incorrectly converted to use the unclipped drm_fb_dma_get_gem_addr() helper. This broke offsets into subsampled pixel groups, but also exposed the mismatch between the dimensions used vs the buffer address. Two other drivers were also touched. Patch 1 adds a new helper to return the byte offset into a framebuffer for the start of the pixel block of the given pixel coordinates. Patch 2 adds the new helper to return the buffer address based on clipped coordinates. Patch 3 switches the sun4i driver to the new helper, and fixes the luma plane buffer address offset for subsampled YUV formats. Patch 4 converts the imx/dc driver to use the new helper. This fixes a mismatch between the programmed coordinates and the buffer address. Patch 5 replaces the open coded buffer address calculation in the imx/dcss driver with the new helper. Existing behavior, which might be wrong, is preserved. Please help test. The series is only compile tested on my end. The sun4i changes should revert its behavior to before the drm_fb_dma_get_gem_addr() helper was adopted. The imx/dcss changes should not have any behavioral difference. Thanks ChenYu Chen-Yu Tsai (5): drm: Split framebuffer pixel offset calculation from drm_fb_dma_get_gem_addr() drm/fb-dma-helper: Add drm_fb_dma_get_gem_clipped_addr() drm/sun4i: layers: Fix VI buffer address for clipped offsets drm/imx/dc: plane: Switch to drm_fb_dma_get_gem_clipped_addr() drm/imx/dcss: plane: Switch to drm_fb_dma_get_gem_clipped_addr() drivers/gpu/drm/drm_fb_dma_helper.c | 61 ++++++++++++++------------ drivers/gpu/drm/drm_framebuffer.c | 46 +++++++++++++++++++ drivers/gpu/drm/imx/dc/dc-plane.c | 4 +- drivers/gpu/drm/imx/dcss/dcss-plane.c | 34 ++++++-------- drivers/gpu/drm/sun4i/sun8i_ui_layer.c | 2 +- drivers/gpu/drm/sun4i/sun8i_vi_layer.c | 16 ++++++- include/drm/drm_fb_dma_helper.h | 4 ++ include/drm/drm_framebuffer.h | 3 ++ 8 files changed, 119 insertions(+), 51 deletions(-)