[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-ppc] [Qemu-devel] [PATCH v4 4/4] spapr_pci: populate ibm, loc-
From: |
Nikunj A Dadhania |
Subject: |
Re: [Qemu-ppc] [Qemu-devel] [PATCH v4 4/4] spapr_pci: populate ibm, loc-code |
Date: |
Tue, 19 May 2015 12:26:43 +0530 |
User-agent: |
Notmuch/0.17+27~gae47d61 (http://notmuchmail.org) Emacs/24.3.1 (x86_64-redhat-linux-gnu) |
Alexey Kardashevskiy <address@hidden> writes:
> On 05/19/2015 02:51 PM, Nikunj A Dadhania wrote:
>> Alexey Kardashevskiy <address@hidden> writes:
>>
>>> On 05/07/2015 05:21 PM, Nikunj A Dadhania wrote:
>>>> Each hardware instance has a platform unique location code. The OF
>>>> device tree that describes a part of a hardware entity must include
>>>> the “ibm,loc-code” property with a value that represents the location
>>>> code for that hardware entity.
>>>>
>>>> Populate ibm,loc-code.
>>>>
>>>> 1) PCI passthru devices need to identify with its own ibm,loc-code
>>>> available on the host. In failure cases use:
>>>> vfio_<name>:<phb-index>:<slot>.<fn>
>>>>
>>>> 2) Emulated devices encode as following:
>>>> qemu_<name>:<phb-index>:<slot>.<fn>
>>>>
>>>> Signed-off-by: Nikunj A Dadhania <address@hidden>
>>>> ---
>>>> hw/ppc/spapr_pci.c | 98
>>>> +++++++++++++++++++++++++++++++++++++++++++++++-------
>>>> 1 file changed, 86 insertions(+), 12 deletions(-)
>>>>
>>>> diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c
>>>> index 12f1b9c..d901007 100644
>>>> --- a/hw/ppc/spapr_pci.c
>>>> +++ b/hw/ppc/spapr_pci.c
>>>> @@ -769,6 +769,81 @@ static uint32_t
>>>> spapr_phb_get_pci_drc_index(sPAPRPHBState *phb,
>>>> return drck->get_index(drc);
>>>> }
>>>>
>>>> +static bool spapr_phb_vfio_get_devspec_value(PCIDevice *pdev, char
>>>> **value)
>>>
>>> Does it have to be a separate function?
>>
>> For better readability, i would prefer it this way.
>
> This is why I asked - I was having problems understanding the difference
> between these two having 6 words names ;) Do not insist though.
>
This is what I have now, simplified:
+static char *spapr_phb_vfio_get_loc_code(sPAPRPHBState *sphb, PCIDevice *pdev)
+{
+ char *path = NULL, *buf = NULL;
+ char *host = NULL;
+
+ /* Get the PCI VFIO host id */
+ host = object_property_get_str(OBJECT(pdev), "host", NULL);
+ if (!host) {
+ goto err_out;
+ }
+
+ /* Construct the path of the file that will give us the DT location */
+ path = g_strdup_printf("/sys/bus/pci/devices/%s/devspec", host);
+ g_free(host);
+ if (path && !g_file_get_contents(path, &buf, NULL, NULL)) {
+ goto err_out;
+ }
+ g_free(path);
+
+ /* Construct and read from host device tree the loc-code */
+ path = g_strdup_printf("/proc/device-tree%s/ibm,loc-code", buf);
+ g_free(buf);
+ if (path && !g_file_get_contents(path, &buf, NULL, NULL)) {
+ goto err_out;
+ }
+ return buf;
+
+err_out:
+ g_free(path);
+ return NULL;
+}
+
+static char *spapr_phb_get_loc_code(sPAPRPHBState *sphb, PCIDevice *pdev)
+{
+ if (object_dynamic_cast(OBJECT(pdev), "vfio-pci")) {
+ char *buf = spapr_phb_vfio_get_loc_code(sphb, pdev);
+
+ /*
+ * In case of failures reading the loc-code, make it up
+ * indicating a vfio device
+ */
+ if (!buf) {
+ buf = g_strdup_printf("vfio_%s:%02d:%02d.%1d", pdev->name,
+ sphb->index, PCI_SLOT(pdev->devfn),
+ PCI_FUNC(pdev->devfn));
+ }
+ return buf;
+ } else {
+ return g_strdup_printf("qemu_%s:%02d:%02d.%1d", pdev->name,
+ sphb->index, PCI_SLOT(pdev->devfn),
+ PCI_FUNC(pdev->devfn));
+ }
+}
+
Regards
Nikunj
- [Qemu-ppc] [PATCH v4 0/4] spapr_pci: DT field fixes and PCI DT node creation in QEMU, Nikunj A Dadhania, 2015/05/07
- [Qemu-ppc] [PATCH v4 1/4] spapr_pci: encode missing 64-bit memory address space, Nikunj A Dadhania, 2015/05/07
- [Qemu-ppc] [PATCH v4 2/4] spapr_pci: encode class code including Prog IF register, Nikunj A Dadhania, 2015/05/07
- [Qemu-ppc] [PATCH v4 3/4] spapr_pci: enumerate and add PCI device tree, Nikunj A Dadhania, 2015/05/07
- [Qemu-ppc] [PATCH v4 4/4] spapr_pci: populate ibm,loc-code, Nikunj A Dadhania, 2015/05/07
- Re: [Qemu-ppc] [PATCH v4 4/4] spapr_pci: populate ibm,loc-code, Alexey Kardashevskiy, 2015/05/08
- Re: [Qemu-ppc] [Qemu-devel] [PATCH v4 4/4] spapr_pci: populate ibm, loc-code, Nikunj A Dadhania, 2015/05/19
- Re: [Qemu-ppc] [Qemu-devel] [PATCH v4 4/4] spapr_pci: populate ibm, loc-code, Alexey Kardashevskiy, 2015/05/19
- Re: [Qemu-ppc] [Qemu-devel] [PATCH v4 4/4] spapr_pci: populate ibm, loc-code, Nikunj A Dadhania, 2015/05/19
- Re: [Qemu-ppc] [Qemu-devel] [PATCH v4 4/4] spapr_pci: populate ibm, loc-code,
Nikunj A Dadhania <=
- Re: [Qemu-ppc] [Qemu-devel] [PATCH v4 4/4] spapr_pci: populate ibm, loc-code, Alexey Kardashevskiy, 2015/05/19
- Re: [Qemu-ppc] [Qemu-devel] [PATCH v4 4/4] spapr_pci: populate ibm, loc-code, Nikunj A Dadhania, 2015/05/19
- Re: [Qemu-ppc] [Qemu-devel] [PATCH v4 4/4] spapr_pci: populate ibm, loc-code, Alexey Kardashevskiy, 2015/05/19
- Re: [Qemu-ppc] [Qemu-devel] [PATCH v4 4/4] spapr_pci: populate ibm, loc-code, Nikunj A Dadhania, 2015/05/19
- Re: [Qemu-ppc] [Qemu-devel] [PATCH v4 4/4] spapr_pci: populate ibm, loc-code, Alexander Graf, 2015/05/19
- Re: [Qemu-ppc] [Qemu-devel] [PATCH v4 4/4] spapr_pci: populate ibm, loc-code, Nikunj A Dadhania, 2015/05/19