On Tue, 2020-06-23 at 11:11 +1000, Alexey Kardashevskiy wrote: > > On 23/06/2020 04:58, Leonardo Bras wrote: > > Hello Alexey, thanks for the feedback! > > > > On Mon, 2020-06-22 at 20:02 +1000, Alexey Kardashevskiy wrote: > > > On 19/06/2020 15:06, Leonardo Bras wrote: > > > > Platforms supporting the DDW option starting with LoPAR level 2.7 > > > > implement > > > > ibm,ddw-extensions. The first extension available (index 2) carries the > > > > token for ibm,reset-pe-dma-windows rtas call, which is used to restore > > > > the default DMA window for a device, if it has been deleted. > > > > > > > > It does so by resetting the TCE table allocation for the PE to it's > > > > boot time value, available in "ibm,dma-window" device tree node. > > > > > > > > Signed-off-by: Leonardo Bras <leobra...@gmail.com> > > > > --- > > > > arch/powerpc/platforms/pseries/iommu.c | 33 ++++++++++++++++++++++++++ > > > > 1 file changed, 33 insertions(+) > > > > > > > > diff --git a/arch/powerpc/platforms/pseries/iommu.c > > > > b/arch/powerpc/platforms/pseries/iommu.c > > > > index e5a617738c8b..5e1fbc176a37 100644 > > > > --- a/arch/powerpc/platforms/pseries/iommu.c > > > > +++ b/arch/powerpc/platforms/pseries/iommu.c > > > > @@ -1012,6 +1012,39 @@ static phys_addr_t ddw_memory_hotplug_max(void) > > > > return max_addr; > > > > } > > > > > > > > +/* > > > > + * Platforms supporting the DDW option starting with LoPAR level 2.7 > > > > implement > > > > + * ibm,ddw-extensions, which carries the rtas token for > > > > + * ibm,reset-pe-dma-windows. > > > > + * That rtas-call can be used to restore the default DMA window for > > > > the device. > > > > + */ > > > > +static void reset_dma_window(struct pci_dev *dev, struct device_node > > > > *par_dn) > > > > +{ > > > > + int ret; > > > > + u32 cfg_addr, ddw_ext[3]; > > > > + u64 buid; > > > > + struct device_node *dn; > > > > + struct pci_dn *pdn; > > > > + > > > > + ret = of_property_read_u32_array(par_dn, "ibm,ddw-extensions", > > > > + &ddw_ext[0], 3); > > > > > > s/3/2/ as for the reset extension you do not need the "64bit largest > > > block" extension. > > > > Sure, I will update this. > > > > > > > > > + if (ret) > > > > + return; > > > > + > > > > + dn = pci_device_to_OF_node(dev); > > > > + pdn = PCI_DN(dn); > > > > + buid = pdn->phb->buid; > > > > + cfg_addr = ((pdn->busno << 16) | (pdn->devfn << 8)); > > > > + > > > > + ret = rtas_call(ddw_ext[1], 3, 1, NULL, cfg_addr, > > > > > > Here the "reset" extention is in ddw_ext[1]. Hm. 1/4 has a bug then. > > > > Humm, in 1/4 I used dd_ext[0] (how many extensions) and ddw_ext[2] (64- > > bit largest window count). I fail to see the bug here. > > There is none, my bad :) > > > > > And I am pretty sure it won't compile as reset_dma_window() is not used > > > and it is static so fold it into one the next patches. Thanks, > > > > Sure, I will do that. > > I was questioning myself about this and thought it would be better to > > split for easier revision. > > People separate things when a patch is really huge but even then I miss > the point - I'd really like to see a new function _and_ its uses in the > same patch, otherwise I either need to jump between mails or apply the > series, either is little but extra work :) Thanks,
Sure, that makes sense. I will keep that in mind for future patchsets (and v2). Thank you! > > > > > > > > > + BUID_HI(buid), BUID_LO(buid)); > > > > + if (ret) > > > > + dev_info(&dev->dev, > > > > + "ibm,reset-pe-dma-windows(%x) %x %x %x > > > > returned %d ", > > > > + ddw_ext[1], cfg_addr, BUID_HI(buid), > > > > BUID_LO(buid), > > > > + ret); > > > > +} > > > > + > > > > /* > > > > * If the PE supports dynamic dma windows, and there is space for a > > > > table > > > > * that can map all pages in a linear offset, then setup such a table, > > > > > > > > Best regards, > > Leonardo > >