All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: Eric Auger <eric.auger@linaro.org>
Cc: b.reynal@virtualopensystems.com,
	Peter Crosthwaite <peter.crosthwaite@xilinx.com>,
	eric.auger@st.com, vikrams@codeaurora.org,
	Patch Tracking <patches@linaro.org>,
	QEMU Developers <qemu-devel@nongnu.org>,
	Alex Williamson <alex.williamson@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Christoffer Dall <christoffer.dall@linaro.org>
Subject: Re: [Qemu-devel] [RESEND PATCH v16 1/6] hw/arm/sysbus-fdt: enable vfio-calxeda-xgmac dynamic instantiation
Date: Tue, 16 Jun 2015 09:29:09 +0100	[thread overview]
Message-ID: <CAFEAcA9fjq8xOVD-9_D+Vvm984G4Jt-7KF_Ax4aPVQwssMCHLQ@mail.gmail.com> (raw)
In-Reply-To: <1434386038-9246-2-git-send-email-eric.auger@linaro.org>

On 15 June 2015 at 17:33, Eric Auger <eric.auger@linaro.org> wrote:
> This patch allows the instantiation of the vfio-calxeda-xgmac device
> from the QEMU command line (-device vfio-calxeda-xgmac,host="<device>").
>
> A specialized device tree node is created for the guest, containing
> compat, dma-coherent, reg and interrupts properties.
>
> Signed-off-by: Eric Auger <eric.auger@linaro.org>
>

Minor nits:

> +/* Device Specific Code */
> +
> +/**
> + * add_calxeda_midway_xgmac_fdt_node
> + *
> + * Generates a simple node with following properties:
> + * compatible string, regs, interrupts, dma-coherent
> + */
> +static int add_calxeda_midway_xgmac_fdt_node(SysBusDevice *sbdev, void *opaque)
> +{
> +    PlatformBusFDTData *data = opaque;
> +    PlatformBusDevice *pbus = data->pbus;
> +    void *fdt = data->fdt;
> +    const char *parent_node = data->pbus_node_name;
> +    int compat_str_len, i, ret = -1;
> +    char *nodename;
> +    uint32_t *irq_attr, *reg_attr;
> +    uint64_t mmio_base, irq_number;
> +    VFIOPlatformDevice *vdev = VFIO_PLATFORM_DEVICE(sbdev);
> +    VFIODevice *vbasedev = &vdev->vbasedev;
> +
> +    mmio_base = platform_bus_get_mmio_addr(pbus, sbdev, 0);
> +    nodename = g_strdup_printf("%s/%s@%" PRIx64, parent_node,
> +                               vbasedev->name, mmio_base);
> +    qemu_fdt_add_subnode(fdt, nodename);
> +
> +    compat_str_len = strlen(vdev->compat) + 1;
> +    qemu_fdt_setprop(fdt, nodename, "compatible",
> +                          vdev->compat, compat_str_len);
> +
> +    qemu_fdt_setprop(fdt, nodename, "dma-coherent", "", 0);
> +
> +    reg_attr = g_new(uint32_t, vbasedev->num_regions*2);

You should have spaces around the '*' operator here (and in a
couple of other places below).

> +    for (i = 0; i < vbasedev->num_regions; i++) {
> +        mmio_base = platform_bus_get_mmio_addr(pbus, sbdev, i);
> +        reg_attr[2*i] = cpu_to_be32(mmio_base);
> +        reg_attr[2*i+1] = cpu_to_be32(
> +                                memory_region_size(&vdev->regions[i]->mem));
> +    }
> +    ret = qemu_fdt_setprop(fdt, nodename, "reg", reg_attr,
> +                           vbasedev->num_regions*2*sizeof(uint32_t));
> +    if (ret) {
> +        error_report("could not set reg property of node %s", nodename);
> +        goto fail_reg;
> +    }
> +
> +    irq_attr = g_new(uint32_t, vbasedev->num_irqs*3);
> +    for (i = 0; i < vbasedev->num_irqs; i++) {
> +        irq_number = platform_bus_get_irqn(pbus, sbdev , i)
> +                         + data->irq_start;
> +        irq_attr[3*i] = cpu_to_be32(0);
> +        irq_attr[3*i+1] = cpu_to_be32(irq_number);
> +        irq_attr[3*i+2] = cpu_to_be32(0x4);

In virt.c the magic numbers in cells 0 and 2 have #defines
(GIC_FDT_IRQ_TYPE_SPI and GIC_FDT_IRQ_FLAGS_LEVEL_HI).

(1) maybe we should pull those out into a header so you can use them here
(2) is this device really using a level-triggered interrupt?

> +    }
> +   ret = qemu_fdt_setprop(fdt, nodename, "interrupts",
> +                     irq_attr, vbasedev->num_irqs*3*sizeof(uint32_t));
> +    if (ret) {
> +        error_report("could not set interrupts property of node %s",
> +                     nodename);
> +    }
> +    g_free(irq_attr);
> +fail_reg:
> +    g_free(reg_attr);
> +    g_free(nodename);
> +    return ret;
> +}
> +
>  /* list of supported dynamic sysbus devices */
>  static const NodeCreationPair add_fdt_node_functions[] = {
> +    {TYPE_VFIO_CALXEDA_XGMAC, add_calxeda_midway_xgmac_fdt_node},
>      {"", NULL}, /* last element */
>  };

This file could get big if we have a lot of platform passthrough
devices, but let's hope we don't...

Otherwise:
Acked-by: Peter Maydell <peter.maydell@linaro.org>

-- PMM

  reply	other threads:[~2015-06-16  8:29 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-15 16:33 [Qemu-devel] [RESEND PATCH v16 0/6] KVM platform device passthrough Eric Auger
2015-06-15 16:33 ` [Qemu-devel] [RESEND PATCH v16 1/6] hw/arm/sysbus-fdt: enable vfio-calxeda-xgmac dynamic instantiation Eric Auger
2015-06-16  8:29   ` Peter Maydell [this message]
2015-06-16  8:44     ` Eric Auger
2015-06-16  8:57       ` Peter Maydell
2015-06-15 16:33 ` [Qemu-devel] [RESEND PATCH v16 2/6] kvm: rename kvm_irqchip_[add, remove]_irqfd_notifier with gsi suffix Eric Auger
2015-06-24  9:53   ` Paolo Bonzini
2015-06-15 16:33 ` [Qemu-devel] [RESEND PATCH v16 3/6] kvm-all.c: add qemu_irq/gsi hash table and utility routines Eric Auger
2015-06-24  9:53   ` Paolo Bonzini
2015-06-26 11:41   ` Peter Maydell
2015-06-26 11:56     ` Eric Auger
2015-06-15 16:33 ` [Qemu-devel] [RESEND PATCH v16 4/6] intc: arm_gic_kvm: set the qemu_irq/gsi mapping Eric Auger
2015-06-24  9:54   ` Paolo Bonzini
2015-06-26 11:43   ` Peter Maydell
2015-06-26 11:59     ` Eric Auger
2015-06-15 16:33 ` [Qemu-devel] [RESEND PATCH v16 5/6] sysbus: add irq_routing_notifier Eric Auger
2015-06-15 16:33 ` [Qemu-devel] [RESEND PATCH v16 6/6] hw/vfio/platform: add irqfd support Eric Auger
2015-06-26 11:57   ` Peter Maydell
2015-06-26 12:19     ` Eric Auger
2015-06-26 16:21   ` Alex Williamson
2015-06-26 16:26     ` Paolo Bonzini
2015-06-26 16:31       ` Eric Auger
2015-06-26 16:46         ` Alex Williamson
2015-06-22  7:56 ` [Qemu-devel] [RESEND PATCH v16 0/6] KVM platform device passthrough Eric Auger
2015-06-24  9:55 ` Paolo Bonzini
2015-06-24  9:59   ` Eric Auger
2015-06-24 10:10     ` Paolo Bonzini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAFEAcA9fjq8xOVD-9_D+Vvm984G4Jt-7KF_Ax4aPVQwssMCHLQ@mail.gmail.com \
    --to=peter.maydell@linaro.org \
    --cc=alex.williamson@redhat.com \
    --cc=b.reynal@virtualopensystems.com \
    --cc=christoffer.dall@linaro.org \
    --cc=eric.auger@linaro.org \
    --cc=eric.auger@st.com \
    --cc=patches@linaro.org \
    --cc=pbonzini@redhat.com \
    --cc=peter.crosthwaite@xilinx.com \
    --cc=qemu-devel@nongnu.org \
    --cc=vikrams@codeaurora.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.