From patchwork Sat Sep 5 20:04:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 11759313 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DD265618 for ; Sat, 5 Sep 2020 20:04:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C10F120757 for ; Sat, 5 Sep 2020 20:04:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="qWKY2JQJ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728804AbgIEUEo (ORCPT ); Sat, 5 Sep 2020 16:04:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49704 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728798AbgIEUEm (ORCPT ); Sat, 5 Sep 2020 16:04:42 -0400 Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 11133C061244; Sat, 5 Sep 2020 13:04:42 -0700 (PDT) Received: by mail-pf1-x443.google.com with SMTP id w7so6490927pfi.4; Sat, 05 Sep 2020 13:04: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:in-reply-to:references :mime-version:content-transfer-encoding; bh=2FYkuDdKfZnq0C2m032hzkvhRzd15B2Kmt9oLbZcU5c=; b=qWKY2JQJVIVP82B9PMT8o59t7UeJfDP0M57e6PEpnRmQiAkv/XDHDzfJtUGRAze7RY /gRRSsZgAylliFIJJb6VwFZLX92OBNhK/DmDNfw76YOXqt2wDltCb1b3MTRzT8oOl+OB +wNYpspgkedR91cUN7PYaCBfYvrcIG4eZ3W7ERMOmV2ApLfirq4mOjbIAtQObKqP8Hwn SLQ48WQfxNJLWGL9nJitbWQIjxK5+LfXA/4mipexRl6KN3jO+km1G+JR7m4+jChO9QSX 2dbGZr0uNkhOAKQZ49OIsK4eqZKtGdN4b2JcyG8CUUOaX6SNWvIHzrpLOdzMChj19k0d +qgw== 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=2FYkuDdKfZnq0C2m032hzkvhRzd15B2Kmt9oLbZcU5c=; b=RJp/kplPMze2wVrxWf8xEh6gjaJfd+a6wVOZQFvJKL1Iq/5VmLXHDeDF08H4YQCZSf GcoIB9L82rIea140fgpL2HEaq0/U85Os2+0iUeF8MFDLUUK2ISY+Htfu5A/10o6sSadE 0Fyv+GfCTrGGJfkMd7Nrj1K0Mtqt3CYdlaPzEX1x4EOVuavhsIISsq67dRpwqY5PcWKf A9XVgS64EpH4t6xQf1G20kUYpP1RipFwLKTSCNCNlyN5YPWkjq13lb1mqHW1ZmCJ0mu5 AqVEMIrqo1c9KhnSbZYa1NeBBvXOeS0uRGlJbqA9AU/+qRialpvO3LRBWDA8ML36Fs2K dtxw== X-Gm-Message-State: AOAM533Xl2cy5cpwy8uhEJRjX9FYQSaO50JJV1g5hi6RhStRz8s0qNaB nTpdHMUWXFlMbhB+CfmaC9s= X-Google-Smtp-Source: ABdhPJwddwGkqZ5LMMfsLeNsMODFf+8mNE/mLvdKlIbjFrKEoaXKpLuP5A0CfAvslNYsBpWAkipirw== X-Received: by 2002:a63:4a1a:: with SMTP id x26mr7795439pga.295.1599336281558; Sat, 05 Sep 2020 13:04:41 -0700 (PDT) Received: from localhost (c-73-25-156-94.hsd1.or.comcast.net. [73.25.156.94]) by smtp.gmail.com with ESMTPSA id m13sm834177pjl.45.2020.09.05.13.04.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Sep 2020 13:04:40 -0700 (PDT) From: Rob Clark To: iommu@lists.linux-foundation.org, dri-devel@lists.freedesktop.org, Will Deacon , Robin Murphy , Joerg Roedel Cc: linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, Bjorn Andersson , Sibi Sankar , Vivek Gautam , Stephen Boyd , Akhil P Oommen , Jordan Crouse , Rob Clark , Jonathan Marek , Greg Kroah-Hartman , Krishna Reddy , linux-arm-kernel@lists.infradead.org (moderated list:ARM SMMU DRIVERS), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v17 12/20] iommu/arm-smmu: Pass io-pgtable config to implementation specific function Date: Sat, 5 Sep 2020 13:04:18 -0700 Message-Id: <20200905200454.240929-13-robdclark@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200905200454.240929-1-robdclark@gmail.com> References: <20200905200454.240929-1-robdclark@gmail.com> MIME-Version: 1.0 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: Jordan Crouse Construct the io-pgtable config before calling the implementation specific init_context function and pass it so the implementation specific function can get a chance to change it before the io-pgtable is created. Signed-off-by: Jordan Crouse Signed-off-by: Rob Clark Reviewed-by: Bjorn Andersson --- drivers/iommu/arm/arm-smmu/arm-smmu-impl.c | 3 ++- drivers/iommu/arm/arm-smmu/arm-smmu.c | 11 ++++++----- drivers/iommu/arm/arm-smmu/arm-smmu.h | 3 ++- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu-impl.c b/drivers/iommu/arm/arm-smmu/arm-smmu-impl.c index f4ff124a1967..a9861dcd0884 100644 --- a/drivers/iommu/arm/arm-smmu/arm-smmu-impl.c +++ b/drivers/iommu/arm/arm-smmu/arm-smmu-impl.c @@ -68,7 +68,8 @@ static int cavium_cfg_probe(struct arm_smmu_device *smmu) return 0; } -static int cavium_init_context(struct arm_smmu_domain *smmu_domain) +static int cavium_init_context(struct arm_smmu_domain *smmu_domain, + struct io_pgtable_cfg *pgtbl_cfg) { struct cavium_smmu *cs = container_of(smmu_domain->smmu, struct cavium_smmu, smmu); diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu.c b/drivers/iommu/arm/arm-smmu/arm-smmu.c index 09c42af9f31e..37d8d49299b4 100644 --- a/drivers/iommu/arm/arm-smmu/arm-smmu.c +++ b/drivers/iommu/arm/arm-smmu/arm-smmu.c @@ -795,11 +795,6 @@ static int arm_smmu_init_domain_context(struct iommu_domain *domain, cfg->asid = cfg->cbndx; smmu_domain->smmu = smmu; - if (smmu->impl && smmu->impl->init_context) { - ret = smmu->impl->init_context(smmu_domain); - if (ret) - goto out_unlock; - } pgtbl_cfg = (struct io_pgtable_cfg) { .pgsize_bitmap = smmu->pgsize_bitmap, @@ -810,6 +805,12 @@ static int arm_smmu_init_domain_context(struct iommu_domain *domain, .iommu_dev = smmu->dev, }; + if (smmu->impl && smmu->impl->init_context) { + ret = smmu->impl->init_context(smmu_domain, &pgtbl_cfg); + if (ret) + goto out_clear_smmu; + } + if (smmu_domain->non_strict) pgtbl_cfg.quirks |= IO_PGTABLE_QUIRK_NON_STRICT; diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu.h b/drivers/iommu/arm/arm-smmu/arm-smmu.h index d890a4a968e8..83294516ac08 100644 --- a/drivers/iommu/arm/arm-smmu/arm-smmu.h +++ b/drivers/iommu/arm/arm-smmu/arm-smmu.h @@ -386,7 +386,8 @@ struct arm_smmu_impl { u64 val); int (*cfg_probe)(struct arm_smmu_device *smmu); int (*reset)(struct arm_smmu_device *smmu); - int (*init_context)(struct arm_smmu_domain *smmu_domain); + int (*init_context)(struct arm_smmu_domain *smmu_domain, + struct io_pgtable_cfg *cfg); void (*tlb_sync)(struct arm_smmu_device *smmu, int page, int sync, int status); int (*def_domain_type)(struct device *dev);