From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B0C7C4749F5 for ; Tue, 4 Aug 2026 16:25:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785860721; cv=none; b=b9SJQFlNGnx+hDpn0RwkyOLsgO8Ri/+SNs0x0TEJcego4J0Pkj3DdkvM4hpL0pWo1k5IBcOzp0l/cYs386zQNOknifUQVuaTI/FgAmcq4APjDvIZTkI9WTa2fAY5yBahVkNfm6Um0B1AEA6bI/AhpEF9JiQafWbt3mMAzDcQAO0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785860721; c=relaxed/simple; bh=NAlE9xuWd+CbhPN4mDk9UF/4pM/OLyUdtNaqoUxbFuo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=uiSUK8srTpY6FPtOfg0yPCdzccRPlBDKIX6oPZYd/cj+6PnXRKmeX0tizoB2ST39kOyaCA00QW/NW1XzdWqHFnsj3g8pAWhuGId4R5VQI5NzhtxmGBb1wmVtEiGyIP+Wl1jVfCFp7EpQUR057b4rUBaz8SaZrurPD662y71TlOE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=MjRd4qEb; arc=none smtp.client-ip=209.85.128.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="MjRd4qEb" Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-4953de5be0aso60035e9.0 for ; Tue, 04 Aug 2026 09:25:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1785860709; x=1786465509; darn=vger.kernel.org; h=content-type:content-transfer-encoding:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=9gYefvAyqnzn8QAHjERbxmBW19GFjgq4+owbZqEl8b0=; b=MjRd4qEbbVEWYT9Gy+MuWzLapxxAguJfVpHDxyUtzKDUQcHNuX2GsFVRc5sAbqKTYC qjNTo8aFEWeKmwLq8vQ6NbNjxZ5yZFnLvpfeAcyPbTFS/RboT0bEGWW/iQOGzF3avkMX TWNQg7ZppVp00P/NPqUg8MgqPJOfQAyPif54Q7u2qo9fEFfdnsMgAn78agAvNbgWCNJ5 BGoYzkpcmFZKYK5fJgcvtkiFW+Y8r8EaP3zvXuBoMpz2V5GZselXBO/fPrLd8gBBJOgP RfI33wEUT0Na1J2jTiCF4WCKLWNq3oIjQXvQaGHZlT+Zi4kNUZi4OMolPhztYci0ZYEM BXAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785860709; x=1786465509; h=content-type:content-transfer-encoding:mime-version:references :in-reply-to: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=9gYefvAyqnzn8QAHjERbxmBW19GFjgq4+owbZqEl8b0=; b=MTUISuL29PnubsS77G74cxCtQZ1FdThKaxs7QN3qDGRd4DJeJWfQ3783ovHQVE5X2A TLLs8/uaBcCfYQ1CJP7lBgpoZH3EYthvIm6g9FV2wUX/3JzeCViNMhzEaFAfKbFypt4P j6AUtAtrBmwVeeDxfV6BuixE/QdnR9Xo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+qRvkwJXc90b8nQJO6gTPKdNMwQYNyBhsz GAP0ZEz4MqGVqF1U8jTwwl3h8mM5XP1NvI348rzgJfNL4gi6bvnP1eSRgT4rV6NdAdiVNN+Je/A A4RItVDF5RVIvbtw== X-Received: by 2002:a05:600d:8492:b0:496:c9cd:e7ab with SMTP id 5b1f17b1804b1-4980c64b873mr280626065e9.5.1785860708981; Tue, 04 Aug 2026 09:25:08 -0700 (PDT) Received: from jernej-laptop.localnet (APN-122-102-118-gprs.simobil.net. [46.122.102.118]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-47fec249a5fsm897076f8f.33.2026.08.04.09.25.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Aug 2026 09:25:08 -0700 (PDT) From: Jernej =?UTF-8?B?xaBrcmFiZWM=?= To: wens@kernel.org Cc: maarten.lankhorst@linux.intel.com, mripard@kernel.org, tzimmermann@suse.de, airlied@gmail.com, simona@ffwll.ch, samuel@sholland.org, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org Subject: Re: [PATCH 13/13] drm/sun4i: Align VI buffer addresses for subsampled formats Date: Tue, 04 Aug 2026 18:25:06 +0200 Message-ID: In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Dne torek, 4. avgust 2026 ob 13:14:38 Srednjeevropski poletni =C4=8Das je C= hen-Yu Tsai napisal(a): > On Tue, Aug 4, 2026 at 1:25=E2=80=AFAM Chen-Yu Tsai wro= te: > > > > On Tue, Aug 4, 2026 at 12:11=E2=80=AFAM Jernej Skrabec wrote: > > > > > > This is a partial revert of commit 79ac1c945ab8 ("drm/sun4i: layers: > > > Use drm_fb_dma_get_gem_addr() to get display memory"). > > > > > > Chroma must start at the beginning of a subsampling block, for example > > > chroma start address for NV12 must be aligned to 2 pixels. > > > drm_fb_dma_get_gem_addr() offsets luma by the exact source coordinates > > > and chroma by the coordinates divided by the subsampling factor, so f= or > > > odd offsets both planes no longer describe the same pixel, which the > > > Display Engine scaler can't handle. > > > > > > Align source coordinates down for all planes instead. Remaining shift > > > of one pixel is already compensated with scaler phase shift in > > > sun8i_vi_layer_update_coord(). > > > > Well I think this applies to the format in general, and probably should > > be fixed in drm_fb_dma_get_gem_addr() instead? > > > > > Fixes: 79ac1c945ab8 ("drm/sun4i: layers: Use drm_fb_dma_get_gem_addr(= ) to get display memory") > > > Signed-off-by: Jernej Skrabec > > > --- > > > drivers/gpu/drm/sun4i/sun8i_vi_layer.c | 20 ++++++++++++++++++-- > > > 1 file changed, 18 insertions(+), 2 deletions(-) > > > > > > diff --git a/drivers/gpu/drm/sun4i/sun8i_vi_layer.c b/drivers/gpu/drm= /sun4i/sun8i_vi_layer.c > > > index 09f668c8af24..ad036cb9d88e 100644 > > > --- a/drivers/gpu/drm/sun4i/sun8i_vi_layer.c > > > +++ b/drivers/gpu/drm/sun4i/sun8i_vi_layer.c > > > @@ -197,15 +197,31 @@ static void sun8i_vi_layer_update_buffer(struct= sun8i_layer *layer, > > > struct drm_plane_state *state =3D plane->state; > > > struct drm_framebuffer *fb =3D state->fb; > > > const struct drm_format_info *format =3D fb->format; > > > + struct drm_gem_dma_object *gem; > > > + u32 dx, dy, src_x, src_y; > > > dma_addr_t dma_addr; > > > u32 ch_base; > > > int i; > > > > > > ch_base =3D sun8i_channel_base(layer); > > > > > > + /* Adjust x and y to be divisible by subsampling factor */ > > > + src_x =3D (state->src.x1 >> 16) & ~(format->hsub - 1); > > > + src_y =3D (state->src.y1 >> 16) & ~(format->vsub - 1); > > > > AFAICT the only difference compared to drm_fb_dma_get_gem_addr() > > is the masking here, i.e. round_down(). > > > > > + > > > for (i =3D 0; i < format->num_planes; i++) { > > > - /* Get the start of the displayed memory */ > > > - dma_addr =3D drm_fb_dma_get_gem_addr(fb, state, i); > > > + gem =3D drm_fb_dma_get_gem_obj(fb, i); > > > + dma_addr =3D gem->dma_addr + fb->offsets[i]; > > > + > > > + dx =3D src_x; > > > + dy =3D src_y; > > > + if (i > 0) { > > > + dx /=3D format->hsub; > > > + dy /=3D format->vsub; > > > + } > > > + > > > + dma_addr +=3D dx * format->cpp[i]; > > > + dma_addr +=3D dy * fb->pitches[i]; > > > > > > Where as the helper has (or used to have before the blocksize stuff): > > > > paddr +=3D (format->cpp[plane] * (state->src_x >> 16)) / fb->format= =2D>hsub; > > paddr +=3D (fb->pitches[plane] * (state->src_y >> 16)) / fb->format= =2D>vsub; > > > > Am I missing something? >=20 > After some headbanging on my end I see that the offset for the Y plane > needs to be rounded down. >=20 > But instead of reverting the whole thing and open-coding the helper > again, could you adjust the address returned by the helper for odd > offsets? Yes, that's also an option. I'll do it in v2. >=20 > And just a heads up, this also needs a clipped version of > drm_fb_dma_get_gem_addr() as sun8i_ui_layer_update_coord() uses the > clipped dimensions. I am currently working on this part. Can you explain a bit more? I don't see why it needs any adjustement. Best regards, Jernej >=20 >=20 > ChenYu >=20 > > > > > > /* Set the line width */ > > > DRM_DEBUG_DRIVER("Layer %d. line width: %d bytes\n", > > > -- > > > 2.43.0 > > > >=20