From patchwork Thu Jun 3 16:46:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 12297679 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9A783C47097 for ; Thu, 3 Jun 2021 16:51:28 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6455D613F1 for ; Thu, 3 Jun 2021 16:51:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6455D613F1 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; 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=QhvfkGDHLGG8ZXLXNTmRJWGZz1HkrX7IGjItGTRfgrI=; b=klzP9iRxaLJamY m0CUTW2JFBc1trBkAyNBqfYW9pIssSAnNE88SxgBpGcSTpAnse7CuM5h+Dde978DN3Du9MwxB5rLY 9MF54uo4u1TMbOO09FMGmE0FmyvuFzv9dUM67QBPKhxPDhYJSm2+9/98taOVJVNnLdiJTB2RO3F5w CawqsCtlM1Z4+OFAbqeyi9r5MjlBBPXss4hipZdP3vwlr8IklG1uR6JC9dUMOwU53XtWemoiIb1rc VXrtnGu58dE5EcBKRQMesNx+AAelhaMh2ieWnHJ/+andaqaHZ49JFWJsVnLDqG8tWqfocZsZ1fBqw gZJyQBf3IWunM3Tn6E9w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1loqWA-009cGu-Gn; Thu, 03 Jun 2021 16:48:27 +0000 Received: from mail-ed1-f44.google.com ([209.85.208.44]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1loqTv-009bE0-Fc for linux-arm-kernel@lists.infradead.org; Thu, 03 Jun 2021 16:46:08 +0000 Received: by mail-ed1-f44.google.com with SMTP id b11so7918057edy.4 for ; Thu, 03 Jun 2021 09:46:06 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=VlNxvqMh2IT7k8GWqSLT7kJqPAFU4Cya45iZg+g4Vc4=; b=Zu/ezZh0v9MeUs3qS/pHQ9pRZvTfL/Cqwv4R0B6/VuXkpBg1uWUXtbDZlI3hXXKBGX OwVzW52158BlV3RzQpM8MFlBoDtFQsNlTv0orvpZoI8kGGuVBlj6+P6Uv+vRCoA3Tzox 7QW7pTrBQ6Mfsq0SKQ+dJ+yuTvKMhcIVFrnlUxrHjIbMQ8fFZU7qyB5yxUfJz7qIZfzd 3bwdKSNUycLAafoaEnEnRyT2SyvG8CJdJSBM5IaS2gCrtFxJbymhtrbXWkuk2Di3/9Sp NrS+kmNwVw/gfVNS2uf2k49gsYQtyuh7Qyj18zOPtmjaSGtf1iNaJzZjIARoFqvgVdnI SgRw== 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=VlNxvqMh2IT7k8GWqSLT7kJqPAFU4Cya45iZg+g4Vc4=; b=YyY6xD49sdoCSFLoBD0kXdiK7gjzOQcc4VmlNHN2R1notKGB7Era5vsGLsEJbjGYVs gq2jbvzav9BNzpD9HgMjl5Xn658hO5qiic2CjoMzvdRxIvsfArHjJIwKUrrMnwfQ/F7/ +8eEE9ojhv7ePXgEwuw3U683gcjAtymL6WK2SVQPTFj75xZBpr/HemlgrLGymienVExz KaR9FgKNRNugB9kzMKA9z9f4jYnEubr7DOsAk0qlxnKSXrQ8LIeUx3WrjoeJPAAi0Uqv 8isfIFk3DijMr+sIm88Ioh7jKu13+d2WEOcQfcuaUFLZaP0TD1nYufYgVng7VqkbV6EM 1s2Q== X-Gm-Message-State: AOAM5305vyBkuYo2EDwB0FRNty62U3SyAla+N+2uEwAIlAK1ISugSckj cNqB+7ynof9quCBA5Oo8CEk= X-Google-Smtp-Source: ABdhPJxXrXwWK4QFgB5nUksaiKnWR+sh8XjHBPlh2ZAs/Xu5vH2IbScqCAAZFdw1SPRaf2s7vskTHQ== X-Received: by 2002:a05:6402:b17:: with SMTP id bm23mr411771edb.236.1622738705681; Thu, 03 Jun 2021 09:45:05 -0700 (PDT) Received: from localhost ([62.96.65.119]) by smtp.gmail.com with ESMTPSA id cz14sm1972696edb.84.2021.06.03.09.45.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Jun 2021 09:45:04 -0700 (PDT) From: Thierry Reding To: Thierry Reding , Will Deacon , Krzysztof Kozlowski Subject: [PATCH v3 3/9] iommu/arm-smmu: Implement ->probe_finalize() Date: Thu, 3 Jun 2021 18:46:26 +0200 Message-Id: <20210603164632.1000458-4-thierry.reding@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210603164632.1000458-1-thierry.reding@gmail.com> References: <20210603164632.1000458-1-thierry.reding@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210603_094607_567261_6A73183E X-CRM114-Status: GOOD ( 14.19 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Joerg Roedel , iommu@lists.linux-foundation.org, Jon Hunter , Nicolin Chen , linux-tegra@vger.kernel.org, Robin Murphy , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Thierry Reding Implement a ->probe_finalize() callback that can be used by vendor implementations to perform extra programming necessary after devices have been attached to the SMMU. Signed-off-by: Thierry Reding --- Changes in v2: - remove unnecessarily paranoid check drivers/iommu/arm/arm-smmu/arm-smmu.c | 13 +++++++++++++ drivers/iommu/arm/arm-smmu/arm-smmu.h | 1 + 2 files changed, 14 insertions(+) diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu.c b/drivers/iommu/arm/arm-smmu/arm-smmu.c index 6f72c4d208ca..d20ce4d57df2 100644 --- a/drivers/iommu/arm/arm-smmu/arm-smmu.c +++ b/drivers/iommu/arm/arm-smmu/arm-smmu.c @@ -1450,6 +1450,18 @@ static void arm_smmu_release_device(struct device *dev) iommu_fwspec_free(dev); } +static void arm_smmu_probe_finalize(struct device *dev) +{ + struct arm_smmu_master_cfg *cfg; + struct arm_smmu_device *smmu; + + cfg = dev_iommu_priv_get(dev); + smmu = cfg->smmu; + + if (smmu->impl->probe_finalize) + smmu->impl->probe_finalize(smmu, dev); +} + static struct iommu_group *arm_smmu_device_group(struct device *dev) { struct arm_smmu_master_cfg *cfg = dev_iommu_priv_get(dev); @@ -1569,6 +1581,7 @@ static struct iommu_ops arm_smmu_ops = { .iova_to_phys = arm_smmu_iova_to_phys, .probe_device = arm_smmu_probe_device, .release_device = arm_smmu_release_device, + .probe_finalize = arm_smmu_probe_finalize, .device_group = arm_smmu_device_group, .enable_nesting = arm_smmu_enable_nesting, .set_pgtable_quirks = arm_smmu_set_pgtable_quirks, diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu.h b/drivers/iommu/arm/arm-smmu/arm-smmu.h index c31a59d35c64..147c95e7c59c 100644 --- a/drivers/iommu/arm/arm-smmu/arm-smmu.h +++ b/drivers/iommu/arm/arm-smmu/arm-smmu.h @@ -439,6 +439,7 @@ struct arm_smmu_impl { struct device *dev, int start); void (*write_s2cr)(struct arm_smmu_device *smmu, int idx); void (*write_sctlr)(struct arm_smmu_device *smmu, int idx, u32 reg); + void (*probe_finalize)(struct arm_smmu_device *smmu, struct device *dev); }; #define INVALID_SMENDX -1