1. 04 2月, 2008 4 次提交
    • R
      virtio: handle interrupts after callbacks turned off · 81a8deab
      Rusty Russell 提交于
      Anthony Liguori found double interrupt suppression in the virtio_net
      driver, triggered by two skb_recv_done's in a row.  This is because
      virtio_ring's interrupt suppression is a best-effort optimization: it
      contains no synchronization so the host can miss it and still send
      interrupts.
      
      But it's certainly nicer for virtio users if calling disable_cb
      actually disables callbacks, so we check for the race in the interrupt
      routine.
      
      Note: SMP guests might require syncronization here, but since
      disable_cb is actually called from interrupt context, there has to be
      some form of synchronization before the next same interrupt handler is
      called (Linux guarantees that the same device's irq handler will never
      run simultanously on multiple CPUs).
      Signed-off-by: NRusty Russell <rusty@rustcorp.com.au>
      81a8deab
    • R
      virtio: reset function · 6e5aa7ef
      Rusty Russell 提交于
      A reset function solves three problems:
      
      1) It allows us to renegotiate features, eg. if we want to upgrade a
         guest driver without rebooting the guest.
      
      2) It gives us a clean way of shutting down virtqueues: after a reset,
         we know that the buffers won't be used by the host, and
      
      3) It helps the guest recover from messed-up drivers.
      
      So we remove the ->shutdown hook, and the only way we now remove
      feature bits is via reset.
      
      We leave it to the driver to do the reset before it deletes queues:
      the balloon driver, for example, needs to chat to the host in its
      remove function.
      Signed-off-by: NRusty Russell <rusty@rustcorp.com.au>
      6e5aa7ef
    • R
      virtio: clarify NO_NOTIFY flag usage · 426e3e0a
      Rusty Russell 提交于
      The other side (host) can set the NO_NOTIFY flag as an optimization,
      to say "no need to kick me when you add things".  Make it clear that
      this is advisory only; especially that we should always notify when
      the ring is full.
      Signed-off-by: NRusty Russell <rusty@rustcorp.com.au>
      426e3e0a
    • R
      virtio: explicit enable_cb/disable_cb rather than callback return. · 18445c4d
      Rusty Russell 提交于
      It seems that virtio_net wants to disable callbacks (interrupts) before
      calling netif_rx_schedule(), so we can't use the return value to do so.
      
      Rename "restart" to "cb_enable" and introduce "cb_disable" hook: callback
      now returns void, rather than a boolean.
      Signed-off-by: NRusty Russell <rusty@rustcorp.com.au>
      18445c4d
  2. 12 11月, 2007 2 次提交
    • R
      virtio: Force use of power-of-two for descriptor ring sizes · 42b36cc0
      Rusty Russell 提交于
      The virtio descriptor rings of size N-1 were nicely set up to be
      aligned to an N-byte boundary.  But as Anthony Liguori points out, the
      free-running indices used by virtio require that the sizes be a power
      of 2, otherwise we get problems on wrap (demonstrated with lguest).
      
      So we replace the clever "2^n-1" scheme with a simple "align to page
      boundary" scheme: this means that all virtio rings take at least two
      pages, but it's safer than guessing cache alignment.
      Signed-off-by: NRusty Russell <rusty@rustcorp.com.au>
      42b36cc0
    • A
      virtio: Fix used_idx wrap-around · 1bc4953e
      Anthony Liguori 提交于
      The more_used() function compares the vq->vring.used->idx with last_used_idx.
      Since vq->vring.used->idx is a 16-bit integer, and last_used_idx is an
      unsigned int, this results in unpredictable behavior when vq->vring.used->idx
      wraps around.
      
      This patch corrects this by changing last_used_idx to the correct type.
      Signed-off-by: NAnthony Liguori <aliguori@us.ibm.com>
      Signed-off-by: NRusty Russell <rusty@rustcorp.com.au>
      1bc4953e
  3. 23 10月, 2007 1 次提交
    • R
      Virtio helper routines for a descriptor ringbuffer implementation · 0a8a69dd
      Rusty Russell 提交于
      These helper routines supply most of the virtqueue_ops for hypervisors
      which want to use a ring for virtio.  Unlike the previous lguest
      implementation:
      
      1) The rings are variable sized (2^n-1 elements).
      2) They have an unfortunate limit of 65535 bytes per sg element.
      3) The page numbers are always 64 bit (PAE anyone?)
      4) They no longer place used[] on a separate page, just a separate
         cacheline.
      5) We do a modulo on a variable.  We could be tricky if we cared.
      6) Interrupts and notifies are suppressed using flags within the rings.
      
      Users need only get the ring pages and provide a notify hook (KVM
      wants the guest to allocate the rings, lguest does it sanely).
      Signed-off-by: NRusty Russell <rusty@rustcorp.com.au>
      Cc: Dor Laor <dor.laor@qumranet.com>
      0a8a69dd