Received: by 2002:a25:b323:0:0:0:0:0 with SMTP id l35csp251171ybj; Thu, 19 Sep 2019 13:51:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqyk8QtaFXuKprU0l+OkWIid2CbwA0LJKqBRgHfevmPThlUABFd+C2Syy4W5CoGekjiNeHp4 X-Received: by 2002:a50:f703:: with SMTP id g3mr18139792edn.43.1568926277927; Thu, 19 Sep 2019 13:51:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568926277; cv=none; d=google.com; s=arc-20160816; b=LFCSDmGSyXh/RG9PuHxGmBLxtgxCMZiThKmSd2TumDEMN2VOFslLWD79iHb3M+r07z 7/WC12jFYn4opKzzyH7YUYqVGBwt3HPsquV68Dtze0QJEqw++VjQ/JrPYm/ABYs/oZN2 nfyObL+DognZf74AoJ0VFfWwJTnJXlB259Wc+tX79fg9zDTjGwIvHupa6DbDsegMxQp8 DS4EkDqbLdVCjpMlvZX47CFMPDsdu8GxEq5vTc1PUl4fuXUMj/fPWyPSSdH7dYwHu2k+ mSOj3wYs7lW3PNsgpkUpU4LXB1VZnVQW06bYCDCk3b1yy8hCIYL2tssjJBIPDdFddciy QGUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=yic2bDSQvOGyK05i6zWexPg+z8iu2akZCAIBwfSlM4U=; b=jsn4hUd/FgSWr34po09C9TXYOwMlEJFORRi+cY1tusVbrhEnIMXtfXIklb5qnPoPHL T/vuLmU/Z/+Mqn0i7iMvOCRPvG+Ev5KhZynOg4epx6VC/9TATnwwOkzYMBPSBhVQV5pK CmiSv8w2s1rp/cMasxTjKFVLe5Di7TUCoD5kiauujx+njHfioZmTHgbLk5K9iHaUBJrK NDXqWZ6WHpCX2AajGb8/6ZdXGuYU+oL4A2LOzkTA242Ge/hdaIh2fVMGuXjJjX+RJJzY oimRbvR2oOged9bAbMkGrjLKP2u4sUveXPTfz29b/ruf7cGon9jawyWFmh7VBOxAvJEk nebA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RxBIEWkz; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bq16si5215877ejb.221.2019.09.19.13.50.54; Thu, 19 Sep 2019 13:51:17 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RxBIEWkz; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390892AbfISPF1 (ORCPT + 99 others); Thu, 19 Sep 2019 11:05:27 -0400 Received: from mail-ed1-f67.google.com ([209.85.208.67]:38582 "EHLO mail-ed1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389179AbfISPF1 (ORCPT ); Thu, 19 Sep 2019 11:05:27 -0400 Received: by mail-ed1-f67.google.com with SMTP id a23so3522101edv.5 for ; Thu, 19 Sep 2019 08:05:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=yic2bDSQvOGyK05i6zWexPg+z8iu2akZCAIBwfSlM4U=; b=RxBIEWkzx/5W626K0TPy3NrQD+9xUc2EtjQq5wij6HuQ4p6J8/jo5dqn0wVA5Xnd18 m6jKndTL7m3KJWdcqYOd4bsX0jZ7Vpbu5CEpsnoYfC/es2QHVjlN1+TMtJpntIs21qlr O11fuKKCW0K7V+2I6q9rIXJZFLDAbAN7KSxiBeGQmspKYs5LogftnMCA/QSS4D+5fbOf AKHw+EUSbdFxbZeYccacevGazTtWWjnf3dPhGTeBsBgjYaCXheAf3LA/dFJlW8vnlUeK e6jlulH6fQf0bErESyCyq7GoPE2/efqefs5t7xY6Sd2zGC8XeaCm1KufYPTcGcBnoC/D QXdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=yic2bDSQvOGyK05i6zWexPg+z8iu2akZCAIBwfSlM4U=; b=ob7/g6DpiM14DcgNeXQexkFI0JfxIZUaMIN7YeAD4rh2YqrYDT1+Xvha2Vt27Ll17o wO3ea2JWVedSBzzR1YzCF2a4nO+X5BR2oMe4kzbmA1ZUOo9DcvFe6ro8QJE09M3/p2aY Z/SmFCdQHUkfFA5vWKTZ5ox5cgxOVPh7xpb9eyuWkohAMOczB4LURxY2kyCrVhbESZHd amG1XzFy4Uo2hEBxXSJauFnNPcQdoWi6Xcz7LGgtDUJP3PGbNIiMQNA9wCTJPqhG/1mg 4AuyqjOhR9r+0l2rJL8JHsvUBc27tH4aVPTesc57GTkdGmmAMFez19dXfWohGNT5WzcX LhGg== X-Gm-Message-State: APjAAAXBReB72B4HEx1ujEGsvGXkL4cviIur+gAYGUNiq/sKLM7PxFzp L4Zbn645D/T8AHsqbrkzc0jaxA== X-Received: by 2002:a17:906:76c2:: with SMTP id q2mr14903775ejn.202.1568905524420; Thu, 19 Sep 2019 08:05:24 -0700 (PDT) Received: from lophozonia ([85.195.192.192]) by smtp.gmail.com with ESMTPSA id e39sm1689919edb.69.2019.09.19.08.05.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Sep 2019 08:05:23 -0700 (PDT) Date: Thu, 19 Sep 2019 17:05:21 +0200 From: Jean-Philippe Brucker To: Auger Eric Cc: mark.rutland@arm.com, devicetree@vger.kernel.org, jacob.jun.pan@linux.intel.com, joro@8bytes.org, linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org, robh+dt@kernel.org, robin.murphy@arm.com Subject: Re: [PATCH 5/8] iommu/arm-smmu-v3: Add second level of context descriptor table Message-ID: <20190919150521.GD1013538@lophozonia> References: <20190610184714.6786-1-jean-philippe.brucker@arm.com> <20190610184714.6786-6-jean-philippe.brucker@arm.com> <3e69caf7-4e8a-4bce-7a89-51e21a0134b1@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3e69caf7-4e8a-4bce-7a89-51e21a0134b1@redhat.com> User-Agent: Mutt/1.12.1 (2019-06-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jul 08, 2019 at 05:13:05PM +0200, Auger Eric wrote: > > #define STRTAB_STE_0_S1FMT GENMASK_ULL(5, 4) > > #define STRTAB_STE_0_S1FMT_LINEAR 0 > > +#define STRTAB_STE_0_S1FMT_4K_L2 1 > As you only use 64kB L2, I guess you can remove the 4K define? I prefer defining all values, but I suppose I can get rid of it. > > + cfg->tables = devm_kzalloc(smmu->dev, sizeof(struct arm_smmu_cd_table) * > > + cfg->num_tables, GFP_KERNEL); > > + if (!cfg->tables) > > + return -ENOMEM; > goto err_free_l1 > > + > > + ret = arm_smmu_alloc_cd_leaf_table(smmu, &cfg->tables[0], num_leaf_entries); > don't you want to do that only in linear case. In 2-level mode, I > understand arm_smmu_get_cd_ptr() will do the job. OK, that might be better > > > + if (ret) > > + goto err_free_l1; > > + > > + if (cfg->l1ptr) > > + arm_smmu_write_cd_l1_desc(cfg->l1ptr, &cfg->tables[0]); > that stuff could be removed as well? Yes > By the way I can see that > arm_smmu_get_cd_ptr() does a arm_smmu_sync_cd after. wouldn't it be > needed here as well? No context table is reachable from a STE at this point, so we don't have to invalidate anything. > > @@ -1815,7 +1935,7 @@ static void arm_smmu_domain_free(struct iommu_domain *domain) > > if (smmu_domain->stage == ARM_SMMU_DOMAIN_S1) { > > struct arm_smmu_s1_cfg *cfg = &smmu_domain->s1_cfg; > > > > - if (cfg->table.ptr) { > > + if (cfg->tables) { > > arm_smmu_free_cd_tables(smmu_domain); > > arm_smmu_bitmap_free(smmu->asid_map, cfg->cd.asid); > I don't get why the arm_smmu_bitmap_free is dependent on cfg->tables. Simply because arm_smmu_bitmap_alloc() and arm_smmu_alloc_cd_tables() are both performed in arm_smmu_domain_finalise_s1(). A domain returned by arm_smmu_domain_alloc() is not fully initialized, it still needs to be finalized by arm_smmu_attach_dev(). So here we check whether the domain has been finalized or not. Zero being a valid ASID in this driver, we can't check whether cfg->cd.asid is valid, so we check cfg->tables instead. And I forgot to clear cfg->tables after failure of domain_finalise in this series, I'll need to fix it. Thanks, Jean