From patchwork Sat May 13 09:47:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shameerali Kolothum Thodi X-Patchwork-Id: 9725115 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 50AD760381 for ; Sat, 13 May 2017 09:54:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3107B288CF for ; Sat, 13 May 2017 09:54:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 22D1E288D3; Sat, 13 May 2017 09:54:22 +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_SIGNED, DKIM_VALID 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 AEA45288CF for ; Sat, 13 May 2017 09:54:21 +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:MIME-Version:References:In-Reply-To: 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: List-Owner; bh=0xcd/oabdmQbFBKzowCYomLDVNNfCioBtipFCWZvVA0=; b=IOU9ECUeURKFxC vCVFjMWmzPil+6di5C870UBwwU3u3fggpEIN0F8z/bR0k/+QdIkqrHt1WYhgfFyg8NGoSBgyXoOaG UcrEK8cMAwLPpKI8eJohoiNDnjNdYIlS3GvjGyJ1rBN1/PgNUkf1qiAqYJBr1AgbAxT7OMxbLN5ux eARB1DvxGgQ3qPputB+qV61i/alwc9TnYZ3gMW9aNDyy8Y3ZDO9V3a3Og2bvD60K2IDoq5EWAu/ka lME8CwXbqtP75qTFghkSSr4gSt/2pHOFZiYqnHv16OrxTfZRvJIVHR0qqggzl8nlTLlCc8rLZf6Gw MQoyhQzCWlC/UZWYZrOw==; 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 1d9Tki-0002Xj-Vt; Sat, 13 May 2017 09:54:21 +0000 Received: from szxga03-in.huawei.com ([45.249.212.189]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1d9TiO-00008b-Du for linux-arm-kernel@lists.infradead.org; Sat, 13 May 2017 09:51:58 +0000 Received: from 172.30.72.54 (EHLO DGGEML404-HUB.china.huawei.com) ([172.30.72.54]) by dggrg03-dlp.huawei.com (MOS 4.4.6-GA FastPath queued) with ESMTP id ANM88405; Sat, 13 May 2017 17:51:24 +0800 (CST) Received: from S00345302A-PC.china.huawei.com (10.47.91.84) by DGGEML404-HUB.china.huawei.com (10.3.17.39) with Microsoft SMTP Server id 14.3.301.0; Sat, 13 May 2017 17:50:56 +0800 From: shameer To: , , , , Subject: [RFC v1 2/7] iommu/arm-smmu-v3: Add erratum framework functions Date: Sat, 13 May 2017 10:47:26 +0100 Message-ID: <20170513094731.3676-3-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20170513094731.3676-1-shameerali.kolothum.thodi@huawei.com> References: <20170513094731.3676-1-shameerali.kolothum.thodi@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.47.91.84] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A090204.5916D71C.011E, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: b23a9c723fbcb97cfe65d31edb629bd8 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170513_025157_197398_0881A615 X-CRM114-Status: UNSURE ( 9.87 ) X-CRM114-Notice: Please train this message. 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: devicetree@vger.kernel.org, gabriele.paoloni@huawei.com, john.garry@huawei.com, linuxarm@huawei.com, shameer , linux-acpi@vger.kernel.org, iommu@lists.linux-foundation.org, wangzhou1@hisilicon.com, guohanjun@huawei.com, linux-arm-kernel@lists.infradead.org, devel@acpica.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 This will provide a way to replace the existing skip_prefetch_cmd erratum using the new framework. Signed-off-by: shameer --- drivers/iommu/arm-smmu-v3.c | 58 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c index a166590..f20d5d5 100644 --- a/drivers/iommu/arm-smmu-v3.c +++ b/drivers/iommu/arm-smmu-v3.c @@ -664,16 +664,72 @@ enum smmu_erratum_match_type { se_match_dt, }; +void erratum_skip_prefetch_cmd(struct arm_smmu_device *smmu, void *arg) +{ + smmu->options |= ARM_SMMU_OPT_SKIP_PREFETCH; +} + struct smmu_erratum_workaround { enum smmu_erratum_match_type match_type; const void *id; /* Indicate the Erratum ID */ const char *desc_str; + void (*enable)(struct arm_smmu_device *, void *); }; static const struct smmu_erratum_workaround smmu_workarounds[] = { }; +typedef bool (*se_match_fn_t)(const struct smmu_erratum_workaround *, + const void *); +static +bool smmu_check_dt_erratum(const struct smmu_erratum_workaround *wa, + const void *arg) +{ + const struct device_node *np = arg; + + return of_property_read_bool(np, wa->id); +} + +static void smmu_enable_errata(struct arm_smmu_device *smmu, + enum smmu_erratum_match_type type, + se_match_fn_t match_fn, + void *arg) +{ + const struct smmu_erratum_workaround *wa = smmu_workarounds; + + for (; wa->desc_str; wa++) { + if (wa->match_type != type) + continue; + + if (match_fn(wa, arg)) { + if (wa->enable) { + wa->enable(smmu, arg); + dev_info(smmu->dev, + "Enabling workaround for %s\n", + wa->desc_str); + } + } + } +} + + +static void smmu_check_workarounds(struct arm_smmu_device *smmu, + enum smmu_erratum_match_type type, + void *arg) +{ + se_match_fn_t match_fn = NULL; + + switch (type) { + case se_match_dt: + match_fn = smmu_check_dt_erratum; + break; + } + + smmu_enable_errata(smmu, type, match_fn, arg); + +} + static struct arm_smmu_domain *to_smmu_domain(struct iommu_domain *dom) { return container_of(dom, struct arm_smmu_domain, domain); @@ -2641,6 +2697,8 @@ static int arm_smmu_device_dt_probe(struct platform_device *pdev, parse_driver_options(smmu); + smmu_check_workarounds(smmu, se_match_dt, dev->of_node); + if (of_dma_is_coherent(dev->of_node)) smmu->features |= ARM_SMMU_FEAT_COHERENCY;