From: Alexey Kardashevskiy <aik@ozlabs.ru>
To: David Gibson <david@gibson.dropbear.id.au>
Cc: Alexander Graf <agraf@suse.de>,
Michael Roth <mdroth@linux.vnet.ibm.com>,
qemu-devel@nongnu.org,
Alex Williamson <alex.williamson@redhat.com>,
qemu-ppc@nongnu.org, Gavin Shan <gwshan@linux.vnet.ibm.com>
Subject: Re: [Qemu-devel] [PATCH qemu v6 11/15] spapr_pci: Do complete reset of DMA config when resetting PHB
Date: Wed, 22 Apr 2015 19:17:54 +1000 [thread overview]
Message-ID: <55376742.3060703@ozlabs.ru> (raw)
In-Reply-To: <20150422063903.GP31815@voom.redhat.com>
On 04/22/2015 04:39 PM, David Gibson wrote:
> On Sat, Apr 11, 2015 at 01:24:40AM +1000, Alexey Kardashevskiy wrote:
>> On a system reset, DMA configuration has to reset too. At the moment
>> it clears the table content. This is enough for the single table case
>> but with DDW, we will also have to disable all DMA windows except
>> the default one. Furthermore according to sPAPR, if the guest removed
>> the default window and created a huge one at the same zero offset on
>> a PCI bus, the reset handler has to recreate the default window with
>> the default properties (2GB big, 4K pages).
>>
>> This reworks SPAPR PHB code to disable the existing DMA window on reset
>> and then configure and enable the default window.
>> Without DDW that means that the same window will be disabled and then
>> enabled with no other change in behaviour.
>>
>> This changes the table creation to do it in one place in PHB (VFIO PHB
>> just inherits the behaviour from PHB). The actual table allocation is
>> done from the reset handler and this is where finish_realize() is called.
>
> Looks like your commit message needs an update - you already got rid
> of finish_realize() at this point in the series.
>
>> This disables all DMA windows on a PHB reset. It does not make any
>> difference now as there is just one DMA window but it will later with DDW
>> patches.
>>
>> spapr_phb_dma_reset() and spapr_phb_dma_remove_window() will be used
>> in following patch so make it public.
>>
>> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
>> ---
>> hw/ppc/spapr_pci.c | 45 ++++++++++++++++++++++++++++++++++++---------
>> hw/ppc/spapr_pci_vfio.c | 6 ------
>> include/hw/pci-host/spapr.h | 3 +++
>> 3 files changed, 39 insertions(+), 15 deletions(-)
>>
>> diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c
>> index 664687c..3d40f5b 100644
>> --- a/hw/ppc/spapr_pci.c
>> +++ b/hw/ppc/spapr_pci.c
>> @@ -736,7 +736,6 @@ static void spapr_phb_realize(DeviceState *dev, Error **errp)
>> SysBusDevice *s = SYS_BUS_DEVICE(dev);
>> sPAPRPHBState *sphb = SPAPR_PCI_HOST_BRIDGE(s);
>> PCIHostState *phb = PCI_HOST_BRIDGE(s);
>> - sPAPRPHBClass *info = SPAPR_PCI_HOST_BRIDGE_GET_CLASS(s);
>> char *namebuf;
>> int i;
>> PCIBus *bus;
>> @@ -887,14 +886,6 @@ static void spapr_phb_realize(DeviceState *dev, Error **errp)
>> return;
>> }
>>
>> - info->dma_capabilities_update(sphb);
>> - info->dma_init_window(sphb, sphb->dma_liobn, SPAPR_TCE_PAGE_SHIFT,
>> - sphb->dma32_window_size);
>> - tcet = spapr_tce_find_by_liobn(sphb->dma_liobn);
>> - if (!tcet) {
>> - error_setg(errp, "failed to create TCE table");
>> - return;
>> - }
>> memory_region_add_subregion(&sphb->iommu_root, 0,
>> spapr_tce_get_iommu(tcet));
>>
>> @@ -923,6 +914,40 @@ static int spapr_phb_dma_init_window(sPAPRPHBState *sphb,
>> return 0;
>> }
>>
>> +int spapr_phb_dma_remove_window(sPAPRPHBState *sphb,
>> + sPAPRTCETable *tcet)
>
> The only caller of this is just below, why is it not static?
rtas_ibm_remove_pe_dma_window() will call it in "[PATCH qemu v6 14/15]
spapr_pci/spapr_pci_vfio: Support Dynamic DMA Windows (DDW)". I do not see
much sense in making it static first and then making it public in later
patch, should I fix this anyway (do not care that much) or updated commit
log will be enough?
>
>> +{
>> + spapr_tce_table_disable(tcet);
>> +
>> + return 0;
>> +}
>> +
>> +static int spapr_phb_disable_dma_windows(Object *child, void *opaque)
>> +{
>> + sPAPRPHBState *sphb = SPAPR_PCI_HOST_BRIDGE(opaque);
>> + sPAPRTCETable *tcet = (sPAPRTCETable *)
>> + object_dynamic_cast(child, TYPE_SPAPR_TCE_TABLE);
>> +
>> + if (tcet) {
>> + spapr_phb_dma_remove_window(sphb, tcet);
>> + }
>> +
>> + return 0;
>> +}
>> +
>> +int spapr_phb_dma_reset(sPAPRPHBState *sphb)
>> +{
>> + const uint32_t liobn = SPAPR_PCI_LIOBN(sphb->index, 0);
>> + sPAPRPHBClass *spc = SPAPR_PCI_HOST_BRIDGE_GET_CLASS(sphb);
>> +
>> + spc->dma_capabilities_update(sphb); /* Refresh @has_vfio status */
>> + object_child_foreach(OBJECT(sphb), spapr_phb_disable_dma_windows, sphb);
>> + spc->dma_init_window(sphb, liobn, SPAPR_TCE_PAGE_SHIFT,
>> + sphb->dma32_window_size);
>> +
>> + return 0;
>> +}
>> +
>> static int spapr_phb_children_reset(Object *child, void *opaque)
>> {
>> DeviceState *dev = (DeviceState *) object_dynamic_cast(child, TYPE_DEVICE);
>> @@ -936,6 +961,8 @@ static int spapr_phb_children_reset(Object *child, void *opaque)
>>
>> static void spapr_phb_reset(DeviceState *qdev)
>> {
>> + spapr_phb_dma_reset(SPAPR_PCI_HOST_BRIDGE(qdev));
>> +
>> /* Reset the IOMMU state */
>> object_child_foreach(OBJECT(qdev), spapr_phb_children_reset, NULL);
>> }
>> diff --git a/hw/ppc/spapr_pci_vfio.c b/hw/ppc/spapr_pci_vfio.c
>> index a5b97d0..f89e053 100644
>> --- a/hw/ppc/spapr_pci_vfio.c
>> +++ b/hw/ppc/spapr_pci_vfio.c
>> @@ -58,11 +58,6 @@ static int spapr_phb_vfio_dma_init_window(sPAPRPHBState *sphb,
>> return 0;
>> }
>>
>> -static void spapr_phb_vfio_reset(DeviceState *qdev)
>> -{
>> - /* Do nothing */
>> -}
>> -
>> static int spapr_phb_vfio_eeh_set_option(sPAPRPHBState *sphb,
>> unsigned int addr, int option)
>> {
>> @@ -176,7 +171,6 @@ static void spapr_phb_vfio_class_init(ObjectClass *klass, void *data)
>> sPAPRPHBClass *spc = SPAPR_PCI_HOST_BRIDGE_CLASS(klass);
>>
>> dc->props = spapr_phb_vfio_properties;
>> - dc->reset = spapr_phb_vfio_reset;
>> spc->dma_capabilities_update = spapr_phb_vfio_dma_capabilities_update;
>> spc->dma_init_window = spapr_phb_vfio_dma_init_window;
>> spc->eeh_set_option = spapr_phb_vfio_eeh_set_option;
>> diff --git a/include/hw/pci-host/spapr.h b/include/hw/pci-host/spapr.h
>> index 3074145..7fda78e 100644
>> --- a/include/hw/pci-host/spapr.h
>> +++ b/include/hw/pci-host/spapr.h
>> @@ -140,5 +140,8 @@ void spapr_pci_rtas_init(void);
>> sPAPRPHBState *spapr_pci_find_phb(sPAPREnvironment *spapr, uint64_t buid);
>> PCIDevice *spapr_pci_find_dev(sPAPREnvironment *spapr, uint64_t buid,
>> uint32_t config_addr);
>> +int spapr_phb_dma_remove_window(sPAPRPHBState *sphb,
>> + sPAPRTCETable *tcet);
>> +int spapr_phb_dma_reset(sPAPRPHBState *sphb);
>>
>> #endif /* __HW_SPAPR_PCI_H__ */
>
--
Alexey
next prev parent reply other threads:[~2015-04-22 9:18 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-10 15:24 [Qemu-devel] [PATCH qemu v6 00/15] spapr: vfio: Enable Dynamic DMA windows (DDW) Alexey Kardashevskiy
2015-04-10 15:24 ` [Qemu-devel] [PATCH qemu v6 01/15] linux headers update for DDW on SPAPR Alexey Kardashevskiy
2015-04-10 15:24 ` [Qemu-devel] [PATCH qemu v6 02/15] vmstate: Define VARRAY with VMS_ALLOC Alexey Kardashevskiy
2015-04-15 3:47 ` David Gibson
2015-04-10 15:24 ` [Qemu-devel] [PATCH qemu v6 03/15] spapr_pci: Make find_phb()/find_dev() public Alexey Kardashevskiy
2015-04-21 20:44 ` Michael Roth
2015-04-10 15:24 ` [Qemu-devel] [PATCH qemu v6 04/15] vfio: spapr: Move SPAPR-related code to a separate file Alexey Kardashevskiy
2015-04-16 7:50 ` Thomas Huth
2015-04-16 16:27 ` Alexey Kardashevskiy
2015-04-10 15:24 ` [Qemu-devel] [PATCH qemu v6 05/15] spapr_pci_vfio: Enable multiple groups per container Alexey Kardashevskiy
2015-04-22 5:34 ` David Gibson
2015-04-10 15:24 ` [Qemu-devel] [PATCH qemu v6 06/15] spapr_pci: Convert finish_realize() to dma_capabilities_update()+dma_init_window() Alexey Kardashevskiy
2015-04-22 5:39 ` David Gibson
2015-04-10 15:24 ` [Qemu-devel] [PATCH qemu v6 07/15] vfio: spapr: Add SPAPR IOMMU v2 support (DMA memory preregistering) Alexey Kardashevskiy
2015-04-16 10:07 ` Thomas Huth
2015-04-24 5:55 ` Alexey Kardashevskiy
2015-04-22 5:53 ` David Gibson
2015-04-22 9:38 ` Alexey Kardashevskiy
2015-04-29 5:58 ` David Gibson
2015-04-10 15:24 ` [Qemu-devel] [PATCH qemu v6 08/15] spapr_iommu: Introduce "enabled" state for TCE table Alexey Kardashevskiy
2015-04-16 10:59 ` Thomas Huth
2015-04-22 6:14 ` David Gibson
2015-04-22 9:10 ` Alexey Kardashevskiy
2015-04-10 15:24 ` [Qemu-devel] [PATCH qemu v6 09/15] spapr_iommu: Add root memory region Alexey Kardashevskiy
2015-04-10 15:24 ` [Qemu-devel] [PATCH qemu v6 10/15] spapr_pci_vfio: Remove unnecessary cast to sPAPRPHBVFIOState Alexey Kardashevskiy
2015-04-16 10:31 ` Thomas Huth
2015-04-17 1:55 ` Alexey Kardashevskiy
2015-04-22 6:33 ` David Gibson
2015-04-10 15:24 ` [Qemu-devel] [PATCH qemu v6 11/15] spapr_pci: Do complete reset of DMA config when resetting PHB Alexey Kardashevskiy
2015-04-22 6:39 ` David Gibson
2015-04-22 9:17 ` Alexey Kardashevskiy [this message]
2015-04-10 15:24 ` [Qemu-devel] [PATCH qemu v6 12/15] spapr_vfio_pci: Remove redundant spapr-pci-vfio-host-bridge Alexey Kardashevskiy
2015-04-22 6:47 ` David Gibson
2015-04-22 9:06 ` Alexey Kardashevskiy
2015-04-10 15:24 ` [Qemu-devel] [PATCH qemu v6 13/15] spapr: Add pseries-2.4 machine Alexey Kardashevskiy
2015-04-22 6:48 ` David Gibson
2015-04-10 15:24 ` [Qemu-devel] [PATCH qemu v6 14/15] spapr_pci/spapr_pci_vfio: Support Dynamic DMA Windows (DDW) Alexey Kardashevskiy
2015-04-10 15:24 ` [Qemu-devel] [PATCH qemu v6 15/15] vfio: Enable DDW ioctls to VFIO IOMMU driver Alexey Kardashevskiy
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=55376742.3060703@ozlabs.ru \
--to=aik@ozlabs.ru \
--cc=agraf@suse.de \
--cc=alex.williamson@redhat.com \
--cc=david@gibson.dropbear.id.au \
--cc=gwshan@linux.vnet.ibm.com \
--cc=mdroth@linux.vnet.ibm.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.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 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).