Received: by 2002:a05:7412:798b:b0:fc:a2b0:25d7 with SMTP id fb11csp424678rdb; Thu, 22 Feb 2024 07:56:38 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV6rupyUCMMMvqjIa1CauJX63F+62cPEv4pkJMwhUYRSfhUT4KrdO0/6g20TRQBfztbXxQb74c9cFkW4CBjUjnkHNrdlH7vbFs7qfkW6Q== X-Google-Smtp-Source: AGHT+IHFSAV4HvwfjZzF4sCqwUWBA3Zyc1Uk1tlihT226/3QC4SwaT57L1oMyK+jDN3MncT9MKtF X-Received: by 2002:a05:6358:28c:b0:176:29cf:7b3a with SMTP id w12-20020a056358028c00b0017629cf7b3amr26046809rwj.12.1708617398150; Thu, 22 Feb 2024 07:56:38 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708617398; cv=pass; d=google.com; s=arc-20160816; b=MLz56s6IKkOpW7Nz+9AuTtmXuY99bZIl92UytWsK1NJrRGvoD0jNdWHxUQAWFwhlhH i1O21935CEHkvNXIrXseNg8dAva137zt1OuKQE1kyUfy5s8HWdqOVMetPZOE8jQrIy55 CtVcBhIrVE0VUCmvFPW+faT6W7iM/izTkN+rD8SK2MVp17o5cN3hv/3wAmNIZhoFqbx6 Lcve5VrI2w8zoFqoPvWBwWJtODyhjrAxDxEpjxlSO/Qjd7fKR/BQP9Pw4JaeRIIiKw6V WeVR1y0CDNf/JckLysMACwZnbCqCW4rH5AvB4D2nncGibXtPUVQPp+k6BENOvzkfIrQo K1kg== 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-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76807-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id k21-20020a6568d5000000b005cdfd4aa8b3si10249459pgt.193.2024.02.22.07.56.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 07:56:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-76807-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; 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-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76807-linux.lists.archive=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 1C39528C7F0 for ; Thu, 22 Feb 2024 15:45:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4DE3A14D44C; Thu, 22 Feb 2024 15:41:59 +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 Content-Transfer-Encoding: 8bit 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)); -- 2.34.1