From: Eric Auger <eric.auger@linaro.org>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: eric.auger@st.com, "QEMU Developers" <qemu-devel@nongnu.org>,
qemu-arm <qemu-arm@nongnu.org>,
"David Gibson" <david@gibson.dropbear.id.au>,
"Alex Williamson" <alex.williamson@redhat.com>,
"Alex Bennée" <alex.bennee@linaro.org>,
"Thomas Huth" <thuth@redhat.com>,
"Peter Crosthwaite" <crosthwaitepeter@gmail.com>,
"Patch Tracking" <patches@linaro.org>,
"Christoffer Dall" <christoffer.dall@linaro.org>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Baptiste Reynal" <b.reynal@virtualopensystems.com>,
"Suravee Suthikulpanit" <suravee.suthikulpanit@amd.com>,
thomas.lendacky@amd.com
Subject: Re: [PATCH v5 7/8] hw/arm/sysbus-fdt: enable amd-xgbe dynamic instantiation
Date: Mon, 1 Feb 2016 14:11:57 +0100 [thread overview]
Message-ID: <56AF599D.8010903@linaro.org> (raw)
In-Reply-To: <CAFEAcA9T2OxhC7si7LVc7WX--F-kbHms9QgdN99PWjO-ns9TDg@mail.gmail.com>
Hi Peter,
On 01/25/2016 03:33 PM, Peter Maydell wrote:
> On 18 January 2016 at 15:16, Eric Auger <eric.auger@linaro.org> wrote:
>> This patch allows the instantiation of the vfio-amd-xgbe device
>> from the QEMU command line (-device vfio-amd-xgbe,host="<device>").
>>
>> The guest is exposed with a device tree node that combines the description
>> of both XGBE and PHY (representation supported from 4.2 onwards kernel):
>> Documentation/devicetree/bindings/net/amd-xgbe.txt.
>>
>> There are 5 register regions, 6 interrupts including 4 optional
>> edge-sensitive per-channel interrupts.
>>
>> Some property values are inherited from host device tree. Host device tree
>> must feature a combined XGBE/PHY representation (>= 4.2 host kernel).
>>
>> 2 clock nodes (dma and ptp) also are created. It is checked those clocks
>> are fixed on host side.
>>
>> AMD XGBE node creation function has a dependency on vfio Linux header and
>> more generally node creation function for VFIO platform devices only make
>> sense with CONFIG_LINUX so let's protect this code with #ifdef CONFIG_LINUX.
>>
>> Signed-off-by: Eric Auger <eric.auger@linaro.org>
>
>> hw/arm/sysbus-fdt.c | 195 ++++++++++++++++++++++++++++++++++++++++++++++++++--
>> 1 file changed, 189 insertions(+), 6 deletions(-)
>
> I'll let it pass for this patchset, but this file is starting to
> get big, and probably needs some kind of split into common functions
> in one file and then a separate file for each pass-through device,
> if they're all going to require 200-odd lines to deal with.
That's understood. If you don't mind i would rather introduce that move
in a separate series then.
Thanks
Eric
>
>> +/**
>> + * sysfs_to_dt_name: convert the name found in sysfs into the node name
>> + * for instance e0900000.xgmac is converted into xgmac@e0900000
>> + * @sysfs_name: directory name in sysfs
>> + *
>> + * returns the device tree name upon success or NULL in case the sysfs name
>> + * does not match the expected format
>> + */
>> +static char *sysfs_to_dt_name(const char *sysfs_name)
>> +{
>> + gchar **substrings = g_strsplit(sysfs_name, ".", 2);
>> + char *dt_name = NULL;
>> +
>> + if (!substrings || !substrings[1] || !substrings[0]) {
>
> We should check substrings[0] before substrings[1], as otherwise
> if we're passed the empty string we'll index off the end of the
> vector.
>
>> + goto out;
>> + }
>> + dt_name = g_strdup_printf("%s@%s", substrings[1], substrings[0]);
>> +out:
>> + g_strfreev(substrings);
>> + return dt_name;
>> +}
>> +
>> /* Device Specific Code */
>>
>> /**
>> @@ -243,9 +269,166 @@ fail_reg:
>> return ret;
>> }
>>
>> +
>> +/* AMD xgbe properties whose values are copied/pasted from host */
>> +static HostProperty amd_xgbe_copied_properties[] = {
>> + {"compatible", false},
>> + {"dma-coherent", true},
>> + {"amd,per-channel-interrupt", true},
>> + {"phy-mode", false},
>> + {"mac-address", true},
>> + {"amd,speed-set", false},
>> + {"amd,serdes-blwc", true},
>> + {"amd,serdes-cdr-rate", true},
>> + {"amd,serdes-pq-skew", true},
>> + {"amd,serdes-tx-amp", true},
>> + {"amd,serdes-dfe-tap-config", true},
>> + {"amd,serdes-dfe-tap-enable", true},
>> + {"clock-names", false},
>> +};
>> +
>> +/**
>> + * add_amd_xgbe_fdt_node
>> + *
>> + * Generates the combined xgbe/phy node following kernel >=4.2
>> + * binding documentation:
>> + * Documentation/devicetree/bindings/net/amd-xgbe.txt:
>> + * Also 2 clock nodes are created (dma and ptp)
>> + *
>> + * self-asserts in case of error
>
> "asserts".
>
>> + 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(GIC_FDT_IRQ_TYPE_SPI);
>> + irq_attr[3 * i + 1] = cpu_to_be32(irq_number);
>> + /*
>> + * General device interrupt and PCS auto-negociation interrupts are
>
> "negotiation"
>
>> + * level-sensitive while the 4 per-channel interrupts are edge
>> + * sensitive
>> + */
>> + QLIST_FOREACH(intp, &vdev->intp_list, next) {
>> + if (intp->pin == i) {
>> + break;
>> + }
>> + }
>> + if (intp->flags & VFIO_IRQ_INFO_AUTOMASKED) {
>> + irq_attr[3 * i + 2] = cpu_to_be32(GIC_FDT_IRQ_FLAGS_LEVEL_HI);
>> + } else {
>> + irq_attr[3 * i + 2] = cpu_to_be32(GIC_FDT_IRQ_FLAGS_EDGE_LO_HI);
>> + }
>> + }
>> + qemu_fdt_setprop(guest_fdt, nodename, "interrupts",
>> + irq_attr, vbasedev->num_irqs * 3 * sizeof(uint32_t));
>> +
>> + g_free(host_fdt);
>> + g_strfreev(node_path);
>> + g_free(irq_attr);
>> + g_free(reg_attr);
>> + g_free(nodename);
>> + return 0;
>> +}
>> +
>> +#endif /* CONFIG_LINUX */
>> +
>> /* list of supported dynamic sysbus devices */
>> static const NodeCreationPair add_fdt_node_functions[] = {
>> +#ifdef CONFIG_LINUX
>> {TYPE_VFIO_CALXEDA_XGMAC, add_calxeda_midway_xgmac_fdt_node},
>> + {TYPE_VFIO_AMD_XGBE, add_amd_xgbe_fdt_node},
>> +#endif
>> {"", NULL}, /* last element */
>> };
>
> thanks
> -- PMM
>
next prev parent reply other threads:[~2016-02-01 13:12 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-18 15:16 [PATCH v5 0/8] AMD XGBE KVM platform passthrough Eric Auger
2016-01-18 15:16 ` [PATCH v5 1/8] hw/vfio/platform: amd-xgbe device Eric Auger
2016-01-18 15:16 ` [PATCH v5 2/8] device_tree: introduce load_device_tree_from_sysfs Eric Auger
2016-01-25 14:13 ` Peter Maydell
2016-02-01 13:11 ` Eric Auger
2016-01-18 15:16 ` [PATCH v5 3/8] device_tree: introduce qemu_fdt_node_path Eric Auger
2016-01-25 14:26 ` Peter Maydell
2016-01-25 14:41 ` Eric Auger
2016-01-18 15:16 ` [PATCH v5 4/8] device_tree: qemu_fdt_getprop converted to use the error API Eric Auger
2016-01-18 15:16 ` [PATCH v5 5/8] device_tree: qemu_fdt_getprop_cell " Eric Auger
2016-01-18 15:16 ` [PATCH v5 6/8] hw/arm/sysbus-fdt: helpers for clock node generation Eric Auger
2016-01-25 14:05 ` Peter Maydell
2016-01-25 14:09 ` Eric Auger
2016-01-25 14:34 ` Peter Maydell
2016-01-25 14:43 ` Peter Maydell
2016-01-25 14:51 ` Eric Auger
2016-01-18 15:16 ` [PATCH v5 7/8] hw/arm/sysbus-fdt: enable amd-xgbe dynamic instantiation Eric Auger
2016-01-25 14:33 ` Peter Maydell
2016-02-01 13:11 ` Eric Auger [this message]
2016-01-18 15:16 ` [PATCH v5 8/8] hw/arm/sysbus-fdt: remove qemu_fdt_setprop returned value check Eric Auger
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=56AF599D.8010903@linaro.org \
--to=eric.auger@linaro.org \
--cc=alex.bennee@linaro.org \
--cc=alex.williamson@redhat.com \
--cc=b.reynal@virtualopensystems.com \
--cc=christoffer.dall@linaro.org \
--cc=crosthwaitepeter@gmail.com \
--cc=david@gibson.dropbear.id.au \
--cc=eric.auger@st.com \
--cc=patches@linaro.org \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=suravee.suthikulpanit@amd.com \
--cc=thomas.lendacky@amd.com \
--cc=thuth@redhat.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).