Re: [PATCH v4 6/7] powerpc/pseries/iommu: Make use of DDW even if it does not map the partition

From: Leonardo Bras
Date: Tue Jul 21 2020 - 17:39:49 EST


On Thu, 2020-07-16 at 04:16 -0300, Leonardo Bras wrote:
> +static void iommu_pseries_table_update(struct pci_dev *dev,
> + struct device_node *pdn)
> +{
> + const struct dynamic_dma_window_prop *ddw;
> + struct pci_dn *pci;
> + int len;
> +
> + ddw = of_get_property(pdn, DMA64_PROPNAME, &len);
> + if (!ddw || len < sizeof(struct dynamic_dma_window_prop))
> + return;
> +
> + iommu_table_update(pci->table_group->tables[0], pci->phb->node,
> + ddw->liobn, ddw->dma_base, ddw->tce_shift,
> + ddw->window_shift);
> +}
> +
> static void pci_dma_dev_setup_pSeriesLP(struct pci_dev *dev)
> {
> struct device_node *pdn, *dn;
> @@ -1382,6 +1403,7 @@ static bool iommu_bypass_supported_pSeriesLP(struct pci_dev *pdev, u64 dma_mask)
> pdev->dev.archdata.dma_offset = enable_ddw(pdev, pdn);
> if (pdev->dev.archdata.dma_offset)
> return true;
> + iommu_pseries_table_update(pdev, pdn);
> }
>

Noticed a bug in this one: pci is not getting assigned.
My bad, there must have been a merge error.

Also, I will refactor the function to make use of pdn only, as I can do
pci = PCI_DN(pdn) (I think it's better this way).

Sorry for the buggy patch.

Best regards,