From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jon Hunter Subject: Re: [PATCH 1/2] iommu/tegra: Add support for struct iommu_device Date: Wed, 30 Aug 2017 15:22:05 +0100 Message-ID: References: <1502317752-8792-1-git-send-email-joro@8bytes.org> <1502317752-8792-2-git-send-email-joro@8bytes.org> <20170830120902.kqtxh2ls4ob7xpwy@8bytes.org> Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20170830120902.kqtxh2ls4ob7xpwy-zLv9SwRftAIdnm+yROfE0A@public.gmane.org> Content-Language: en-US Sender: linux-tegra-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: Joerg Roedel Cc: Hiroshi Doyu , Thierry Reding , Robin Murphy , iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org, linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Joerg Roedel List-Id: linux-tegra@vger.kernel.org Hi Joerg, On 30/08/17 13:09, Joerg Roedel wrote: > Hi Jon, > > On Wed, Aug 30, 2017 at 12:04:38PM +0100, Jon Hunter wrote: >> 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. > > Thanks for the report. Can you please test whether the patch below > fixes the problem? > > Thanks, > > Joerg > > diff --git a/drivers/iommu/tegra-smmu.c b/drivers/iommu/tegra-smmu.c > index 2802e12e6a54..48ffbe95a663 100644 > --- a/drivers/iommu/tegra-smmu.c > +++ b/drivers/iommu/tegra-smmu.c > @@ -949,10 +949,6 @@ struct tegra_smmu *tegra_smmu_probe(struct device *dev, > > tegra_smmu_ahb_enable(); > > - err = bus_set_iommu(&platform_bus_type, &tegra_smmu_ops); > - 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); > @@ -965,6 +961,10 @@ struct tegra_smmu *tegra_smmu_probe(struct device *dev, > return ERR_PTR(err); > } > > + err = bus_set_iommu(&platform_bus_type, &tegra_smmu_ops); > + if (err < 0) > + return ERR_PTR(err); > + Yes I can confirm that this fixes the crash. I assume that you will fix the error path for bus_set_iommu() above as I believe now it needs to call iommu_device_sysfs_remove(). Cheers! Jon -- nvpublic From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751504AbdH3OYT (ORCPT ); Wed, 30 Aug 2017 10:24:19 -0400 Received: from hqemgate14.nvidia.com ([216.228.121.143]:7444 "EHLO hqemgate14.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751317AbdH3OYR (ORCPT ); Wed, 30 Aug 2017 10:24:17 -0400 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Wed, 30 Aug 2017 07:23:49 -0700 Subject: Re: [PATCH 1/2] iommu/tegra: Add support for struct iommu_device To: Joerg Roedel CC: Hiroshi Doyu , Thierry Reding , Robin Murphy , , , , Joerg Roedel References: <1502317752-8792-1-git-send-email-joro@8bytes.org> <1502317752-8792-2-git-send-email-joro@8bytes.org> <20170830120902.kqtxh2ls4ob7xpwy@8bytes.org> From: Jon Hunter Message-ID: Date: Wed, 30 Aug 2017 15:22:05 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <20170830120902.kqtxh2ls4ob7xpwy@8bytes.org> X-Originating-IP: [10.21.132.162] X-ClientProxiedBy: UKMAIL102.nvidia.com (10.26.138.15) To UKMAIL101.nvidia.com (10.26.138.13) Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Joerg, On 30/08/17 13:09, Joerg Roedel wrote: > Hi Jon, > > On Wed, Aug 30, 2017 at 12:04:38PM +0100, Jon Hunter wrote: >> 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. > > Thanks for the report. Can you please test whether the patch below > fixes the problem? > > Thanks, > > Joerg > > diff --git a/drivers/iommu/tegra-smmu.c b/drivers/iommu/tegra-smmu.c > index 2802e12e6a54..48ffbe95a663 100644 > --- a/drivers/iommu/tegra-smmu.c > +++ b/drivers/iommu/tegra-smmu.c > @@ -949,10 +949,6 @@ struct tegra_smmu *tegra_smmu_probe(struct device *dev, > > tegra_smmu_ahb_enable(); > > - err = bus_set_iommu(&platform_bus_type, &tegra_smmu_ops); > - 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); > @@ -965,6 +961,10 @@ struct tegra_smmu *tegra_smmu_probe(struct device *dev, > return ERR_PTR(err); > } > > + err = bus_set_iommu(&platform_bus_type, &tegra_smmu_ops); > + if (err < 0) > + return ERR_PTR(err); > + Yes I can confirm that this fixes the crash. I assume that you will fix the error path for bus_set_iommu() above as I believe now it needs to call iommu_device_sysfs_remove(). Cheers! Jon -- nvpublic