virtio_mmio.c (c5111a5b1a603cbad4bb3b49ae9a77dbc2252a59) virtio_mmio.c (af8ececda185078c096852edb4e1d7a2349e6856)
1// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3 * Virtio memory mapped device driver
4 *
5 * Copyright 2011-2014, ARM Ltd.
6 *
7 * This module allows virtio devices to be used over a virtual, memory mapped
8 * platform device.

--- 47 unchanged lines hidden (view full) ---

56
57#include <linux/acpi.h>
58#include <linux/dma-mapping.h>
59#include <linux/highmem.h>
60#include <linux/interrupt.h>
61#include <linux/io.h>
62#include <linux/list.h>
63#include <linux/module.h>
1// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3 * Virtio memory mapped device driver
4 *
5 * Copyright 2011-2014, ARM Ltd.
6 *
7 * This module allows virtio devices to be used over a virtual, memory mapped
8 * platform device.

--- 47 unchanged lines hidden (view full) ---

56
57#include <linux/acpi.h>
58#include <linux/dma-mapping.h>
59#include <linux/highmem.h>
60#include <linux/interrupt.h>
61#include <linux/io.h>
62#include <linux/list.h>
63#include <linux/module.h>
64#include <linux/of.h>
65#include <linux/platform_device.h>
66#include <linux/pm.h>
67#include <linux/slab.h>
68#include <linux/spinlock.h>
69#include <linux/virtio.h>
70#include <linux/virtio_config.h>
71#include <uapi/linux/virtio_mmio.h>
72#include <linux/virtio_ring.h>

--- 208 unchanged lines hidden (view full) ---

281 struct virtio_mmio_device *vm_dev = to_virtio_mmio_device(vq->vdev);
282
283 /* We write the queue's selector into the notification register to
284 * signal the other end */
285 writel(vq->index, vm_dev->base + VIRTIO_MMIO_QUEUE_NOTIFY);
286 return true;
287}
288
64#include <linux/platform_device.h>
65#include <linux/pm.h>
66#include <linux/slab.h>
67#include <linux/spinlock.h>
68#include <linux/virtio.h>
69#include <linux/virtio_config.h>
70#include <uapi/linux/virtio_mmio.h>
71#include <linux/virtio_ring.h>

--- 208 unchanged lines hidden (view full) ---

280 struct virtio_mmio_device *vm_dev = to_virtio_mmio_device(vq->vdev);
281
282 /* We write the queue's selector into the notification register to
283 * signal the other end */
284 writel(vq->index, vm_dev->base + VIRTIO_MMIO_QUEUE_NOTIFY);
285 return true;
286}
287
288static bool vm_notify_with_data(struct virtqueue *vq)
289{
290 struct virtio_mmio_device *vm_dev = to_virtio_mmio_device(vq->vdev);
291 u32 data = vring_notification_data(vq);
292
293 writel(data, vm_dev->base + VIRTIO_MMIO_QUEUE_NOTIFY);
294
295 return true;
296}
297
289/* Notify all virtqueues on an interrupt. */
290static irqreturn_t vm_interrupt(int irq, void *opaque)
291{
292 struct virtio_mmio_device *vm_dev = opaque;
293 struct virtio_mmio_vq_info *info;
294 unsigned long status;
295 unsigned long flags;
296 irqreturn_t ret = IRQ_NONE;

--- 62 unchanged lines hidden (view full) ---

359 synchronize_irq(platform_get_irq(vm_dev->pdev, 0));
360}
361
362static struct virtqueue *vm_setup_vq(struct virtio_device *vdev, unsigned int index,
363 void (*callback)(struct virtqueue *vq),
364 const char *name, bool ctx)
365{
366 struct virtio_mmio_device *vm_dev = to_virtio_mmio_device(vdev);
298/* Notify all virtqueues on an interrupt. */
299static irqreturn_t vm_interrupt(int irq, void *opaque)
300{
301 struct virtio_mmio_device *vm_dev = opaque;
302 struct virtio_mmio_vq_info *info;
303 unsigned long status;
304 unsigned long flags;
305 irqreturn_t ret = IRQ_NONE;

--- 62 unchanged lines hidden (view full) ---

368 synchronize_irq(platform_get_irq(vm_dev->pdev, 0));
369}
370
371static struct virtqueue *vm_setup_vq(struct virtio_device *vdev, unsigned int index,
372 void (*callback)(struct virtqueue *vq),
373 const char *name, bool ctx)
374{
375 struct virtio_mmio_device *vm_dev = to_virtio_mmio_device(vdev);
376 bool (*notify)(struct virtqueue *vq);
367 struct virtio_mmio_vq_info *info;
368 struct virtqueue *vq;
369 unsigned long flags;
370 unsigned int num;
371 int err;
372
377 struct virtio_mmio_vq_info *info;
378 struct virtqueue *vq;
379 unsigned long flags;
380 unsigned int num;
381 int err;
382
383 if (__virtio_test_bit(vdev, VIRTIO_F_NOTIFICATION_DATA))
384 notify = vm_notify_with_data;
385 else
386 notify = vm_notify;
387
373 if (!name)
374 return NULL;
375
376 /* Select the queue we're interested in */
377 writel(index, vm_dev->base + VIRTIO_MMIO_QUEUE_SEL);
378
379 /* Queue shouldn't already be set up. */
380 if (readl(vm_dev->base + (vm_dev->version == 1 ?

--- 12 unchanged lines hidden (view full) ---

393 num = readl(vm_dev->base + VIRTIO_MMIO_QUEUE_NUM_MAX);
394 if (num == 0) {
395 err = -ENOENT;
396 goto error_new_virtqueue;
397 }
398
399 /* Create the vring */
400 vq = vring_create_virtqueue(index, num, VIRTIO_MMIO_VRING_ALIGN, vdev,
388 if (!name)
389 return NULL;
390
391 /* Select the queue we're interested in */
392 writel(index, vm_dev->base + VIRTIO_MMIO_QUEUE_SEL);
393
394 /* Queue shouldn't already be set up. */
395 if (readl(vm_dev->base + (vm_dev->version == 1 ?

--- 12 unchanged lines hidden (view full) ---

408 num = readl(vm_dev->base + VIRTIO_MMIO_QUEUE_NUM_MAX);
409 if (num == 0) {
410 err = -ENOENT;
411 goto error_new_virtqueue;
412 }
413
414 /* Create the vring */
415 vq = vring_create_virtqueue(index, num, VIRTIO_MMIO_VRING_ALIGN, vdev,
401 true, true, ctx, vm_notify, callback, name);
416 true, true, ctx, notify, callback, name);
402 if (!vq) {
403 err = -ENOMEM;
404 goto error_new_virtqueue;
405 }
406
407 vq->num_max = num;
408
409 /* Activate the queue */

--- 444 unchanged lines hidden ---
417 if (!vq) {
418 err = -ENOMEM;
419 goto error_new_virtqueue;
420 }
421
422 vq->num_max = num;
423
424 /* Activate the queue */

--- 444 unchanged lines hidden ---