From patchwork Tue Jun 5 13:33:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sylwester Nawrocki X-Patchwork-Id: 50129 Received: from vger.kernel.org ([209.132.180.67]) by www.linuxtv.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fQC6M-0005pP-Cz; Tue, 05 Jun 2018 13:34:19 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752165AbeFENeQ (ORCPT + 1 other); Tue, 5 Jun 2018 09:34:16 -0400 Received: from mailout2.samsung.com ([203.254.224.25]:35274 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752284AbeFENeN (ORCPT ); Tue, 5 Jun 2018 09:34:13 -0400 Received: from epcas1p2.samsung.com (unknown [182.195.41.46]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20180605133411epoutp02d9031cfcefc134588681ddb40d69363d~1RvF0ahmi0214602146epoutp02J; Tue, 5 Jun 2018 13:34:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20180605133411epoutp02d9031cfcefc134588681ddb40d69363d~1RvF0ahmi0214602146epoutp02J DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1528205651; bh=Tag68bn+Cd0SxeZjtC8X4Rx0T+aFevaGmOlYvqXgm3E=; h=From:To:Cc:Subject:Date:References:From; b=gg/WSndXPfGQXIM3bcIJEuzCp+wb5rBVXOqB5wNF1L2a/DMUP52sB2/Im+z4Rs3ZD YMoWZBEZ0e1rwFDK0ee9xrDVl5Z6YmMkqM/jChrBFqJJ6/hkS4T3e/A9CBMrjhLV5Q TGw1DzV70ddc22OcZCFUjuGhK8kgbCCQGUPjpF0E= Received: from epsmges1p4.samsung.com (unknown [182.195.42.56]) by epcas1p3.samsung.com (KnoxPortal) with ESMTP id 20180605133411epcas1p3b0ac0cc9087911a26d0aa2434ad03e16~1RvFqkJSN0246102461epcas1p3_; Tue, 5 Jun 2018 13:34:11 +0000 (GMT) Received: from epcas1p4.samsung.com ( [182.195.41.48]) by epsmges1p4.samsung.com (Symantec Messaging Gateway) with SMTP id A0.58.04343.351961B5; Tue, 5 Jun 2018 22:34:11 +0900 (KST) Received: from epsmgms2p1new.samsung.com (unknown [182.195.42.142]) by epcas1p3.samsung.com (KnoxPortal) with ESMTP id 20180605133410epcas1p36084a2286fb9e7ad27d6488cc6b99b4e~1RvFL7gC82284122841epcas1p3W; Tue, 5 Jun 2018 13:34:10 +0000 (GMT) X-AuditID: b6c32a38-773ff700000010f7-10-5b1691536715 Received: from epmmp2 ( [203.254.227.17]) by epsmgms2p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 00.07.03915.251961B5; Tue, 5 Jun 2018 22:34:10 +0900 (KST) Received: from AMDC3061.digital.local ([106.116.147.40]) by mmp2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0P9U00LMQR0QQC60@mmp2.samsung.com>; Tue, 05 Jun 2018 22:34:10 +0900 (KST) From: Sylwester Nawrocki To: linux-media@vger.kernel.org Cc: linux-samsung-soc@vger.kernel.org, m.szyprowski@samsung.com, b.zolnierkie@samsung.com, Sylwester Nawrocki Subject: [PATCH] s5p-mfc: Fix buffer look up in s5p_mfc_handle_frame_{new, copy_time} functions Date: Tue, 05 Jun 2018 15:33:59 +0200 Message-id: <20180605133359.10203-1-s.nawrocki@samsung.com> X-Mailer: git-send-email 2.14.2 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpmkeLIzCtJLcpLzFFi42LZdljTQDd4oli0wcw53BYbZ6xntejZsJXV Ysb5fUwWa4/cZbc4/Kad1YHVo2/LKkaPz5vkApiiuGxSUnMyy1KL9O0SuDK23e5mL9gsV7Hu /TW2BsYdkl2MnBwSAiYSu5Z1snYxcnEICexglJgzbRM7hPOdUaLt2SxWmKpV0w4zQyQ2MEps vrKQDcL5xSjRfmY9O0gVm4ChRO/RPkYQW0RAXuJJ7w2wImaBDkaJZbv/MoMkhAUSJSas2QA2 lkVAVeLLrxYmEJtXwFri84xvLBDr5CXeL7jPCNIsIXCWVaJl/11miISLxLyzZ9kgbGGJV8e3 AG3mALKlJS4dtYUIV0vs2t7NDNELtLjlwnaoXmuJw8cvgi1mFuCTePe1hxWil1eio00IosRD orPnENgNQgKxEle7PrFMYJRYwMiwilEstaA4Nz212LDARK84Mbe4NC9dLzk/dxMjOGq0LHYw 7jnnc4hRgINRiYd3RbdYtBBrYllxZe4hRgkOZiURXh53oBBvSmJlVWpRfnxRaU5q8SFGaQ4W JXHeipsC0UIC6YklqdmpqQWpRTBZJg5OqQZGtg9qn2yM+aeWms72nPVI4bs+64aaqOXn32y6 VNrT9rfikK9IFsuChGfZCTujj2489SLFas09Wf/TWW7SM3LU0w8o/pG0/xHKbnLyV5LxJiMh vaubmsouCz58m3vw4AUFywJWgdXTn+9OCYvYHXep+7fXSvZjjmvz5/xi9WpcKsutedXytWSu EktxRqKhFnNRcSIANfavd5YCAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrDJMWRmVeSWpSXmKPExsVy+t9jQd2giWLRBk1vVC02zljPatGzYSur xYzz+5gs1h65y25x+E07qwOrR9+WVYwenzfJBTBFcdmkpOZklqUW6dslcGVsu93NXrBZrmLd +2tsDYw7JLsYOTkkBEwkVk07zNzFyMUhJLCOUeLDpansEM4vRom322azglSxCRhK9B7tYwSx RQTkJZ703mADKWIW6GCUWLPxGjNIQlggUWLCmg1gDSwCqhJffrUwgdi8AtYSn2d8Y4FYJy/x fsF9xgmMXAsYGVYxSqYWFOem5xYbFRjmpZbrFSfmFpfmpesl5+duYgT6edthrb4djPeXxB9i FOBgVOLhZegTixZiTSwrrsw9xCjBwawkwsvjDhTiTUmsrEotyo8vKs1JLT7EKM3BoiTOezvv WKSQQHpiSWp2ampBahFMlomDU6qBca5o0q1aT+lFDgx3zLL/+Vw78VaDiXtejfTvM1HynFcS 9uuZ13Cc7Yw1zdf0cOIUNQ3jOv390hmhCEWR5ivz/qiId/Kf83A9o/xPZo62xQL9h9Nf/Al/ uH7NpWP7jfWfmRnyrjbI+8GtVXD8omxXF+ubF2pWMt8NdujP+iy+33HZt8SpBrujlViKMxIN tZiLihMBEmS5JO8BAAA= X-CMS-MailID: 20180605133410epcas1p36084a2286fb9e7ad27d6488cc6b99b4e X-Msg-Generator: CA CMS-TYPE: 101P X-CMS-RootMailID: 20180605133410epcas1p36084a2286fb9e7ad27d6488cc6b99b4e References: Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Look up of buffers in s5p_mfc_handle_frame_new, s5p_mfc_handle_frame_copy_time functions is not working properly for DMA addresses above 2 GiB. As a result flags and timestamp of returned buffers are not set correctly and it breaks operation of GStreamer/OMX plugins which rely on the CAPTURE buffer queue flags. Due to improper return type of the get_dec_y_adr, get_dspl_y_adr callbacks and sign bit extension these callbacks return incorrect address values, e.g. 0xfffffffffefc0000 instead of 0x00000000fefc0000. Then the statement: "if (vb2_dma_contig_plane_dma_addr(&dst_buf->b->vb2_buf, 0) == dec_y_addr)" is always false, which breaks looking up capture queue buffers. To ensure proper matching by address u32 type is used for the DMA addresses. This should work on all related SoCs, since the MFC DMA address width is not larger than 32-bit. Changes done in this patch are minimal as there is a larger patch series pending refactoring the whole driver. Signed-off-by: Sylwester Nawrocki --- drivers/media/platform/s5p-mfc/s5p_mfc.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c b/drivers/media/platform/s5p-mfc/s5p_mfc.c index a80251ed3143..780548dd650e 100644 --- a/drivers/media/platform/s5p-mfc/s5p_mfc.c +++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c @@ -254,24 +254,24 @@ static void s5p_mfc_handle_frame_all_extracted(struct s5p_mfc_ctx *ctx) static void s5p_mfc_handle_frame_copy_time(struct s5p_mfc_ctx *ctx) { struct s5p_mfc_dev *dev = ctx->dev; - struct s5p_mfc_buf *dst_buf, *src_buf; - size_t dec_y_addr; + struct s5p_mfc_buf *dst_buf, *src_buf; + u32 dec_y_addr; unsigned int frame_type; /* Make sure we actually have a new frame before continuing. */ frame_type = s5p_mfc_hw_call(dev->mfc_ops, get_dec_frame_type, dev); if (frame_type == S5P_FIMV_DECODE_FRAME_SKIPPED) return; - dec_y_addr = s5p_mfc_hw_call(dev->mfc_ops, get_dec_y_adr, dev); + dec_y_addr = (u32)s5p_mfc_hw_call(dev->mfc_ops, get_dec_y_adr, dev); /* Copy timestamp / timecode from decoded src to dst and set appropriate flags. */ src_buf = list_entry(ctx->src_queue.next, struct s5p_mfc_buf, list); list_for_each_entry(dst_buf, &ctx->dst_queue, list) { - if (vb2_dma_contig_plane_dma_addr(&dst_buf->b->vb2_buf, 0) - == dec_y_addr) { - dst_buf->b->timecode = - src_buf->b->timecode; + u32 addr = (u32)vb2_dma_contig_plane_dma_addr(&dst_buf->b->vb2_buf, 0); + + if (addr == dec_y_addr) { + dst_buf->b->timecode = src_buf->b->timecode; dst_buf->b->vb2_buf.timestamp = src_buf->b->vb2_buf.timestamp; dst_buf->b->flags &= @@ -307,10 +307,10 @@ static void s5p_mfc_handle_frame_new(struct s5p_mfc_ctx *ctx, unsigned int err) { struct s5p_mfc_dev *dev = ctx->dev; struct s5p_mfc_buf *dst_buf; - size_t dspl_y_addr; + u32 dspl_y_addr; unsigned int frame_type; - dspl_y_addr = s5p_mfc_hw_call(dev->mfc_ops, get_dspl_y_adr, dev); + dspl_y_addr = (u32)s5p_mfc_hw_call(dev->mfc_ops, get_dspl_y_adr, dev); if (IS_MFCV6_PLUS(dev)) frame_type = s5p_mfc_hw_call(dev->mfc_ops, get_disp_frame_type, ctx); @@ -329,9 +329,10 @@ static void s5p_mfc_handle_frame_new(struct s5p_mfc_ctx *ctx, unsigned int err) /* The MFC returns address of the buffer, now we have to * check which videobuf does it correspond to */ list_for_each_entry(dst_buf, &ctx->dst_queue, list) { + u32 addr = (u32)vb2_dma_contig_plane_dma_addr(&dst_buf->b->vb2_buf, 0); + /* Check if this is the buffer we're looking for */ - if (vb2_dma_contig_plane_dma_addr(&dst_buf->b->vb2_buf, 0) - == dspl_y_addr) { + if (addr == dspl_y_addr) { list_del(&dst_buf->list); ctx->dst_queue_cnt--; dst_buf->b->sequence = ctx->sequence;