Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp2603186ybc; Mon, 18 Nov 2019 01:36:15 -0800 (PST) X-Google-Smtp-Source: APXvYqy8r3DNthszb298aKEuTbAz5JX5sCipXlHAgvdyk1I1aoKaB9W1N2Kk3Bzkvo4IppU5wwhY X-Received: by 2002:a17:906:52c3:: with SMTP id w3mr25865339ejn.122.1574069774904; Mon, 18 Nov 2019 01:36:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574069774; cv=none; d=google.com; s=arc-20160816; b=QxzH8QRLYdSDUyuA6eqsT05/8eUOXBXgihkU36PFuezzbgD4D3/ni5s4NIqQL+YUwa vEzgvRjeLxrLFOPFur+Ezc1Raa1zN3Y94tMmvIFGtoBF4cWO2du/ikUKvNI+elDNUqtH E8MU1aUGk/SEUPmKyMBZbsuBnD6PNnPymaUarc15LHog4uYQOxtezXmL1DYAkZas2s53 5LaHpXohpQR/eP2ieDLz3/5AoTy+KJB8kkqgBUixaZ1Ac6T/cpmna5gqKI9xyspoyDF7 wdqjKnKu8b5B/6Ml/T65hF1axp4cscXRHlsmjobSaUlIV6wT8COnvgAPJGLQtyGzIaZ/ GkKQ== 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=lr/4E5ZW9jz9oShySXGCc5V6Txdcr0g9QJ5gIXifIGk=; b=WG2EoNpzCT5fXC8aQ+2KtgCPZHR5IpoaXvj6KOZ8H/ENctQVhWCxaHGJXuq1bEgEfQ VsysGhc5N2gVGQ3TABur8EdphnKW6TCK3JL9ao8azF5QqiKFXOoUJEyr/9VOVS3bpK5L X2eXVYFXMkNAY5KUM6WIDZwONcDnYRIx2+T4XIqfWUIjLtMhN/qUpovUb9DNnCpGYJ78 c5X9rSvr7Wymou69prlwvJM2KaBzCnsnLJM0yBQ2/cc2VCiUuYLft9YB4K4NcXqao5U0 raosFZMjjVZjCKOV1chmL1K6kxzLC7sqyCV39bsZ+Up2QYvdl//74uTpUu11pptmj3R/ zP+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=W6V9SCS3; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 95si12452873edq.244.2019.11.18.01.35.50; Mon, 18 Nov 2019 01:36:14 -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; dkim=pass header.i=@chromium.org header.s=google header.b=W6V9SCS3; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726563AbfKRJen (ORCPT + 99 others); Mon, 18 Nov 2019 04:34:43 -0500 Received: from mail-il1-f195.google.com ([209.85.166.195]:35689 "EHLO mail-il1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726464AbfKRJen (ORCPT ); Mon, 18 Nov 2019 04:34:43 -0500 Received: by mail-il1-f195.google.com with SMTP id z12so15371747ilp.2 for ; Mon, 18 Nov 2019 01:34:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=lr/4E5ZW9jz9oShySXGCc5V6Txdcr0g9QJ5gIXifIGk=; b=W6V9SCS3NzD7+ytXHksdvuTMYaJofAh3nWAX40damlaaJWjWjZHtQ+k6ikYy6z6QM1 VHwrlguvhMqY7NmZM9gTooG0Z9XHILEXYgbysYUT6DYzcl/XH1wIjioMeK/75YCyLtb/ aUi3Yq3X/P9iXf6Kg85iW+swL8ttWmJ0SlonE= 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=lr/4E5ZW9jz9oShySXGCc5V6Txdcr0g9QJ5gIXifIGk=; b=LR4PU5hQa8lXqb+xLi4SctAhfMOc5m7rGthpsASc1w5Y5F/JRRqCLanXn4NmD1ayZG 8UJOG9nTMr+U6TkQFfD80G+eNnTI7d2JvhaheHxeflnLape7MsVr3jNfXq1U6paYdvOJ Sq3jV+2tp+u4InQShqLbCisDDOWOnJh+E6KH3YHP2+kwsBAIXz4rEnH0OH46RNgugjCI IJbxpjXnlHDt2hDUG5ElXLCBot0VfI5EUlcDqB5gqw0fA4S3bNIa2qQUqCeXG9uYRkHh bQf2jnwVLHEDB93kQE5Aj5OgxHEr+FJwGTDPrhANnN2HG6e2af8tSdS4Gf2ynkYQK0B8 dEOg== X-Gm-Message-State: APjAAAV+Yhrn6ldEmdo1EF3XmkpaLPXinPBrpnZ1lJsldItQ5Tow68wq zSaiJDmqa8M4xbdfIwLUKcVkm6fDeWcNHrqHERHXWg== X-Received: by 2002:a92:d608:: with SMTP id w8mr14471824ilm.308.1574069682145; Mon, 18 Nov 2019 01:34:42 -0800 (PST) MIME-Version: 1.0 References: <20190830074103.16671-1-bibby.hsieh@mediatek.com> <20190830074103.16671-3-bibby.hsieh@mediatek.com> In-Reply-To: <20190830074103.16671-3-bibby.hsieh@mediatek.com> From: Hsin-Yi Wang Date: Mon, 18 Nov 2019 17:34:16 +0800 Message-ID: Subject: Re: [PATCH 2/2] drm/mediatek: Apply CMDQ control flow To: Bibby Hsieh Cc: David Airlie , Matthias Brugger , Daniel Vetter , dri-devel@lists.freedesktop.org, linux-mediatek@lists.infradead.org, Nicolas Boichat , Yongqiang Niu , lkml , tfiga@chromium.org, CK Hu , Thierry Reding , Philipp Zabel , YT Shen , "moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE" 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 On Fri, Aug 30, 2019 at 7:41 AM Bibby Hsieh wrote: > @@ -405,26 +458,69 @@ void mtk_drm_crtc_cursor_update(struct drm_crtc *crtc, struct drm_plane *plane, > return; > > mutex_lock(&priv->hw_lock); > - plane_helper_funcs->atomic_update(plane, plane_state); > - for (i = 0; i < mtk_crtc->layer_nr; i++) { > - struct drm_plane *plane = &mtk_crtc->planes[i]; > - struct mtk_plane_state *plane_state; > + if (IS_ENABLED(CONFIG_MTK_CMDQ) && mtk_crtc->cmdq_client) { > + struct mtk_crtc_state *mtk_crtc_state = > + to_mtk_crtc_state(crtc->state); > + struct mtk_cmdq_cb_data *cb_data; > + > + mtk_crtc_state->cmdq_handle = > + cmdq_pkt_create(mtk_crtc->cmdq_client, > + PAGE_SIZE); > + cmdq_pkt_clear_event(mtk_crtc_state->cmdq_handle, > + mtk_crtc->cmdq_event); > + cmdq_pkt_wfe(mtk_crtc_state->cmdq_handle, mtk_crtc->cmdq_event); > + plane_helper_funcs->atomic_update(plane, plane_state); > + cb_data = kmalloc(sizeof(*cb_data), GFP_KERNEL); Check kmalloc failure? > + cb_data->cmdq_handle = mtk_crtc_state->cmdq_handle; > + cmdq_pkt_flush_async(mtk_crtc_state->cmdq_handle, > + ddp_cmdq_cursor_cb, cb_data); > @@ -494,13 +599,29 @@ static void mtk_drm_crtc_atomic_flush(struct drm_crtc *crtc, > struct drm_crtc_state *old_crtc_state) > { > struct drm_atomic_state *old_atomic_state = old_crtc_state->state; > + struct drm_crtc_state *crtc_state = crtc->state; > + struct mtk_crtc_state *state = to_mtk_crtc_state(crtc_state); > + struct cmdq_pkt *cmdq_handle = state->cmdq_handle; > struct mtk_drm_crtc *mtk_crtc = to_mtk_crtc(crtc); > struct mtk_drm_private *priv = crtc->dev->dev_private; > + struct mtk_cmdq_cb_data *cb_data; > unsigned int pending_planes = 0; > int i; > > - if (mtk_crtc->event) > - mtk_crtc->pending_needs_vblank = true; > + DRM_DEBUG_DRIVER("[CRTC:%u] [STATE:%p(%p)->%p(%p)]\n", crtc->base.id, > + old_crtc_state, old_crtc_state->state, > + crtc_state, crtc_state->state); > + > + if (IS_ENABLED(CONFIG_MTK_CMDQ) && mtk_crtc->cmdq_client) { > + drm_atomic_state_get(old_atomic_state); > + cb_data = kmalloc(sizeof(*cb_data), GFP_KERNEL); Check kmalloc failure? > + cb_data->state = old_crtc_state; > + cb_data->cmdq_handle = cmdq_handle;