From patchwork Tue Mar 28 10:41:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil Kovvuri X-Patchwork-Id: 9648815 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 368AD602C8 for ; Tue, 28 Mar 2017 10:50:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3374027813 for ; Tue, 28 Mar 2017 10:50:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2838F28338; Tue, 28 Mar 2017 10:50:41 +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=-1.9 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM 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 B314823B23 for ; Tue, 28 Mar 2017 10:50:40 +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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=Vdm8k1wes+kEDpC/say5HyWUlng3IC4pitnlqr8RcS8=; b=Pm0 vkWQdm85GuCz6MqMP4IF6UYhQ0WyJSkfBcCmcNWzv631PGJI60MfcEZ7/UB8fhaAn2PCW9n8SyKLH jGLzF2/ciwbKE1sI+zIBZ6/g7WKfzwIvq9UuXSXstCx/wR9uvnLUi0b1aDQ773jUn597oLZa6YgMq SCc1/zPlAeVbL0Q7REUQJe5PQL8Y1jueiF0OmbOlXY48RQnpYJXamsAIsGsThwUPQVioLHZ84Vz0t kWlEsHvVXdJ6krPnbUNcAFt/qzgIeME13YI2iyJhjPSIk6SFcUTGjqJu5kwK8eYPwPyJhM720uoO6 19/Xt0Hx/UkVF5bl5ziZBvkTUZU0Hrw==; 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 1csoho-0006Sy-O2; Tue, 28 Mar 2017 10:50:28 +0000 Received: from mail-pg0-x241.google.com ([2607:f8b0:400e:c05::241]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1csoZf-0000mI-MX for linux-arm-kernel@lists.infradead.org; Tue, 28 Mar 2017 10:42:12 +0000 Received: by mail-pg0-x241.google.com with SMTP id o123so17613691pga.1 for ; Tue, 28 Mar 2017 03:41:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=wKyXL7dbBwnoO4sGjg182/jJNwBy6MhgA8mNcSU0HOo=; b=cA35XgUhfy96KGkpvWFT4CtoQD0/J7V4vbzIDBsI+PczHMr0BBnY1vbby7Hj37E0ji QHd0HoV8TymhBQDKFguy1Scb5bpxuSi0XOLyrPQ634AHLNRtNqDBenwCPgrcAYKBcpQp kGWuY3BLfs0kOik9XaVQMUcimIpsFcL08MVyc5OahVpeOI1pfPJkZkXeHkL0f8FrB097 Mxg9lcrI9zzF8yD/nYsf7Nc0nS4xQKYm+V0rSeEX284FCOy9e+G60y0uWqCK7lTZpu4V dCMzcGQ1kHLZokRIonIMdy1+hTG8njrzqF6mZHhnSaXbm/WW3sXvJynaNUQP0vzFp/b7 YJLQ== 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; bh=wKyXL7dbBwnoO4sGjg182/jJNwBy6MhgA8mNcSU0HOo=; b=gw5rQLbIvKQXfYUyodpsPdrUUOM/Unv6lUTYvqi9paHiGx86std3nsxaGNddFnPti1 a0JPUyTIaF4jPW7MZrMso0uBkKTgtPpcVxb0Y3gjq/tf8mAlySfMIW05Myv7GhGSpJuM quCWgFHYND9Rj6GJNe9g2t3H1ocjyQa2fj7rcpvub7adqdRJdJAdyz2R1II/Le6NvehB nygHujMB6sJqhJNeZQ1l6OdHwgobdEqCmPwKlb0GIifLpIN3y76IyBtryfqmHDAESBgL zzfJm5CdUNfEITgqt+71iLGBQeCTTGLDOOIPeLoC6bh4zFyzwAW0X9tThzDewrUDGBX+ GsKg== X-Gm-Message-State: AFeK/H1Slpyt1bNsnJdmW5UUQp43MhlccPGa/tGhgg3PCuhmkkrJ+ykcNq98n88vDpU6AQ== X-Received: by 10.84.175.129 with SMTP id t1mr35246169plb.17.1490697702388; Tue, 28 Mar 2017 03:41:42 -0700 (PDT) Received: from machine421.in.caveonetworks.com ([14.140.2.178]) by smtp.googlemail.com with ESMTPSA id y186sm6651492pfg.52.2017.03.28.03.41.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 28 Mar 2017 03:41:41 -0700 (PDT) From: sunil.kovvuri@gmail.com To: will.deacon@arm.com, robin.murphy@arm.com Subject: [PATCH] iommu/arm-smmu: Fix 16bit ASID configuration Date: Tue, 28 Mar 2017 16:11:12 +0530 Message-Id: <1490697672-15928-1-git-send-email-sunil.kovvuri@gmail.com> X-Mailer: git-send-email 2.7.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170328_034204_122450_DB18A589 X-CRM114-Status: GOOD ( 12.88 ) 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: iommu@lists.linux-foundation.org, Sunil Goutham , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 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 From: Sunil Goutham 16bit ASID should be enabled before initializing TTBR0/1, otherwise only LSB 8bit ASID will be considered. Hence moving configuration of TTBCR register ahead of TTBR0/1 while initializing context bank. Signed-off-by: Sunil Goutham --- drivers/iommu/arm-smmu.c | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c index 9b33700..2845d73 100644 --- a/drivers/iommu/arm-smmu.c +++ b/drivers/iommu/arm-smmu.c @@ -758,6 +758,28 @@ static void arm_smmu_init_context_bank(struct arm_smmu_domain *smmu_domain, } writel_relaxed(reg, gr1_base + ARM_SMMU_GR1_CBAR(cfg->cbndx)); + /* TTBCR */ + if (stage1) { + if (cfg->fmt == ARM_SMMU_CTX_FMT_AARCH32_S) { + reg = pgtbl_cfg->arm_v7s_cfg.tcr; + reg2 = 0; + } else { + reg = pgtbl_cfg->arm_lpae_s1_cfg.tcr; + reg2 = pgtbl_cfg->arm_lpae_s1_cfg.tcr >> 32; + reg2 |= TTBCR2_SEP_UPSTREAM; + /* 16bit ASID should be enabled before write to TTBR, + * otherwise only LSB 8bit will be considered. + */ + if (cfg->fmt == ARM_SMMU_CTX_FMT_AARCH64) + reg2 |= TTBCR2_AS; + } + if (smmu->version > ARM_SMMU_V1) + writel_relaxed(reg2, cb_base + ARM_SMMU_CB_TTBCR2); + } else { + reg = pgtbl_cfg->arm_lpae_s2_cfg.vtcr; + } + writel_relaxed(reg, cb_base + ARM_SMMU_CB_TTBCR); + /* TTBRs */ if (stage1) { u16 asid = ARM_SMMU_CB_ASID(smmu, cfg); @@ -781,25 +803,6 @@ static void arm_smmu_init_context_bank(struct arm_smmu_domain *smmu_domain, writeq_relaxed(reg64, cb_base + ARM_SMMU_CB_TTBR0); } - /* TTBCR */ - if (stage1) { - if (cfg->fmt == ARM_SMMU_CTX_FMT_AARCH32_S) { - reg = pgtbl_cfg->arm_v7s_cfg.tcr; - reg2 = 0; - } else { - reg = pgtbl_cfg->arm_lpae_s1_cfg.tcr; - reg2 = pgtbl_cfg->arm_lpae_s1_cfg.tcr >> 32; - reg2 |= TTBCR2_SEP_UPSTREAM; - if (cfg->fmt == ARM_SMMU_CTX_FMT_AARCH64) - reg2 |= TTBCR2_AS; - } - if (smmu->version > ARM_SMMU_V1) - writel_relaxed(reg2, cb_base + ARM_SMMU_CB_TTBCR2); - } else { - reg = pgtbl_cfg->arm_lpae_s2_cfg.vtcr; - } - writel_relaxed(reg, cb_base + ARM_SMMU_CB_TTBCR); - /* MAIRs (stage-1 only) */ if (stage1) { if (cfg->fmt == ARM_SMMU_CTX_FMT_AARCH32_S) {