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: 10692013 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 813525A4 for ; Wed, 21 Nov 2018 06:38:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 701012B83F for ; Wed, 21 Nov 2018 06:38:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 648FE2B84A; Wed, 21 Nov 2018 06:38:08 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 005362B83F for ; Wed, 21 Nov 2018 06:38:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728141AbeKURLR (ORCPT ); Wed, 21 Nov 2018 12:11:17 -0500 Received: from mail-pl1-f196.google.com ([209.85.214.196]:33447 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726877AbeKURLR (ORCPT ); Wed, 21 Nov 2018 12:11:17 -0500 Received: by mail-pl1-f196.google.com with SMTP id z23so4015668plo.0 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=WoegmUmOTBwdVKXl1loLsol6XtsdyAVejFQVPTLR66JqQsvTop98iTrVcvmNCgJWTc folEiZq+4TfquzPghRDqF3tAcYFV//65lNpIlL2tqINOSnMbHayRBXkp0HIS1ZHMQT15 HnCuecZx57Qgwqfyy/jmsiW9qohg6sDKSaKVitQ96X5mVQeGO5u+89rh6OUKHSc7w0GJ dxcka37esaVOs2WzOsYI3Mj1EQPvh+2Fm/pZc6uADIIQg3nJmvnuyH5GEtEQ5m+r1sKM JUCfekHugXEdKzvOBVC3U7c8XBN5nOeSoPtOy78qShm5N2pTOA1uByRvFpf1mIk2GxvU yWZQ== X-Gm-Message-State: AGRZ1gJTAGY3DSm99ndBe4+HWoTBWoKEONMALtuO8wC/1Z21JwHoacS8 X3nDvAdd89xXFu0YSvRKKZbbN/8GQbU= 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 Cc: linux-kernel@vger.kernel.org, Tiffany Lin , Andrew-CT Chen , Mauro Carvalho Chehab , Matthias Brugger , linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, hiroh@chromium.org, Tomasz Figa 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 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.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]; }; /*