From patchwork Thu Feb 22 15:41:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chun-Kuang Hu X-Patchwork-Id: 204836 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp31638dyb; Thu, 22 Feb 2024 07:56:35 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUv+ytaf6+idh+s0jnIXNGYIMgI92AHajbEiLtzsrl2AiYPgR+dCpA80BYZ6vrW5SdxTQaVIr4vip/XKifpj1fkFh4hrg== X-Google-Smtp-Source: AGHT+IGBYYhuxDoNDjrVNpBYxYEO17DedU4M3rqocatyNPw1D+TD8LuADhKywXnEYC5AL+LICrZv X-Received: by 2002:aa7:8b86:0:b0:6e3:6e83:4279 with SMTP id r6-20020aa78b86000000b006e36e834279mr12411416pfd.28.1708617394924; Thu, 22 Feb 2024 07:56:34 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708617394; cv=pass; d=google.com; s=arc-20160816; b=T6UUXx+XHycXEoyWpzA75LP/ISTQ35JBINntrkpNz9YJUqhIl7IHFLPhYtxP5sJgGC Xn/tXzHS6uLIzTbh3xJlD1b/L1T0qfkskUqclYaXuU1cMvKGrkL8eJUx5EkNFNS2ga+d LvU6znzTc6KLZgkThTbwnopbZjAalhMpVzmazJbYVrbLdhcHCIjbf526DQSewq4zdX2T x/C1YlJtOOffFc3nTloiepwVAA4AcugpOs5/8FEpDeOjrVKnNrKPAJrDRK1+AXyn/BKw hVuQMMAdF75YEbBAs23EgYD9mwzYkzOG0HqyecMWNZ+wN60dwXUHozpk3x6HxERx7W9M MlwA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=o2lFpqVZSjYcpKx1VqOIje41okLbu68nZb28RiY01sA=; fh=vD8tJ9d2mp7H51jNKyMUDglMjHY1Ew4hzsuiSabS+YY=; b=IXPMWsVnezFPRpE3c4b9qGAoXy4sArRafoLxElUMU4NezrXDYJLJj4ReaSCDLY7Zkh /+N/wl3dr1HtzjQ66w80UH5h+/qKwW0wMjySk3qamEDmkgAFtpoYx0JJVcdfggO1WLOq QzDVPCirb6U1K6lquAJwNKxSwaSyQwgJbGkdeN87qcKl4FfvSeuV+ZyojsW64se3jZNh YS1ifollVxxw/zpTavWC2JO7s+N9msECn60lRMCX+PE/+ZorbVTjXIOJtcppwFt1bNbn Bo9gRznNrCYWtmFWRX1yWlqOKT3+S7AIVvao67vZjVCXExSOI4dhS4KydXf2t25nbYi3 saHg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=p1c65uyn; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-76807-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76807-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id s5-20020a056a0008c500b006e09670b2f7si9561186pfu.107.2024.02.22.07.56.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 07:56:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-76807-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=p1c65uyn; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-76807-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76807-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 1CCC528C903 for ; Thu, 22 Feb 2024 15:45:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 045481509B4; Thu, 22 Feb 2024 15:42:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="p1c65uyn" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5213660EC7; Thu, 22 Feb 2024 15:41:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708616518; cv=none; b=ZRm7Ui9/onsnsUpjaC+UnShrjxCIgSKnwrvb2awLVzZFmYyr4tA4ixQiQdBmjlAX52BcFNcLK3ubpfZU9N+sBIZ8FOlJl6npLx7L7wxOaBsQ5BXDEg+JIKd5NKmcWGZRV8P5/e3v5OuxS0Hp7/fWgAg9xp+CxuHoPGoI758pEOY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708616518; c=relaxed/simple; bh=8s/AE2Lvj5xM13lRGG/ygcRJb/+6WUbmfaVrUP2qSz0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Yu43Q6+EbNpf6L6qK/rQJm2ncXz+UR0tKGLktv7YH2+U/WzEfSw+TisrWI6zKDunv+3idvEofrWNZS6oJqxPTUdMlSv4Nyxf/l5W3vKOnWGafcaWnF1kHs8SP8VRkbLQiNBpyHV0YiftLONVcAjOKAEV4hKitDKLZKDdDHzvHY0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=p1c65uyn; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 04137C43601; Thu, 22 Feb 2024 15:41:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708616517; bh=8s/AE2Lvj5xM13lRGG/ygcRJb/+6WUbmfaVrUP2qSz0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=p1c65uynO06Q+jx9RFAiP9vWUSRKGgvfkj6UXpCWnWf+XjVPUyNrh6x8WwC2R5kwx JNCiHJyhnTlRwTNffysBLEjfPfxX5aYQPpwwEXS1mmni9vz0yAcKVBbpacpgmYams4 cG7foLyWBBNjZdTYkkuQGfTWtkFIJ/IdkFjR4rMjuJ+bVksWnkSOY48sukoMWrDslv n8yRYEemp52iXka9p2aPXkiwSrNZ8DXZ1zCZfKaPw6n92leEbE720kwarSk06C5ftK Dpm7I1V7ynnAZUxaHLdNSqR72kd9h0EhbLbHdb1Lo5TcvIo9ZYqXB0mmxxGIHF4KEw 7ketiNKMvCtww== From: Chun-Kuang Hu To: Matthias Brugger , AngeloGioacchino Del Regno , Mauro Carvalho Chehab , Moudy Ho , "Jason-JH . Lin" , linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org Cc: Chun-Kuang Hu Subject: [PATCH v2 09/12] drm/mediatek: Use cmdq_pkt_create() and cmdq_pkt_destroy() Date: Thu, 22 Feb 2024 15:41:17 +0000 Message-Id: <20240222154120.16959-10-chunkuang.hu@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240222154120.16959-1-chunkuang.hu@kernel.org> References: <20240222154120.16959-1-chunkuang.hu@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791615193520756252 X-GMAIL-MSGID: 1791615193520756252 Use cmdq_pkt_create() and cmdq_pkt_destroy() common function instead of implementing drm version. Signed-off-by: Chun-Kuang Hu --- drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 46 +++---------------------- 1 file changed, 4 insertions(+), 42 deletions(-) diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c index df693fa268ce..96c0db44dc79 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c +++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c @@ -111,44 +111,6 @@ static void mtk_drm_finish_page_flip(struct mtk_drm_crtc *mtk_crtc) } } -#if IS_REACHABLE(CONFIG_MTK_CMDQ) -static int mtk_drm_cmdq_pkt_create(struct cmdq_client *client, struct cmdq_pkt *pkt, - size_t size) -{ - struct device *dev; - dma_addr_t dma_addr; - - pkt->va_base = kzalloc(size, GFP_KERNEL); - if (!pkt->va_base) - return -ENOMEM; - - pkt->buf_size = size; - pkt->cl = (void *)client; - - dev = client->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); - return -ENOMEM; - } - - pkt->pa_base = dma_addr; - - return 0; -} - -static void mtk_drm_cmdq_pkt_destroy(struct cmdq_pkt *pkt) -{ - struct cmdq_client *client = (struct cmdq_client *)pkt->cl; - - dma_unmap_single(client->chan->mbox->dev, pkt->pa_base, pkt->buf_size, - DMA_TO_DEVICE); - kfree(pkt->va_base); -} -#endif - static void mtk_drm_crtc_destroy(struct drm_crtc *crtc) { struct mtk_drm_crtc *mtk_crtc = to_mtk_crtc(crtc); @@ -156,7 +118,7 @@ static void mtk_drm_crtc_destroy(struct drm_crtc *crtc) mtk_mutex_put(mtk_crtc->mutex); #if IS_REACHABLE(CONFIG_MTK_CMDQ) - mtk_drm_cmdq_pkt_destroy(&mtk_crtc->cmdq_handle); + cmdq_pkt_destroy(&mtk_crtc->cmdq_client, &mtk_crtc->cmdq_handle); if (mtk_crtc->cmdq_client.chan) { mbox_free_channel(mtk_crtc->cmdq_client.chan); @@ -1083,9 +1045,9 @@ int mtk_drm_crtc_create(struct drm_device *drm_dev, mbox_free_channel(mtk_crtc->cmdq_client.chan); mtk_crtc->cmdq_client.chan = NULL; } else { - ret = mtk_drm_cmdq_pkt_create(&mtk_crtc->cmdq_client, - &mtk_crtc->cmdq_handle, - PAGE_SIZE); + ret = cmdq_pkt_create(&mtk_crtc->cmdq_client, + &mtk_crtc->cmdq_handle, + PAGE_SIZE); if (ret) { dev_dbg(dev, "mtk_crtc %d failed to create cmdq packet\n", drm_crtc_index(&mtk_crtc->base));