1. 12 Jun, 2018 1 commit
    • Kees Cook's avatar
      treewide: Use array_size() in vmalloc() · 42bc47b3
      Kees Cook authored
      The vmalloc() function has no 2-factor argument form, so multiplication
      factors need to be wrapped in array_size(). This patch replaces cases of:
      
              vmalloc(a * b)
      
      with:
              vmalloc(array_size(a, b))
      
      as well as handling cases of:
      
              vmalloc(a * b * c)
      
      with:
      
              vmalloc(array3_size(a, b, c))
      
      This does, however, attempt to ignore constant size factors like:
      
              vmalloc(4 * 1024)
      
      though any constants defined via macros get caught up in the conversion.
      
      Any factors with a sizeof() of "unsigned char", "char", and "u8" were
      dropped, since they're redundant.
      
      The Coccinelle script used for this was:
      
      // Fix redundant parens around sizeof().
      @@
      type TYPE;
      expression THING, E;
      @@
      
      (
        vmalloc(
      -	(sizeof(TYPE)) * E
      +	sizeof(TYPE) * E
        , ...)
      |
        vmalloc(
      -	(sizeof(THING)) * E
      +	sizeof(THING) * E
        , ...)
      )
      
      // Drop single-byte sizes and redundant parens.
      @@
      expression COUNT;
      typedef u8;
      typedef __u8;
      @@
      
      (
        vmalloc(
      -	sizeof(u8) * (COUNT)
      +	COUNT
        , ...)
      |
        vmalloc(
      -	sizeof(__u8) * (COUNT)
      +	COUNT
        , ...)
      |
        vmalloc(
      -	sizeof(char) * (COUNT)
      +	COUNT
        , ...)
      |
        vmalloc(
      -	sizeof(unsigned char) * (COUNT)
      +	COUNT
        , ...)
      |
        vmalloc(
      -	sizeof(u8) * COUNT
      +	COUNT
        , ...)
      |
        vmalloc(
      -	sizeof(__u8) * COUNT
      +	COUNT
        , ...)
      |
        vmalloc(
      -	sizeof(char) * COUNT
      +	COUNT
        , ...)
      |
        vmalloc(
      -	sizeof(unsigned char) * COUNT
      +	COUNT
        , ...)
      )
      
      // 2-factor product with sizeof(type/expression) and identifier or constant.
      @@
      type TYPE;
      expression THING;
      identifier COUNT_ID;
      constant COUNT_CONST;
      @@
      
      (
        vmalloc(
      -	sizeof(TYPE) * (COUNT_ID)
      +	array_size(COUNT_ID, sizeof(TYPE))
        , ...)
      |
        vmalloc(
      -	sizeof(TYPE) * COUNT_ID
      +	array_size(COUNT_ID, sizeof(TYPE))
        , ...)
      |
        vmalloc(
      -	sizeof(TYPE) * (COUNT_CONST)
      +	array_size(COUNT_CONST, sizeof(TYPE))
        , ...)
      |
        vmalloc(
      -	sizeof(TYPE) * COUNT_CONST
      +	array_size(COUNT_CONST, sizeof(TYPE))
        , ...)
      |
        vmalloc(
      -	sizeof(THING) * (COUNT_ID)
      +	array_size(COUNT_ID, sizeof(THING))
        , ...)
      |
        vmalloc(
      -	sizeof(THING) * COUNT_ID
      +	array_size(COUNT_ID, sizeof(THING))
        , ...)
      |
        vmalloc(
      -	sizeof(THING) * (COUNT_CONST)
      +	array_size(COUNT_CONST, sizeof(THING))
        , ...)
      |
        vmalloc(
      -	sizeof(THING) * COUNT_CONST
      +	array_size(COUNT_CONST, sizeof(THING))
        , ...)
      )
      
      // 2-factor product, only identifiers.
      @@
      identifier SIZE, COUNT;
      @@
      
        vmalloc(
      -	SIZE * COUNT
      +	array_size(COUNT, SIZE)
        , ...)
      
      // 3-factor product with 1 sizeof(type) or sizeof(expression), with
      // redundant parens removed.
      @@
      expression THING;
      identifier STRIDE, COUNT;
      type TYPE;
      @@
      
      (
        vmalloc(
      -	sizeof(TYPE) * (COUNT) * (STRIDE)
      +	array3_size(COUNT, STRIDE, sizeof(TYPE))
        , ...)
      |
        vmalloc(
      -	sizeof(TYPE) * (COUNT) * STRIDE
      +	array3_size(COUNT, STRIDE, sizeof(TYPE))
        , ...)
      |
        vmalloc(
      -	sizeof(TYPE) * COUNT * (STRIDE)
      +	array3_size(COUNT, STRIDE, sizeof(TYPE))
        , ...)
      |
        vmalloc(
      -	sizeof(TYPE) * COUNT * STRIDE
      +	array3_size(COUNT, STRIDE, sizeof(TYPE))
        , ...)
      |
        vmalloc(
      -	sizeof(THING) * (COUNT) * (STRIDE)
      +	array3_size(COUNT, STRIDE, sizeof(THING))
        , ...)
      |
        vmalloc(
      -	sizeof(THING) * (COUNT) * STRIDE
      +	array3_size(COUNT, STRIDE, sizeof(THING))
        , ...)
      |
        vmalloc(
      -	sizeof(THING) * COUNT * (STRIDE)
      +	array3_size(COUNT, STRIDE, sizeof(THING))
        , ...)
      |
        vmalloc(
      -	sizeof(THING) * COUNT * STRIDE
      +	array3_size(COUNT, STRIDE, sizeof(THING))
        , ...)
      )
      
      // 3-factor product with 2 sizeof(variable), with redundant parens removed.
      @@
      expression THING1, THING2;
      identifier COUNT;
      type TYPE1, TYPE2;
      @@
      
      (
        vmalloc(
      -	sizeof(TYPE1) * sizeof(TYPE2) * COUNT
      +	array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
        , ...)
      |
        vmalloc(
      -	sizeof(TYPE1) * sizeof(THING2) * (COUNT)
      +	array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
        , ...)
      |
        vmalloc(
      -	sizeof(THING1) * sizeof(THING2) * COUNT
      +	array3_size(COUNT, sizeof(THING1), sizeof(THING2))
        , ...)
      |
        vmalloc(
      -	sizeof(THING1) * sizeof(THING2) * (COUNT)
      +	array3_size(COUNT, sizeof(THING1), sizeof(THING2))
        , ...)
      |
        vmalloc(
      -	sizeof(TYPE1) * sizeof(THING2) * COUNT
      +	array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
        , ...)
      |
        vmalloc(
      -	sizeof(TYPE1) * sizeof(THING2) * (COUNT)
      +	array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
        , ...)
      )
      
      // 3-factor product, only identifiers, with redundant parens removed.
      @@
      identifier STRIDE, SIZE, COUNT;
      @@
      
      (
        vmalloc(
      -	(COUNT) * STRIDE * SIZE
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      |
        vmalloc(
      -	COUNT * (STRIDE) * SIZE
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      |
        vmalloc(
      -	COUNT * STRIDE * (SIZE)
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      |
        vmalloc(
      -	(COUNT) * (STRIDE) * SIZE
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      |
        vmalloc(
      -	COUNT * (STRIDE) * (SIZE)
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      |
        vmalloc(
      -	(COUNT) * STRIDE * (SIZE)
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      |
        vmalloc(
      -	(COUNT) * (STRIDE) * (SIZE)
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      |
        vmalloc(
      -	COUNT * STRIDE * SIZE
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      )
      
      // Any remaining multi-factor products, first at least 3-factor products
      // when they're not all constants...
      @@
      expression E1, E2, E3;
      constant C1, C2, C3;
      @@
      
      (
        vmalloc(C1 * C2 * C3, ...)
      |
        vmalloc(
      -	E1 * E2 * E3
      +	array3_size(E1, E2, E3)
        , ...)
      )
      
      // And then all remaining 2 factors products when they're not all constants.
      @@
      expression E1, E2;
      constant C1, C2;
      @@
      
      (
        vmalloc(C1 * C2, ...)
      |
        vmalloc(
      -	E1 * E2
      +	array_size(E1, E2)
        , ...)
      )
      Signed-off-by: default avatarKees Cook <keescook@chromium.org>
      42bc47b3
  2. 16 May, 2018 1 commit
  3. 11 May, 2018 2 commits
    • Mauro Carvalho Chehab's avatar
      media: dvb_frontend: cleanup some coding style errors · 09c2cc98
      Mauro Carvalho Chehab authored
      This is a core media file... it shoudn't have so many coding
      style issues! The last patch ended by being submitted with
      an error like that, very likely due to some cut and paste
      issue.
      
      Maybe it is time to clean it up. Do it with the auto
      fix logic:
      
       ./scripts/checkpatch.pl -f drivers/media/dvb-core/dvb_frontend.c --strict --fix-inplace
      
      Then manually fix the errors introduced by it.
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
      09c2cc98
    • Max Kellermann's avatar
      media: dvbdev: add a mutex protecting the "mdev" pointer · f17c403a
      Max Kellermann authored
      During destruction, a race condition in
      dvb_media_controller_disable_source() can cause a kernel crash,
      because the "mdev" pointer has been read successfully while another
      task executes dvb_usb_media_device_unregister(), which destroys the
      object.  Example for such a crash:
      
          general protection fault: 0000 [#1] SMP
          CPU: 1 PID: 301 Comm: vdr Not tainted 4.8.1-nuc+ #102
          [142B blob data]
          task: ffff8802301f2040 task.stack: ffff880233728000
          RIP: 0010:[<ffffffff816c296b>]  [<ffffffff816c296b>] dvb_frontend_release+0xcb/0x120
          RSP: 0018:ffff88023372bdd8  EFLAGS: 00010202
          RAX: 001fd55c000000da RBX: ffff880236bad810 RCX: 0000000000000000
          RDX: ffff880235bd81f0 RSI: 0000000000000246 RDI: ffff880235bd81e8
          RBP: ffff88023372be00 R08: 0000000000000000 R09: 0000000000000000
          R10: 0000000000000000 R11: ffff88022f009910 R12: 0000000000000000
          R13: ffff880235a21a80 R14: ffff880235bd8000 R15: ffff880235bb8a78
          FS:  0000000000000000(0000) GS:ffff88023fd00000(0000) knlGS:0000000000000000
          CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
          CR2: 00007f96edd69818 CR3: 0000000002406000 CR4: 00000000001006e0
          Stack:
           ffff88022f009900 0000000000000008 ffff880235bb8a78 ffff8802344fbb20
           ffff880236437b40 ffff88023372be48 ffffffff8117a81e ffff880235bb8a78
           ffff88022f009910 ffff8802335a7400 ffff8802301f2040 ffff88022f009900
          Call Trace:
           [<ffffffff8117a81e>] __fput+0xde/0x1d0
           [<ffffffff8117a949>] ____fput+0x9/0x10
           [<ffffffff810a9fce>] task_work_run+0x7e/0xa0
           [<ffffffff81094bab>] do_exit+0x27b/0xa50
           [<ffffffff810407e3>] ? __do_page_fault+0x1c3/0x430
           [<ffffffff81095402>] do_group_exit+0x42/0xb0
           [<ffffffff8109547f>] SyS_exit_group+0xf/0x10
           [<ffffffff8108bedb>] entry_SYSCALL_64_fastpath+0x13/0x8f
          Code: 31 c9 49 8d be e8 01 00 00 ba 01 00 00 00 be 03 00 00 00 e8 68 2d a0 ff 48 8b 83 10 03 00 00 48 8b 80 88 00 00 00 48 85 c0 74 12 <48> 8b 80 88 02 00 00 48 85 c0 74 06 49 8b 7d
          RIP  [<ffffffff816c296b>] dvb_frontend_release+0xcb/0x120
      
      [mchehab+samsung@kernel.org: fix a Coding Style issue]
      Signed-off-by: default avatarMax Kellermann <max.kellermann@gmail.com>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
      f17c403a
  4. 09 May, 2018 1 commit
  5. 05 May, 2018 1 commit
  6. 04 May, 2018 1 commit
  7. 17 Apr, 2018 1 commit
    • Mauro Carvalho Chehab's avatar
      media: dvb_frontend: fix locking issues at dvb_frontend_get_event() · 76d81243
      Mauro Carvalho Chehab authored
      As warned by smatch:
      	drivers/media/dvb-core/dvb_frontend.c:314 dvb_frontend_get_event() warn: inconsistent returns 'sem:&fepriv->sem'.
      	  Locked on:   line 288
      	               line 295
      	               line 306
      	               line 314
      	  Unlocked on: line 303
      
      The lock implementation for get event is wrong, as, if an
      interrupt occurs, down_interruptible() will fail, and the
      routine will call up() twice when userspace calls the ioctl
      again.
      
      The bad code is there since when Linux migrated to git, in
      2005.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
      76d81243
  8. 04 Apr, 2018 1 commit
  9. 22 Mar, 2018 2 commits
    • Mauro Carvalho Chehab's avatar
      media: dvb_frontend: add proper __user annotations · f44d6107
      Mauro Carvalho Chehab authored
      Solves those warnings:
      	drivers/media/dvb-core/dvb_frontend.c:2297:39: warning: incorrect type in argument 1 (different address spaces)
      	drivers/media/dvb-core/dvb_frontend.c:2297:39:    expected void const [noderef] <asn:1>*<noident>
      	drivers/media/dvb-core/dvb_frontend.c:2297:39:    got struct dtv_property *props
      	drivers/media/dvb-core/dvb_frontend.c:2331:39: warning: incorrect type in argument 1 (different address spaces)
      	drivers/media/dvb-core/dvb_frontend.c:2331:39:    expected void const [noderef] <asn:1>*<noident>
      	drivers/media/dvb-core/dvb_frontend.c:2331:39:    got struct dtv_property *props
      
      No functional changes.
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
      f44d6107
    • Mauro Carvalho Chehab's avatar
      media: dvbdev: handle ENOMEM error at dvb_module_probe() · 39adb4e7
      Mauro Carvalho Chehab authored
      If allocation of struct board_info fails, return NULL from
      dvb_module_probe().
      
      Fix this warning:
      	drivers/media/dvb-core/dvbdev.c:958 dvb_module_probe() error: potential null dereference 'board_info'.  (kzalloc returns null)
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
      39adb4e7
  10. 07 Mar, 2018 1 commit
  11. 06 Mar, 2018 2 commits
  12. 23 Feb, 2018 4 commits
  13. 11 Feb, 2018 1 commit
    • Linus Torvalds's avatar
      vfs: do bulk POLL* -> EPOLL* replacement · a9a08845
      Linus Torvalds authored
      This is the mindless scripted replacement of kernel use of POLL*
      variables as described by Al, done by this script:
      
          for V in IN OUT PRI ERR RDNORM RDBAND WRNORM WRBAND HUP RDHUP NVAL MSG; do
              L=`git grep -l -w POLL$V | grep -v '^t' | grep -v /um/ | grep -v '^sa' | grep -v '/poll.h$'|grep -v '^D'`
              for f in $L; do sed -i "-es/^\([^\"]*\)\(\<POLL$V\>\)/\\1E\\2/" $f; done
          done
      
      with de-mangling cleanups yet to come.
      
      NOTE! On almost all architectures, the EPOLL* constants have the same
      values as the POLL* constants do.  But they keyword here is "almost".
      For various bad reasons they aren't the same, and epoll() doesn't
      actually work quite correctly in some cases due to this on Sparc et al.
      
      The next patch from Al will sort out the final differences, and we
      should be all done.
      Scripted-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      a9a08845
  14. 06 Feb, 2018 1 commit
  15. 29 Jan, 2018 2 commits
  16. 04 Jan, 2018 2 commits
  17. 29 Dec, 2017 1 commit
  18. 28 Dec, 2017 8 commits
    • Mauro Carvalho Chehab's avatar
      media: move dvb kAPI headers to include/media · fada1935
      Mauro Carvalho Chehab authored
      Except for DVB, all media kAPI headers are at include/media.
      
      Move the headers to it.
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
      fada1935
    • Mauro Carvalho Chehab's avatar
      media: dvb-core: get rid of mmap reserved field · a114a585
      Mauro Carvalho Chehab authored
      The "reserved" field was a way, used at V4L2 API, to add new
      data to existing structs without breaking userspace. However,
      there are now clever ways of doing that, without needing to add
      an uneeded overhead. So, get rid of them.
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
      a114a585
    • Mauro Carvalho Chehab's avatar
      media: dvb-core: make DVB mmap API optional · 4021053e
      Mauro Carvalho Chehab authored
      This API is still experimental. Make it optional, allowing to
      compile the code without it.
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
      4021053e
    • Mauro Carvalho Chehab's avatar
      media: dvb_vb2: add SPDX headers · 7b361cf0
      Mauro Carvalho Chehab authored
      This code is released under GPL. Add the corresponding SPDX
      headers.
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
      7b361cf0
    • Mauro Carvalho Chehab's avatar
      media: dvb_vb2: Use the sanitized value after processed by VB2 core · 19393a03
      Mauro Carvalho Chehab authored
      if the number of buffers requested by the user is too big, the
      VB core will truncate to a valid value.
      
      Use it, instead of what the user requested.
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
      19393a03
    • Mauro Carvalho Chehab's avatar
      media: dvb_vb2: limit reqbufs size to a sane value · 2c06aa7c
      Mauro Carvalho Chehab authored
      It is not a good idea to let users to request a very high buffer
      size.
      
      So, add an upper limit.
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
      2c06aa7c
    • Mauro Carvalho Chehab's avatar
      media: dvb_vb2: fix a warning about streamoff logic · 7b6c96d5
      Mauro Carvalho Chehab authored
      The streamoff logic is causing those warnings:
      
       WARNING: CPU: 3 PID: 3382 at drivers/media/v4l2-core/videobuf2-core.c:1652 __vb2_queue_cancel+0x177/0x250 [videobuf2_core]
       Modules linked in: bnep fuse xt_CHECKSUM iptable_mangle tun ebtable_filter ebtables ip6table_filter ip6_tables xt_physdev br_netfilter bluetooth bridge rfkill ecdh_generic stp llc nf_log_ipv4 nf_log_common xt_LOG xt_conntrack ipt_MASQUERADE nf_nat_masquerade_ipv4 iptable_nat nf_conntrack_ipv4 nf_defrag_ipv4 nf_nat_ipv4 nf_nat nf_conntrack libcrc32c sunrpc vfat fat snd_hda_codec_hdmi rc_dib0700_nec i915 rc_pinnacle_pctv_hd em28xx_rc a8293 ts2020 m88ds3103 i2c_mux em28xx_dvb dib8000 dvb_usb_dib0700 dib0070 dib7000m dib0090 dvb_usb dvb_core uvcvideo snd_usb_audio videobuf2_v4l2 dib3000mc videobuf2_vmalloc videobuf2_memops dibx000_common videobuf2_core rc_core snd_usbmidi_lib snd_rawmidi em28xx tveeprom v4l2_common videodev media intel_rapl x86_pkg_temp_thermal intel_powerclamp coretemp snd_hda_intel
       kvm_intel snd_hda_codec kvm snd_hwdep snd_hda_core snd_seq irqbypass crct10dif_pclmul crc32_pclmul i2c_algo_bit ghash_clmulni_intel snd_seq_device drm_kms_helper snd_pcm intel_cstate intel_uncore snd_timer tpm_tis drm mei_wdt iTCO_wdt iTCO_vendor_support tpm_tis_core snd intel_rapl_perf mei_me mei tpm i2c_i801 soundcore lpc_ich video binfmt_misc hid_logitech_hidpp hid_logitech_dj e1000e crc32c_intel ptp pps_core analog gameport joydev
       CPU: 3 PID: 3382 Comm: lt-dvbv5-zap Not tainted 4.14.0+ #3
       Hardware name:                  /D53427RKE, BIOS RKPPT10H.86A.0048.2017.0506.1545 05/06/2017
       task: ffff94b93bbe1e40 task.stack: ffffb7a98320c000
       RIP: 0010:__vb2_queue_cancel+0x177/0x250 [videobuf2_core]
       RSP: 0018:ffffb7a98320fd40 EFLAGS: 00010202
       RAX: 0000000000000001 RBX: ffff94b92ff72428 RCX: 0000000000000000
       RDX: 0000000000000001 RSI: 0000000000000001 RDI: ffff94b92ff72428
       RBP: ffffb7a98320fd68 R08: ffff94b92ff725d8 R09: ffffb7a98320fcc8
       R10: ffff94b978003d98 R11: ffff94b92ff72428 R12: ffff94b92ff72428
       R13: 0000000000000282 R14: ffff94b92059ae20 R15: dead000000000100
       FS:  0000000000000000(0000) GS:ffff94b99e380000(0000) knlGS:0000000000000000
       CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
       CR2: 0000555953007d70 CR3: 000000012be09004 CR4: 00000000001606e0
       Call Trace:
        vb2_core_streamoff+0x28/0x90 [videobuf2_core]
        dvb_vb2_stream_off+0xd1/0x150 [dvb_core]
        dvb_dvr_release+0x114/0x120 [dvb_core]
        __fput+0xdf/0x1e0
        ____fput+0xe/0x10
        task_work_run+0x94/0xc0
        do_exit+0x2dc/0xba0
        do_group_exit+0x47/0xb0
        SyS_exit_group+0x14/0x20
        entry_SYSCALL_64_fastpath+0x1a/0xa5
       RIP: 0033:0x7f775e931ed8
       RSP: 002b:00007fff07019d68 EFLAGS: 00000246 ORIG_RAX: 00000000000000e7
       RAX: ffffffffffffffda RBX: 0000000001d02690 RCX: 00007f775e931ed8
       RDX: 0000000000000001 RSI: 000000000000003c RDI: 0000000000000001
       RBP: 00007fff0701a500 R08: 00000000000000e7 R09: ffffffffffffff70
       R10: 00007f775e854dd8 R11: 0000000000000246 R12: 0000000000000000
       R13: 00000000035fa000 R14: 000000000000000a R15: 000000000000000a
       Code: 00 00 04 74 1c 44 89 e8 49 83 c5 01 41 39 84 24 88 01 00 00 77 8a 5b 41 5c 41 5d 41 5e 41 5f 5d c3 48 89 df e8 bb fd ff ff eb da <0f> ff 41 8b b4 24 88 01 00 00 85 f6 74 34 bb 01 00 00 00 eb 10
      
      There are actually two issues here:
      
      1) list_del() should be called when changing the buffer state;
      
      2) The logic with marks the buffers as done is at the wrong place.
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
      7b6c96d5
    • Satendra Singh Thakur's avatar
      media: videobuf2: Add new uAPI for DVB streaming I/O · 57868acc
      Satendra Singh Thakur authored
      Adds a new uAPI for DVB to use streaming I/O which is implemented
      based on videobuf2, using those new ioctls:
      
      - DMX_REQBUFS:  Request kernel to allocate buffers which count and size
      	        are dedicated by user.
      - DMX_QUERYBUF: Get the buffer information like a memory offset which
      		will mmap() and be shared with user-space.
      - DMX_EXPBUF:   Just for testing whether buffer-exporting success or not.
      - DMX_QBUF:     Pass the buffer to kernel-space.
      - DMX_DQBUF:    Get back the buffer which may contain TS data.
      
      Originally developed by: Junghak Sung <jh1009.sung@samsung.com>, as
      seen at:
      	https://patchwork.linuxtv.org/patch/31613/
      	https://patchwork.kernel.org/patch/7334301/
      
      The original patch was written before merging VB2-core functionalities
      upstream. When such series was added, several adjustments were made,
      fixing some issues with	V4L2, causing the original patch to be
      non-trivially rebased.
      
      After rebased, a few bugs in the patch were fixed. The patch was
      also enhanced it and polling functionality got added.
      
      The main changes over the original patch are:
      
      dvb_vb2_fill_buffer():
      	- Set the size of the outgoing buffer after while loop using
      	  vb2_set_plane_payload;
      
      	- Added NULL check for source buffer as per normal convention
      	  of demux driver, this is called twice, first time with valid
      	  buffer second time with NULL pointer, if its not handled,
      	  it will result in  crash
      
      	- Restricted spinlock for only list_* operations
      
      dvb_vb2_init():
      	- Restricted q->io_modes to only VB2_MMAP as its the only
      	  supported mode
      
      dvb_vb2_release():
      	- Replaced the && in if condiion with &, because otherwise
      	  it was always getting satisfied.
      
      dvb_vb2_stream_off():
      	- Added list_del code for enqueud buffers upon stream off
      
      dvb_vb2_poll():
      	- Added this new function in order to support polling
      
      dvb_demux_poll() and dvb_dvr_poll()
      	- dvb_vb2_poll() is now called from these functions
      
      - Ported this patch and latest videobuf2 to lower kernel versions and
        tested auto scan.
      Co-developed-by: default avatarJunghak Sung <jh1009.sung@samsung.com>
      
      [mchehab@s-opensource.com: checkpatch fixes]
      Signed-off-by: default avatarJunghak Sung <jh1009.sung@samsung.com>
      Signed-off-by: default avatarGeunyoung Kim <nenggun.kim@samsung.com>
      Acked-by: default avatarSeung-Woo Kim <sw0312.kim@samsung.com>
      Acked-by: default avatarInki Dae <inki.dae@samsung.com>
      Signed-off-by: default avatarSatendra Singh Thakur <satendra.t@samsung.com>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
      57868acc
  19. 19 Dec, 2017 4 commits
  20. 18 Dec, 2017 2 commits
  21. 14 Dec, 2017 1 commit