Merge branch 'for-linus' of git://git.kernel.dk/linux-block
authorLinus Torvalds <torvalds@linux-foundation.org>
Wed, 24 Sep 2014 16:51:50 +0000 (09:51 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 24 Sep 2014 16:51:50 +0000 (09:51 -0700)
Pull one last block fix from Jens Axboe:
 "We've had an issue with scsi-mq where probing takes forever.  This was
  bisected down to the percpu changes for blk_mq_queue_enter(), and the
  fact we now suffer an RCU grace period when killing a queue.  SCSI
  creates and destroys tons of queues, so this let to 10s of seconds of
  stalls at boot for some.

  Tejun has a real fix for this, but it's too involved for 3.17.  So
  this is a temporary workaround to expedite the queue killing until we
  can fold in the real fix for 3.18 when that merge window opens"

* 'for-linus' of git://git.kernel.dk/linux-block:
  blk-mq, percpu_ref: implement a kludge for SCSI blk-mq stall during probe

21 files changed:
Documentation/DocBook/media/v4l/compat.xml
Documentation/DocBook/media/v4l/func-poll.xml
Documentation/DocBook/media/v4l/v4l2.xml
Documentation/DocBook/media/v4l/vidioc-subdev-g-selection.xml
arch/x86/crypto/aesni-intel_glue.c
drivers/crypto/ccp/ccp-crypto-main.c
drivers/crypto/ccp/ccp-dev.c
drivers/crypto/qat/qat_dh895xcc/adf_dh895xcc_hw_data.h
drivers/md/raid1.c
drivers/media/common/cx2341x.c
drivers/media/dvb-frontends/cx24123.c
drivers/media/i2c/adv7604.c
drivers/media/radio/radio-miropcm20.c
drivers/media/usb/em28xx/em28xx-video.c
drivers/media/usb/em28xx/em28xx.h
drivers/media/v4l2-core/videobuf2-core.c
drivers/media/v4l2-core/videobuf2-dma-sg.c
drivers/pci/hotplug/pciehp_hpc.c
drivers/pci/probe.c
include/linux/ccp.h
include/media/videobuf2-core.h

index eee6f0f4aa433cb535d6375bf307273a8e3d1c22..3a626d1b8f2e4d8022831f0961fbb83bc359b487 100644 (file)
@@ -2545,6 +2545,30 @@ fields changed from _s32 to _u32.
       </orderedlist>
     </section>
 
+    <section>
+      <title>V4L2 in Linux 3.16</title>
+      <orderedlist>
+        <listitem>
+         <para>Added event V4L2_EVENT_SOURCE_CHANGE.
+         </para>
+        </listitem>
+      </orderedlist>
+    </section>
+
+    <section>
+      <title>V4L2 in Linux 3.17</title>
+      <orderedlist>
+        <listitem>
+         <para>Extended &v4l2-pix-format;. Added format flags.
+         </para>
+        </listitem>
+        <listitem>
+         <para>Added compound control types and &VIDIOC-QUERY-EXT-CTRL;.
+         </para>
+        </listitem>
+      </orderedlist>
+    </section>
+
     <section id="other">
       <title>Relation of V4L2 to other Linux multimedia APIs</title>
 
index 85cad8bff5ba79aecec18c721650d5994137bbc7..4c73f115219b5f4f923250e83dac3f001cbfc094 100644 (file)
@@ -29,9 +29,12 @@ can suspend execution until the driver has captured data or is ready
 to accept data for output.</para>
 
     <para>When streaming I/O has been negotiated this function waits
-until a buffer has been filled or displayed and can be dequeued with
-the &VIDIOC-DQBUF; ioctl. When buffers are already in the outgoing
-queue of the driver the function returns immediately.</para>
+until a buffer has been filled by the capture device and can be dequeued
+with the &VIDIOC-DQBUF; ioctl. For output devices this function waits
+until the device is ready to accept a new buffer to be queued up with
+the &VIDIOC-QBUF; ioctl for display. When buffers are already in the outgoing
+queue of the driver (capture) or the incoming queue isn't full (display)
+the function returns immediately.</para>
 
     <para>On success <function>poll()</function> returns the number of
 file descriptors that have been selected (that is, file descriptors
@@ -44,10 +47,22 @@ Capture devices set the <constant>POLLIN</constant> and
 flags. When the function timed out it returns a value of zero, on
 failure it returns <returnvalue>-1</returnvalue> and the
 <varname>errno</varname> variable is set appropriately. When the
-application did not call &VIDIOC-QBUF; or &VIDIOC-STREAMON; yet the
+application did not call &VIDIOC-STREAMON; the
 <function>poll()</function> function succeeds, but sets the
 <constant>POLLERR</constant> flag in the
-<structfield>revents</structfield> field.</para>
+<structfield>revents</structfield> field. When the
+application has called &VIDIOC-STREAMON; for a capture device but hasn't
+yet called &VIDIOC-QBUF;, the <function>poll()</function> function
+succeeds and sets the <constant>POLLERR</constant> flag in the
+<structfield>revents</structfield> field. For output devices this
+same situation will cause <function>poll()</function> to succeed
+as well, but it sets the <constant>POLLOUT</constant> and
+<constant>POLLWRNORM</constant> flags in the <structfield>revents</structfield>
+field.</para>
+
+    <para>If an event occurred (see &VIDIOC-DQEVENT;) then
+<constant>POLLPRI</constant> will be set in the <structfield>revents</structfield>
+field and <function>poll()</function> will return.</para>
 
     <para>When use of the <function>read()</function> function has
 been negotiated and the driver does not capture yet, the
@@ -58,10 +73,18 @@ continuously (as opposed to, for example, still images) the function
 may return immediately.</para>
 
     <para>When use of the <function>write()</function> function has
-been negotiated the <function>poll</function> function just waits
+been negotiated and the driver does not stream yet, the
+<function>poll</function> function starts streaming. When that fails
+it returns a <constant>POLLERR</constant> as above. Otherwise it waits
 until the driver is ready for a non-blocking
 <function>write()</function> call.</para>
 
+    <para>If the caller is only interested in events (just
+<constant>POLLPRI</constant> is set in the <structfield>events</structfield>
+field), then <function>poll()</function> will <emphasis>not</emphasis>
+start streaming if the driver does not stream yet. This makes it
+possible to just poll for events and not for buffers.</para>
+
     <para>All drivers implementing the <function>read()</function> or
 <function>write()</function> function or streaming I/O must also
 support the <function>poll()</function> function.</para>
index f2f81f06a17ba54718b693c54d024a6640576a5f..7cfe618f754d35fecfb9c55e7ef3efad72c539f4 100644 (file)
@@ -152,10 +152,11 @@ structs, ioctls) must be noted in more detail in the history chapter
 applications. -->
 
       <revision>
-       <revnumber>3.16</revnumber>
-       <date>2014-05-27</date>
-       <authorinitials>lp</authorinitials>
-       <revremark>Extended &v4l2-pix-format;. Added format flags.
+       <revnumber>3.17</revnumber>
+       <date>2014-08-04</date>
+       <authorinitials>lp, hv</authorinitials>
+       <revremark>Extended &v4l2-pix-format;. Added format flags. Added compound control types
+and VIDIOC_QUERY_EXT_CTRL.
        </revremark>
       </revision>
 
@@ -538,7 +539,7 @@ and discussions on the V4L mailing list.</revremark>
 </partinfo>
 
 <title>Video for Linux Two API Specification</title>
- <subtitle>Revision 3.14</subtitle>
+ <subtitle>Revision 3.17</subtitle>
 
   <chapter id="common">
     &sub-common;
index 1ba9e999af3fec1bed5a3a116f37ac0358caf4e0..c62a7360719b56c32d227717cfc93a82e9ca30cc 100644 (file)
          </row>
          <row>
            <entry>&v4l2-rect;</entry>
-           <entry><structfield>rect</structfield></entry>
+           <entry><structfield>r</structfield></entry>
            <entry>Selection rectangle, in pixels.</entry>
          </row>
          <row>
index 888950f29fd90f09574db838251725c49e28934a..a7ccd57f19e45531744eeab841c5ac7e41101074 100644 (file)
@@ -481,7 +481,7 @@ static void ctr_crypt_final(struct crypto_aes_ctx *ctx,
        crypto_inc(ctrblk, AES_BLOCK_SIZE);
 }
 
-#ifdef CONFIG_AS_AVX
+#if 0  /* temporary disabled due to failing crypto tests */
 static void aesni_ctr_enc_avx_tfm(struct crypto_aes_ctx *ctx, u8 *out,
                              const u8 *in, unsigned int len, u8 *iv)
 {
@@ -1522,7 +1522,7 @@ static int __init aesni_init(void)
                aesni_gcm_dec_tfm = aesni_gcm_dec;
        }
        aesni_ctr_enc_tfm = aesni_ctr_enc;
-#ifdef CONFIG_AS_AVX
+#if 0  /* temporary disabled due to failing crypto tests */
        if (cpu_has_avx) {
                /* optimize performance of ctr mode encryption transform */
                aesni_ctr_enc_tfm = aesni_ctr_enc_avx_tfm;
index 20dc848481e703b0867e6e460ff35184c705bdc5..4d4e016d755b0737368e9acef3052dd694ecf291 100644 (file)
@@ -367,6 +367,10 @@ static int ccp_crypto_init(void)
 {
        int ret;
 
+       ret = ccp_present();
+       if (ret)
+               return ret;
+
        spin_lock_init(&req_queue_lock);
        INIT_LIST_HEAD(&req_queue.cmds);
        req_queue.backlog = &req_queue.cmds;
index a7d110652a748e74ad6b562ad26fd4520426a34e..c6e6171eb6d31f764ab8e944174323f3a8ee5006 100644 (file)
@@ -54,6 +54,20 @@ static inline void ccp_del_device(struct ccp_device *ccp)
        ccp_dev = NULL;
 }
 
+/**
+ * ccp_present - check if a CCP device is present
+ *
+ * Returns zero if a CCP device is present, -ENODEV otherwise.
+ */
+int ccp_present(void)
+{
+       if (ccp_get_device())
+               return 0;
+
+       return -ENODEV;
+}
+EXPORT_SYMBOL_GPL(ccp_present);
+
 /**
  * ccp_enqueue_cmd - queue an operation for processing by the CCP
  *
index b707f292b377f1366962ac61c46dbd55be1ae384..65dd1ff93d3bf6b0ba5b0bf9cfb56fc5d15edcbc 100644 (file)
@@ -66,7 +66,7 @@
 #define ADF_DH895XCC_ETR_MAX_BANKS 32
 #define ADF_DH895XCC_SMIAPF0_MASK_OFFSET (0x3A000 + 0x28)
 #define ADF_DH895XCC_SMIAPF1_MASK_OFFSET (0x3A000 + 0x30)
-#define ADF_DH895XCC_SMIA0_MASK 0xFFFF
+#define ADF_DH895XCC_SMIA0_MASK 0xFFFFFFFF
 #define ADF_DH895XCC_SMIA1_MASK 0x1
 /* Error detection and correction */
 #define ADF_DH895XCC_AE_CTX_ENABLES(i) (i * 0x1000 + 0x20818)
index d7690f86fdb9a6202edfa6d8fa5f95517fe8e75b..55de4f6f7eaf47a4633e231d0943f3766f66aee5 100644 (file)
@@ -540,11 +540,7 @@ static int read_balance(struct r1conf *conf, struct r1bio *r1_bio, int *max_sect
        has_nonrot_disk = 0;
        choose_next_idle = 0;
 
-       if (conf->mddev->recovery_cp < MaxSector &&
-           (this_sector + sectors >= conf->next_resync))
-               choose_first = 1;
-       else
-               choose_first = 0;
+       choose_first = (conf->mddev->recovery_cp < this_sector + sectors);
 
        for (disk = 0 ; disk < conf->raid_disks * 2 ; disk++) {
                sector_t dist;
@@ -831,7 +827,7 @@ static void flush_pending_writes(struct r1conf *conf)
  *    there is no normal IO happeing.  It must arrange to call
  *    lower_barrier when the particular background IO completes.
  */
-static void raise_barrier(struct r1conf *conf)
+static void raise_barrier(struct r1conf *conf, sector_t sector_nr)
 {
        spin_lock_irq(&conf->resync_lock);
 
@@ -841,6 +837,7 @@ static void raise_barrier(struct r1conf *conf)
 
        /* block any new IO from starting */
        conf->barrier++;
+       conf->next_resync = sector_nr;
 
        /* For these conditions we must wait:
         * A: while the array is in frozen state
@@ -849,14 +846,17 @@ static void raise_barrier(struct r1conf *conf)
         * C: next_resync + RESYNC_SECTORS > start_next_window, meaning
         *    next resync will reach to the window which normal bios are
         *    handling.
+        * D: while there are any active requests in the current window.
         */
        wait_event_lock_irq(conf->wait_barrier,
                            !conf->array_frozen &&
                            conf->barrier < RESYNC_DEPTH &&
+                           conf->current_window_requests == 0 &&
                            (conf->start_next_window >=
                             conf->next_resync + RESYNC_SECTORS),
                            conf->resync_lock);
 
+       conf->nr_pending++;
        spin_unlock_irq(&conf->resync_lock);
 }
 
@@ -866,6 +866,7 @@ static void lower_barrier(struct r1conf *conf)
        BUG_ON(conf->barrier <= 0);
        spin_lock_irqsave(&conf->resync_lock, flags);
        conf->barrier--;
+       conf->nr_pending--;
        spin_unlock_irqrestore(&conf->resync_lock, flags);
        wake_up(&conf->wait_barrier);
 }
@@ -877,12 +878,10 @@ static bool need_to_wait_for_sync(struct r1conf *conf, struct bio *bio)
        if (conf->array_frozen || !bio)
                wait = true;
        else if (conf->barrier && bio_data_dir(bio) == WRITE) {
-               if (conf->next_resync < RESYNC_WINDOW_SECTORS)
-                       wait = true;
-               else if ((conf->next_resync - RESYNC_WINDOW_SECTORS
-                               >= bio_end_sector(bio)) ||
-                        (conf->next_resync + NEXT_NORMALIO_DISTANCE
-                               <= bio->bi_iter.bi_sector))
+               if ((conf->mddev->curr_resync_completed
+                    >= bio_end_sector(bio)) ||
+                   (conf->next_resync + NEXT_NORMALIO_DISTANCE
+                    <= bio->bi_iter.bi_sector))
                        wait = false;
                else
                        wait = true;
@@ -919,8 +918,8 @@ static sector_t wait_barrier(struct r1conf *conf, struct bio *bio)
        }
 
        if (bio && bio_data_dir(bio) == WRITE) {
-               if (conf->next_resync + NEXT_NORMALIO_DISTANCE
-                   <= bio->bi_iter.bi_sector) {
+               if (bio->bi_iter.bi_sector >=
+                   conf->mddev->curr_resync_completed) {
                        if (conf->start_next_window == MaxSector)
                                conf->start_next_window =
                                        conf->next_resync +
@@ -1186,6 +1185,7 @@ read_again:
                                   atomic_read(&bitmap->behind_writes) == 0);
                }
                r1_bio->read_disk = rdisk;
+               r1_bio->start_next_window = 0;
 
                read_bio = bio_clone_mddev(bio, GFP_NOIO, mddev);
                bio_trim(read_bio, r1_bio->sector - bio->bi_iter.bi_sector,
@@ -1548,8 +1548,13 @@ static void close_sync(struct r1conf *conf)
        mempool_destroy(conf->r1buf_pool);
        conf->r1buf_pool = NULL;
 
+       spin_lock_irq(&conf->resync_lock);
        conf->next_resync = 0;
        conf->start_next_window = MaxSector;
+       conf->current_window_requests +=
+               conf->next_window_requests;
+       conf->next_window_requests = 0;
+       spin_unlock_irq(&conf->resync_lock);
 }
 
 static int raid1_spare_active(struct mddev *mddev)
@@ -2150,7 +2155,7 @@ static void fix_read_error(struct r1conf *conf, int read_disk,
                        d--;
                        rdev = conf->mirrors[d].rdev;
                        if (rdev &&
-                           test_bit(In_sync, &rdev->flags))
+                           !test_bit(Faulty, &rdev->flags))
                                r1_sync_page_io(rdev, sect, s,
                                                conf->tmppage, WRITE);
                }
@@ -2162,7 +2167,7 @@ static void fix_read_error(struct r1conf *conf, int read_disk,
                        d--;
                        rdev = conf->mirrors[d].rdev;
                        if (rdev &&
-                           test_bit(In_sync, &rdev->flags)) {
+                           !test_bit(Faulty, &rdev->flags)) {
                                if (r1_sync_page_io(rdev, sect, s,
                                                    conf->tmppage, READ)) {
                                        atomic_add(s, &rdev->corrected_errors);
@@ -2541,9 +2546,8 @@ static sector_t sync_request(struct mddev *mddev, sector_t sector_nr, int *skipp
 
        bitmap_cond_end_sync(mddev->bitmap, sector_nr);
        r1_bio = mempool_alloc(conf->r1buf_pool, GFP_NOIO);
-       raise_barrier(conf);
 
-       conf->next_resync = sector_nr;
+       raise_barrier(conf, sector_nr);
 
        rcu_read_lock();
        /*
index 103ef6bad2e2267685f13b296d3012b9d447aa29..be763150b8aad014692871091e5cf702e333d3df 100644 (file)
@@ -1490,6 +1490,7 @@ static struct v4l2_ctrl *cx2341x_ctrl_new_custom(struct v4l2_ctrl_handler *hdl,
 {
        struct v4l2_ctrl_config cfg;
 
+       memset(&cfg, 0, sizeof(cfg));
        cx2341x_ctrl_fill(id, &cfg.name, &cfg.type, &min, &max, &step, &def, &cfg.flags);
        cfg.ops = &cx2341x_ops;
        cfg.id = id;
index 72fb5838cae0d7aec7f51bd83bebe5b0afe459b6..7975c6608e20feaf6e664d627a8c3a752dd2e4c3 100644 (file)
@@ -1095,6 +1095,7 @@ struct dvb_frontend *cx24123_attach(const struct cx24123_config *config,
                sizeof(state->tuner_i2c_adapter.name));
        state->tuner_i2c_adapter.algo      = &cx24123_tuner_i2c_algo;
        state->tuner_i2c_adapter.algo_data = NULL;
+       state->tuner_i2c_adapter.dev.parent = i2c->dev.parent;
        i2c_set_adapdata(&state->tuner_i2c_adapter, state);
        if (i2c_add_adapter(&state->tuner_i2c_adapter) < 0) {
                err("tuner i2c bus could not be initialized\n");
index d4fa213ba74ae40ee20c8d31ebebfcfca28f0bb2..de88b980a8370bea73e380da85eb33fe50610761 100644 (file)
@@ -2325,7 +2325,7 @@ static int adv7604_log_status(struct v4l2_subdev *sd)
        v4l2_info(sd, "HDCP keys read: %s%s\n",
                        (hdmi_read(sd, 0x04) & 0x20) ? "yes" : "no",
                        (hdmi_read(sd, 0x04) & 0x10) ? "ERROR" : "");
-       if (!is_hdmi(sd)) {
+       if (is_hdmi(sd)) {
                bool audio_pll_locked = hdmi_read(sd, 0x04) & 0x01;
                bool audio_sample_packet_detect = hdmi_read(sd, 0x18) & 0x01;
                bool audio_mute = io_read(sd, 0x65) & 0x40;
index 998919e97dfe27a60c68c1cdb34a5ed95d34ff1c..7b35e633118d68952e22ddb60e4869055eb5a478 100644 (file)
@@ -27,6 +27,7 @@
 
 #include <linux/module.h>
 #include <linux/init.h>
+#include <linux/io.h>
 #include <linux/delay.h>
 #include <linux/videodev2.h>
 #include <linux/kthread.h>
index 90dec2955f1ca5e790b18fa421c071c7b49aca00..29abc379551e5d6f79483520a892006dca848ed7 100644 (file)
@@ -1342,7 +1342,7 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
        struct em28xx *dev = video_drvdata(file);
        struct em28xx_v4l2 *v4l2 = dev->v4l2;
 
-       if (v4l2->streaming_users > 0)
+       if (vb2_is_busy(&v4l2->vb_vidq))
                return -EBUSY;
 
        vidioc_try_fmt_vid_cap(file, priv, f);
@@ -1883,8 +1883,9 @@ static int em28xx_v4l2_open(struct file *filp)
                return -EINVAL;
        }
 
-       em28xx_videodbg("open dev=%s type=%s\n",
-                       video_device_node_name(vdev), v4l2_type_names[fh_type]);
+       em28xx_videodbg("open dev=%s type=%s users=%d\n",
+                       video_device_node_name(vdev), v4l2_type_names[fh_type],
+                       v4l2->users);
 
        if (mutex_lock_interruptible(&dev->lock))
                return -ERESTARTSYS;
@@ -1897,9 +1898,7 @@ static int em28xx_v4l2_open(struct file *filp)
                return ret;
        }
 
-       if (v4l2_fh_is_singular_file(filp)) {
-               em28xx_videodbg("first opened filehandle, initializing device\n");
-
+       if (v4l2->users == 0) {
                em28xx_set_mode(dev, EM28XX_ANALOG_MODE);
 
                if (vdev->vfl_type != VFL_TYPE_RADIO)
@@ -1910,8 +1909,6 @@ static int em28xx_v4l2_open(struct file *filp)
                 * of some i2c devices
                 */
                em28xx_wake_i2c(dev);
-       } else {
-               em28xx_videodbg("further filehandles are already opened\n");
        }
 
        if (vdev->vfl_type == VFL_TYPE_RADIO) {
@@ -1921,6 +1918,7 @@ static int em28xx_v4l2_open(struct file *filp)
 
        kref_get(&dev->ref);
        kref_get(&v4l2->ref);
+       v4l2->users++;
 
        mutex_unlock(&dev->lock);
 
@@ -2027,11 +2025,12 @@ static int em28xx_v4l2_close(struct file *filp)
        struct em28xx_v4l2    *v4l2 = dev->v4l2;
        int              errCode;
 
-       mutex_lock(&dev->lock);
+       em28xx_videodbg("users=%d\n", v4l2->users);
 
-       if (v4l2_fh_is_singular_file(filp)) {
-               em28xx_videodbg("last opened filehandle, shutting down device\n");
+       vb2_fop_release(filp);
+       mutex_lock(&dev->lock);
 
+       if (v4l2->users == 1) {
                /* No sense to try to write to the device */
                if (dev->disconnected)
                        goto exit;
@@ -2050,12 +2049,10 @@ static int em28xx_v4l2_close(struct file *filp)
                        em28xx_errdev("cannot change alternate number to "
                                        "0 (error=%i)\n", errCode);
                }
-       } else {
-               em28xx_videodbg("further opened filehandles left\n");
        }
 
 exit:
-       vb2_fop_release(filp);
+       v4l2->users--;
        kref_put(&v4l2->ref, em28xx_free_v4l2);
        mutex_unlock(&dev->lock);
        kref_put(&dev->ref, em28xx_free_device);
index 84ef8efdb148c1dcf81d5be799a2f819bde3d3f5..4360338e7b310a2ab985eca427ef34124ddf15a5 100644 (file)
@@ -524,6 +524,7 @@ struct em28xx_v4l2 {
        int sensor_yres;
        int sensor_xtal;
 
+       int users;              /* user count for exclusive use */
        int streaming_users;    /* number of actively streaming users */
 
        u32 frequency;          /* selected tuner frequency */
index c359006074a8ccafeb3a7c4150873f1c13b0d2b9..25d3ae2188cb29fc2338e0dc976d21db17829447 100644 (file)
@@ -971,6 +971,7 @@ static int __reqbufs(struct vb2_queue *q, struct v4l2_requestbuffers *req)
         * to the userspace.
         */
        req->count = allocated_buffers;
+       q->waiting_for_buffers = !V4L2_TYPE_IS_OUTPUT(q->type);
 
        return 0;
 }
@@ -1018,6 +1019,7 @@ static int __create_bufs(struct vb2_queue *q, struct v4l2_create_buffers *create
                memset(q->plane_sizes, 0, sizeof(q->plane_sizes));
                memset(q->alloc_ctx, 0, sizeof(q->alloc_ctx));
                q->memory = create->memory;
+               q->waiting_for_buffers = !V4L2_TYPE_IS_OUTPUT(q->type);
        }
 
        num_buffers = min(create->count, VIDEO_MAX_FRAME - q->num_buffers);
@@ -1130,7 +1132,7 @@ EXPORT_SYMBOL_GPL(vb2_plane_vaddr);
  */
 void *vb2_plane_cookie(struct vb2_buffer *vb, unsigned int plane_no)
 {
-       if (plane_no > vb->num_planes || !vb->planes[plane_no].mem_priv)
+       if (plane_no >= vb->num_planes || !vb->planes[plane_no].mem_priv)
                return NULL;
 
        return call_ptr_memop(vb, cookie, vb->planes[plane_no].mem_priv);
@@ -1165,13 +1167,10 @@ void vb2_buffer_done(struct vb2_buffer *vb, enum vb2_buffer_state state)
        if (WARN_ON(vb->state != VB2_BUF_STATE_ACTIVE))
                return;
 
-       if (!q->start_streaming_called) {
-               if (WARN_ON(state != VB2_BUF_STATE_QUEUED))
-                       state = VB2_BUF_STATE_QUEUED;
-       } else if (WARN_ON(state != VB2_BUF_STATE_DONE &&
-                          state != VB2_BUF_STATE_ERROR)) {
-                       state = VB2_BUF_STATE_ERROR;
-       }
+       if (WARN_ON(state != VB2_BUF_STATE_DONE &&
+                   state != VB2_BUF_STATE_ERROR &&
+                   state != VB2_BUF_STATE_QUEUED))
+               state = VB2_BUF_STATE_ERROR;
 
 #ifdef CONFIG_VIDEO_ADV_DEBUG
        /*
@@ -1762,6 +1761,12 @@ static int vb2_start_streaming(struct vb2_queue *q)
        q->start_streaming_called = 0;
 
        dprintk(1, "driver refused to start streaming\n");
+       /*
+        * If you see this warning, then the driver isn't cleaning up properly
+        * after a failed start_streaming(). See the start_streaming()
+        * documentation in videobuf2-core.h for more information how buffers
+        * should be returned to vb2 in start_streaming().
+        */
        if (WARN_ON(atomic_read(&q->owned_by_drv_count))) {
                unsigned i;
 
@@ -1777,6 +1782,12 @@ static int vb2_start_streaming(struct vb2_queue *q)
                /* Must be zero now */
                WARN_ON(atomic_read(&q->owned_by_drv_count));
        }
+       /*
+        * If done_list is not empty, then start_streaming() didn't call
+        * vb2_buffer_done(vb, VB2_BUF_STATE_QUEUED) but STATE_ERROR or
+        * STATE_DONE.
+        */
+       WARN_ON(!list_empty(&q->done_list));
        return ret;
 }
 
@@ -1812,6 +1823,7 @@ static int vb2_internal_qbuf(struct vb2_queue *q, struct v4l2_buffer *b)
         */
        list_add_tail(&vb->queued_entry, &q->queued_list);
        q->queued_count++;
+       q->waiting_for_buffers = false;
        vb->state = VB2_BUF_STATE_QUEUED;
        if (V4L2_TYPE_IS_OUTPUT(q->type)) {
                /*
@@ -2123,6 +2135,12 @@ static void __vb2_queue_cancel(struct vb2_queue *q)
        if (q->start_streaming_called)
                call_void_qop(q, stop_streaming, q);
 
+       /*
+        * If you see this warning, then the driver isn't cleaning up properly
+        * in stop_streaming(). See the stop_streaming() documentation in
+        * videobuf2-core.h for more information how buffers should be returned
+        * to vb2 in stop_streaming().
+        */
        if (WARN_ON(atomic_read(&q->owned_by_drv_count))) {
                for (i = 0; i < q->num_buffers; ++i)
                        if (q->bufs[i]->state == VB2_BUF_STATE_ACTIVE)
@@ -2272,6 +2290,7 @@ static int vb2_internal_streamoff(struct vb2_queue *q, enum v4l2_buf_type type)
         * their normal dequeued state.
         */
        __vb2_queue_cancel(q);
+       q->waiting_for_buffers = !V4L2_TYPE_IS_OUTPUT(q->type);
 
        dprintk(3, "successful\n");
        return 0;
@@ -2590,10 +2609,17 @@ unsigned int vb2_poll(struct vb2_queue *q, struct file *file, poll_table *wait)
        }
 
        /*
-        * There is nothing to wait for if no buffer has been queued and the
-        * queue isn't streaming, or if the error flag is set.
+        * There is nothing to wait for if the queue isn't streaming, or if the
+        * error flag is set.
+        */
+       if (!vb2_is_streaming(q) || q->error)
+               return res | POLLERR;
+       /*
+        * For compatibility with vb1: if QBUF hasn't been called yet, then
+        * return POLLERR as well. This only affects capture queues, output
+        * queues will always initialize waiting_for_buffers to false.
         */
-       if ((list_empty(&q->queued_list) && !vb2_is_streaming(q)) || q->error)
+       if (q->waiting_for_buffers)
                return res | POLLERR;
 
        /*
index adefc31bb85302ab93648081f95951a47753409c..9b163a440f89881e354e76748907a39b1783dc6f 100644 (file)
@@ -113,7 +113,7 @@ static void *vb2_dma_sg_alloc(void *alloc_ctx, unsigned long size, gfp_t gfp_fla
                goto fail_pages_alloc;
 
        ret = sg_alloc_table_from_pages(&buf->sg_table, buf->pages,
-                       buf->num_pages, 0, size, gfp_flags);
+                       buf->num_pages, 0, size, GFP_KERNEL);
        if (ret)
                goto fail_table_alloc;
 
index 5e01ae39ec46a29930b3ac21de0d7a3fd3900314..2a412fa3b338f4b8399685c5b46e43a4e925871a 100644 (file)
@@ -160,7 +160,7 @@ static void pcie_wait_cmd(struct controller *ctrl)
            ctrl->slot_ctrl & PCI_EXP_SLTCTL_CCIE)
                rc = wait_event_timeout(ctrl->queue, !ctrl->cmd_busy, timeout);
        else
-               rc = pcie_poll_cmd(ctrl, timeout);
+               rc = pcie_poll_cmd(ctrl, jiffies_to_msecs(timeout));
 
        /*
         * Controllers with errata like Intel CF118 don't generate
index e3cf8a2e629216208750bc96ed84285e7a2c0118..4170113cde6141a9962b23a9d6342647a0465210 100644 (file)
@@ -775,7 +775,7 @@ int pci_scan_bridge(struct pci_bus *bus, struct pci_dev *dev, int max, int pass)
        /* Check if setup is sensible at all */
        if (!pass &&
            (primary != bus->number || secondary <= bus->number ||
-            secondary > subordinate || subordinate > bus->busn_res.end)) {
+            secondary > subordinate)) {
                dev_info(&dev->dev, "bridge configuration invalid ([bus %02x-%02x]), reconfiguring\n",
                         secondary, subordinate);
                broken = 1;
@@ -838,23 +838,18 @@ int pci_scan_bridge(struct pci_bus *bus, struct pci_dev *dev, int max, int pass)
                        goto out;
                }
 
-               if (max >= bus->busn_res.end) {
-                       dev_warn(&dev->dev, "can't allocate child bus %02x from %pR\n",
-                                max, &bus->busn_res);
-                       goto out;
-               }
-
                /* Clear errors */
                pci_write_config_word(dev, PCI_STATUS, 0xffff);
 
-               /* The bus will already exist if we are rescanning */
+               /* Prevent assigning a bus number that already exists.
+                * This can happen when a bridge is hot-plugged, so in
+                * this case we only re-scan this bus. */
                child = pci_find_bus(pci_domain_nr(bus), max+1);
                if (!child) {
                        child = pci_add_new_bus(bus, dev, max+1);
                        if (!child)
                                goto out;
-                       pci_bus_insert_busn_res(child, max+1,
-                                               bus->busn_res.end);
+                       pci_bus_insert_busn_res(child, max+1, 0xff);
                }
                max++;
                buses = (buses & 0xff000000)
@@ -913,11 +908,6 @@ int pci_scan_bridge(struct pci_bus *bus, struct pci_dev *dev, int max, int pass)
                /*
                 * Set the subordinate bus number to its real value.
                 */
-               if (max > bus->busn_res.end) {
-                       dev_warn(&dev->dev, "max busn %02x is outside %pR\n",
-                                max, &bus->busn_res);
-                       max = bus->busn_res.end;
-               }
                pci_bus_update_busn_res_end(child, max);
                pci_write_config_byte(dev, PCI_SUBORDINATE_BUS, max);
        }
index ebcc9d1462198d990a9a473f0fecd435045f7b53..7f437036baa4bec9efa4fd1f8b619f9849889218 100644 (file)
@@ -26,6 +26,13 @@ struct ccp_cmd;
 #if defined(CONFIG_CRYPTO_DEV_CCP_DD) || \
        defined(CONFIG_CRYPTO_DEV_CCP_DD_MODULE)
 
+/**
+ * ccp_present - check if a CCP device is present
+ *
+ * Returns zero if a CCP device is present, -ENODEV otherwise.
+ */
+int ccp_present(void);
+
 /**
  * ccp_enqueue_cmd - queue an operation for processing by the CCP
  *
@@ -53,6 +60,11 @@ int ccp_enqueue_cmd(struct ccp_cmd *cmd);
 
 #else /* CONFIG_CRYPTO_DEV_CCP_DD is not enabled */
 
+static inline int ccp_present(void)
+{
+       return -ENODEV;
+}
+
 static inline int ccp_enqueue_cmd(struct ccp_cmd *cmd)
 {
        return -ENODEV;
index fc910a622451b2bb112bdd5ba784a7cadfcbb315..2fefcf491aa853f8ed868a92f39e8da594422c9b 100644 (file)
@@ -295,7 +295,7 @@ struct vb2_buffer {
  *                     can return an error if hardware fails, in that case all
  *                     buffers that have been already given by the @buf_queue
  *                     callback are to be returned by the driver by calling
- *                     @vb2_buffer_done(VB2_BUF_STATE_DEQUEUED).
+ *                     @vb2_buffer_done(VB2_BUF_STATE_QUEUED).
  *                     If you need a minimum number of buffers before you can
  *                     start streaming, then set @min_buffers_needed in the
  *                     vb2_queue structure. If that is non-zero then
@@ -380,6 +380,9 @@ struct v4l2_fh;
  * @start_streaming_called: start_streaming() was called successfully and we
  *             started streaming.
  * @error:     a fatal error occurred on the queue
+ * @waiting_for_buffers: used in poll() to check if vb2 is still waiting for
+ *             buffers. Only set for capture queues if qbuf has not yet been
+ *             called since poll() needs to return POLLERR in that situation.
  * @fileio:    file io emulator internal data, used only if emulator is active
  * @threadio:  thread io internal data, used only if thread is active
  */
@@ -417,6 +420,7 @@ struct vb2_queue {
        unsigned int                    streaming:1;
        unsigned int                    start_streaming_called:1;
        unsigned int                    error:1;
+       unsigned int                    waiting_for_buffers:1;
 
        struct vb2_fileio_data          *fileio;
        struct vb2_threadio_data        *threadio;