Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp1875572pxb; Thu, 7 Oct 2021 17:36:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyUh6TOH6sQg+BdLB3Cua/VwuafWTPUkG9iAKDf8pT6fUtw76KUGkT6b+q7eVmBNMmMgQ9G X-Received: by 2002:a63:bf4a:: with SMTP id i10mr2224263pgo.196.1633653415101; Thu, 07 Oct 2021 17:36:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633653415; cv=none; d=google.com; s=arc-20160816; b=PW3U40sTmpI+t0yaJbLcyqEDapZP8Q2pWKCy775gzvB4FY9jg/Oh8WjDCrelItGCvz 2i/EkM6ASNwNT/CeEa3WJNDH6G+Hm4eHMqw8EVHalwzjvqcQCRM8DVGB8lGQd7MwlSUt WeXT05KrrZal6kv0Zgef5Kz8xFxGdtEG0zmqwZGBo7AsriybFRsyB0fWS1ykHt8H0+dV nQxQVsfT+Pq1toIxeWPsWTmCK4r6Qz+jPuk8iMT27P21gGjTawpdK7B3BJj3pXWRNcmc uxNtDgke6uMJKZY2gqEITg/g8nmd85e2IyfdcpxAs1lAMAopB7wmu7yqmwoIrEm7Fx4V Q8lg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=/HM1xo36c01MajcqJqcYXDzH8cb4Aay2h1njCUDkYm0=; b=qZp0U+H8N0R4ezyLK4vcCWSQrOE7HkY3ptuPwYrBAKU+fjbIfIbaziXblBcahL5DAh SbnMfPEd9pbt2F9cDXDfDgXEN6nrfwXDeqv7si2AcrCfwQT6yH797khINpjTz6NcQsvG OfIgA35/+v3IJEBaDxlrrIDRtLTo5Hi/AJWRWmuLvV+2jgmi4povPKr/MBpL0mMfNunX Qi4v/BpEGFpd15DuwsRSAc4RvK61QoLcJC8uVF1ZIgo3TEgpdbm80neD1LmkcexONWBq R0qYDizwVlQskwIM4ITCaeyUjeG0tiC0kxkpH0f2qDlbdo8au6jPmi+jcZIFBtlEYgx4 5Vyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="Z/ZAdieF"; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n2si1496427plf.362.2021.10.07.17.36.42; Thu, 07 Oct 2021 17:36:55 -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=@kernel.org header.s=k20201202 header.b="Z/ZAdieF"; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241394AbhJGXzW (ORCPT + 99 others); Thu, 7 Oct 2021 19:55:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:45048 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241436AbhJGXzS (ORCPT ); Thu, 7 Oct 2021 19:55:18 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2343061090; Thu, 7 Oct 2021 23:53:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1633650804; bh=mPRVdtxzBthmAzQsdEWN6hMyf+MHv7KWVtcwYta4aVc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Z/ZAdieFY4/KWaLn+0UR5xpDC91Z8RhCchUxaUJdafOwY8GM8CymsakgPE9E35EAs n3oZSE2AqABe3dct69b0UJSk+dAHpVpFguP+NL8FfX+/pWNOkIC1QaBq9h3evTvSxY xrDFrJX6a5pLzWaNsSkiOhpCdnC1EtVNlqCEnqpB9xOgHUCfusG0OaFp1tKD3Q4m1V kK8eOpr1aGdi0PMJpmsX78d88kdNLKf7mmqQp2ZE7wUxA3gVAh++na9XmAJkhCdi/J o3wTyDJp3fm4VVlP0mxI2mg0drQ5G4P0rKJ6I3zSaL33Ur4IM/IhB5IwpyflaEN320 dqeShNSkuMuTQ== From: Chun-Kuang Hu To: Philipp Zabel , David Airlie , Daniel Vetter , Enric Balletbo Serra Cc: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-mediatek@lists.infradead.org, Chun-Kuang Hu Subject: [PATCH 4/5] Revert "drm/mediatek: Remove struct cmdq_client" Date: Fri, 8 Oct 2021 07:53:09 +0800 Message-Id: <20211007235310.14626-5-chunkuang.hu@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211007235310.14626-1-chunkuang.hu@kernel.org> References: <20211007235310.14626-1-chunkuang.hu@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This reverts commit f4be17cd5b14dd73545b0e014a63ebe9ab5ef837. Commit c1ec54b7b5af ("drm/mediatek: Use mailbox rx_callback instead of cmdq_task_cb") would cause numerous mtk cmdq mailbox driver warning: WARNING: CPU: 0 PID: 0 at drivers/mailbox/mtk-cmdq-mailbox.c:198 cmdq_task_exec_done+0xb8/0xe0 So revert that patch and all the patches depend on that patch. Reported-by: Enric Balletbo Serra Signed-off-by: Chun-Kuang Hu --- drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 80 ++++++------------------- 1 file changed, 18 insertions(+), 62 deletions(-) diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c index 0cd5b9ed8956..3f9802d21bf0 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c +++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c @@ -52,8 +52,7 @@ struct mtk_drm_crtc { bool pending_async_planes; #if IS_REACHABLE(CONFIG_MTK_CMDQ) - struct mbox_client cmdq_cl; - struct mbox_chan *cmdq_chan; + struct cmdq_client *cmdq_client; u32 cmdq_event; #endif @@ -225,51 +224,11 @@ struct mtk_ddp_comp *mtk_drm_ddp_comp_for_plane(struct drm_crtc *crtc, } #if IS_REACHABLE(CONFIG_MTK_CMDQ) -static struct cmdq_pkt *mtk_drm_cmdq_pkt_create(struct mbox_chan *chan, size_t size) -{ - struct cmdq_pkt *pkt; - struct device *dev; - dma_addr_t dma_addr; - - pkt = kzalloc(sizeof(*pkt), GFP_KERNEL); - if (!pkt) - return ERR_PTR(-ENOMEM); - pkt->va_base = kzalloc(size, GFP_KERNEL); - if (!pkt->va_base) { - kfree(pkt); - return ERR_PTR(-ENOMEM); - } - pkt->buf_size = size; - - dev = chan->mbox->dev; - dma_addr = dma_map_single(dev, pkt->va_base, pkt->buf_size, - DMA_TO_DEVICE); - if (dma_mapping_error(dev, dma_addr)) { - dev_err(dev, "dma map failed, size=%u\n", (u32)(u64)size); - kfree(pkt->va_base); - kfree(pkt); - return ERR_PTR(-ENOMEM); - } - - pkt->pa_base = dma_addr; - - return pkt; -} - -static void mtk_drm_cmdq_pkt_destroy(struct mbox_chan *chan, struct cmdq_pkt *pkt) -{ - dma_unmap_single(chan->mbox->dev, pkt->pa_base, pkt->buf_size, - DMA_TO_DEVICE); - kfree(pkt->va_base); - kfree(pkt); -} - static void ddp_cmdq_cb(struct mbox_client *cl, void *mssg) { - struct mtk_drm_crtc *mtk_crtc = container_of(cl, struct mtk_drm_crtc, cmdq_cl); struct cmdq_cb_data *data = mssg; - mtk_drm_cmdq_pkt_destroy(mtk_crtc->cmdq_chan, data->pkt); + cmdq_pkt_destroy(data->pkt); } #endif @@ -513,19 +472,19 @@ static void mtk_drm_crtc_update_config(struct mtk_drm_crtc *mtk_crtc, mtk_mutex_release(mtk_crtc->mutex); } #if IS_REACHABLE(CONFIG_MTK_CMDQ) - if (mtk_crtc->cmdq_chan) { - mbox_flush(mtk_crtc->cmdq_chan, 2000); - cmdq_handle = mtk_drm_cmdq_pkt_create(mtk_crtc->cmdq_chan, PAGE_SIZE); + if (mtk_crtc->cmdq_client) { + mbox_flush(mtk_crtc->cmdq_client->chan, 2000); + cmdq_handle = cmdq_pkt_create(mtk_crtc->cmdq_client, PAGE_SIZE); cmdq_pkt_clear_event(cmdq_handle, mtk_crtc->cmdq_event); cmdq_pkt_wfe(cmdq_handle, mtk_crtc->cmdq_event, false); mtk_crtc_ddp_config(crtc, cmdq_handle); cmdq_pkt_finalize(cmdq_handle); - dma_sync_single_for_device(mtk_crtc->cmdq_chan->mbox->dev, + dma_sync_single_for_device(mtk_crtc->cmdq_client->chan->mbox->dev, cmdq_handle->pa_base, cmdq_handle->cmd_buf_size, DMA_TO_DEVICE); - mbox_send_message(mtk_crtc->cmdq_chan, cmdq_handle); - mbox_client_txdone(mtk_crtc->cmdq_chan, 0); + mbox_send_message(mtk_crtc->cmdq_client->chan, cmdq_handle); + mbox_client_txdone(mtk_crtc->cmdq_client->chan, 0); } #endif mtk_crtc->config_updating = false; @@ -539,7 +498,7 @@ static void mtk_crtc_ddp_irq(void *data) struct mtk_drm_private *priv = crtc->dev->dev_private; #if IS_REACHABLE(CONFIG_MTK_CMDQ) - if (!priv->data->shadow_register && !mtk_crtc->cmdq_chan) + if (!priv->data->shadow_register && !mtk_crtc->cmdq_client) #else if (!priv->data->shadow_register) #endif @@ -879,20 +838,17 @@ int mtk_drm_crtc_create(struct drm_device *drm_dev, mutex_init(&mtk_crtc->hw_lock); #if IS_REACHABLE(CONFIG_MTK_CMDQ) - mtk_crtc->cmdq_cl.dev = mtk_crtc->mmsys_dev; - mtk_crtc->cmdq_cl.tx_block = false; - mtk_crtc->cmdq_cl.knows_txdone = true; - mtk_crtc->cmdq_cl.rx_callback = ddp_cmdq_cb; - mtk_crtc->cmdq_chan = - mbox_request_channel(&mtk_crtc->cmdq_cl, - drm_crtc_index(&mtk_crtc->base)); - if (IS_ERR(mtk_crtc->cmdq_chan)) { + mtk_crtc->cmdq_client = + cmdq_mbox_create(mtk_crtc->mmsys_dev, + drm_crtc_index(&mtk_crtc->base)); + if (IS_ERR(mtk_crtc->cmdq_client)) { dev_dbg(dev, "mtk_crtc %d failed to create mailbox client, writing register by CPU now\n", drm_crtc_index(&mtk_crtc->base)); - mtk_crtc->cmdq_chan = NULL; + mtk_crtc->cmdq_client = NULL; } - if (mtk_crtc->cmdq_chan) { + if (mtk_crtc->cmdq_client) { + mtk_crtc->cmdq_client->client.rx_callback = ddp_cmdq_cb; ret = of_property_read_u32_index(priv->mutex_node, "mediatek,gce-events", drm_crtc_index(&mtk_crtc->base), @@ -900,8 +856,8 @@ int mtk_drm_crtc_create(struct drm_device *drm_dev, if (ret) { dev_dbg(dev, "mtk_crtc %d failed to get mediatek,gce-events property\n", drm_crtc_index(&mtk_crtc->base)); - mbox_free_channel(mtk_crtc->cmdq_chan); - mtk_crtc->cmdq_chan = NULL; + cmdq_mbox_destroy(mtk_crtc->cmdq_client); + mtk_crtc->cmdq_client = NULL; } } #endif -- 2.25.1