On Thu, Apr 18, 2019 at 06:26:06PM +0100, Julien Grall wrote:
> +int iommu_dma_prepare_msi(struct msi_desc *desc, phys_addr_t msi_addr)
>  {
> +     struct device *dev = msi_desc_to_dev(desc);
>       struct iommu_domain *domain = iommu_get_domain_for_dev(dev);
>       struct iommu_dma_cookie *cookie;
>       unsigned long flags;
>  
> +     if (!domain || !domain->iova_cookie) {
> +             desc->iommu_cookie = NULL;
> +             return 0;
> +     }
>  
>       cookie = domain->iova_cookie;
>  
> @@ -908,10 +908,33 @@ void iommu_dma_map_msi_msg(int irq, struct msi_msg *msg)
>        * of an MSI from within an IPI handler.
>        */
>       spin_lock_irqsave(&cookie->msi_lock, flags);
> +     desc->iommu_cookie = iommu_dma_get_msi_page(dev, msi_addr, domain);
>       spin_unlock_irqrestore(&cookie->msi_lock, flags);
>  
> +     return (desc->iommu_cookie) ? 0 : -ENOMEM;

No need for the braces.  Also I personally find a:

        if (!desc->iommu_cookie)
                return -ENOMEM;
        return 0;

much more readable, but that might just be personal preference.
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu

Reply via email to