diff mbox series

[v3,4/4] media: camss: sm8250: Pipeline starting and stopping for multiple virtual channels

Message ID 20221007132009.1886-5-quic_mmitkov@quicinc.com (mailing list archive)
State New, archived
Headers show
Series media: camss: sm8250: Virtual channels support for SM8250 | expand

Commit Message

Milen Mitkov (Consultant) Oct. 7, 2022, 1:20 p.m. UTC
From: Milen Mitkov <quic_mmitkov@quicinc.com>

Use the multistream series function video_device_pipeline_alloc_start
to allows multiple clients of the same pipeline.

If any of the entities in the pipeline doesn't return success at stop
(e.g. if a VFE line remains running), the full pipeline won't be stopped.
This allows for stopping and starting streams at any point without
disrupting the other running streams.

Signed-off-by: Milen Mitkov <quic_mmitkov@quicinc.com>
---
 .../media/platform/qcom/camss/camss-video.c   | 21 ++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

Comments

Bryan O'Donoghue Oct. 7, 2022, 2:44 p.m. UTC | #1
On 07/10/2022 14:20, quic_mmitkov@quicinc.com wrote:
> From: Milen Mitkov <quic_mmitkov@quicinc.com>
> 
> Use the multistream series function video_device_pipeline_alloc_start
> to allows multiple clients of the same pipeline.
> 
> If any of the entities in the pipeline doesn't return success at stop
> (e.g. if a VFE line remains running), the full pipeline won't be stopped.
> This allows for stopping and starting streams at any point without
> disrupting the other running streams.
> 
> Signed-off-by: Milen Mitkov <quic_mmitkov@quicinc.com>
> ---
>   .../media/platform/qcom/camss/camss-video.c   | 21 ++++++++++++++++---
>   1 file changed, 18 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/media/platform/qcom/camss/camss-video.c b/drivers/media/platform/qcom/camss/camss-video.c
> index 81fb3a5bc1d5..b042faf3dcda 100644
> --- a/drivers/media/platform/qcom/camss/camss-video.c
> +++ b/drivers/media/platform/qcom/camss/camss-video.c
> @@ -353,6 +353,7 @@ static int video_get_subdev_format(struct camss_video *video,
>   
>   	fmt.pad = pad;
>   	fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE;
> +	fmt.stream = 0;
>   
>   	ret = v4l2_subdev_call(subdev, pad, get_fmt, NULL, &fmt);
>   	if (ret)
> @@ -493,9 +494,11 @@ static int video_start_streaming(struct vb2_queue *q, unsigned int count)
>   	struct v4l2_subdev *subdev;
>   	int ret;
>   
> -	ret = video_device_pipeline_start(vdev, &video->pipe);
> -	if (ret < 0)
> +	ret = video_device_pipeline_alloc_start(vdev);
> +	if (ret < 0) {
> +		dev_err(video->camss->dev, "Failed to start media pipeline: %d\n", ret);
>   		return ret;
> +	}
>   
>   	ret = video_check_format(video);
>   	if (ret < 0)
> @@ -536,6 +539,7 @@ static void video_stop_streaming(struct vb2_queue *q)
>   	struct media_entity *entity;
>   	struct media_pad *pad;
>   	struct v4l2_subdev *subdev;
> +	int ret;
>   
>   	entity = &vdev->entity;
>   	while (1) {
> @@ -550,7 +554,18 @@ static void video_stop_streaming(struct vb2_queue *q)
>   		entity = pad->entity;
>   		subdev = media_entity_to_v4l2_subdev(entity);
>   
> -		v4l2_subdev_call(subdev, video, s_stream, 0);
> +		ret = v4l2_subdev_call(subdev, video, s_stream, 0);
> +
> +		if (ret == -EBUSY) {
> +			/* Don't stop if other instances of the pipeline are still running */
> +			dev_dbg(video->camss->dev, "Video pipeline still used, don't stop streaming.\n");
> +			return;
> +		}
> +
> +		if (ret) {
> +			dev_err(video->camss->dev, "Video pipeline stop failed: %d\n", ret);
> +			return;
> +		}
>   	}
>   
>   	video_device_pipeline_stop(vdev);

Hi.

This still doesn't apply to media tip of tree fixes

I get 3/4 patches in then the last one doesn't apply

To ssh://git.linaro.org/people/bryan.odonoghue/kernel.git
  * [new branch]                HEAD -> 
media-tree-fixes-22-10-07+qcom-camss-vc-partial
kernel test robot Oct. 7, 2022, 5:23 p.m. UTC | #2
Hi,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on sailus-media-tree/streams]
[also build test ERROR on next-20221007]
[cannot apply to media-tree/master linus/master v6.0]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/quic_mmitkov-quicinc-com/media-camss-sm8250-Virtual-channels-support-for-SM8250/20221007-212245
base:   git://linuxtv.org/sailus/media_tree.git streams
config: arc-randconfig-r004-20221007
compiler: arceb-elf-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/intel-lab-lkp/linux/commit/6c67d02c94e7e7e733fa48625d26af1a7879d1e0
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review quic_mmitkov-quicinc-com/media-camss-sm8250-Virtual-channels-support-for-SM8250/20221007-212245
        git checkout 6c67d02c94e7e7e733fa48625d26af1a7879d1e0
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=arc SHELL=/bin/bash drivers/media/platform/qcom/camss/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   drivers/media/platform/qcom/camss/camss-video.c: In function 'video_get_subdev_format':
>> drivers/media/platform/qcom/camss/camss-video.c:356:12: error: 'struct v4l2_subdev_format' has no member named 'stream'
     356 |         fmt.stream = 0;
         |            ^


vim +356 drivers/media/platform/qcom/camss/camss-video.c

   341	
   342	static int video_get_subdev_format(struct camss_video *video,
   343					   struct v4l2_format *format)
   344	{
   345		struct v4l2_subdev_format fmt;
   346		struct v4l2_subdev *subdev;
   347		u32 pad;
   348		int ret;
   349	
   350		subdev = video_remote_subdev(video, &pad);
   351		if (subdev == NULL)
   352			return -EPIPE;
   353	
   354		fmt.pad = pad;
   355		fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE;
 > 356		fmt.stream = 0;
   357	
   358		ret = v4l2_subdev_call(subdev, pad, get_fmt, NULL, &fmt);
   359		if (ret)
   360			return ret;
   361	
   362		ret = video_find_format(fmt.format.code,
   363					format->fmt.pix_mp.pixelformat,
   364					video->formats, video->nformats);
   365		if (ret < 0)
   366			return ret;
   367	
   368		format->type = video->type;
   369	
   370		return video_mbus_to_pix_mp(&fmt.format, &format->fmt.pix_mp,
   371					    &video->formats[ret], video->bpl_alignment);
   372	}
   373
kernel test robot Oct. 7, 2022, 9:42 p.m. UTC | #3
Hi,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on sailus-media-tree/streams]
[also build test ERROR on next-20221007]
[cannot apply to media-tree/master linus/master v6.0]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/quic_mmitkov-quicinc-com/media-camss-sm8250-Virtual-channels-support-for-SM8250/20221007-212245
base:   git://linuxtv.org/sailus/media_tree.git streams
config: s390-buildonly-randconfig-r001-20221002
compiler: clang version 16.0.0 (https://github.com/llvm/llvm-project 791a7ae1ba3efd6bca96338e10ffde557ba83920)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install s390 cross compiling tool for clang build
        # apt-get install binutils-s390x-linux-gnu
        # https://github.com/intel-lab-lkp/linux/commit/6c67d02c94e7e7e733fa48625d26af1a7879d1e0
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review quic_mmitkov-quicinc-com/media-camss-sm8250-Virtual-channels-support-for-SM8250/20221007-212245
        git checkout 6c67d02c94e7e7e733fa48625d26af1a7879d1e0
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=s390 SHELL=/bin/bash drivers/media/platform/qcom/camss/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   In file included from drivers/media/platform/qcom/camss/camss-video.c:13:
   In file included from include/media/v4l2-device.h:12:
   In file included from include/media/media-device.h:16:
   In file included from include/linux/pci.h:39:
   In file included from include/linux/io.h:13:
   In file included from arch/s390/include/asm/io.h:75:
   include/asm-generic/io.h:547:31: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           val = __raw_readb(PCI_IOBASE + addr);
                             ~~~~~~~~~~ ^
   include/asm-generic/io.h:560:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr));
                                                           ~~~~~~~~~~ ^
   include/uapi/linux/byteorder/big_endian.h:37:59: note: expanded from macro '__le16_to_cpu'
   #define __le16_to_cpu(x) __swab16((__force __u16)(__le16)(x))
                                                             ^
   include/uapi/linux/swab.h:102:54: note: expanded from macro '__swab16'
   #define __swab16(x) (__u16)__builtin_bswap16((__u16)(x))
                                                        ^
   In file included from drivers/media/platform/qcom/camss/camss-video.c:13:
   In file included from include/media/v4l2-device.h:12:
   In file included from include/media/media-device.h:16:
   In file included from include/linux/pci.h:39:
   In file included from include/linux/io.h:13:
   In file included from arch/s390/include/asm/io.h:75:
   include/asm-generic/io.h:573:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr));
                                                           ~~~~~~~~~~ ^
   include/uapi/linux/byteorder/big_endian.h:35:59: note: expanded from macro '__le32_to_cpu'
   #define __le32_to_cpu(x) __swab32((__force __u32)(__le32)(x))
                                                             ^
   include/uapi/linux/swab.h:115:54: note: expanded from macro '__swab32'
   #define __swab32(x) (__u32)__builtin_bswap32((__u32)(x))
                                                        ^
   In file included from drivers/media/platform/qcom/camss/camss-video.c:13:
   In file included from include/media/v4l2-device.h:12:
   In file included from include/media/media-device.h:16:
   In file included from include/linux/pci.h:39:
   In file included from include/linux/io.h:13:
   In file included from arch/s390/include/asm/io.h:75:
   include/asm-generic/io.h:584:33: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           __raw_writeb(value, PCI_IOBASE + addr);
                               ~~~~~~~~~~ ^
   include/asm-generic/io.h:594:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           __raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr);
                                                         ~~~~~~~~~~ ^
   include/asm-generic/io.h:604:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           __raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr);
                                                         ~~~~~~~~~~ ^
   include/asm-generic/io.h:692:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           readsb(PCI_IOBASE + addr, buffer, count);
                  ~~~~~~~~~~ ^
   include/asm-generic/io.h:700:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           readsw(PCI_IOBASE + addr, buffer, count);
                  ~~~~~~~~~~ ^
   include/asm-generic/io.h:708:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           readsl(PCI_IOBASE + addr, buffer, count);
                  ~~~~~~~~~~ ^
   include/asm-generic/io.h:717:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           writesb(PCI_IOBASE + addr, buffer, count);
                   ~~~~~~~~~~ ^
   include/asm-generic/io.h:726:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           writesw(PCI_IOBASE + addr, buffer, count);
                   ~~~~~~~~~~ ^
   include/asm-generic/io.h:735:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           writesl(PCI_IOBASE + addr, buffer, count);
                   ~~~~~~~~~~ ^
>> drivers/media/platform/qcom/camss/camss-video.c:356:6: error: no member named 'stream' in 'struct v4l2_subdev_format'
           fmt.stream = 0;
           ~~~ ^
   12 warnings and 1 error generated.


vim +356 drivers/media/platform/qcom/camss/camss-video.c

   341	
   342	static int video_get_subdev_format(struct camss_video *video,
   343					   struct v4l2_format *format)
   344	{
   345		struct v4l2_subdev_format fmt;
   346		struct v4l2_subdev *subdev;
   347		u32 pad;
   348		int ret;
   349	
   350		subdev = video_remote_subdev(video, &pad);
   351		if (subdev == NULL)
   352			return -EPIPE;
   353	
   354		fmt.pad = pad;
   355		fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE;
 > 356		fmt.stream = 0;
   357	
   358		ret = v4l2_subdev_call(subdev, pad, get_fmt, NULL, &fmt);
   359		if (ret)
   360			return ret;
   361	
   362		ret = video_find_format(fmt.format.code,
   363					format->fmt.pix_mp.pixelformat,
   364					video->formats, video->nformats);
   365		if (ret < 0)
   366			return ret;
   367	
   368		format->type = video->type;
   369	
   370		return video_mbus_to_pix_mp(&fmt.format, &format->fmt.pix_mp,
   371					    &video->formats[ret], video->bpl_alignment);
   372	}
   373
Robert Foss Oct. 13, 2022, 8:43 a.m. UTC | #4
On Fri, 7 Oct 2022 at 15:20, <quic_mmitkov@quicinc.com> wrote:
>
> From: Milen Mitkov <quic_mmitkov@quicinc.com>
>
> Use the multistream series function video_device_pipeline_alloc_start
> to allows multiple clients of the same pipeline.
>
> If any of the entities in the pipeline doesn't return success at stop
> (e.g. if a VFE line remains running), the full pipeline won't be stopped.
> This allows for stopping and starting streams at any point without
> disrupting the other running streams.
>
> Signed-off-by: Milen Mitkov <quic_mmitkov@quicinc.com>
> ---
>  .../media/platform/qcom/camss/camss-video.c   | 21 ++++++++++++++++---
>  1 file changed, 18 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/media/platform/qcom/camss/camss-video.c b/drivers/media/platform/qcom/camss/camss-video.c
> index 81fb3a5bc1d5..b042faf3dcda 100644
> --- a/drivers/media/platform/qcom/camss/camss-video.c
> +++ b/drivers/media/platform/qcom/camss/camss-video.c
> @@ -353,6 +353,7 @@ static int video_get_subdev_format(struct camss_video *video,
>
>         fmt.pad = pad;
>         fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE;
> +       fmt.stream = 0;
>
>         ret = v4l2_subdev_call(subdev, pad, get_fmt, NULL, &fmt);
>         if (ret)
> @@ -493,9 +494,11 @@ static int video_start_streaming(struct vb2_queue *q, unsigned int count)
>         struct v4l2_subdev *subdev;
>         int ret;
>
> -       ret = video_device_pipeline_start(vdev, &video->pipe);
> -       if (ret < 0)
> +       ret = video_device_pipeline_alloc_start(vdev);
> +       if (ret < 0) {
> +               dev_err(video->camss->dev, "Failed to start media pipeline: %d\n", ret);
>                 return ret;
> +       }
>
>         ret = video_check_format(video);
>         if (ret < 0)
> @@ -536,6 +539,7 @@ static void video_stop_streaming(struct vb2_queue *q)
>         struct media_entity *entity;
>         struct media_pad *pad;
>         struct v4l2_subdev *subdev;
> +       int ret;
>
>         entity = &vdev->entity;
>         while (1) {
> @@ -550,7 +554,18 @@ static void video_stop_streaming(struct vb2_queue *q)
>                 entity = pad->entity;
>                 subdev = media_entity_to_v4l2_subdev(entity);
>
> -               v4l2_subdev_call(subdev, video, s_stream, 0);
> +               ret = v4l2_subdev_call(subdev, video, s_stream, 0);
> +
> +               if (ret == -EBUSY) {
> +                       /* Don't stop if other instances of the pipeline are still running */
> +                       dev_dbg(video->camss->dev, "Video pipeline still used, don't stop streaming.\n");
> +                       return;
> +               }
> +
> +               if (ret) {
> +                       dev_err(video->camss->dev, "Video pipeline stop failed: %d\n", ret);
> +                       return;
> +               }
>         }
>
>         video_device_pipeline_stop(vdev);
> --
> 2.37.3
>

Reviewed-by: Robert Foss <robert.foss@linaro.org>
diff mbox series

Patch

diff --git a/drivers/media/platform/qcom/camss/camss-video.c b/drivers/media/platform/qcom/camss/camss-video.c
index 81fb3a5bc1d5..b042faf3dcda 100644
--- a/drivers/media/platform/qcom/camss/camss-video.c
+++ b/drivers/media/platform/qcom/camss/camss-video.c
@@ -353,6 +353,7 @@  static int video_get_subdev_format(struct camss_video *video,
 
 	fmt.pad = pad;
 	fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE;
+	fmt.stream = 0;
 
 	ret = v4l2_subdev_call(subdev, pad, get_fmt, NULL, &fmt);
 	if (ret)
@@ -493,9 +494,11 @@  static int video_start_streaming(struct vb2_queue *q, unsigned int count)
 	struct v4l2_subdev *subdev;
 	int ret;
 
-	ret = video_device_pipeline_start(vdev, &video->pipe);
-	if (ret < 0)
+	ret = video_device_pipeline_alloc_start(vdev);
+	if (ret < 0) {
+		dev_err(video->camss->dev, "Failed to start media pipeline: %d\n", ret);
 		return ret;
+	}
 
 	ret = video_check_format(video);
 	if (ret < 0)
@@ -536,6 +539,7 @@  static void video_stop_streaming(struct vb2_queue *q)
 	struct media_entity *entity;
 	struct media_pad *pad;
 	struct v4l2_subdev *subdev;
+	int ret;
 
 	entity = &vdev->entity;
 	while (1) {
@@ -550,7 +554,18 @@  static void video_stop_streaming(struct vb2_queue *q)
 		entity = pad->entity;
 		subdev = media_entity_to_v4l2_subdev(entity);
 
-		v4l2_subdev_call(subdev, video, s_stream, 0);
+		ret = v4l2_subdev_call(subdev, video, s_stream, 0);
+
+		if (ret == -EBUSY) {
+			/* Don't stop if other instances of the pipeline are still running */
+			dev_dbg(video->camss->dev, "Video pipeline still used, don't stop streaming.\n");
+			return;
+		}
+
+		if (ret) {
+			dev_err(video->camss->dev, "Video pipeline stop failed: %d\n", ret);
+			return;
+		}
 	}
 
 	video_device_pipeline_stop(vdev);