From patchwork Wed May 4 11:40:07 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Auger Eric X-Patchwork-Id: 67121 Delivered-To: patches@linaro.org Received: by 10.140.92.199 with SMTP id b65csp129655qge; Wed, 4 May 2016 04:40:42 -0700 (PDT) X-Received: by 10.28.48.203 with SMTP id w194mr9167342wmw.67.1462362032425; Wed, 04 May 2016 04:40:32 -0700 (PDT) Return-Path: Received: from mail-wm0-x22a.google.com (mail-wm0-x22a.google.com. [2a00:1450:400c:c09::22a]) by mx.google.com with ESMTPS id db7si4318760wjc.243.2016.05.04.04.40.32 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 May 2016 04:40:32 -0700 (PDT) Received-SPF: pass (google.com: domain of eric.auger@linaro.org designates 2a00:1450:400c:c09::22a as permitted sender) client-ip=2a00:1450:400c:c09::22a; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: domain of eric.auger@linaro.org designates 2a00:1450:400c:c09::22a as permitted sender) smtp.mailfrom=eric.auger@linaro.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: by mail-wm0-x22a.google.com with SMTP id e201so184002498wme.0 for ; Wed, 04 May 2016 04:40:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=66Jc6C2dE0cc5iCOAGqTeuOVX+KyAvUJr1xSBfU7CqE=; b=cNQxgmh5PZWIsBdFyqvxSbr6OrYzvtVjPVno2162SH7H8fGULdqVACZ/iX8KqG0CIU 5IonrG4WFxhbG1BVqvhjR3DewxYttW8PZdQF+Gs6/H0M6Y3ufR1oxTFY5yl5cgR26PLW mDb5fcu7NTt1FXyXZzv5Ys/6Nd5fm2S2E5ntI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=66Jc6C2dE0cc5iCOAGqTeuOVX+KyAvUJr1xSBfU7CqE=; b=LwZHZ6NgM/ZvM198VjMZZhcj+DVaULNPMOIjmOLv7UlNlvFfmeGh4801S/v70VO38N J3JRuj79xK0K5f4FO8jHAoBlSlCVjZoIDrGoyEehUk9mS+wT3125U6hfzgryEfvmjIWX QogloJMb2wPMzTsRJ9LL62F/nAq6d4eGsDL8qO9WjNxdHKRCFtlDSt/QEH2LKRjxouO7 HnM5iybMTSWY2SOhhBBmMFVx+ptPL+oVt5MlMdyPv2WeqStY0HrzFe5pT6neoJeeNfs0 y3F1b0XT35dlJWUZ4dzJUyMSV7w4IOZmgWRAWvyt/aco7fMyGW3mqnhSH/WISqJu6jLc NvGA== X-Gm-Message-State: AOPr4FXXtE2tE/G7iqM6GqPdD084stUiKviTyzrkh86UkExKcZ7ueKidUv/zZWMtd5S0QH4GKiA= X-Received: by 10.28.227.138 with SMTP id a132mr29255186wmh.35.1462362032135; Wed, 04 May 2016 04:40:32 -0700 (PDT) Return-Path: Received: from new-host-61.home (LMontsouris-657-1-37-90.w80-11.abo.wanadoo.fr. [80.11.198.90]) by smtp.gmail.com with ESMTPSA id u6sm3766963wjh.2.2016.05.04.04.40.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 04 May 2016 04:40:30 -0700 (PDT) From: Eric Auger To: eric.auger@st.com, eric.auger@linaro.org, robin.murphy@arm.com, alex.williamson@redhat.com, will.deacon@arm.com, joro@8bytes.org, tglx@linutronix.de, jason@lakedaemon.net, marc.zyngier@arm.com, christoffer.dall@linaro.org, linux-arm-kernel@lists.infradead.org Cc: patches@linaro.org, linux-kernel@vger.kernel.org, Bharat.Bhushan@freescale.com, pranav.sawargaonkar@gmail.com, p.fedin@samsung.com, iommu@lists.linux-foundation.org, Jean-Philippe.Brucker@arm.com, julien.grall@arm.com, yehuday@marvell.com Subject: [PATCH v9 8/8] iommu/arm-smmu: get/put the msi cookie Date: Wed, 4 May 2016 11:40:07 +0000 Message-Id: <1462362007-2753-9-git-send-email-eric.auger@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1462362007-2753-1-git-send-email-eric.auger@linaro.org> References: <1462362007-2753-1-git-send-email-eric.auger@linaro.org> For IOMMU_DOMAIN_UNMANAGED type we now also get the msi cookie in both arm-smmu and arm-smmu-v3. This initializes resources for MSI doorbell mapping. Signed-off-by: Eric Auger --- drivers/iommu/arm-smmu-v3.c | 16 ++++++++++++---- drivers/iommu/arm-smmu.c | 15 +++++++++++---- 2 files changed, 23 insertions(+), 8 deletions(-) -- 1.9.1 diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c index bf222b5..b5d9826 100644 --- a/drivers/iommu/arm-smmu-v3.c +++ b/drivers/iommu/arm-smmu-v3.c @@ -22,6 +22,7 @@ #include #include +#include #include #include #include @@ -1411,15 +1412,21 @@ static struct iommu_domain *arm_smmu_domain_alloc(unsigned type) return NULL; if (type == IOMMU_DOMAIN_DMA && - iommu_get_dma_cookie(&smmu_domain->domain)) { - kfree(smmu_domain); - return NULL; - } + iommu_get_dma_cookie(&smmu_domain->domain)) + goto err; + + if (type == IOMMU_DOMAIN_UNMANAGED && + iommu_get_msi_cookie(&smmu_domain->domain)) + goto err; + smmu_domain->domain.msi_geometry = msi_geometry; mutex_init(&smmu_domain->init_mutex); spin_lock_init(&smmu_domain->pgtbl_lock); return &smmu_domain->domain; +err: + kfree(smmu_domain); + return NULL; } static int arm_smmu_bitmap_alloc(unsigned long *map, int span) @@ -1445,6 +1452,7 @@ static void arm_smmu_domain_free(struct iommu_domain *domain) struct arm_smmu_domain *smmu_domain = to_smmu_domain(domain); struct arm_smmu_device *smmu = smmu_domain->smmu; + iommu_put_msi_cookie(domain); iommu_put_dma_cookie(domain); free_io_pgtable_ops(smmu_domain->pgtbl_ops); diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c index 55f429d..0908985 100644 --- a/drivers/iommu/arm-smmu.c +++ b/drivers/iommu/arm-smmu.c @@ -30,6 +30,7 @@ #include #include +#include #include #include #include @@ -990,10 +991,12 @@ static struct iommu_domain *arm_smmu_domain_alloc(unsigned type) return NULL; if (type == IOMMU_DOMAIN_DMA && - iommu_get_dma_cookie(&smmu_domain->domain)) { - kfree(smmu_domain); - return NULL; - } + iommu_get_dma_cookie(&smmu_domain->domain)) + goto err; + + if (type == IOMMU_DOMAIN_UNMANAGED && + iommu_get_msi_cookie(&smmu_domain->domain)) + goto err; smmu_domain->domain.msi_geometry = msi_geometry; @@ -1001,6 +1004,9 @@ static struct iommu_domain *arm_smmu_domain_alloc(unsigned type) spin_lock_init(&smmu_domain->pgtbl_lock); return &smmu_domain->domain; +err: + kfree(smmu_domain); + return NULL; } static void arm_smmu_domain_free(struct iommu_domain *domain) @@ -1011,6 +1017,7 @@ static void arm_smmu_domain_free(struct iommu_domain *domain) * Free the domain resources. We assume that all devices have * already been detached. */ + iommu_put_msi_cookie(domain); iommu_put_dma_cookie(domain); arm_smmu_destroy_domain_context(domain); kfree(smmu_domain);