On Sun, Jun 23, 2019 at 08:37:41PM +0300, Dmitry Osipenko wrote:
> On ARM32 we don't want any of the clients device to be backed by the
> implicit domain, simply because we can't afford such a waste on older
> Tegra SoCs that have very few domains available in total. The recent IOMMU
> support addition for the Video Decoder hardware uncovered the problem
> that an unfortunate drivers probe order results in the DRM driver probe
> failure if CONFIG_ARM_DMA_USE_IOMMU=y due to a shortage of IOMMU domains
> caused by the implicit backing. The host1x_client_register() is a common
> function that is invoked by all of the relevant DRM drivers during theirs
> probe and hence it is convenient to remove the implicit backing there,
> resolving the problem.
> 
> Signed-off-by: Dmitry Osipenko <[email protected]>
> ---
>  drivers/gpu/host1x/bus.c | 19 +++++++++++++++++++
>  1 file changed, 19 insertions(+)

I don't really want to do this in a central place like this. If we
really do need this, why can't we do it in the individual drivers? Also,
we already call host1x_client_iommu_attach() from all the drivers and
that detaches from the IOMMU as well. So I'm not sure I understand why
this is needed.

Thierry

> 
> diff --git a/drivers/gpu/host1x/bus.c b/drivers/gpu/host1x/bus.c
> index 742aa9ff21b8..559df3974afb 100644
> --- a/drivers/gpu/host1x/bus.c
> +++ b/drivers/gpu/host1x/bus.c
> @@ -14,6 +14,10 @@
>  #include "bus.h"
>  #include "dev.h"
>  
> +#if IS_ENABLED(CONFIG_ARM_DMA_USE_IOMMU)
> +#include <asm/dma-iommu.h>
> +#endif
> +
>  static DEFINE_MUTEX(clients_lock);
>  static LIST_HEAD(clients);
>  
> @@ -710,6 +714,21 @@ int host1x_client_register(struct host1x_client *client)
>       struct host1x *host1x;
>       int err;
>  
> +#if IS_ENABLED(CONFIG_ARM_DMA_USE_IOMMU)
> +     /*
> +      * The client's driver could be backed by implicit IOMMU mapping
> +      * and we don't want to have that because all of current Tegra
> +      * drivers are managing IOMMU by themselves. This is a convenient
> +      * place for unmapping of the implicit mapping because this function
> +      * is called by all host1x drivers during theirs probe.
> +      */
> +     if (client->dev->archdata.mapping) {
> +             struct dma_iommu_mapping *mapping =
> +                     to_dma_iommu_mapping(client->dev);
> +             arm_iommu_detach_device(client->dev);
> +             arm_iommu_release_mapping(mapping);
> +     }
> +#endif
>       mutex_lock(&devices_lock);
>  
>       list_for_each_entry(host1x, &devices, list) {
> -- 
> 2.22.0
> 

Attachment: signature.asc
Description: PGP signature

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Reply via email to