From patchwork Thu Nov 2 15:51:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Philippe Brucker X-Patchwork-Id: 10038925 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 24CE0602D8 for ; Thu, 2 Nov 2017 15:50:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 12DC629164 for ; Thu, 2 Nov 2017 15:50:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 07B3429191; Thu, 2 Nov 2017 15:50:59 +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=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 95CCA29164 for ; Thu, 2 Nov 2017 15:50:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=O5o6yRYiu93SPyCQy5atrrrZuG3/S6lRGVNr4D59eE4=; b=nmDMCZPTxsHiwm eTMD9ElhsIPDRu2/3xpqcB4b+Ye+kpcBFZ2Dh3K6yw/xjaEHE6U0wNVDbNeX7G5NeMBZN8yCSDYY4 ZN39a7R+8K+pZvP/dHSujLjaub6iK2E3IVNCDgxnzl2NBHLuke6F5loI5cn4oPh78OtIu+RfVxQFL E8PtOeIbW0Gn1XeU4qPqZ6ydvgXU3qIESdeb8H77rDoD+BjZUhRUTjHxpb4m44Mx5kDD7qXgrVMgQ VElML+Y+dopnqw+EI/vpYWAm2CSGmPtQzj5E9q4tGEQMIWhUS3t5FD+fx3Os6VZCKJbelMZ1HGHGE jlvRRz4efQ8b3a5W4l7g==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1eAHla-0004v9-IE; Thu, 02 Nov 2017 15:50:50 +0000 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70] helo=foss.arm.com) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1eAHl5-00032r-Sv for linux-arm-kernel@lists.infradead.org; Thu, 02 Nov 2017 15:50:27 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 726021435; Thu, 2 Nov 2017 08:49:59 -0700 (PDT) Received: from e106794-lin.localdomain (e106794-lin.cambridge.arm.com [10.1.210.50]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 517023F24A; Thu, 2 Nov 2017 08:49:54 -0700 (PDT) Date: Thu, 2 Nov 2017 15:51:53 +0000 From: Jean-Philippe Brucker To: Shameerali Kolothum Thodi Subject: Re: [RFCv2 PATCH 14/36] iommu/arm-smmu-v3: Add support for Substream IDs Message-ID: <20171102155152.GA11899@e106794-lin.localdomain> References: <20171006133203.22803-1-jean-philippe.brucker@arm.com> <20171006133203.22803-15-jean-philippe.brucker@arm.com> <5FC3163CFD30C246ABAA99954A238FA838454887@FRAEML521-MBX.china.huawei.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <5FC3163CFD30C246ABAA99954A238FA838454887@FRAEML521-MBX.china.huawei.com> User-Agent: Mutt/1.9.1 (2017-09-22) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171102_085020_147506_40492D3E X-CRM114-Status: GOOD ( 17.42 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , "xieyisheng \(A\)" , Gabriele Paoloni , "linux-pci@vger.kernel.org" , Will Deacon , Linuxarm , "okaya@codeaurora.org" , Lorenzo Pieralisi , "yi.l.liu@intel.com" , "ashok.raj@intel.com" , "tn@semihalf.com" , "joro@8bytes.org" , "robdclark@gmail.com" , "linux-acpi@vger.kernel.org" , Catalin Marinas , "rfranz@cavium.com" , "lenb@kernel.org" , "devicetree@vger.kernel.org" , "jacob.jun.pan@linux.intel.com" , "alex.williamson@redhat.com" , "robh+dt@kernel.org" , "Leizhen \(ThunderTown\)" , "bhelgaas@google.com" , "linux-arm-kernel@lists.infradead.org" , Robin Murphy , "liubo \(CU\)" , "rjw@rjwysocki.net" , "iommu@lists.linux-foundation.org" , "hanjun.guo@linaro.org" , Sudeep Holla , "dwmw2@infradead.org" , "nwatters@codeaurora.org" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Hi Shameer, On Thu, Nov 02, 2017 at 12:49:32PM +0000, Shameerali Kolothum Thodi wrote: > 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, > > 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: > > > I am not sure this is right place do this. Please take a look. Thanks for testing the series and reporting the bug. I added the following patch to branch svm/current, does it work for you? Thanks, Jean diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c index 42c8378624ed..edda466adc81 100644 --- a/drivers/iommu/arm-smmu-v3.c +++ b/drivers/iommu/arm-smmu-v3.c @@ -3169,9 +3169,7 @@ static int arm_smmu_add_device(struct device *dev) } } - if (smmu->ssid_bits) - master->num_ssids = 1 << min(smmu->ssid_bits, - fwspec->num_pasid_bits); + master->num_ssids = 1 << min(smmu->ssid_bits, fwspec->num_pasid_bits); if (fwspec->can_stall && smmu->features & ARM_SMMU_FEAT_STALLS) { master->can_fault = true;