From patchwork Thu Dec 19 16:30:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Philippe Brucker X-Patchwork-Id: 182136 Delivered-To: patch@linaro.org Received: by 2002:a92:d0a:0:0:0:0:0 with SMTP id 10csp702337iln; Thu, 19 Dec 2019 08:31:29 -0800 (PST) X-Google-Smtp-Source: APXvYqx/ODvxt4UfwcJpvs4edIZsgi6Neixp6kTle+Lqm8DS+hXzjlaF+J2KTuAXU88egPf+wxvO X-Received: by 2002:a9d:760f:: with SMTP id k15mr9588857otl.65.1576773089845; Thu, 19 Dec 2019 08:31:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576773089; cv=none; d=google.com; s=arc-20160816; b=QSdC45yI9yCc47mUx53qw9czFvdnpkW7ccdZY1tE6jEG9v5gppFy7NVH6xvtbus175 fZPX3SSxYttKbM600/2iy6UQxWkU09m6rsgynXHfJmEI0LJB2n16VGJSa+T4GWhHmeaI dUeWxv4lom9J4FG0IE2jr+SrTfjaHMZTaCnSHivvvmbm+DAP4tjae9xiP7sqaO51DCyy TzGZJY/M827+HhGMUsCJPFWgexzVDbKnc9TUgbmDmPi4mfeQC/fALIUf07VuBdgMpo+w /h3FBXTtXak77XXNPfpgGQCrrQOg0euRqPTbBpQaJHg1I97yIICAm05o8Q/eWUnkxyPq /L+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Y2ql+LZRHzKAFXmCII7idFGR9pobHaST91PSU352afA=; b=msID2maWTiWBMY2uY0pVpfDwweY9AVCsvLQJ3MKV1q05KDqFu8tnD0l5eJrCVWStRI KgMaUaKf1aTIzFouDcLBgN2sErFS77w0DGSZ9GOtrVX1hiXOSrX6uN1q77pRGDuf1EmA TUTVGnrNV9LHdOq9hMxUfwEvmdUPzRUwhMVS2/nvm/3hORP+mMiD3+Q7jH+sk8gjkbis 1QAK/hBnVnnhjzK40XhCOuVI3YUrWIkkOgrVh6XMJLYOAVrOKkxfEbuiMHTTbIIxyNjt oMp2gZnht3ZkRr1hBt6iJEbf/0d8AgeH4VINZRG7p3fk5+k1yhFJGBveu2HRQkZzvM/R 33+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OlzF5Xba; spf=pass (google.com: best guess record for domain of linux-acpi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-acpi-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 n25si2200080oij.175.2019.12.19.08.31.29; Thu, 19 Dec 2019 08:31:29 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-acpi-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=OlzF5Xba; spf=pass (google.com: best guess record for domain of linux-acpi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-acpi-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 S1726877AbfLSQb2 (ORCPT + 7 others); Thu, 19 Dec 2019 11:31:28 -0500 Received: from mail-wr1-f65.google.com ([209.85.221.65]:40092 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726945AbfLSQb1 (ORCPT ); Thu, 19 Dec 2019 11:31:27 -0500 Received: by mail-wr1-f65.google.com with SMTP id c14so6611654wrn.7 for ; Thu, 19 Dec 2019 08:31:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Y2ql+LZRHzKAFXmCII7idFGR9pobHaST91PSU352afA=; b=OlzF5XbaVii57zrhytb/hwfGmYY4T7zMd5P2PTa89/4Vy01jLCbHqt7K0XyMZgnegn JbGdWFoGavtJMLBnbSNDbH0SIeT8uLqLacuLaI4B9rXcVV/gOHlQjkjK0vUQZcIKDL5F s+JrJ0Fnt/RpzGXCy8Y+mDgeLc3MR2slZvuKXYYLOtpqgO1HD+FxzZIHOguitSlBdnH1 KjqDahZXqO/cGkh7XElSuIP6Mb9ED2Tq2UIo7t0t8YUfIIV2o58EVF0sWTMkz/tvE7Uj c24OEPkN+xpsuKzgpKA+f0Sb+IZaGA+K5wdsa9fFDgHk4+ZU8M0Z7/czyhJ/SpvTD+BW qWJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Y2ql+LZRHzKAFXmCII7idFGR9pobHaST91PSU352afA=; b=pv0vwOOVYKzfROwdRfKlexnbsUECeqkgXNJ519IcS5o4rkdTC5Fseh18JQEM9O4Vhg ZQ+H9JeeycXO/H2YMi3NjneNRUz3pM3Wj+/Yv4AizKTGDeuCzY6H1A3gslZsRZd3SmDD J69g2RzVL/obT5iCqKTli31Qb/er3Fwmeq+tTqTcmbNpf8KG6z5hgRVmm/ij0XB2KcqN lXr9hxNzH8LINtfVFZSGmXOFJR7gtC1icRvggADo/7olmUunS3+acgRvhkbyLuGVA0Ia KGliexSSC0+TRWVbElI+7KQ/I1ppV8Lt4MVfDqLjwxh78aJz5U4T2e0bCO+/By1bFPkd 9yHg== X-Gm-Message-State: APjAAAVgxkAZ1vzpaR5d7kLGoCvCuny3wGjrqs8HU2DVcUkH123zZuAW t2Bd9dTl2EVZCecL5lHYdpPzuQ== X-Received: by 2002:a05:6000:367:: with SMTP id f7mr10132123wrf.174.1576773085466; Thu, 19 Dec 2019 08:31:25 -0800 (PST) Received: from localhost.localdomain (adsl-84-227-176-239.adslplus.ch. [84.227.176.239]) by smtp.gmail.com with ESMTPSA id u22sm7092068wru.30.2019.12.19.08.31.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Dec 2019 08:31:25 -0800 (PST) From: Jean-Philippe Brucker To: linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org, devicetree@vger.kernel.org, iommu@lists.linux-foundation.org Cc: joro@8bytes.org, robh+dt@kernel.org, mark.rutland@arm.com, lorenzo.pieralisi@arm.com, guohanjun@huawei.com, sudeep.holla@arm.com, rjw@rjwysocki.net, lenb@kernel.org, will@kernel.org, robin.murphy@arm.com, bhelgaas@google.com, eric.auger@redhat.com, jonathan.cameron@huawei.com, zhangfei.gao@linaro.org Subject: [PATCH v4 05/13] iommu/arm-smmu-v3: Prepare arm_smmu_s1_cfg for SSID support Date: Thu, 19 Dec 2019 17:30:25 +0100 Message-Id: <20191219163033.2608177-6-jean-philippe@linaro.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191219163033.2608177-1-jean-philippe@linaro.org> References: <20191219163033.2608177-1-jean-philippe@linaro.org> MIME-Version: 1.0 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org When adding SSID support to the SMMUv3 driver, we'll need to manipulate leaf pasid tables and context descriptors. Extract the context descriptor structure and introduce a new table structure. Reviewed-by: Eric Auger Reviewed-by: Jonathan Cameron Signed-off-by: Jean-Philippe Brucker --- drivers/iommu/arm-smmu-v3.c | 44 +++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 19 deletions(-) -- 2.24.1 diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c index 837b4283b4dc..b287e303b1d7 100644 --- a/drivers/iommu/arm-smmu-v3.c +++ b/drivers/iommu/arm-smmu-v3.c @@ -553,16 +553,21 @@ struct arm_smmu_strtab_l1_desc { dma_addr_t l2ptr_dma; }; +struct arm_smmu_ctx_desc { + u16 asid; + u64 ttbr; + u64 tcr; + u64 mair; +}; + +struct arm_smmu_cd_table { + __le64 *ptr; + dma_addr_t ptr_dma; +}; + struct arm_smmu_s1_cfg { - __le64 *cdptr; - dma_addr_t cdptr_dma; - - struct arm_smmu_ctx_desc { - u16 asid; - u64 ttbr; - u64 tcr; - u64 mair; - } cd; + struct arm_smmu_cd_table table; + struct arm_smmu_ctx_desc cd; }; struct arm_smmu_s2_cfg { @@ -1471,6 +1476,7 @@ static void arm_smmu_write_ctx_desc(struct arm_smmu_device *smmu, struct arm_smmu_s1_cfg *cfg) { u64 val; + __le64 *cdptr = cfg->table.ptr; /* * We don't need to issue any invalidation here, as we'll invalidate @@ -1488,12 +1494,12 @@ static void arm_smmu_write_ctx_desc(struct arm_smmu_device *smmu, if (smmu->features & ARM_SMMU_FEAT_STALL_FORCE) val |= CTXDESC_CD_0_S; - cfg->cdptr[0] = cpu_to_le64(val); + cdptr[0] = cpu_to_le64(val); val = cfg->cd.ttbr & CTXDESC_CD_1_TTB0_MASK; - cfg->cdptr[1] = cpu_to_le64(val); + cdptr[1] = cpu_to_le64(val); - cfg->cdptr[3] = cpu_to_le64(cfg->cd.mair); + cdptr[3] = cpu_to_le64(cfg->cd.mair); } /* Stream table manipulation functions */ @@ -1624,7 +1630,7 @@ static void arm_smmu_write_strtab_ent(struct arm_smmu_master *master, u32 sid, !(smmu->features & ARM_SMMU_FEAT_STALL_FORCE)) dst[1] |= cpu_to_le64(STRTAB_STE_1_S1STALLD); - val |= (s1_cfg->cdptr_dma & STRTAB_STE_0_S1CTXPTR_MASK) | + val |= (s1_cfg->table.ptr_dma & STRTAB_STE_0_S1CTXPTR_MASK) | FIELD_PREP(STRTAB_STE_0_CFG, STRTAB_STE_0_CFG_S1_TRANS); } @@ -2138,11 +2144,11 @@ 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->cdptr) { + if (cfg->table.ptr) { dmam_free_coherent(smmu_domain->smmu->dev, CTXDESC_CD_DWORDS << 3, - cfg->cdptr, - cfg->cdptr_dma); + cfg->table.ptr, + cfg->table.ptr_dma); arm_smmu_bitmap_free(smmu->asid_map, cfg->cd.asid); } @@ -2167,9 +2173,9 @@ static int arm_smmu_domain_finalise_s1(struct arm_smmu_domain *smmu_domain, if (asid < 0) return asid; - cfg->cdptr = dmam_alloc_coherent(smmu->dev, CTXDESC_CD_DWORDS << 3, - &cfg->cdptr_dma, GFP_KERNEL); - if (!cfg->cdptr) { + cfg->table.ptr = dmam_alloc_coherent(smmu->dev, CTXDESC_CD_DWORDS << 3, + &cfg->table.ptr_dma, GFP_KERNEL); + if (!cfg->table.ptr) { dev_warn(smmu->dev, "failed to allocate context descriptor\n"); ret = -ENOMEM; goto out_free_asid;