Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp5964121ybi; Wed, 12 Jun 2019 11:29:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqyWz7R/YTMNbYsK2+7bye2RylEefubSBf3SWtxfmtgu6oKiHyoGWJqcXIaupl3vmM/QJdC0 X-Received: by 2002:a17:902:b487:: with SMTP id y7mr22993590plr.219.1560364193569; Wed, 12 Jun 2019 11:29:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560364193; cv=none; d=google.com; s=arc-20160816; b=Sldun8P+W11DP3zD0bd589rHlUL3hoA4zf880CgsgEWfKhpkY+4t/5L1d8OTAzUVFs mU5SvX1dC+eTWaJQDlvE8+I1NTjYL0Z9nrk9bYgX93TCEGiAg5d3yo8nwFuOi9XBXe2P RUdYVwcfF1mDcvjMKCCnxdYfGgBErrlAiUHxwU1WiNradytdFUeCiF8cOjuFm9Oy8nDG c/jz5PAEiCfBrTVeC6wqiqik+wKMpJLt9KSsROp64bX9H4yZ8jGdNa+Ml5GqDji8DHzO dvQKkCwGH31hUGt9U2E2LljhKFQgmQxo3jDOmCsb2PSRsuN0fwlLXP5mP3L9TcIdeXWN bzlg== 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=+79M0qC52KBqcZi+aAUpykO9qkYyBvSKoD8+NYjzNgM=; b=WIQ/WBor+TruNJhCJ0KV90Dg6oo4aEnNrVPzZn35XOv0mUivKZ62clYSBQzz7iKnCc z0WK/oLgAQ3oknf2eVhHpqaQdWZyDkgcLaqo4uUZURDhpNJXR6YRVnN+UwTqVuLbFKy6 HW8qNRwf2odAyQFozue0DLu1b6hI++JtZZzvC53f1yPBgOt++5MMVZvQ2c9xDCmrJWsf EqE7ETy99gYg/BaVPT8kpGHS96DU4RPaLUlXlybZbZwSWhcA35wf61vY/qBvLZlk3C/G 9dCLKu/cEiXlXqInZcsru22cCU6E1l8Swxh9SA5bVx/EuRXIWKPgU7YwBr3JuYSliP71 0ebQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="UMBN/yAC"; 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 e6si434169pgb.41.2019.06.12.11.29.38; Wed, 12 Jun 2019 11:29:53 -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="UMBN/yAC"; 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 S1726599AbfFLS25 (ORCPT + 99 others); Wed, 12 Jun 2019 14:28:57 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:34540 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726167AbfFLS24 (ORCPT ); Wed, 12 Jun 2019 14:28:56 -0400 Received: by mail-pf1-f196.google.com with SMTP id c85so10178668pfc.1 for ; Wed, 12 Jun 2019 11:28:56 -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=+79M0qC52KBqcZi+aAUpykO9qkYyBvSKoD8+NYjzNgM=; b=UMBN/yACkW2pNaFWRj1LqT4MeRqs6jVBZFDrKU77NJNGt1VVfDJJhryte4q7uKq3Ib fn1OfIpyKXGCm7/wU587tEChAQygjDEwkz/IvzS4nUjtKgzz1jngIK+x1Owt2Eia+HVu /H3V5yPWRDxfYXA9Zhsb+5mKKfM9WZcjmkQ0aUy0DC6BZQF9QdY+AKqLMUnXcuBjUYUQ cjyNOX/IaQ9GipKJj+d2B3ic/GXtZiogNyyhysUgWqMt1PnGnLNvJbhM01n4sMR9wSzK Jod4ubMgCZ1RKt2iHUw+WaJtNpBjESm5rnza2DmyPbXAeLFJLpY+m13EdM+fbV/wan6J WYUQ== 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=+79M0qC52KBqcZi+aAUpykO9qkYyBvSKoD8+NYjzNgM=; b=I1pqGlk6yfwKC1aCeC/fYIRJdtRX6m7HJ0hclMVYeWipR9N/2Dx7vVFujp1IiT+Oxx k+0zkxxSDKGgqYVVuxCEjc3YoW4i+UrDtRvETHFAodCr6UVB6aN+DhAn50t90l79F5Yz 6/3JgQ/ppU8yqPTWthXOXTxbzrvM15a0mAF9VzoobWxL5A4KuHU45GQ4TEIC5PsmyIQa f7F7S4VpKE73KJFOBzXyKLUyLN/EIZ1thxtdHj2B1g54eGlsReMxSmF6S96hcHpuMnYg 1OB6amqGjD+8oD5SGMiHsw8M9+C3/35tUwFTMagtk8BQ8HosNR598PqkBeoFyXhhsZ2/ 9h2g== X-Gm-Message-State: APjAAAW8Xb0V02vVbChA9GvdM1ivGF3Y74nR8ojPk3oxTlngsmHyPql3 w7WEiWu7mlLi/VdKyzp+xDF5fQ== X-Received: by 2002:a63:a08:: with SMTP id 8mr26483042pgk.46.1560364135521; Wed, 12 Jun 2019 11:28:55 -0700 (PDT) Received: from minitux (104-188-17-28.lightspeed.sndgca.sbcglobal.net. [104.188.17.28]) by smtp.gmail.com with ESMTPSA id q198sm252178pfq.155.2019.06.12.11.28.53 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 12 Jun 2019 11:28:54 -0700 (PDT) Date: Wed, 12 Jun 2019 11:28:52 -0700 From: Bjorn Andersson To: Jeffrey Hugo Cc: Joerg Roedel , Will Deacon , Robin Murphy , Patrick Daly , Jeffrey Hugo , MSM , lkml , iommu@lists.linux-foundation.org, Vivek Gautam , linux-arm-kernel@lists.infradead.org Subject: Re: [RFC 2/2] iommu: arm-smmu: Don't blindly use first SMR to calculate mask Message-ID: <20190612182852.GA4814@minitux> References: <20190605210856.20677-1-bjorn.andersson@linaro.org> <20190605210856.20677-3-bjorn.andersson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.12.0 (2019-05-25) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed 12 Jun 10:58 PDT 2019, Jeffrey Hugo wrote: > On Wed, Jun 5, 2019 at 3:09 PM Bjorn Andersson > wrote: > > > > With the SMRs inherited from the bootloader the first SMR might actually > > be valid and in use. As such probing the SMR mask using the first SMR > > might break a stream in use. Search for an unused stream and use this to > > probe the SMR mask. > > > > Signed-off-by: Bjorn Andersson > > Reviewed-by: Jeffrey Hugo > > I don't quite like the situation where the is no SMR to compute the mask, but I > think the way you've handled it is the best option/ > Right, if this happens we would end up using the smr_mask that was previously calculated. We just won't update it based on the hardware. > I'm curious, why is this not included in patch #1? Seems like patch > #1 introduces > the issue, yet doesn't also fix it. > You're right, didn't think about that. This needs to either predate that patch or be included in it. Thanks, Bjorn > > --- > > drivers/iommu/arm-smmu.c | 20 ++++++++++++++++---- > > 1 file changed, 16 insertions(+), 4 deletions(-) > > > > diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c > > index c8629a656b42..0c6f5fe6f382 100644 > > --- a/drivers/iommu/arm-smmu.c > > +++ b/drivers/iommu/arm-smmu.c > > @@ -1084,23 +1084,35 @@ static void arm_smmu_test_smr_masks(struct arm_smmu_device *smmu) > > { > > void __iomem *gr0_base = ARM_SMMU_GR0(smmu); > > u32 smr; > > + int idx; > > > > if (!smmu->smrs) > > return; > > > > + for (idx = 0; idx < smmu->num_mapping_groups; idx++) { > > + smr = readl_relaxed(gr0_base + ARM_SMMU_GR0_SMR(idx)); > > + if (!(smr & SMR_VALID)) > > + break; > > + } > > + > > + if (idx == smmu->num_mapping_groups) { > > + dev_err(smmu->dev, "Unable to compute streamid_mask\n"); > > + return; > > + } > > + > > /* > > * SMR.ID bits may not be preserved if the corresponding MASK > > * bits are set, so check each one separately. We can reject > > * masters later if they try to claim IDs outside these masks. > > */ > > smr = smmu->streamid_mask << SMR_ID_SHIFT; > > - writel_relaxed(smr, gr0_base + ARM_SMMU_GR0_SMR(0)); > > - smr = readl_relaxed(gr0_base + ARM_SMMU_GR0_SMR(0)); > > + writel_relaxed(smr, gr0_base + ARM_SMMU_GR0_SMR(idx)); > > + smr = readl_relaxed(gr0_base + ARM_SMMU_GR0_SMR(idx)); > > smmu->streamid_mask = smr >> SMR_ID_SHIFT; > > > > smr = smmu->streamid_mask << SMR_MASK_SHIFT; > > - writel_relaxed(smr, gr0_base + ARM_SMMU_GR0_SMR(0)); > > - smr = readl_relaxed(gr0_base + ARM_SMMU_GR0_SMR(0)); > > + writel_relaxed(smr, gr0_base + ARM_SMMU_GR0_SMR(idx)); > > + smr = readl_relaxed(gr0_base + ARM_SMMU_GR0_SMR(idx)); > > smmu->smr_mask_mask = smr >> SMR_MASK_SHIFT; > > } > > > > -- > > 2.18.0 > > > > > > _______________________________________________ > > linux-arm-kernel mailing list > > linux-arm-kernel@lists.infradead.org > > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel