All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jon Hunter <jonathanh@nvidia.com>
To: Joerg Roedel <joro@8bytes.org>, Hiroshi Doyu <hdoyu@nvidia.com>,
	Thierry Reding <thierry.reding@gmail.com>
Cc: Robin Murphy <robin.murphy@arm.com>,
	iommu@lists.linux-foundation.org, linux-tegra@vger.kernel.org,
	linux-kernel@vger.kernel.org, Joerg Roedel <jroedel@suse.de>
Subject: Re: [PATCH 1/2] iommu/tegra: Add support for struct iommu_device
Date: Wed, 30 Aug 2017 12:04:38 +0100	[thread overview]
Message-ID: <f857ad53-66ca-0aa9-947a-f517443d114d@nvidia.com> (raw)
In-Reply-To: <1502317752-8792-2-git-send-email-joro@8bytes.org>


On 09/08/17 23:29, Joerg Roedel wrote:
> From: Joerg Roedel <jroedel@suse.de>
> 
> Add a struct iommu_device to each tegra-smmu and register it
> with the iommu-core. Also link devices added to the driver
> to their respective hardware iommus.
> 
> Signed-off-by: Joerg Roedel <jroedel@suse.de>
> ---
>  drivers/iommu/tegra-smmu.c | 25 +++++++++++++++++++++++++
>  1 file changed, 25 insertions(+)
> 
> diff --git a/drivers/iommu/tegra-smmu.c b/drivers/iommu/tegra-smmu.c
> index faa9c1e..2802e12 100644
> --- a/drivers/iommu/tegra-smmu.c
> +++ b/drivers/iommu/tegra-smmu.c
> @@ -36,6 +36,8 @@ struct tegra_smmu {
>  	struct list_head list;
>  
>  	struct dentry *debugfs;
> +
> +	struct iommu_device iommu;	/* IOMMU Core code handle */
>  };
>  
>  struct tegra_smmu_as {
> @@ -720,6 +722,9 @@ static int tegra_smmu_add_device(struct device *dev)
>  			 * first match.
>  			 */
>  			dev->archdata.iommu = smmu;
> +
> +			iommu_device_link(&smmu->iommu, dev);
> +
>  			break;
>  		}
>  
> @@ -737,6 +742,11 @@ static int tegra_smmu_add_device(struct device *dev)
>  
>  static void tegra_smmu_remove_device(struct device *dev)
>  {
> +	struct tegra_smmu *smmu = dev->archdata.iommu;
> +
> +	if (smmu)
> +		iommu_device_unlink(&smmu->iommu, dev);
> +
>  	dev->archdata.iommu = NULL;
>  	iommu_group_remove_device(dev);
>  }
> @@ -943,6 +953,18 @@ struct tegra_smmu *tegra_smmu_probe(struct device *dev,
>  	if (err < 0)
>  		return ERR_PTR(err);
>  
> +	err = iommu_device_sysfs_add(&smmu->iommu, dev, NULL, dev_name(dev));
> +	if (err)
> +		return ERR_PTR(err);
> +
> +	iommu_device_set_ops(&smmu->iommu, &tegra_smmu_ops);
> +
> +	err = iommu_device_register(&smmu->iommu);
> +	if (err) {
> +		iommu_device_sysfs_remove(&smmu->iommu);
> +		return ERR_PTR(err);
> +	}
> +
>  	if (IS_ENABLED(CONFIG_DEBUG_FS))
>  		tegra_smmu_debugfs_init(smmu);
>  
> @@ -951,6 +973,9 @@ struct tegra_smmu *tegra_smmu_probe(struct device *dev,
>  
>  void tegra_smmu_remove(struct tegra_smmu *smmu)
>  {
> +	iommu_device_unregister(&smmu->iommu);
> +	iommu_device_sysfs_remove(&smmu->iommu);
> +
>  	if (IS_ENABLED(CONFIG_DEBUG_FS))
>  		tegra_smmu_debugfs_exit(smmu);
>  }
> 

With next-20170829 I am seeing several Tegra boards crashing [0][1] on
boot in tegra_smmu_probe() and the bisect is point to this commit. Looks
like there maybe a sequence problem between calls to bus_set_iommu() and
iommu_device_add_sysfs() which results in a NULL pointer dereference.

You can see the full crash log here [1].

Cheers
Jon

[0] https://nvtb.github.io//linux-next/
[1]
https://nvtb.github.io//linux-next/test_next-20170829/20170829024534/boot/tegra124-jetson-tk1/tegra124-jetson-tk1/tegra_defconfig_log.txt

WARNING: multiple messages have this Message-ID (diff)
From: Jon Hunter <jonathanh@nvidia.com>
To: Joerg Roedel <joro@8bytes.org>, Hiroshi Doyu <hdoyu@nvidia.com>,
	"Thierry Reding" <thierry.reding@gmail.com>
Cc: Robin Murphy <robin.murphy@arm.com>,
	<iommu@lists.linux-foundation.org>, <linux-tegra@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>, Joerg Roedel <jroedel@suse.de>
Subject: Re: [PATCH 1/2] iommu/tegra: Add support for struct iommu_device
Date: Wed, 30 Aug 2017 12:04:38 +0100	[thread overview]
Message-ID: <f857ad53-66ca-0aa9-947a-f517443d114d@nvidia.com> (raw)
In-Reply-To: <1502317752-8792-2-git-send-email-joro@8bytes.org>


On 09/08/17 23:29, Joerg Roedel wrote:
> From: Joerg Roedel <jroedel@suse.de>
> 
> Add a struct iommu_device to each tegra-smmu and register it
> with the iommu-core. Also link devices added to the driver
> to their respective hardware iommus.
> 
> Signed-off-by: Joerg Roedel <jroedel@suse.de>
> ---
>  drivers/iommu/tegra-smmu.c | 25 +++++++++++++++++++++++++
>  1 file changed, 25 insertions(+)
> 
> diff --git a/drivers/iommu/tegra-smmu.c b/drivers/iommu/tegra-smmu.c
> index faa9c1e..2802e12 100644
> --- a/drivers/iommu/tegra-smmu.c
> +++ b/drivers/iommu/tegra-smmu.c
> @@ -36,6 +36,8 @@ struct tegra_smmu {
>  	struct list_head list;
>  
>  	struct dentry *debugfs;
> +
> +	struct iommu_device iommu;	/* IOMMU Core code handle */
>  };
>  
>  struct tegra_smmu_as {
> @@ -720,6 +722,9 @@ static int tegra_smmu_add_device(struct device *dev)
>  			 * first match.
>  			 */
>  			dev->archdata.iommu = smmu;
> +
> +			iommu_device_link(&smmu->iommu, dev);
> +
>  			break;
>  		}
>  
> @@ -737,6 +742,11 @@ static int tegra_smmu_add_device(struct device *dev)
>  
>  static void tegra_smmu_remove_device(struct device *dev)
>  {
> +	struct tegra_smmu *smmu = dev->archdata.iommu;
> +
> +	if (smmu)
> +		iommu_device_unlink(&smmu->iommu, dev);
> +
>  	dev->archdata.iommu = NULL;
>  	iommu_group_remove_device(dev);
>  }
> @@ -943,6 +953,18 @@ struct tegra_smmu *tegra_smmu_probe(struct device *dev,
>  	if (err < 0)
>  		return ERR_PTR(err);
>  
> +	err = iommu_device_sysfs_add(&smmu->iommu, dev, NULL, dev_name(dev));
> +	if (err)
> +		return ERR_PTR(err);
> +
> +	iommu_device_set_ops(&smmu->iommu, &tegra_smmu_ops);
> +
> +	err = iommu_device_register(&smmu->iommu);
> +	if (err) {
> +		iommu_device_sysfs_remove(&smmu->iommu);
> +		return ERR_PTR(err);
> +	}
> +
>  	if (IS_ENABLED(CONFIG_DEBUG_FS))
>  		tegra_smmu_debugfs_init(smmu);
>  
> @@ -951,6 +973,9 @@ struct tegra_smmu *tegra_smmu_probe(struct device *dev,
>  
>  void tegra_smmu_remove(struct tegra_smmu *smmu)
>  {
> +	iommu_device_unregister(&smmu->iommu);
> +	iommu_device_sysfs_remove(&smmu->iommu);
> +
>  	if (IS_ENABLED(CONFIG_DEBUG_FS))
>  		tegra_smmu_debugfs_exit(smmu);
>  }
> 

With next-20170829 I am seeing several Tegra boards crashing [0][1] on
boot in tegra_smmu_probe() and the bisect is point to this commit. Looks
like there maybe a sequence problem between calls to bus_set_iommu() and
iommu_device_add_sysfs() which results in a NULL pointer dereference.

You can see the full crash log here [1].

Cheers
Jon

[0] https://nvtb.github.io//linux-next/
[1]
https://nvtb.github.io//linux-next/test_next-20170829/20170829024534/boot/tegra124-jetson-tk1/tegra124-jetson-tk1/tegra_defconfig_log.txt

  parent reply	other threads:[~2017-08-30 11:04 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-09 22:29 [PATCH 0/2] iommu/tegra*: Add support for struct iommu_device Joerg Roedel
2017-08-09 22:29 ` Joerg Roedel
2017-08-09 22:29 ` [PATCH 1/2] iommu/tegra: " Joerg Roedel
     [not found]   ` <1502317752-8792-2-git-send-email-joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>
2017-08-18 12:47     ` Thierry Reding
2017-08-18 12:47       ` Thierry Reding
2017-08-30 11:04   ` Jon Hunter [this message]
2017-08-30 11:04     ` Jon Hunter
2017-08-30 12:09     ` Joerg Roedel
     [not found]       ` <20170830120902.kqtxh2ls4ob7xpwy-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>
2017-08-30 14:22         ` Jon Hunter
2017-08-30 14:22           ` Jon Hunter
     [not found]           ` <c6ee1ce0-7193-be63-c84d-73795c727d26-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2017-08-30 15:30             ` Joerg Roedel
2017-08-30 15:30               ` Joerg Roedel
2017-08-30 15:30               ` Joerg Roedel
     [not found]               ` <20170830153034.GK19533-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>
2017-08-30 16:53                 ` Jon Hunter
2017-08-30 16:53                   ` Jon Hunter
2017-08-31 10:23                 ` Jon Hunter
2017-08-31 10:23                   ` Jon Hunter
     [not found] ` <1502317752-8792-1-git-send-email-joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>
2017-08-09 22:29   ` [PATCH 2/2] iommu/tegra-gart: " Joerg Roedel
2017-08-09 22:29     ` Joerg Roedel
     [not found]     ` <1502317752-8792-3-git-send-email-joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>
2017-08-16 22:21       ` Dmitry Osipenko
2017-08-16 22:21         ` Dmitry Osipenko
     [not found]         ` <66711b72-455f-8ec1-e6f7-5946480dde14-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-08-17 13:52           ` Thierry Reding
2017-08-17 13:52             ` Thierry Reding
2017-08-17 17:17             ` Dmitry Osipenko
2017-08-18 12:47     ` Thierry Reding
2017-08-17 13:58   ` [PATCH 0/2] iommu/tegra*: " Thierry Reding
2017-08-17 13:58     ` Thierry Reding
2017-08-31 12:24 [PATCH 1/2] iommu/tegra: " Jörg Rödel

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=f857ad53-66ca-0aa9-947a-f517443d114d@nvidia.com \
    --to=jonathanh@nvidia.com \
    --cc=hdoyu@nvidia.com \
    --cc=iommu@lists.linux-foundation.org \
    --cc=joro@8bytes.org \
    --cc=jroedel@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=robin.murphy@arm.com \
    --cc=thierry.reding@gmail.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.