From patchwork Wed Nov 21 06:37:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Figa X-Patchwork-Id: 10692017 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 443AB13AD for ; Wed, 21 Nov 2018 06:38:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2E7672B842 for ; Wed, 21 Nov 2018 06:38:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1E4D32B83F; Wed, 21 Nov 2018 06:38:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id BC1EE2B83F for ; Wed, 21 Nov 2018 06:38:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=YG8QNkN2nkMuu/iXjtKhHqFpGPPvZBjAeDKu8H0rJLs=; b=PMKF+TR0OcTEYx LCqb6A4EPko+ePNBiks1mNgY6/xIIqSeLd31cEUUH3LmU3xk5iQLyG63VAlYoRpW+o8Fj+fbyYCiH 5WrxPNwZExgzadDsZSuvs7maDubwwgxio9dpni736nEulcsMFjx5LnHpd0JrinAJ2zhmm4Rqlxm03 BYIAbSj+SQfv36uqqEcT0OkbEOJUyPD2PaAKG/nY4WeTFkBX6GXwlMi43EgZ4xPWos6bNDgh5tTCo Ctbp3QdM9k8AsYF4KMJUKJi23H8BVD7iZXnbtPfKz0+w92oUz0VwaCGS0mO0j1yzER+VB5OKQddYP IprAdslwUSc1RYsB5o2g==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gPM9Z-0002Ob-Jn; Wed, 21 Nov 2018 06:38:25 +0000 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gPM9R-0002FT-MN for linux-mediatek@lists.infradead.org; Wed, 21 Nov 2018 06:38:19 +0000 Received: by mail-pl1-x642.google.com with SMTP id e5so4005682plb.5 for ; Tue, 20 Nov 2018 22:38:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=RGLCkqahISwC4vlHT0y91a6MaGY0OERKfY8BG0Tp2wo=; b=aDHl3ByL5vtebZKl960NivHiY1cD1BYGxPgcvXDcVoiRj31ZP4qVvF2vWpy0z+Nxfg EE65l7a9HUcTcEOANA97pdP9Aj8MzCvmB46dl/1VyVZ8wjRu0YE/eNnZVc0ob9+ZyyaZ FuZ+iAMQf4gmyfsBri7i0TzvjIA/ckBdn/XnA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=RGLCkqahISwC4vlHT0y91a6MaGY0OERKfY8BG0Tp2wo=; b=YL732nLG5CwB1EZvP9GB2e45j1wAdBEwUrmfCZdl/tHbnnrolsMmthNFoWCbBKUXip lihDzN/SlgkndRtPXqs2+8+R0M4m5CtrE9b8vw9b1cd35prRx84z/g+xyohWXxlKMAT+ MeOXgQZr1xKV6MEcJXZKXasIpOmFd+O/LewliR8oYeVaBnq1Z5fH9qSi/sX6+i1DeGcr 0xvA2hxM24OjEkXvLU/2yWUipBHTyodilsLXTyU8FoXZZr9pxggV9cskwHv4gWtizjrD /m3qdJgKR5zjYvZ86xNoP6AtC/U7N5igyxeRQZgkgnW44GwK/oI8d7TsD1sCSOKNTlB5 dbUw== X-Gm-Message-State: AGRZ1gKd+eczKrUB5q2gsbhm9fH2BKfhwRpTE/MtZKfJ8fZVzPBCW5+B LUjY75TCTtcPTtjbZ+pzZD1iMg== X-Google-Smtp-Source: AJdET5e2LXvM/6ZN1VpqAgChWY976d83gkpvXOnUK+hy6zqLo8Sjfiqb2Mkec4xhEtgYiLpYl5w3vw== X-Received: by 2002:a62:682:: with SMTP id 124-v6mr5515308pfg.161.1542782285681; Tue, 20 Nov 2018 22:38:05 -0800 (PST) Received: from tfiga.tok.corp.google.com ([2401:fa00:4:4:5b21:5966:1198:d1e9]) by smtp.gmail.com with ESMTPSA id e14-v6sm50847369pfn.46.2018.11.20.22.38.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 20 Nov 2018 22:38:05 -0800 (PST) From: Tomasz Figa To: linux-media@vger.kernel.org Subject: [PATCH] media: mtk-vcodec: Remove VA from encoder frame buffers Date: Wed, 21 Nov 2018 15:37:59 +0900 Message-Id: <20181121063759.26374-1-tfiga@chromium.org> X-Mailer: git-send-email 2.19.1.1215.g8438c0b245-goog MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181120_223817_724636_9E8BE91F X-CRM114-Status: GOOD ( 11.97 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andrew-CT Chen , Tiffany Lin , linux-kernel@vger.kernel.org, Tomasz Figa , linux-mediatek@lists.infradead.org, Matthias Brugger , hiroh@chromium.org, Mauro Carvalho Chehab , linux-arm-kernel@lists.infradead.org Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The encoder driver has no need to do any CPU access to the source frame buffers. Use a separate structure for holding DMA addresses and sizes for those and remove, so we do not end up introducing any erroneous dereferences of those VAs. This fixes DMA-buf import from exporters that do not provide contiguous kernel mappings, which includes the MTK DRM driver. Signed-off-by: Tomasz Figa --- drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c | 6 +----- drivers/media/platform/mtk-vcodec/mtk_vcodec_util.h | 5 +++++ drivers/media/platform/mtk-vcodec/venc_drv_if.h | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c index 54631ad1c71e..d1f12257bf66 100644 --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c @@ -1087,7 +1087,6 @@ static void mtk_venc_worker(struct work_struct *work) src_buf = v4l2_m2m_src_buf_remove(ctx->m2m_ctx); memset(&frm_buf, 0, sizeof(frm_buf)); for (i = 0; i < src_buf->num_planes ; i++) { - frm_buf.fb_addr[i].va = vb2_plane_vaddr(src_buf, i); frm_buf.fb_addr[i].dma_addr = vb2_dma_contig_plane_dma_addr(src_buf, i); frm_buf.fb_addr[i].size = @@ -1098,14 +1097,11 @@ static void mtk_venc_worker(struct work_struct *work) bs_buf.size = (size_t)dst_buf->planes[0].length; mtk_v4l2_debug(2, - "Framebuf VA=%p PA=%llx Size=0x%zx;VA=%p PA=0x%llx Size=0x%zx;VA=%p PA=0x%llx Size=%zu", - frm_buf.fb_addr[0].va, + "Framebuf PA=%llx Size=0x%zx;PA=0x%llx Size=0x%zx;PA=0x%llx Size=%zu", (u64)frm_buf.fb_addr[0].dma_addr, frm_buf.fb_addr[0].size, - frm_buf.fb_addr[1].va, (u64)frm_buf.fb_addr[1].dma_addr, frm_buf.fb_addr[1].size, - frm_buf.fb_addr[2].va, (u64)frm_buf.fb_addr[2].dma_addr, frm_buf.fb_addr[2].size); diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_util.h b/drivers/media/platform/mtk-vcodec/mtk_vcodec_util.h index 06c254f5c171..9bf6e8d1b9c9 100644 --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_util.h +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_util.h @@ -25,6 +25,11 @@ struct mtk_vcodec_mem { dma_addr_t dma_addr; }; +struct mtk_vcodec_fb { + size_t size; + dma_addr_t dma_addr; +}; + struct mtk_vcodec_ctx; struct mtk_vcodec_dev; diff --git a/drivers/media/platform/mtk-vcodec/venc_drv_if.h b/drivers/media/platform/mtk-vcodec/venc_drv_if.h index a6e7d32e55cb..55ecda844894 100644 --- a/drivers/media/platform/mtk-vcodec/venc_drv_if.h +++ b/drivers/media/platform/mtk-vcodec/venc_drv_if.h @@ -106,7 +106,7 @@ struct venc_enc_param { * @fb_addr: plane frame buffer addresses */ struct venc_frm_buf { - struct mtk_vcodec_mem fb_addr[MTK_VCODEC_MAX_PLANES]; + struct mtk_vcodec_fb fb_addr[MTK_VCODEC_MAX_PLANES]; }; /*