public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: Hsia-Jun Li <Randy.Li@synaptics.com>
To: Tomasz Figa <tfiga@chromium.org>
Cc: Benjamin Gaignard <benjamin.gaignard@collabora.com>,
	linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, m.szyprowski@samsung.com,
	linux-mediatek@lists.infradead.org,
	linux-arm-msm@vger.kernel.org, hverkuil-cisco@xs4all.nl,
	ezequiel@vanguardiasur.com.ar, p.zabel@pengutronix.de,
	linux-rockchip@lists.infradead.org, mchehab@kernel.org,
	linux-staging@lists.linux.dev, ming.qian@nxp.com,
	kernel@collabora.com, gregkh@linuxfoundation.org,
	nicolas.dufresne@collabora.com
Subject: Re: [PATCH v3 04/11] media: videobuf2: Stop define VB2_MAX_FRAME as global
Date: Fri, 28 Jul 2023 15:24:42 +0800	[thread overview]
Message-ID: <9bc67e88-bce1-b812-aa57-76eca764cb38@synaptics.com> (raw)
In-Reply-To: <CAAFQd5D3NUqvkJFYgystFVFRQvq-5S0ZNUOrv1LJqmCA_8+a_w@mail.gmail.com>



On 7/28/23 15:03, Tomasz Figa wrote:
> CAUTION: Email originated externally, do not click links or open attachments unless you recognize the sender and know the content is safe.
> 
> 
> On Fri, Jul 28, 2023 at 3:55 PM Hsia-Jun Li <Randy.Li@synaptics.com> wrote:
>>
>>
>>
>> On 7/28/23 14:46, Tomasz Figa wrote:
>>> CAUTION: Email originated externally, do not click links or open attachments unless you recognize the sender and know the content is safe.
>>>
>>>
>>> On Mon, Jul 17, 2023 at 4:44 PM Hsia-Jun Li <Randy.Li@synaptics.com> wrote:
>>>>
>>>>
>>>> On 7/12/23 18:48, Tomasz Figa wrote:
>>>>> CAUTION: Email originated externally, do not click links or open attachments unless you recognize the sender and know the content is safe.
>>>>>
>>>>>
>>>>> On Mon, Jul 03, 2023 at 04:35:30PM +0800, Hsia-Jun Li wrote:
>>>>>> On 7/3/23 16:09, Benjamin Gaignard wrote:
>>>>>>> CAUTION: Email originated externally, do not click links or open
>>>>>>> attachments unless you recognize the sender and know the content is
>>>>>>> safe.
>>>>>>>
>>>>>>>
>>>>>>> Le 30/06/2023 à 11:51, Hsia-Jun Li a écrit :
>>>>>>>> On 6/22/23 21:13, Benjamin Gaignard wrote:
>>>>>>>>> CAUTION: Email originated externally, do not click links or open
>>>>>>>>> attachments unless you recognize the sender and know the content is
>>>>>>>>> safe.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> After changing bufs arrays to a dynamic allocated array
>>>>>>>>> VB2_MAX_FRAME doesn't mean anything for videobuf2 core.
>>>>>>>> I think make it 64 which is the VB2_MAX_FRAME in Android GKI kernel is
>>>>>>>> more reasonable.
>>>>>>>>
>>>>>>>> It would be hard to iterate the whole array, it would go worse with a
>>>>>>>> filter. Such iterate may need to go twice because you mix
>>>>>>>> post-processing buffer and decoding buffer(with MV) in the same array.
>>>>>>> Here I don't want to change drivers behavior so I keep the same value.
>>>>>>> If it happens that they need more buffers, like for dynamic resolution
>>>>>>> change
>>>>>>> feature for Verisilicon VP9 decoder, case by case patches will be needed.
>>>>>>>
>>>>>> I just don't like the idea that using a variant length array here.
>>>>>>
>>>>> "I don't like" is not an argument. We had a number of arguments for
>>>>> using a generic helper (originally idr, but later decided to go with
>>>>> XArray, because the former is now deprecated) that we pointed out in
>>>>> our review comments for previous revisions. It wasn't really about the
>>>>> size being variable, but rather avoiding open coding things in vb2 and
>>>>> duplicating what's already implemented in generic code.
>>>>
>>>> I just want to say I don't think we need a variable length array to
>>>> store the buffer here.
>>>>
>>>> And the below is the reason that such a case could be avoided in the
>>>> first place.
>>>>
>>>>>
>>>>>> And I could explain why you won't need so many buffers for the performance
>>>>>> of decoding.
>>>>>>
>>>>>> VP9 could support 10 reference frames in dpb.
>>>>>>
>>>>>> Even for those frequent resolution changing test set, it would only happen
>>>>>> to two resolutions,
>>>>>>
>>>>>> 32 would be enough for 20 buffers of two resolution plus golden frames. It
>>>>>> also leaves enough slots for re-order latency.
>>>>>>
>>>>>> If your case had more two resolutions, likes low->medium->high.
>>>>>>
>>>>>> I would suggest just skip the medium resolutions, just allocate the lower
>>>>>> one first for fast playback then the highest for all the possible
>>>>>>
>>>>>> medium cases. Reallocation happens frequently would only cause memory
>>>>>> fragment, nothing benefits your performance.
>>>>>>
>>>>> We have mechanisms in the kernel to deal with memory fragmentation
>>>>> (migration/compaction) and it would still only matters for the
>>>>> pathologic cases of hardware that require physically contiguous memory.
>>>>> Modern hardware with proper DMA capabilities can either scatter-gather
>>>>> or are equipped with an IOMMU, so the allocation always happens in page
>>>>> granularity and fragmentation is avoided.
>>>>
>>>> Unfortunately, there are more devices that didn't have a IOMMU attached
>>>> to it, supporting scatter gather is more odd.
>>>>
>>>> It would be more likely that IOMMU would be disabled for the performance
>>>> reason.
>>>
>>> These days IOMMU is totally mandatory if you want to think about
>>> having any level of security in your system. Sure, there could be some
>>> systems that are completely isolated from any external environment,
>>> like some offline industry automation machines, but then arguably
>>> their running conditions would also be quite static and require very
>>> little memory re-allocation.
>> Vendor just decided not to included such hardware.
>> That is why From ION to DMA-heap, people like to allocate from a cavout
>> out memory.
>>>
>>> I also don't buy the performance reason. CPUs have been behind MMUs
>>> for ages and nobody is running them with paging disabled for
>>> performance reasons. Similarly, most of the modern consumer systems
>> Page lookup would increase the delay. Besides a few upstream devices
>> prove them only use a level 1 page table without TBL.
> 
> That's just an excuse for a bad hardware design/implementation. As I
> said, there are good IOMMU implementations out there that don't suffer
> from performance issues.
> 
I could do nothing about that.
Besides, even with TLB, cache missing could happen frequently, 
especially we need to access many (5~16, 10 usually) buffers and more 
11MBytes each in a hardware processing.
You can't have a very large TLB.
>>> (mobile phones, PCs) run with IOMMUs enabled for pretty much anything
>>> because of the security reason and they don't seem to be having any
>> If the page is secure, you can't operate it in a insecure IOMMU or MMU.
>> The most security way here, we should use a dedicated memory(or a zone
>> in unified memory).
> 
> You still need something to enforce that the hardware is not accessing
> memory that it's not supposed to access. How do you do that without an
> IOMMU?
> 
If you know the arm security pipeline and security controller, you could 
found we could reserved a range of memory for a security id(devices in 
secure world may be a different security domain).
Besides, a MMU or security MPU could mark some pages for the secure 
world access only, it doesn't mean the device need an IOMMU to access 
them. The MPU could filter the access through the AXI id.
>> I believe there are more users in mobile for DMA-heap than kernel's dma
>> allocation API.
> 
> Yes, but that's completely separate from whether there is an IOMMU or
> not. It's just a different allocation API.
> 
The memory heap would mean a dedicated memory usually(we don't talk 
about system heap or why there are many vendor heaps). Dedicated memory 
means contiguous memory in the most of cases.
>>> performance issues. In fact, it can improve the performance, because
>>> memory allocation is much easier and without contiguous careouts (as
>>> we used to have long ago on Android devices) the extra memory can be
>>> used for buffers and caches to improve system performance.
>>>
>>> Best regards,
>>> Tomasz
>>>
>>>>
>>>>>
>>>>> Best regards,
>>>>> Tomasz
>>>>>
>>>>>>>>> Remove it from the core definitions but keep it for drivers internal
>>>>>>>>> needs.
>>>>>>>>>
>>>>>>>>> Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
>>>>>>>>> ---
>>>>>>>>>      drivers/media/common/videobuf2/videobuf2-core.c | 2 ++
>>>>>>>>>      drivers/media/platform/amphion/vdec.c | 1 +
>>>>>>>>> .../media/platform/mediatek/vcodec/vdec/vdec_vp9_req_lat_if.c | 2 ++
>>>>>>>>>      drivers/media/platform/qcom/venus/hfi.h | 2 ++
>>>>>>>>>      drivers/media/platform/verisilicon/hantro_hw.h | 2 ++
>>>>>>>>>      drivers/staging/media/ipu3/ipu3-v4l2.c | 2 ++
>>>>>>>>>      include/media/videobuf2-core.h | 1 -
>>>>>>>>>      include/media/videobuf2-v4l2.h | 4 ----
>>>>>>>>>      8 files changed, 11 insertions(+), 5 deletions(-)
>>>>>>>>>
>>>>>>>>> diff --git a/drivers/media/common/videobuf2/videobuf2-core.c
>>>>>>>>> b/drivers/media/common/videobuf2/videobuf2-core.c
>>>>>>>>> index 86e1e926fa45..899783f67580 100644
>>>>>>>>> --- a/drivers/media/common/videobuf2/videobuf2-core.c
>>>>>>>>> +++ b/drivers/media/common/videobuf2/videobuf2-core.c
>>>>>>>>> @@ -31,6 +31,8 @@
>>>>>>>>>
>>>>>>>>>      #include <trace/events/vb2.h>
>>>>>>>>>
>>>>>>>>> +#define VB2_MAX_FRAME  32
>>>>>>>>> +
>>>>>>>>>      static int debug;
>>>>>>>>>      module_param(debug, int, 0644);
>>>>>>>>>
>>>>>>>>> diff --git a/drivers/media/platform/amphion/vdec.c
>>>>>>>>> b/drivers/media/platform/amphion/vdec.c
>>>>>>>>> index 3fa1a74a2e20..b3219f6d17fa 100644
>>>>>>>>> --- a/drivers/media/platform/amphion/vdec.c
>>>>>>>>> +++ b/drivers/media/platform/amphion/vdec.c
>>>>>>>>> @@ -28,6 +28,7 @@
>>>>>>>>>
>>>>>>>>>      #define VDEC_MIN_BUFFER_CAP            8
>>>>>>>>>      #define VDEC_MIN_BUFFER_OUT            8
>>>>>>>>> +#define VB2_MAX_FRAME                  32
>>>>>>>>>
>>>>>>>>>      struct vdec_fs_info {
>>>>>>>>>             char name[8];
>>>>>>>>> diff --git
>>>>>>>>> a/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp9_req_lat_if.c
>>>>>>>>> b/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp9_req_lat_if.c
>>>>>>>>> index 6532a69f1fa8..a1e0f24bb91c 100644
>>>>>>>>> --- a/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp9_req_lat_if.c
>>>>>>>>> +++ b/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp9_req_lat_if.c
>>>>>>>>> @@ -16,6 +16,8 @@
>>>>>>>>>      #include "../vdec_drv_if.h"
>>>>>>>>>      #include "../vdec_vpu_if.h"
>>>>>>>>>
>>>>>>>>> +#define VB2_MAX_FRAME  32
>>>>>>>>> +
>>>>>>>>>      /* reset_frame_context defined in VP9 spec */
>>>>>>>>>      #define VP9_RESET_FRAME_CONTEXT_NONE0 0
>>>>>>>>>      #define VP9_RESET_FRAME_CONTEXT_NONE1 1
>>>>>>>>> diff --git a/drivers/media/platform/qcom/venus/hfi.h
>>>>>>>>> b/drivers/media/platform/qcom/venus/hfi.h
>>>>>>>>> index f25d412d6553..bd5ca5a8b945 100644
>>>>>>>>> --- a/drivers/media/platform/qcom/venus/hfi.h
>>>>>>>>> +++ b/drivers/media/platform/qcom/venus/hfi.h
>>>>>>>>> @@ -10,6 +10,8 @@
>>>>>>>>>
>>>>>>>>>      #include "hfi_helper.h"
>>>>>>>>>
>>>>>>>>> +#define VB2_MAX_FRAME                          32
>>>>>>>>> +
>>>>>>>>>      #define VIDC_SESSION_TYPE_VPE                  0
>>>>>>>>>      #define VIDC_SESSION_TYPE_ENC                  1
>>>>>>>>>      #define VIDC_SESSION_TYPE_DEC                  2
>>>>>>>>> diff --git a/drivers/media/platform/verisilicon/hantro_hw.h
>>>>>>>>> b/drivers/media/platform/verisilicon/hantro_hw.h
>>>>>>>>> index e83f0c523a30..9e8faf7ba6fb 100644
>>>>>>>>> --- a/drivers/media/platform/verisilicon/hantro_hw.h
>>>>>>>>> +++ b/drivers/media/platform/verisilicon/hantro_hw.h
>>>>>>>>> @@ -15,6 +15,8 @@
>>>>>>>>>      #include <media/v4l2-vp9.h>
>>>>>>>>>      #include <media/videobuf2-core.h>
>>>>>>>>>
>>>>>>>>> +#define VB2_MAX_FRAME  32
>>>>>>>>> +
>>>>>>>>>      #define DEC_8190_ALIGN_MASK    0x07U
>>>>>>>>>
>>>>>>>>>      #define MB_DIM                 16
>>>>>>>>> diff --git a/drivers/staging/media/ipu3/ipu3-v4l2.c
>>>>>>>>> b/drivers/staging/media/ipu3/ipu3-v4l2.c
>>>>>>>>> index e530767e80a5..6627b5c2d4d6 100644
>>>>>>>>> --- a/drivers/staging/media/ipu3/ipu3-v4l2.c
>>>>>>>>> +++ b/drivers/staging/media/ipu3/ipu3-v4l2.c
>>>>>>>>> @@ -10,6 +10,8 @@
>>>>>>>>>      #include "ipu3.h"
>>>>>>>>>      #include "ipu3-dmamap.h"
>>>>>>>>>
>>>>>>>>> +#define VB2_MAX_FRAME  32
>>>>>>>>> +
>>>>>>>>>      /******************** v4l2_subdev_ops ********************/
>>>>>>>>>
>>>>>>>>>      #define IPU3_RUNNING_MODE_VIDEO                0
>>>>>>>>> diff --git a/include/media/videobuf2-core.h
>>>>>>>>> b/include/media/videobuf2-core.h
>>>>>>>>> index 77921cf894ef..080b783d608d 100644
>>>>>>>>> --- a/include/media/videobuf2-core.h
>>>>>>>>> +++ b/include/media/videobuf2-core.h
>>>>>>>>> @@ -20,7 +20,6 @@
>>>>>>>>>      #include <media/media-request.h>
>>>>>>>>>      #include <media/frame_vector.h>
>>>>>>>>>
>>>>>>>>> -#define VB2_MAX_FRAME  (32)
>>>>>>>>>      #define VB2_MAX_PLANES (8)
>>>>>>>>>
>>>>>>>>>      /**
>>>>>>>>> diff --git a/include/media/videobuf2-v4l2.h
>>>>>>>>> b/include/media/videobuf2-v4l2.h
>>>>>>>>> index 5a845887850b..88a7a565170e 100644
>>>>>>>>> --- a/include/media/videobuf2-v4l2.h
>>>>>>>>> +++ b/include/media/videobuf2-v4l2.h
>>>>>>>>> @@ -15,10 +15,6 @@
>>>>>>>>>      #include <linux/videodev2.h>
>>>>>>>>>      #include <media/videobuf2-core.h>
>>>>>>>>>
>>>>>>>>> -#if VB2_MAX_FRAME != VIDEO_MAX_FRAME
>>>>>>>>> -#error VB2_MAX_FRAME != VIDEO_MAX_FRAME
>>>>>>>>> -#endif
>>>>>>>>> -
>>>>>>>>>      #if VB2_MAX_PLANES != VIDEO_MAX_PLANES
>>>>>>>>>      #error VB2_MAX_PLANES != VIDEO_MAX_PLANES
>>>>>>>>>      #endif
>>>>>>>>> --
>>>>>>>>> 2.39.2
>>>>>>>>>
>>>>>> --
>>>>>> Hsia-Jun(Randy) Li
>>>>>>
>>>> --
>>>> Hsia-Jun(Randy) Li
>>>>
>>
>> --
>> Hsia-Jun(Randy) Li

-- 
Hsia-Jun(Randy) Li

  reply	other threads:[~2023-07-28  7:25 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-22 13:13 [PATCH v3 00/11] Add DELETE_BUF ioctl Benjamin Gaignard
2023-06-22 13:13 ` [PATCH v3 01/11] media: videobuf2: Access vb2_queue bufs array through helper functions Benjamin Gaignard
2023-06-23 15:10   ` kernel test robot
2023-06-24 23:34   ` kernel test robot
2023-06-22 13:13 ` [PATCH v3 02/11] media: videobuf2: Use Xarray instead of static buffers array Benjamin Gaignard
2023-06-22 13:13 ` [PATCH v3 03/11] media: videobuf2: Remove VB2_MAX_FRAME limit on buffer storage Benjamin Gaignard
2023-06-22 13:56   ` Dan Carpenter
2023-06-22 14:11   ` Dan Carpenter
2023-06-22 14:13     ` Benjamin Gaignard
2023-06-23  7:02       ` Hans Verkuil
2023-06-23  7:51         ` Benjamin Gaignard
2023-06-22 13:13 ` [PATCH v3 04/11] media: videobuf2: Stop define VB2_MAX_FRAME as global Benjamin Gaignard
2023-06-30  9:51   ` Hsia-Jun Li
2023-07-03  8:09     ` Benjamin Gaignard
2023-07-03  8:35       ` Hsia-Jun Li
2023-07-03 10:53         ` Benjamin Gaignard
2023-07-03 11:05           ` Hsia-Jun Li
2023-07-12 10:48         ` Tomasz Figa
2023-07-17  7:44           ` Hsia-Jun Li
2023-07-28  6:46             ` Tomasz Figa
2023-07-28  6:55               ` Hsia-Jun Li
2023-07-28  7:03                 ` Tomasz Figa
2023-07-28  7:24                   ` Hsia-Jun Li [this message]
2023-09-07  4:15                     ` Tomasz Figa
2023-09-07  6:54                       ` Hsia-Jun Li
2023-06-22 13:13 ` [PATCH v3 05/11] media: verisilicon: Refactor postprocessor to store more buffers Benjamin Gaignard
2023-06-22 13:13 ` [PATCH v3 06/11] media: verisilicon: Store chroma and motion vectors offset Benjamin Gaignard
2023-06-22 13:13 ` [PATCH v3 07/11] media: verisilicon: vp9: Use destination buffer height to compute chroma offset Benjamin Gaignard
2023-06-22 13:13 ` [PATCH v3 08/11] media: verisilicon: postproc: Fix down scale test Benjamin Gaignard
2023-06-22 15:27   ` Benjamin Gaignard
2023-06-22 13:13 ` [PATCH v3 09/11] media: verisilicon: vp9: Allow to change resolution while streaming Benjamin Gaignard
2023-06-22 13:13 ` [PATCH v3 10/11] media: v4l2: Add DELETE_BUF ioctl Benjamin Gaignard
2023-06-22 23:12   ` kernel test robot
2023-06-23  0:25   ` kernel test robot
2023-06-26  7:08   ` [EXT] " Ming Qian
2023-06-26  7:48     ` Benjamin Gaignard
2023-06-26  7:50       ` Benjamin Gaignard
2023-06-26  8:13         ` Ming Qian
2023-06-26  8:04       ` Ming Qian
2023-06-27  7:30   ` Hsia-Jun Li
2023-06-27  8:43     ` Benjamin Gaignard
2023-06-27  8:47       ` Hsia-Jun Li
2023-06-30  9:43         ` Hsia-Jun Li
2023-07-03  8:12           ` Benjamin Gaignard
2023-07-03  8:19             ` Hsia-Jun Li
2023-07-03  8:52               ` Benjamin Gaignard
2023-07-03  9:20                 ` Hsia-Jun Li
2023-07-03 10:35                   ` Benjamin Gaignard
2023-07-03 11:06                     ` Hsia-Jun Li
     [not found]                     ` <8ca2f66e-8ff9-e885-274f-51417b581b78@synaptics.com>
2023-07-03 11:17                       ` Benjamin Gaignard
2023-07-03 15:42                         ` Randy Li
2023-07-13  9:09           ` Tomasz Figa
2023-07-17  2:16             ` Hsia-Jun Li
2023-07-28  6:57               ` Tomasz Figa
2023-07-28  7:26                 ` Hsia-Jun Li
2023-06-22 13:13 ` [PATCH v3 11/11] media: v4l2: Add mem2mem helpers for " Benjamin Gaignard
2023-06-27  7:40 ` [PATCH v3 00/11] Add " Hsia-Jun Li

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9bc67e88-bce1-b812-aa57-76eca764cb38@synaptics.com \
    --to=randy.li@synaptics.com \
    --cc=benjamin.gaignard@collabora.com \
    --cc=ezequiel@vanguardiasur.com.ar \
    --cc=gregkh@linuxfoundation.org \
    --cc=hverkuil-cisco@xs4all.nl \
    --cc=kernel@collabora.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=m.szyprowski@samsung.com \
    --cc=mchehab@kernel.org \
    --cc=ming.qian@nxp.com \
    --cc=nicolas.dufresne@collabora.com \
    --cc=p.zabel@pengutronix.de \
    --cc=tfiga@chromium.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox