Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp190711ybg; Tue, 28 Jul 2020 03:33:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzQ19kYIMqmBaQFkKgzACtFZN4L9uC3FjjIhkTS3a2WthvmU6YfoSOIet39emAu8pAtzPtd X-Received: by 2002:a17:907:104a:: with SMTP id oy10mr18347656ejb.267.1595932416594; Tue, 28 Jul 2020 03:33:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595932416; cv=none; d=google.com; s=arc-20160816; b=ghatPgP1n16Znt37YTX0fO51UmCLhnrNusZD71nVnRTKI/zBkeXgjX8s5dTX7vdr0D HFaYPulFoC/UJLbGCWDuMflm0/edFo05RlICr8gsHdN1TmE+lM8fgIrmCkQQr8d0Q8K+ 2r8AeaNdX+O4SdGfyIjIu7cNZRJrdIImdpo3VjAOXK/AU9T3GZUvjKHC/22kMxDzv1xP wu9A6Tugtwm8bpc8NwgwfvC2s76l5sH2a6U623evT8PHXzn9ozMQTdAB/tW6A84ThX2n e3xi/2N6659L57H1yW4zKCIWhANg1zZq++qTeF32DOO7Rrn48usPVwOIx+MWSLg99zQu NBbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=klH9XyrVq3uSlEXE3zAfesJXPnrCV0J6mB3bxXXeLHI=; b=l5DTCLbNMAIcxZxVTcTRyqeNUdr47ouxOajd/pABczwALWCjIVRz1tRHNwqnVNoUMT rzeTrKDMpCMwVBOSwGdt+PTWyT0KTo3uiUr3sDQZiTDm4l0Z8z148jid+RB2sLy2VC0S ryjcEo4c7eGsViEnsnvtBe/m4OXFFO7g0m4mRXnz1EBs3pRRYFUNG5lsliMIY2jjxkGW wnOWDwN5AgNE9OiAPAsRE0RbbwZX3oFhfgRClLbeiH64ze/YQQzW6tGM22yrBvL3tImI AE8g5twYeJBzL72k2zwd1UODtkI0K+TxJns5rvXk8FWfIJSFT9ZVwSC8AYOMA82MMPFg lyKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@raspberrypi.com header.s=google header.b=Jtgwn639; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=raspberrypi.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v7si5979825edf.362.2020.07.28.03.33.13; Tue, 28 Jul 2020 03:33:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@raspberrypi.com header.s=google header.b=Jtgwn639; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=raspberrypi.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728630AbgG1KcG (ORCPT + 99 others); Tue, 28 Jul 2020 06:32:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728547AbgG1KcG (ORCPT ); Tue, 28 Jul 2020 06:32:06 -0400 Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A82BC061794 for ; Tue, 28 Jul 2020 03:32:06 -0700 (PDT) Received: by mail-wm1-x341.google.com with SMTP id f18so17671617wml.3 for ; Tue, 28 Jul 2020 03:32:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=klH9XyrVq3uSlEXE3zAfesJXPnrCV0J6mB3bxXXeLHI=; b=Jtgwn639L7rCcHeF8Su+nhnl0wfh/jljZ8QPs8S+BQVQGFRp/n90hrkBTzk5eteqae /5M61JjXkFkxNAWZS9PKf55QSCBl2rlavEN7xHeSOywsXapHDLfbNofwV2LXh+rNQHLl WE4mtf9rrjnf/sJYX3KOujasNbmo1wIK90X8LnGiHr8J9Whd0N8ZFWi+WNC90s88OIED 11L33ZyZrNWsys+OeK6GF5TRHAd3ZVrgX6kGbzTrV4TpjMqOOCUpuIkywspjHeBxYjro lXpXwom60ETpdTSGfc80jbou+ftATvrdrHdatj4egO4RV4bGAwL/6Zds604o41XmneDv K1oA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=klH9XyrVq3uSlEXE3zAfesJXPnrCV0J6mB3bxXXeLHI=; b=Ck/TYO+t3DxSjhWegDifF3STyNAqQ0drrC0TDWGAjF6yQL94nxoqLrDJdyIBBhX5Pm 9hbEPVtsw6TMZ8xIp9NgmYWPu7iAHifKn4YXDAH4t9HkiT7YTql6bKeQfyGTQQNZym+U MxPshZq8AjF1uUwl/92W204hrYI1Ivoq3w5NtUEEezctgUX8kVoDu6tyHsE/FWVPyB41 I5/QcTJhyHkmQaJM4bRULJLRW8Xw9RK9ZGYH5Go1hRr+y09MMb8Y1+urhMdAnSf2NPWz oeWDMBVqSbOj6GtYi0Q3y4uSqFgeM+WfCjBz3YWAGvTo/mSKSbOg7wGroIMMOS2Ptr/c +ddQ== X-Gm-Message-State: AOAM533ptYGZmddiJ1GbsPlepyJBL2L5Vwb3QVcDrUnuTdQ130OSKY+D n1N9RThigVCHgcmmAZhI1uzt7sdK6Q+sq4t4i7V+1w== X-Received: by 2002:a1c:e382:: with SMTP id a124mr3176329wmh.96.1595932324875; Tue, 28 Jul 2020 03:32:04 -0700 (PDT) MIME-Version: 1.0 References: <840cb5324364e431b15d4105c85cebf8d12257f0.1594230107.git-series.maxime@cerno.tech> In-Reply-To: <840cb5324364e431b15d4105c85cebf8d12257f0.1594230107.git-series.maxime@cerno.tech> From: Dave Stevenson Date: Tue, 28 Jul 2020 11:31:49 +0100 Message-ID: Subject: Re: [PATCH v4 22/78] drm/vc4: crtc: Move HVS init and close to a function To: Maxime Ripard Cc: Nicolas Saenz Julienne , Eric Anholt , DRI Development , linux-rpi-kernel@lists.infradead.org, bcm-kernel-feedback-list@broadcom.com, linux-arm-kernel@lists.infradead.org, LKML , Tim Gover , Phil Elwell Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Maxime On Wed, 8 Jul 2020 at 18:43, Maxime Ripard wrote: > > In order to make further refactoring easier, let's move the HVS channel > setup / teardown to their own function. > > Signed-off-by: Maxime Ripard Reviewed-by: Dave Stevenson > --- > drivers/gpu/drm/vc4/vc4_hvs.c | 104 +++++++++++++++++++---------------- > 1 file changed, 58 insertions(+), 46 deletions(-) > > diff --git a/drivers/gpu/drm/vc4/vc4_hvs.c b/drivers/gpu/drm/vc4/vc4_hvs.c > index 50f9a9674a7e..78bb1c0b0b76 100644 > --- a/drivers/gpu/drm/vc4/vc4_hvs.c > +++ b/drivers/gpu/drm/vc4/vc4_hvs.c > @@ -196,6 +196,62 @@ static void vc4_hvs_update_gamma_lut(struct drm_crtc *crtc) > vc4_hvs_lut_load(crtc); > } > > +static int vc4_hvs_init_channel(struct vc4_dev *vc4, struct drm_crtc *crtc, > + struct drm_display_mode *mode, bool oneshot) > +{ > + struct vc4_crtc_state *vc4_crtc_state = to_vc4_crtc_state(crtc->state); > + unsigned int chan = vc4_crtc_state->assigned_channel; > + u32 dispctrl; > + > + /* Turn on the scaler, which will wait for vstart to start > + * compositing. > + * When feeding the transposer, we should operate in oneshot > + * mode. > + */ > + dispctrl = SCALER_DISPCTRLX_ENABLE; > + > + if (!vc4->hvs->hvs5) > + dispctrl |= VC4_SET_FIELD(mode->hdisplay, > + SCALER_DISPCTRLX_WIDTH) | > + VC4_SET_FIELD(mode->vdisplay, > + SCALER_DISPCTRLX_HEIGHT) | > + (oneshot ? SCALER_DISPCTRLX_ONESHOT : 0); > + else > + dispctrl |= VC4_SET_FIELD(mode->hdisplay, > + SCALER5_DISPCTRLX_WIDTH) | > + VC4_SET_FIELD(mode->vdisplay, > + SCALER5_DISPCTRLX_HEIGHT) | > + (oneshot ? SCALER5_DISPCTRLX_ONESHOT : 0); > + > + HVS_WRITE(SCALER_DISPCTRLX(chan), dispctrl); > + > + return 0; > +} > + > +static void vc4_hvs_stop_channel(struct drm_device *dev, unsigned int chan) > +{ > + struct vc4_dev *vc4 = to_vc4_dev(dev); > + > + if (HVS_READ(SCALER_DISPCTRLX(chan)) & SCALER_DISPCTRLX_ENABLE) > + return; > + > + HVS_WRITE(SCALER_DISPCTRLX(chan), > + HVS_READ(SCALER_DISPCTRLX(chan)) | SCALER_DISPCTRLX_RESET); > + HVS_WRITE(SCALER_DISPCTRLX(chan), > + HVS_READ(SCALER_DISPCTRLX(chan)) & ~SCALER_DISPCTRLX_ENABLE); > + > + /* Once we leave, the scaler should be disabled and its fifo empty. */ > + WARN_ON_ONCE(HVS_READ(SCALER_DISPCTRLX(chan)) & SCALER_DISPCTRLX_RESET); > + > + WARN_ON_ONCE(VC4_GET_FIELD(HVS_READ(SCALER_DISPSTATX(chan)), > + SCALER_DISPSTATX_MODE) != > + SCALER_DISPSTATX_MODE_DISABLED); > + > + WARN_ON_ONCE((HVS_READ(SCALER_DISPSTATX(chan)) & > + (SCALER_DISPSTATX_FULL | SCALER_DISPSTATX_EMPTY)) != > + SCALER_DISPSTATX_EMPTY); > +} > + > int vc4_hvs_atomic_check(struct drm_crtc *crtc, > struct drm_crtc_state *state) > { > @@ -268,63 +324,19 @@ void vc4_hvs_atomic_enable(struct drm_crtc *crtc, > struct vc4_crtc_state *vc4_state = to_vc4_crtc_state(crtc->state); > struct drm_display_mode *mode = &crtc->state->adjusted_mode; > bool oneshot = vc4_state->feed_txp; > - u32 dispctrl; > > vc4_hvs_update_dlist(crtc); > - > - /* Turn on the scaler, which will wait for vstart to start > - * compositing. > - * When feeding the transposer, we should operate in oneshot > - * mode. > - */ > - dispctrl = SCALER_DISPCTRLX_ENABLE; > - > - if (!vc4->hvs->hvs5) > - dispctrl |= VC4_SET_FIELD(mode->hdisplay, > - SCALER_DISPCTRLX_WIDTH) | > - VC4_SET_FIELD(mode->vdisplay, > - SCALER_DISPCTRLX_HEIGHT) | > - (oneshot ? SCALER_DISPCTRLX_ONESHOT : 0); > - else > - dispctrl |= VC4_SET_FIELD(mode->hdisplay, > - SCALER5_DISPCTRLX_WIDTH) | > - VC4_SET_FIELD(mode->vdisplay, > - SCALER5_DISPCTRLX_HEIGHT) | > - (oneshot ? SCALER5_DISPCTRLX_ONESHOT : 0); > - > - HVS_WRITE(SCALER_DISPCTRLX(vc4_state->assigned_channel), dispctrl); > + vc4_hvs_init_channel(vc4, crtc, mode, oneshot); > } > > void vc4_hvs_atomic_disable(struct drm_crtc *crtc, > struct drm_crtc_state *old_state) > { > struct drm_device *dev = crtc->dev; > - struct vc4_dev *vc4 = to_vc4_dev(dev); > struct vc4_crtc_state *vc4_state = to_vc4_crtc_state(old_state); > unsigned int chan = vc4_state->assigned_channel; > > - if (HVS_READ(SCALER_DISPCTRLX(chan)) & > - SCALER_DISPCTRLX_ENABLE) { > - HVS_WRITE(SCALER_DISPCTRLX(chan), > - SCALER_DISPCTRLX_RESET); > - > - /* While the docs say that reset is self-clearing, it > - * seems it doesn't actually. > - */ > - HVS_WRITE(SCALER_DISPCTRLX(chan), 0); > - } > - > - /* Once we leave, the scaler should be disabled and its fifo empty. */ > - > - WARN_ON_ONCE(HVS_READ(SCALER_DISPCTRLX(chan)) & SCALER_DISPCTRLX_RESET); > - > - WARN_ON_ONCE(VC4_GET_FIELD(HVS_READ(SCALER_DISPSTATX(chan)), > - SCALER_DISPSTATX_MODE) != > - SCALER_DISPSTATX_MODE_DISABLED); > - > - WARN_ON_ONCE((HVS_READ(SCALER_DISPSTATX(chan)) & > - (SCALER_DISPSTATX_FULL | SCALER_DISPSTATX_EMPTY)) != > - SCALER_DISPSTATX_EMPTY); > + vc4_hvs_stop_channel(dev, chan); > } > > void vc4_hvs_atomic_flush(struct drm_crtc *crtc, > -- > git-series 0.9.1