From patchwork Thu Nov 2 12:49:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shameerali Kolothum Thodi X-Patchwork-Id: 10038701 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A83E9602D8 for ; Thu, 2 Nov 2017 12:51:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 99C4F28ECE for ; Thu, 2 Nov 2017 12:51:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8DF2E28F65; Thu, 2 Nov 2017 12:51:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 141FD28ECE for ; Thu, 2 Nov 2017 12:51:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754772AbdKBMvD convert rfc822-to-8bit (ORCPT ); Thu, 2 Nov 2017 08:51:03 -0400 Received: from lhrrgout.huawei.com ([194.213.3.17]:39598 "EHLO lhrrgout.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752966AbdKBMvC (ORCPT ); Thu, 2 Nov 2017 08:51:02 -0400 Received: from 172.18.7.190 (EHLO lhreml705-cah.china.huawei.com) ([172.18.7.190]) by lhrrg01-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id DZD01345; Thu, 02 Nov 2017 12:49:44 +0000 (GMT) Received: from FRAEML704-CAH.china.huawei.com (10.206.14.35) by lhreml705-cah.china.huawei.com (10.201.108.46) with Microsoft SMTP Server (TLS) id 14.3.361.1; Thu, 2 Nov 2017 12:49:39 +0000 Received: from FRAEML521-MBX.china.huawei.com ([169.254.1.209]) by FRAEML704-CAH.china.huawei.com ([10.206.14.35]) with mapi id 14.03.0361.001; Thu, 2 Nov 2017 13:49:33 +0100 From: Shameerali Kolothum Thodi To: Jean-Philippe Brucker , "linux-arm-kernel@lists.infradead.org" , "linux-pci@vger.kernel.org" , "linux-acpi@vger.kernel.org" , "devicetree@vger.kernel.org" , "iommu@lists.linux-foundation.org" CC: "mark.rutland@arm.com" , "xieyisheng (A)" , Gabriele Paoloni , "catalin.marinas@arm.com" , "will.deacon@arm.com" , "okaya@codeaurora.org" , "yi.l.liu@intel.com" , "lorenzo.pieralisi@arm.com" , "ashok.raj@intel.com" , "tn@semihalf.com" , "joro@8bytes.org" , "rfranz@cavium.com" , "lenb@kernel.org" , "jacob.jun.pan@linux.intel.com" , "alex.williamson@redhat.com" , "robh+dt@kernel.org" , "Leizhen (ThunderTown)" , "bhelgaas@google.com" , "dwmw2@infradead.org" , "liubo (CU)" , "rjw@rjwysocki.net" , "robdclark@gmail.com" , "hanjun.guo@linaro.org" , "sudeep.holla@arm.com" , "robin.murphy@arm.com" , "nwatters@codeaurora.org" , Linuxarm Subject: RE: [RFCv2 PATCH 14/36] iommu/arm-smmu-v3: Add support for Substream IDs Thread-Topic: [RFCv2 PATCH 14/36] iommu/arm-smmu-v3: Add support for Substream IDs Thread-Index: AQHTPq27cXYEjW7K40Cd2UGlx+2sFqMBLvbA Date: Thu, 2 Nov 2017 12:49:32 +0000 Message-ID: <5FC3163CFD30C246ABAA99954A238FA838454887@FRAEML521-MBX.china.huawei.com> References: <20171006133203.22803-1-jean-philippe.brucker@arm.com> <20171006133203.22803-15-jean-philippe.brucker@arm.com> In-Reply-To: <20171006133203.22803-15-jean-philippe.brucker@arm.com> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.202.227.237] MIME-Version: 1.0 X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A090203.59FB146B.011E, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=169.254.1.209, so=2013-06-18 04:22:30, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: a79f36256f2ee210132bda7e6a557a04 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Hi Jean, > -----Original Message----- > From: linux-arm-kernel [mailto:linux-arm-kernel-bounces@lists.infradead.org] > On Behalf Of Jean-Philippe Brucker > Sent: Friday, October 06, 2017 2:32 PM > To: linux-arm-kernel@lists.infradead.org; linux-pci@vger.kernel.org; linux- > acpi@vger.kernel.org; devicetree@vger.kernel.org; iommu@lists.linux- > foundation.org > Cc: mark.rutland@arm.com; xieyisheng (A) ; > Gabriele Paoloni ; catalin.marinas@arm.com; > will.deacon@arm.com; okaya@codeaurora.org; yi.l.liu@intel.com; > lorenzo.pieralisi@arm.com; ashok.raj@intel.com; tn@semihalf.com; > joro@8bytes.org; rfranz@cavium.com; lenb@kernel.org; > jacob.jun.pan@linux.intel.com; alex.williamson@redhat.com; > robh+dt@kernel.org; Leizhen (ThunderTown) ; > bhelgaas@google.com; dwmw2@infradead.org; liubo (CU) > ; rjw@rjwysocki.net; robdclark@gmail.com; > hanjun.guo@linaro.org; sudeep.holla@arm.com; robin.murphy@arm.com; > nwatters@codeaurora.org > Subject: [RFCv2 PATCH 14/36] iommu/arm-smmu-v3: Add support for > Substream IDs > > At the moment, the SMMUv3 driver offers only one stage-1 or stage-2 > address space to each device. SMMUv3 allows to associate multiple address > spaces per device. In addition to the Stream ID (SID), that identifies a > device, we can now have Substream IDs (SSID) identifying an address space. > In PCIe lingo, SID is called Requester ID (RID) and SSID is called Process > Address-Space ID (PASID). We had a go with this series on HiSIlicon D05 platform which doesn't have support for ssids/ATS/PRI, to make sure it generally works. But observed the below crash on boot, [ 16.009084] WARNING: CPU: 59 PID: 391 at mm/page_alloc.c:3883 __alloc_pages_nodemask+0x19c/0xc48 [ 16.026797] Modules linked in: [ 16.032944] CPU: 59 PID: 391 Comm: kworker/59:1 Not tainted 4.14.0-rc1-159539-ge42aca3 #236 [...] [ 16.068206] Workqueue: events deferred_probe_work_func [ 16.078557] task: ffff8017d38a0000 task.stack: ffff00000b198000 [ 16.090486] PC is at __alloc_pages_nodemask+0x19c/0xc48 [ 16.101013] LR is at __alloc_pages_nodemask+0xe0/0xc48 [ 16.469220] [] __alloc_pages_nodemask+0x19c/0xc48 [ 16.481854] [] alloc_pages_current+0x80/0xcc [ 16.493607] [] __get_free_pages+0xc/0x38 [ 16.504661] [] swiotlb_alloc_coherent+0x64/0x190 [ 16.517117] [] __dma_alloc+0x110/0x204 [ 16.527820] [] dmam_alloc_coherent+0x88/0xf0 [ 16.539575] [] arm_smmu_domain_finalise_s1+0x60/0x248 [ 16.552909] [] arm_smmu_attach_dev+0x264/0x300 [ 16.565013] [] __iommu_attach_device+0x48/0x5c [ 16.577117] [] iommu_group_add_device+0x144/0x3a4 [ 16.589746] [] iommu_group_get_for_dev+0x70/0xf8 [ 16.602201] [] arm_smmu_add_device+0x1a4/0x418 [ 16.614308] [] iort_iommu_configure+0xf0/0x16c [ 16.626416] [] acpi_dma_configure+0x30/0x70 [ 16.637994] [] dma_configure+0xa8/0xd4 [ 16.648695] [] driver_probe_device+0x1a4/0x2dc [ 16.673081] [] bus_for_each_drv+0x54/0x94 [ 16.684307] [] __device_attach+0xc4/0x12c [ 16.695533] [] device_initial_probe+0x10/0x18 [ 16.707462] [] bus_probe_device+0x90/0x98 After a bit of debug it looks like on platforms where ssid is not supported, s1_cfg.num_contexts is set to zero and it eventually results in this crash in, arm_smmu_domain_finalise_s1() -->arm_smmu_alloc_cd_tables()--> arm_smmu_alloc_cd_leaf_table() as num_leaf_entries is zero. With the below fix, it works on D05 now, I am not sure this is right place do this. Please take a look. Thanks, Shameer diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c index 8ad90e2..51f5821 100644 --- a/drivers/iommu/arm-smmu-v3.c +++ b/drivers/iommu/arm-smmu-v3.c @@ -2433,7 +2433,10 @@ static int arm_smmu_domain_finalise(struct iommu_domain *domain, domain->min_pasid = 1; domain->max_pasid = master->num_ssids - 1; smmu_domain->s1_cfg.num_contexts = master->num_ssids; + } else { + smmu_domain->s1_cfg.num_contexts = 1; } + smmu_domain->s1_cfg.can_stall = master->ste.can_stall; break; case ARM_SMMU_DOMAIN_NESTED: