Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp8249500imu; Tue, 4 Dec 2018 05:32:27 -0800 (PST) X-Google-Smtp-Source: AFSGD/UeuNiW2k1Vr/JCbE/w9sMo8ncXu/DSimSkmB6Xya1riM9eVMZw1ngk3o3Z7wxQFimADbJP X-Received: by 2002:a17:902:12f:: with SMTP id 44mr2030695plb.74.1543930347864; Tue, 04 Dec 2018 05:32:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543930347; cv=none; d=google.com; s=arc-20160816; b=XsNysneNdo+JF6S0as7d4hbqhnqj6zMW2HXSydhRatZlezyG+Qspz9umb3XgYwnGUq /ax9kNYUD0XL++kt4TXOWCFdKQei5z/71BG8tKxoc+mhIwT4EGNiCqU0H5ZgCkv2PjDq Wu0/htYbsz5/7oZwvOeK1i/mhjHdPLdCV0kp3HPqI8XJt67T5DwhI9F57oik8Ek1FZ5j tF2Zg6WYNvZ02Lvk+BiWIXm6YGr06CxyKBHuyhsLEZRgKG/BxSGsOWvxji296RiGckOK VJITbNJHu/4dzvoS/X7RTC5CkmLmgzVM8tTF1l/wKJI3TAv3cunDdxVyM45Lge904hpo l5+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:organization:references:in-reply-to:date:cc:to:from :subject:message-id; bh=qh7MkYAIYicgivETqVtFtWSwRs4RFf3Z2z8tkZg7X8g=; b=lTyAmAofIVHjpJA9lCySd7p0bb5PyDvM/37TnSs0Q/3mceGaIKjpzkgvloszPNiwGZ CYwwlOh7rmgmLNG0bVHKWJAb50PQuDJuqNZRSps32cZ9Gde0uGZ8ediyjcMneR4oNxRB pnoaGzhIfDd/+T/1cuJtE/mAKpD9yiFbFfyUC2NEO68TSZHQ0lH1Kivv5KPC3NMG1qgE uQn9FsmwJ4DIXJ2mLAkNWY72sYGrstNjBn2EYElGUpI1/uY3jIVt3LfauxMfF0FcdVYc DGEwWdQxxEzjzHYcvoWyaiyoC2mvU0wuX4d+npr0k2skUZavUaogSG+p5KrybhbHgubM CCRA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u16si18732491plk.192.2018.12.04.05.32.09; Tue, 04 Dec 2018 05:32:27 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726417AbeLDNbM (ORCPT + 99 others); Tue, 4 Dec 2018 08:31:12 -0500 Received: from mail.bootlin.com ([62.4.15.54]:59358 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725910AbeLDNbM (ORCPT ); Tue, 4 Dec 2018 08:31:12 -0500 Received: by mail.bootlin.com (Postfix, from userid 110) id E277420711; Tue, 4 Dec 2018 14:31:09 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail.bootlin.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT shortcircuit=ham autolearn=disabled version=3.4.2 Received: from aptenodytes (aaubervilliers-681-1-79-44.w90-88.abo.wanadoo.fr [90.88.21.44]) by mail.bootlin.com (Postfix) with ESMTPSA id 9ACEC207AD; Tue, 4 Dec 2018 14:30:59 +0100 (CET) Message-ID: <673fa8ed8e43943c29f050fd21954e77789134c3.camel@bootlin.com> Subject: Re: [PATCH v2 34/43] drm/sun4i: Add buffer stride and offset configuration for tiling mode From: Paul Kocialkowski To: Maxime Ripard Cc: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, Maarten Lankhorst , Sean Paul , David Airlie , Chen-Yu Tsai , Thomas Petazzoni , linux-sunxi@googlegroups.com, Daniel Vetter Date: Tue, 04 Dec 2018 14:30:59 +0100 In-Reply-To: <20181127092428.z7p4mxnf3jxuqcv7@flea> References: <20181123092515.2511-1-paul.kocialkowski@bootlin.com> <20181123092515.2511-35-paul.kocialkowski@bootlin.com> <20181127092428.z7p4mxnf3jxuqcv7@flea> Organization: Bootlin Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.30.2 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Tue, 2018-11-27 at 10:24 +0100, Maxime Ripard wrote: > On Fri, Nov 23, 2018 at 10:25:06AM +0100, Paul Kocialkowski wrote: > > This introduces stride and offset configuration for the VPU tiling mode. > > Stride is calculated differently than it is for linear formats and an > > offset is calculated, for which new register definitions are introduced. > > > > Signed-off-by: Paul Kocialkowski > > --- > > drivers/gpu/drm/sun4i/sun4i_frontend.c | 54 ++++++++++++++++++++++++-- > > drivers/gpu/drm/sun4i/sun4i_frontend.h | 7 ++++ > > 2 files changed, 58 insertions(+), 3 deletions(-) > > > > diff --git a/drivers/gpu/drm/sun4i/sun4i_frontend.c b/drivers/gpu/drm/sun4i/sun4i_frontend.c > > index efa1ff0802bd..3f76a5572449 100644 > > --- a/drivers/gpu/drm/sun4i/sun4i_frontend.c > > +++ b/drivers/gpu/drm/sun4i/sun4i_frontend.c > > @@ -125,21 +125,69 @@ void sun4i_frontend_update_buffer(struct sun4i_frontend *frontend, > > { > > struct drm_plane_state *state = plane->state; > > struct drm_framebuffer *fb = state->fb; > > + unsigned int strides[3] = {}; > > + > > dma_addr_t paddr; > > bool swap; > > > > + if (fb->modifier == DRM_FORMAT_MOD_ALLWINNER_TILED) { > > + unsigned int width = state->src_w >> 16; > > + unsigned int offset; > > + > > + /* > > + * In MB32 tiled mode, the stride is defined as the distance > > + * between the start of the end line of the current tile and > > + * the start of the first line in the next vertical tile. > > + * > > + * Tiles are represented in row-major order, thus the end line > > + * of current tile starts at: 31 * 32 (31 lines of 32 cols), > > + * the next vertical tile starts at: 32-bit-aligned-width * 32 > > + * and the distance is: 32 * (32-bit-aligned-width - 31). > > + */ > > + > > + strides[0] = (fb->pitches[0] - 31) * 32; > > + > > + /* Offset of the bottom-right point in the end tile. */ > > + offset = (width + (32 - 1)) & (32 - 1); > > Those computations are a bit obscure. I guess adding a bunch of > defines, and using the round_up / _down and ALIGN macros would help Fair enough, I will add a more explicit comment and a macro in v3. > > + regmap_write(frontend->regs, SUN4I_FRONTEND_TB_OFF0_REG, > > + SUN4I_FRONTEND_TB_OFF_X1(offset)); > > + > > + if (fb->format->num_planes > 1) { > > + strides[1] = (fb->pitches[1] - 31) * 32; > > + > > + regmap_write(frontend->regs, SUN4I_FRONTEND_TB_OFF1_REG, > > + SUN4I_FRONTEND_TB_OFF_X1(offset)); > > + } > > + > > + if (fb->format->num_planes > 2) { > > + strides[2] = (fb->pitches[2] - 31) * 32; > > + > > + regmap_write(frontend->regs, SUN4I_FRONTEND_TB_OFF2_REG, > > + SUN4I_FRONTEND_TB_OFF_X1(offset)); > > + } > > I guess we could fall in a situation where this is not cleared when > moving from a format with 3 planes to one with 2 for example. Would > that break anything? I have tested this case and nothing breaks so we're good! Cheers, Paul -- Paul Kocialkowski, Bootlin (formerly Free Electrons) Embedded Linux and kernel engineering https://bootlin.com