From patchwork Thu Feb 22 15:41:19 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: 204830 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp26518dyb; Thu, 22 Feb 2024 07:46:17 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWpHFc2qFB2N0AQbgpahyJfBi7buvPTJUOoTwqmjsBD2BRjhfCO+lg7rTRCurAgcKuoIYZj4ceEmRhVfgIciVYM/HqO0g== X-Google-Smtp-Source: AGHT+IH49tHeas0wtCy+DnFmEUrf5n5yuHq1UC3nHosq4hdkXKTwrQY8aoKxBC1t/ScaJTwizajM X-Received: by 2002:a62:5887:0:b0:6e4:7590:da67 with SMTP id m129-20020a625887000000b006e47590da67mr10776419pfb.8.1708616777009; Thu, 22 Feb 2024 07:46:17 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708616776; cv=pass; d=google.com; s=arc-20160816; b=BbC1FQh2/rjdVW1Y3bovTe4JiJ+GIE+70fuyBVlCBUQJ+gnOQ57Ib7GxDxebq5X81a n2TZwj4Tgd9E9zX/PJiybhczPbrUj7btRqwlEN8kumqgRNiHGGZoRcNMbw6m8MXoWDzH KUKh0j4a0NjQIN/esoKu71asMtZ/yadU/Oo10YASZQKxgTr00OtRmCx9MVKa+u6ae3yl VG5RA0RBxyNxkGWZKsqDuxLwt1TdLGv0xkbVSUK+AQJFNFL8q68Nc20r468fOpn1OXOg QZm8E3DVE2k4jbTDStvo6VmSpt6YDZ5tGBps3LFmSOOAcWf73wywaYa1hNN02n49skLL qzDA== 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=yrfnvtEETKyA7JCfJ502ChZKTIbLBKz6Spbq7uKIgS4=; fh=vD8tJ9d2mp7H51jNKyMUDglMjHY1Ew4hzsuiSabS+YY=; b=uLe96a1bFNdU6Gqgs4brFsPCBGb0E8pkaijwhpYeJYMy/1JEC0Iw7sGr+OHvLmjb/9 q9acvHWg8NS1AIKnwhZ1bWbWprI1Wvg1EbrayLUYcGji3Z/z6OOjHBUFF4/Q2KX8Elax zc+lzODrNIPqTVmRK5NtuplwPGkIM8irza/oHqC7NWjIxYIzZln4+1xCyp4D4Rr/DQYp giIan+unX09+GIbKd48sh8dcg6+PrydMYd++BvNB3S0jz/uIfLOTXHoIxBYMRuKRf4RZ bwe/CQIceJGi5WoSqeWrYmECFOt6WKxng7wR5vaRVT2eqBtIfavJfTutf9vJzRH+kgTD l7YA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=bMRvnplW; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-76809-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76809-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 y20-20020a056a001c9400b006e4c395c9d2si2303951pfw.77.2024.02.22.07.46.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 07:46:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-76809-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=bMRvnplW; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-76809-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76809-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 CE83628CF56 for ; Thu, 22 Feb 2024 15:46:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A8AE3158D6F; Thu, 22 Feb 2024 15:42:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="bMRvnplW" 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 2A8C21586D5; Thu, 22 Feb 2024 15:42:04 +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=1708616525; cv=none; b=sxSa02wZirBnpcJkilJCP0v+WI68ddtYmM3dyPoGkDXZMNR4b52hPZLvh8IgUhFxv5KMj1ASUpy+PZs9Z2CZEJhastAApmER3eiNQ0HFg5NaFcp+FFzMpPlRISu+5A/7XlsYvms/mHerDaMuZ/hN3KJkAGtWCe/I07mYxfr4jlc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708616525; c=relaxed/simple; bh=KgDcscSofoiJ56aGo6M+RgNx0sKZfbHtKRJhpGa5w9Q=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=QeP32PtRGHVbmLzCIoWfIPdk7JeBf39IlyJiUMKdx2/MgYaVWrixGnwcKebrc8Kj4tCGFL4Rf5iB/AuFHGlXPEAr5cunC+cd2xJaeGQ2+/kYVKQ4Sjr1iHx5BHPn/sfqPTExVY7MwAe2yQ1lG1vQZAgDY4j+NC0Q62v7oWz2X20= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=bMRvnplW; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id EC892C433C7; Thu, 22 Feb 2024 15:42:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708616524; bh=KgDcscSofoiJ56aGo6M+RgNx0sKZfbHtKRJhpGa5w9Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bMRvnplWNr4x0m1A+BadooEBnvlrCUQoEAi8eDvoZ+gs9jt023jMYy/vdPgGMCIKI x33RQJpFw+SxNgNabT81f1WfKax8FGGnF9UJnY9lu3j/U2X71coiWNQsTaXgfBGHWN THMaQqWamo0XU3LXS/PgxKfbWZ6Cn0uYEsQb3XAE9MjtUtxVX79jxi6AwUMj8jKLuI u82Q/MhXrWsx7vu0l+55IQ73dIjtFyP85ep2vjjpNpk9LnM9j2BlsKF7ZGvtnr4io2 psVBM4eLtJgkJ4EepXV4lNx0tVKVKwb0SK3RSNDeI419yC5tLFi4m/1f/Nu2HEDccJ fN6JTn/mWt9Fw== 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 11/12] media: platform: mtk-mdp3: Use cmdq_pkt_create() and cmdq_pkt_destroy() Date: Thu, 22 Feb 2024 15:41:19 +0000 Message-Id: <20240222154120.16959-12-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: 1791614545431142044 X-GMAIL-MSGID: 1791614545431142044 Use cmdq_pkt_create() and cmdq_pkt_destroy() common function instead of implementing mdp3 version. Signed-off-by: Chun-Kuang Hu --- .../platform/mediatek/mdp3/mtk-mdp3-cmdq.c | 45 ++----------------- 1 file changed, 4 insertions(+), 41 deletions(-) diff --git a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c index b720e69b341d..c7a9f142102d 100644 --- a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c +++ b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c @@ -287,43 +287,6 @@ static int mdp_path_config(struct mdp_dev *mdp, struct mdp_cmdq_cmd *cmd, return 0; } -static int mdp_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 mdp_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); - pkt->va_base = NULL; -} - static void mdp_auto_release_work(struct work_struct *work) { struct mdp_cmdq_cmd *cmd; @@ -341,7 +304,7 @@ static void mdp_auto_release_work(struct work_struct *work) atomic_dec(&mdp->job_count); wake_up(&mdp->callback_wq); - mdp_cmdq_pkt_destroy(&cmd->pkt); + cmdq_pkt_destroy(mdp->cmdq_clt, &cmd->pkt); kfree(cmd->comps); cmd->comps = NULL; kfree(cmd); @@ -388,7 +351,7 @@ static void mdp_handle_cmdq_callback(struct mbox_client *cl, void *mssg) atomic_dec(&mdp->job_count); wake_up(&mdp->callback_wq); - mdp_cmdq_pkt_destroy(&cmd->pkt); + cmdq_pkt_destroy(mdp->cmdq_clt, &cmd->pkt); kfree(cmd->comps); cmd->comps = NULL; kfree(cmd); @@ -418,7 +381,7 @@ int mdp_cmdq_send(struct mdp_dev *mdp, struct mdp_cmdq_param *param) goto err_cancel_job; } - ret = mdp_cmdq_pkt_create(mdp->cmdq_clt, &cmd->pkt, SZ_16K); + ret = cmdq_pkt_create(mdp->cmdq_clt, &cmd->pkt, SZ_16K); if (ret) goto err_free_cmd; @@ -513,7 +476,7 @@ int mdp_cmdq_send(struct mdp_dev *mdp, struct mdp_cmdq_param *param) err_free_comps: kfree(comps); err_destroy_pkt: - mdp_cmdq_pkt_destroy(&cmd->pkt); + cmdq_pkt_destroy(mdp->cmdq_clt, &cmd->pkt); err_free_cmd: kfree(cmd); err_cancel_job: