Received: by 2002:a05:7412:798b:b0:fc:a2b0:25d7 with SMTP id fb11csp424129rdb; Thu, 22 Feb 2024 07:55:31 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXFom/L13V+h+5wqrww+4bsBkP3shR5P4QudQ2TUwifRWu8GOcIkM16Fi95HMIbAHzeEBbuULy+KaITY/XzcSpcnZIn4YMtJZc7+kV0Ig== X-Google-Smtp-Source: AGHT+IH/15ieIkDuFo4T9sjlY6lmvF8swi1CpBvrHGmg3GLl8HWLP9bhkbR5QVtawE0WnghP+PtN X-Received: by 2002:a05:6a00:139e:b0:6e4:6187:a7d8 with SMTP id t30-20020a056a00139e00b006e46187a7d8mr15335876pfg.30.1708617331347; Thu, 22 Feb 2024 07:55:31 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708617331; cv=pass; d=google.com; s=arc-20160816; b=sUY0FxEyhk99Eu+pT12C8LoxHSv2BzE656mHwPrmbFZT4Pb+tt1AemPJaE5M4i7gEE k+hhMFjBty9hIjL5+lFpO7aluJZsTiUcIKoDTU297eaw4JDFYkVaOAGNJopsX7hm3iLm VbNyiDaKEqXO+lc6v7PcSVHWU7yUKEioGA4TuLPaT6/PH78oycwxRAorEBSBKxGfg1x/ LBjJB2tbh6psJNd25MhjHSE6wwIs23q0gw910I6RNlF4yRTebLzOpQ3BH8GB2nXZo5ng vhsnZWuLjXj1PJu9qGfs/zGYzJn66LCfvYGICn7iFCPXLUMrnDdRfITVgA2//oqzLgQ0 hgwA== 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-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76809-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 u29-20020a63b55d000000b005d576171e69si6720679pgo.88.2024.02.22.07.55.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 07:55:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-76809-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=bMRvnplW; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-76809-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76809-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 B3A4828CE6A for ; Thu, 22 Feb 2024 15:46:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F3E04158D61; Thu, 22 Feb 2024 15:42:05 +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 Content-Transfer-Encoding: 8bit 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: -- 2.34.1