<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/drivers/virtio, branch v2.6.26</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/
</subtitle>
<id>https://git.shady.money/linux/atom?h=v2.6.26</id>
<link rel='self' href='https://git.shady.money/linux/atom?h=v2.6.26'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/'/>
<updated>2008-06-15T20:46:16Z</updated>
<entry>
<title>virtio: Complete feature negotation before updating status</title>
<updated>2008-06-15T20:46:16Z</updated>
<author>
<name>Mark McLoughlin</name>
<email>markmc@redhat.com</email>
</author>
<published>2008-06-15T13:20:50Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=b92dea67cc66970cda6b5b11895d08e35b4618e7'/>
<id>urn:sha1:b92dea67cc66970cda6b5b11895d08e35b4618e7</id>
<content type='text'>
lguest (in rusty's use-tun-ringfd patch) assumes that the
guest has updated its feature bits before setting its status
to VIRTIO_CONFIG_S_DRIVER_OK.

That's pretty reasonable, so let's make it so.

Signed-off-by: Mark McLoughlin &lt;markmc@redhat.com&gt;
Signed-off-by: Rusty Russell &lt;rusty@rustcorp.com.au&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>virtio: force callback on empty.</title>
<updated>2008-05-30T05:09:46Z</updated>
<author>
<name>Rusty Russell</name>
<email>rusty@rustcorp.com.au</email>
</author>
<published>2008-05-30T20:09:45Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=b4f68be6c5d507afdcd74f5be3df0b1209cda503'/>
<id>urn:sha1:b4f68be6c5d507afdcd74f5be3df0b1209cda503</id>
<content type='text'>
virtio allows drivers to suppress callbacks (ie. interrupts) for
efficiency (no locking, it's just an optimization).

There's a similar mechanism for the host to suppress notifications
coming from the guest: in that case, we ignore the suppression if the
ring is completely full.

It turns out that life is simpler if the host similarly ignores
callback suppression when the ring is completely empty: the network
driver wants to free up old packets in a timely manner, and otherwise
has to use a timer to poll.

We have to remove the code which ignores interrupts when the driver
has disabled them (again, it had no locking and hence was unreliable
anyway).

Signed-off-by: Rusty Russell &lt;rusty@rustcorp.com.au&gt;
</content>
</entry>
<entry>
<title>virtio_net: another race with virtio_net and enable_cb</title>
<updated>2008-05-30T05:09:45Z</updated>
<author>
<name>Christian Borntraeger</name>
<email>borntraeger@de.ibm.com</email>
</author>
<published>2008-05-26T09:29:27Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=52a3a05f3ab82655ffa4c9bf6835565c98a3c2e5'/>
<id>urn:sha1:52a3a05f3ab82655ffa4c9bf6835565c98a3c2e5</id>
<content type='text'>
Hello Rusty,

seems that we still have a problem with virtio_net and the enable_cb callback.
During a long running network stress tests with virtio and got the following
oops:

------------[ cut here ]------------
kernel BUG at drivers/virtio/virtio_ring.c:230!
illegal operation: 0001 [#1] SMP
Modules linked in:
CPU: 0 Not tainted 2.6.26-rc2-kvm-00436-gc94c08b-dirty #34
Process netserver (pid: 2582, task: 000000000fbc4c68, ksp: 000000000f42b990)
Krnl PSW : 0704c00180000000 00000000002d0ec8 (vring_enable_cb+0x1c/0x60)
           R:0 T:1 IO:1 EX:1 Key:0 M:1 W:0 P:0 AS:3 CC:0 PM:0 EA:3
Krnl GPRS: 0000000000000000 0000000000000000 000000000ef3d000 0000000010009800
           0000000000000000 0000000000419ce0 0000000000000080 000000000000007b
           000000000adb5538 000000000ef40900 000000000ef40000 000000000ef40920
           0000000000000000 0000000000000005 000000000029c1b0 000000000fea7d18
Krnl Code: 00000000002d0ebc: a7110001           tmll    %r1,1
           00000000002d0ec0: a7740004           brc     7,2d0ec8
           00000000002d0ec4: a7f40001           brc     15,2d0ec6
          &gt;00000000002d0ec8: a517fffe           nill    %r1,65534
           00000000002d0ecc: 40103000           sth     %r1,0(%r3)
           00000000002d0ed0: 07f0               bcr     15,%r0
           00000000002d0ed2: e31020380004       lg      %r1,56(%r2)
           00000000002d0ed8: a7480000           lhi     %r4,0
Call Trace:
([&lt;000000000029c0fc&gt;] virtnet_poll+0x290/0x3b8)
 [&lt;0000000000333fb8&gt;] net_rx_action+0x9c/0x1b8
 [&lt;00000000001394bc&gt;] __do_softirq+0x74/0x108
 [&lt;000000000010d16a&gt;] do_softirq+0x92/0xac
 [&lt;0000000000139826&gt;] irq_exit+0x72/0xc8
 [&lt;000000000010a7b6&gt;] do_extint+0xe2/0x104
 [&lt;0000000000110508&gt;] ext_no_vtime+0x16/0x1a
Last Breaking-Event-Address:
 [&lt;00000000002d0ec4&gt;] vring_enable_cb+0x18/0x60

I looked into the virtio_net code for some time and I think the following
scenario happened. Please look at virtnet_poll:
[...]
        /* Out of packets? */
        if (received &lt; budget) {
                netif_rx_complete(vi-&gt;dev, napi);
                if (unlikely(!vi-&gt;rvq-&gt;vq_ops-&gt;enable_cb(vi-&gt;rvq))
                    &amp;&amp; napi_schedule_prep(napi)) {
                        vi-&gt;rvq-&gt;vq_ops-&gt;disable_cb(vi-&gt;rvq);
                        __netif_rx_schedule(vi-&gt;dev, napi);
                        goto again;
                }
        }

If an interrupt arrives after netif_rx_complete, a second poll routine can run
on a different cpu. The second check for napi_schedule_prep would prevent any
harm in the network stack, but we have called enable_cb possibly after the
disable_cb in skb_recv_done.

static void skb_recv_done(struct virtqueue *rvq)
{
        struct virtnet_info *vi = rvq-&gt;vdev-&gt;priv;
        /* Schedule NAPI, Suppress further interrupts if successful. */
        if (netif_rx_schedule_prep(vi-&gt;dev, &amp;vi-&gt;napi)) {
                rvq-&gt;vq_ops-&gt;disable_cb(rvq);
                __netif_rx_schedule(vi-&gt;dev, &amp;vi-&gt;napi);
        }
}

That means that the second poll routine runs with interrupts enabled, which is
ok, since we can handle additional interrupts. The problem is now that the
second poll routine might also call enable_cb, triggering the BUG.

The only solution I can come up with, is to remove the BUG statement in
enable_cb - similar to disable_cb. Opinions or better ideas where the oops
could come from?

Signed-off-by: Christian Borntraeger &lt;borntraeger@de.ibm.com&gt;
Signed-off-by: Rusty Russell &lt;rusty@rustcorp.com.au&gt;
</content>
</entry>
<entry>
<title>virtio: set device index in common code.</title>
<updated>2008-05-30T05:09:42Z</updated>
<author>
<name>Rusty Russell</name>
<email>rusty@rustcorp.com.au</email>
</author>
<published>2008-05-30T20:09:42Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=b769f579081943f14e0ff03b7b0bd3a11cf14625'/>
<id>urn:sha1:b769f579081943f14e0ff03b7b0bd3a11cf14625</id>
<content type='text'>
Anthony Liguori points out that three different transports use the virtio code,
but each one keeps its own counter to set the virtio_device's index field.  In
theory (though not in current practice) this means that names could be
duplicated, and that risk grows as more transports are created.

So we move the selection of the unique virtio_device.index into the common code
in virtio.c, which has the side-benefit of removing duplicate code.

The only complexity is that lguest and S/390 use the index to uniquely identify
the device in case of catastrophic failure before register_virtio_device() is
called: now we use the offset within the descriptor page as a unique identifier
for the printks.

Signed-off-by: Rusty Russell &lt;rusty@rustcorp.com.au&gt;
Cc: Christian Borntraeger &lt;borntraeger@de.ibm.com&gt;
Cc: Martin Schwidefsky &lt;schwidefsky@de.ibm.com&gt;
Cc: Carsten Otte &lt;cotte@de.ibm.com&gt;
Cc: Heiko Carstens &lt;heiko.carstens@de.ibm.com&gt;
Cc: Chris Lalancette &lt;clalance@redhat.com&gt;
Cc: Anthony Liguori &lt;anthony@codemonkey.ws&gt;
</content>
</entry>
<entry>
<title>virtio: virtio_pci should not set bus_id.</title>
<updated>2008-05-30T05:09:42Z</updated>
<author>
<name>Rusty Russell</name>
<email>rusty@rustcorp.com.au</email>
</author>
<published>2008-05-30T20:09:42Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=5610bd1524332fe7d651eb56cc780e32763a2ac3'/>
<id>urn:sha1:5610bd1524332fe7d651eb56cc780e32763a2ac3</id>
<content type='text'>
The common virtio code sets the bus_id, overriding anything virtio_pci
sets anyway.

Signed-off-by: Rusty Russell &lt;rusty@rustcorp.com.au&gt;
Cc: Christian Borntraeger &lt;borntraeger@de.ibm.com&gt;
Cc: Martin Schwidefsky &lt;schwidefsky@de.ibm.com&gt;
Cc: Carsten Otte &lt;cotte@de.ibm.com&gt;
Cc: Heiko Carstens &lt;heiko.carstens@de.ibm.com&gt;
Cc: Chris Lalancette &lt;clalance@redhat.com&gt;
Cc: Anthony Liguori &lt;anthony@codemonkey.ws&gt;
</content>
</entry>
<entry>
<title>virtio: bus_id for devices should contain 'virtio'</title>
<updated>2008-05-30T05:09:42Z</updated>
<author>
<name>Rusty Russell</name>
<email>rusty@rustcorp.com.au</email>
</author>
<published>2008-05-30T20:09:41Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=2ad3cfbac58d0a6c6e65aafd9e0e757ca3d35292'/>
<id>urn:sha1:2ad3cfbac58d0a6c6e65aafd9e0e757ca3d35292</id>
<content type='text'>
Chris Lalancette &lt;clalance@redhat.com&gt; points out that virtio.c sets all device
names to '0', '1', etc, which looks silly in /proc/interrupts.  We change this
from '%d' to 'virtio%d'.

Signed-off-by: Rusty Russell &lt;rusty@rustcorp.com.au&gt;
Cc: Christian Borntraeger &lt;borntraeger@de.ibm.com&gt;
Cc: Martin Schwidefsky &lt;schwidefsky@de.ibm.com&gt;
Cc: Carsten Otte &lt;cotte@de.ibm.com&gt;
Cc: Heiko Carstens &lt;heiko.carstens@de.ibm.com&gt;
Cc: Chris Lalancette &lt;clalance@redhat.com&gt;
Cc: Anthony Liguori &lt;anthony@codemonkey.ws&gt;
</content>
</entry>
<entry>
<title>virtio: explicit advertisement of driver features</title>
<updated>2008-05-02T11:50:50Z</updated>
<author>
<name>Rusty Russell</name>
<email>rusty@rustcorp.com.au</email>
</author>
<published>2008-05-03T02:50:50Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=c45a6816c19dee67b8f725e6646d428901a6dc24'/>
<id>urn:sha1:c45a6816c19dee67b8f725e6646d428901a6dc24</id>
<content type='text'>
A recent proposed feature addition to the virtio block driver revealed
some flaws in the API: in particular, we assume that feature
negotiation is complete once a driver's probe function returns.

There is nothing in the API to require this, however, and even I
didn't notice when it was violated.

So instead, we require the driver to specify what features it supports
in a table, we can then move the feature negotiation into the virtio
core.  The intersection of device and driver features are presented in
a new 'features' bitmap in the struct virtio_device.

Note that this highlights the difference between Linux unsigned-long
bitmaps where each unsigned long is in native endian, and a
straight-forward little-endian array of bytes.

Drivers can still remove feature bits in their probe routine if they
really have to.

API changes:
- dev-&gt;config-&gt;feature() no longer gets and acks a feature.
- drivers should advertise their features in the 'feature_table' field
- use virtio_has_feature() for extra sanity when checking feature bits

Signed-off-by: Rusty Russell &lt;rusty@rustcorp.com.au&gt;
</content>
</entry>
<entry>
<title>virtio: change config to guest endian.</title>
<updated>2008-05-02T11:50:50Z</updated>
<author>
<name>Rusty Russell</name>
<email>rusty@rustcorp.com.au</email>
</author>
<published>2008-05-03T02:50:49Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=72e61eb40b55dd57031ec5971e810649f82b0259'/>
<id>urn:sha1:72e61eb40b55dd57031ec5971e810649f82b0259</id>
<content type='text'>
A recent proposed feature addition to the virtio block driver revealed
some flaws in the API, in particular how easy it is to break big
endian machines.

The virtio config space was originally chosen to be little-endian,
because we thought the config might be part of the PCI config space
for virtio_pci.  It's actually a separate mmio region, so that
argument holds little water; as only x86 is currently using the virtio
mechanism, we can change this (but must do so now, before the
impending s390 merge).

API changes:
- __virtio_config_val() just becomes a striaght vdev-&gt;config_get() call.

Signed-off-by: Rusty Russell &lt;rusty@rustcorp.com.au&gt;
</content>
</entry>
<entry>
<title>virtio: fix sparse return void-valued expression warnings</title>
<updated>2008-05-02T11:50:44Z</updated>
<author>
<name>Harvey Harrison</name>
<email>harvey.harrison@gmail.com</email>
</author>
<published>2008-04-01T00:53:55Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=597d56e4b51fc3385e097e52d6e92bf596ff21ec'/>
<id>urn:sha1:597d56e4b51fc3385e097e52d6e92bf596ff21ec</id>
<content type='text'>
drivers/virtio/virtio_pci.c:148:2: warning: returning void-valued expression
drivers/virtio/virtio_pci.c:155:2: warning: returning void-valued expression

Signed-off-by: Harvey Harrison &lt;harvey.harrison@gmail.com&gt;
Signed-off-by: Rusty Russell &lt;rusty@rustcorp.com.au&gt;
</content>
</entry>
<entry>
<title>virtio: ignore corrupted virtqueues rather than spinning.</title>
<updated>2008-05-02T11:50:43Z</updated>
<author>
<name>Rusty Russell</name>
<email>rusty@rustcorp.com.au</email>
</author>
<published>2008-05-03T02:50:43Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=5ef827526fc01820a7a80827802e9fad3f34f937'/>
<id>urn:sha1:5ef827526fc01820a7a80827802e9fad3f34f937</id>
<content type='text'>
A corrupt virtqueue (caused by the other end screwing up) can have
strange results such as a driver spinning: just bail when we try to
get a buffer from a known-broken queue.

Signed-off-by: Rusty Russell &lt;rusty@rustcorp.com.au&gt;
</content>
</entry>
</feed>
