1
0
Fork 0
Rusty.
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1
 
 iQIcBAABAgAGBQJT6CniAAoJENkgDmzRrbjx1EIP/jFv2/pMAmsWAIosB757zIka
 zzy1W+Vnk1f55CDyu4S5l+lupBDf04EwijawRYSJEJNLvA7WMD9B3nG4gzUQLxf/
 AKjQn5e+pOs8XzLVuvwqQrR8JRpir75YgSUeig2P9Ngk9ErNpqmUZ7WUK+wOD8GS
 vxkCIZPLBGDT45r3pK0zDLXtdJXEQZR+tt7MQ/Pvlxvfg+FqQiI0zso/F0Jre1r7
 TcXT6aU2byLASpYT6ZmsW6U69WAWI2XQJ44Mh6J9ql9N463DA38yOCE6nvLEULNK
 ZctmybfC/eGxTW03lOPb12ypBh5sV1nVxccQDnB4eLBzmgL14U7NSwi0e+Mm29F3
 EyVtoCiIev/VAjN5p8R39sdIaFXL4rCc5ic8dORGCN/z2N9VF+k4VKdJVKt64ki9
 Wd228J7ByVDSYxTJ1yLEbPqaeQvjk/0zbSwzIGW9zas7CqlgjWDAviNnHlWUiJ3n
 TW7IzuAA6wD56uXni1b5uXe+4lmCAZpTDgGQ6+hIyb6pzW21Czhy4ooXrPGzxbfo
 ABt4xG9X7cPnexBhoica7RfcWMZQxppUbSgbbWoPKGStw4FUCsbUYjGncCzEnAN4
 ugjOC2H2cAzzgtfFziRBY0QWSoqhnmj/FZl/dt/oC+onM/JuBSKHplRZN84jYXn3
 TycAGncHdrKeEOfU7zNm
 =R3Ul
 -----END PGP SIGNATURE-----

Merge tag 'virtio-next-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux

Pull virtio updates from Rusty Russell.

* tag 'virtio-next-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux:
  Revert "hwrng: virtio - ensure reads happen after successful probe"
  virtio: rng: delay hwrng_register() till driver is ready
  virtio: rng: re-arrange struct elements for better packing
  virtio: rng: remove unused struct element
  virtio: Replace DEFINE_PCI_DEVICE_TABLE macro use
  virtio: console: remove unnecessary null test before debugfs_remove_recursive
hifive-unleashed-5.1
Linus Torvalds 2014-08-10 21:31:04 -07:00
commit 801a71a858
4 changed files with 20 additions and 33 deletions

View File

@ -81,12 +81,6 @@ static void add_early_randomness(struct hwrng *rng)
unsigned char bytes[16];
int bytes_read;
/*
* Currently only virtio-rng cannot return data during device
* probe, and that's handled in virtio-rng.c itself. If there
* are more such devices, this call to rng_get_data can be
* made conditional here instead of doing it per-device.
*/
bytes_read = rng_get_data(rng, bytes, sizeof(bytes), 1);
if (bytes_read > 0)
add_device_randomness(bytes, bytes_read);

View File

@ -28,17 +28,16 @@
static DEFINE_IDA(rng_index_ida);
struct virtrng_info {
struct virtio_device *vdev;
struct hwrng hwrng;
struct virtqueue *vq;
unsigned int data_avail;
struct completion have_data;
bool busy;
char name[25];
unsigned int data_avail;
int index;
bool busy;
bool hwrng_register_done;
};
static bool probe_done;
static void random_recv_done(struct virtqueue *vq)
{
@ -69,13 +68,6 @@ static int virtio_read(struct hwrng *rng, void *buf, size_t size, bool wait)
int ret;
struct virtrng_info *vi = (struct virtrng_info *)rng->priv;
/*
* Don't ask host for data till we're setup. This call can
* happen during hwrng_register(), after commit d9e7972619.
*/
if (unlikely(!probe_done))
return 0;
if (!vi->busy) {
vi->busy = true;
init_completion(&vi->have_data);
@ -137,25 +129,17 @@ static int probe_common(struct virtio_device *vdev)
return err;
}
err = hwrng_register(&vi->hwrng);
if (err) {
vdev->config->del_vqs(vdev);
vi->vq = NULL;
kfree(vi);
ida_simple_remove(&rng_index_ida, index);
return err;
}
probe_done = true;
return 0;
}
static void remove_common(struct virtio_device *vdev)
{
struct virtrng_info *vi = vdev->priv;
vdev->config->reset(vdev);
vi->busy = false;
hwrng_unregister(&vi->hwrng);
if (vi->hwrng_register_done)
hwrng_unregister(&vi->hwrng);
vdev->config->del_vqs(vdev);
ida_simple_remove(&rng_index_ida, vi->index);
kfree(vi);
@ -171,6 +155,16 @@ static void virtrng_remove(struct virtio_device *vdev)
remove_common(vdev);
}
static void virtrng_scan(struct virtio_device *vdev)
{
struct virtrng_info *vi = vdev->priv;
int err;
err = hwrng_register(&vi->hwrng);
if (!err)
vi->hwrng_register_done = true;
}
#ifdef CONFIG_PM_SLEEP
static int virtrng_freeze(struct virtio_device *vdev)
{
@ -195,6 +189,7 @@ static struct virtio_driver virtio_rng_driver = {
.id_table = id_table,
.probe = virtrng_probe,
.remove = virtrng_remove,
.scan = virtrng_scan,
#ifdef CONFIG_PM_SLEEP
.freeze = virtrng_freeze,
.restore = virtrng_restore,

View File

@ -2262,8 +2262,7 @@ static int __init init(void)
unregister:
unregister_virtio_driver(&virtio_console);
free:
if (pdrvdata.debugfs_dir)
debugfs_remove_recursive(pdrvdata.debugfs_dir);
debugfs_remove_recursive(pdrvdata.debugfs_dir);
class_destroy(pdrvdata.class);
return err;
}
@ -2276,8 +2275,7 @@ static void __exit fini(void)
unregister_virtio_driver(&virtio_rproc_serial);
class_destroy(pdrvdata.class);
if (pdrvdata.debugfs_dir)
debugfs_remove_recursive(pdrvdata.debugfs_dir);
debugfs_remove_recursive(pdrvdata.debugfs_dir);
}
module_init(init);
module_exit(fini);

View File

@ -91,7 +91,7 @@ struct virtio_pci_vq_info
};
/* Qumranet donated their vendor ID for devices 0x1000 thru 0x10FF. */
static DEFINE_PCI_DEVICE_TABLE(virtio_pci_id_table) = {
static const struct pci_device_id virtio_pci_id_table[] = {
{ PCI_DEVICE(0x1af4, PCI_ANY_ID) },
{ 0 }
};