All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
To: Michael Roth <mdroth@linux.vnet.ibm.com>, qemu-devel@nongnu.org
Cc: aik@ozlabs.ru, agraf@suse.de, qemu-ppc@nongnu.org,
	tyreld@linux.vnet.ibm.com, bharata.rao@gmail.com,
	nfont@linux.vnet.ibm.com, david@gibson.dropbear.id.au
Subject: Re: [Qemu-devel] [Qemu-ppc] [PATCH v8 15/16] spapr_pci: enable basic hotplug operations
Date: Fri, 24 Apr 2015 16:00:33 +0530	[thread overview]
Message-ID: <87vbglx1h2.fsf@abhimanyu.in.ibm.com> (raw)
In-Reply-To: <1429684100-13354-16-git-send-email-mdroth@linux.vnet.ibm.com>

Hi Michael,

Couple of issues I found during my testing with pci enumerations patches
yesterday:

Michael Roth <mdroth@linux.vnet.ibm.com> writes:

> This enables hotplug of PCI devices to a PHB. Upon hotplug we
> generate the OF-nodes required by PAPR specification and
> IEEE 1275-1994 "PCI Bus Binding to Open Firmware" for the
> device.
>
> We associate the corresponding FDT for these nodes with the DRC
> corresponding to the slot, which will be fetched via
> ibm,configure-connector RTAS calls by the guest as described by PAPR
> specification.
>
> Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
> Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
> ---
>  hw/ppc/spapr_pci.c | 388 +++++++++++++++++++++++++++++++++++++++++++++++++++--
>  1 file changed, 380 insertions(+), 8 deletions(-)
>
[SNIP]
> +
> +/* fill in the 'reg'/'assigned-resources' OF properties for
> + * a PCI device. 'reg' describes resource requirements for a
> + * device's IO/MEM regions, 'assigned-addresses' describes the
> + * actual resource assignments.
> + *
> + * the properties are arrays of ('phys-addr', 'size') pairs describing
> + * the addressable regions of the PCI device, where 'phys-addr' is a
> + * RESOURCE_CELLS_ADDRESS-tuple of 32-bit integers corresponding to
> + * (phys.hi, phys.mid, phys.lo), and 'size' is a
> + * RESOURCE_CELLS_SIZE-tuple corresponding to (size.hi, size.lo).
> + *
> + * phys.hi = 0xYYXXXXZZ, where:
> + *   0xYY = npt000ss
> + *          |||   |
> + *          |||   +-- space code: 1 if IO region, 2 if MEM region

The above is missing 64-bit memory space

00  configuration space 
01  I/O space
10  memory space 32-bit address
11  memory space 64-bit address

> + *          ||+------ for non-relocatable IO: 1 if aliased
> + *          ||        for relocatable IO: 1 if below 64KB
> + *          ||        for MEM: 1 if below 1MB
> + *          |+------- 1 if region is prefetchable
> + *          +-------- 1 if region is non-relocatable
> + *   0xXXXX = bbbbbbbb dddddfff, encoding bus, slot, and function
> + *            bits respectively
> + *   0xZZ = rrrrrrrr, the register number of the BAR corresponding
> + *          to the region
> + *

[SNIP]

> +static void populate_resource_props(PCIDevice *d, ResourceProps *rp)
> +{
> +    int bus_num = pci_bus_num(PCI_BUS(qdev_get_parent_bus(DEVICE(d))));
> +    uint32_t dev_id = (b_bbbbbbbb(bus_num) |
> +                       b_ddddd(PCI_SLOT(d->devfn)) |
> +                       b_fff(PCI_FUNC(d->devfn)));
> +    ResourceFields *reg, *assigned;
> +    int i, reg_idx = 0, assigned_idx = 0;
> +
> +    /* config space region */
> +    reg = &rp->reg[reg_idx++];
> +    reg->phys_hi = cpu_to_be32(dev_id);
> +    reg->phys_mid = 0;
> +    reg->phys_lo = 0;
> +    reg->size_hi = 0;
> +    reg->size_lo = 0;
> +
> +    for (i = 0; i < PCI_NUM_REGIONS; i++) {
> +        if (!d->io_regions[i].size) {
> +            continue;
> +        }
> +
> +        reg = &rp->reg[reg_idx++];
> +
> +        reg->phys_hi = cpu_to_be32(dev_id | b_rrrrrrrr(pci_bar(d, i)));
> +        if (d->io_regions[i].type & PCI_BASE_ADDRESS_SPACE_IO) {
> +            reg->phys_hi |= cpu_to_be32(b_ss(1));
> +        } else {
> +            reg->phys_hi |= cpu_to_be32(b_ss(2));
> +        }

We need to identify 64-bit memory space here.


> +    _FDT(fdt_setprop_cell(fdt, offset, "class-code",
> +                          pci_default_read_config(dev, PCI_CLASS_DEVICE, 2)
> +                            << 8));

Complete class code needs to be encoded in the "class-code" property:

+                         pci_default_read_config(dev, PCI_CLASS_PROG, 3)));


Regards,
Nikunj

  reply	other threads:[~2015-04-24 10:31 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-22  6:28 [Qemu-devel] [PATCH v8 00/16] spapr: add support for pci hotplug Michael Roth
2015-04-22  6:28 ` [Qemu-devel] [PATCH v8 01/16] docs: add sPAPR hotplug/dynamic-reconfiguration documentation Michael Roth
2015-04-22  6:28 ` [Qemu-devel] [PATCH v8 02/16] spapr_drc: initial implementation of sPAPRDRConnector device Michael Roth
2015-04-22  6:28 ` [Qemu-devel] [PATCH v8 03/16] spapr_rtas: add get/set-power-level RTAS interfaces Michael Roth
2015-04-22  6:28 ` [Qemu-devel] [PATCH v8 04/16] spapr_rtas: add set-indicator RTAS interface Michael Roth
2015-04-22  6:28 ` [Qemu-devel] [PATCH v8 05/16] spapr_rtas: add get-sensor-state " Michael Roth
2015-04-22  6:28 ` [Qemu-devel] [PATCH v8 06/16] spapr: add rtas_st_buffer_direct() helper Michael Roth
2015-04-22  6:28 ` [Qemu-devel] [PATCH v8 07/16] spapr_rtas: add ibm, configure-connector RTAS interface Michael Roth
2015-04-28  7:23   ` David Gibson
2015-04-29  5:57     ` Michael Roth
2015-04-22  6:28 ` [Qemu-devel] [PATCH v8 08/16] spapr_events: re-use EPOW event infrastructure for hotplug events Michael Roth
2015-04-22  6:28 ` [Qemu-devel] [PATCH v8 09/16] spapr_events: event-scan RTAS interface Michael Roth
2015-04-22  6:28 ` [Qemu-devel] [PATCH v8 10/16] spapr_drc: add spapr_drc_populate_dt() Michael Roth
2015-04-22  6:28 ` [Qemu-devel] [PATCH v8 11/16] spapr: add pseries-2.4 machine type Michael Roth
2015-04-28  7:25   ` David Gibson
2015-04-29  6:11     ` Michael Roth
2015-04-30  1:03       ` David Gibson
2015-04-22  6:28 ` [Qemu-devel] [PATCH v8 12/16] spapr_pci: add dynamic-reconfiguration option for spapr-pci-host-bridge Michael Roth
2015-04-28  7:26   ` David Gibson
2015-04-22  6:28 ` [Qemu-devel] [PATCH v8 13/16] spapr_pci: create DRConnectors for each PCI slot during PHB realize Michael Roth
2015-04-22  6:28 ` [Qemu-devel] [PATCH v8 14/16] pci: make pci_bar useable outside pci.c Michael Roth
2015-04-28  7:31   ` David Gibson
2015-04-28  8:37     ` Michael S. Tsirkin
2015-04-29  1:51       ` David Gibson
2015-04-22  6:28 ` [Qemu-devel] [PATCH v8 15/16] spapr_pci: enable basic hotplug operations Michael Roth
2015-04-24 10:30   ` Nikunj A Dadhania [this message]
2015-04-22  6:28 ` [Qemu-devel] [PATCH v8 16/16] spapr_pci: emit hotplug add/remove events during hotplug Michael Roth
2015-04-30  4:13 ` [Qemu-devel] [PATCH v8 00/16] spapr: add support for pci hotplug David Gibson
2015-04-30 21:04   ` Michael Roth
2015-04-30 21:35     ` Michael Roth
2015-05-01  5:49     ` David Gibson

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=87vbglx1h2.fsf@abhimanyu.in.ibm.com \
    --to=nikunj@linux.vnet.ibm.com \
    --cc=agraf@suse.de \
    --cc=aik@ozlabs.ru \
    --cc=bharata.rao@gmail.com \
    --cc=david@gibson.dropbear.id.au \
    --cc=mdroth@linux.vnet.ibm.com \
    --cc=nfont@linux.vnet.ibm.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    --cc=tyreld@linux.vnet.ibm.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 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.