From patchwork Thu Apr 28 08:15:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Auger X-Patchwork-Id: 8966201 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 7DEBBBF440 for ; Thu, 28 Apr 2016 08:18:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A142D2027D for ; Thu, 28 Apr 2016 08:18:26 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B60EC2028D for ; Thu, 28 Apr 2016 08:18:25 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1avh8M-0001oj-9G; Thu, 28 Apr 2016 08:17:14 +0000 Received: from mail-wm0-x231.google.com ([2a00:1450:400c:c09::231]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1avh7M-0000Lp-OA for linux-arm-kernel@lists.infradead.org; Thu, 28 Apr 2016 08:16:13 +0000 Received: by mail-wm0-x231.google.com with SMTP id e201so66867333wme.0 for ; Thu, 28 Apr 2016 01:15:52 -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=LWYEY80J640kuh+vMl+BvN0/6EeChrn/KO+R8/y94VWf40tYl1X5ihGDD2TMfvaZyF BjUj/wk3IiUgeATrziUcn9Oat5s6OwLxDHS2LJK7kL9MGDVo81OEu+M2KhY1c48/hJCx fDrbh+NSO0qJbeDg+xGbX9z84yUvmD2uHgs4w= 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=KRFwtFFozUoDbCMSU04ufmgnoLOGEC8d9Xi8O5YY9eUKTVD08FopGsW/UakWwH/LNy G09uilREgo2ZZnSmasna6lgSFZUVFeS+W3fzQuBqc/IA3dFZQtBoY5KZAEeJzWxCGGhl QVh0pAGr6caO4NHX/yLz10okA0vlNfmhc6yyD9yi6GKbt4eMKaU424fCoTQDPBfUi3xd QGV5q9tqEZZPNsoHsUEotqNZwk5OXV88CJEgeNsv8gdxIiAZG2rKdXV769rKPR8conFv L6bZK/9uQpaoywVrfA8Pa1WcdOfVBej37zOTdmHjrHzrKeKfBjwBoiCCow1iOq3Oywp0 mjbQ== X-Gm-Message-State: AOPr4FVx4qLywP+wE3tv2Jgd9xSdYeLfCWbmkGAQxY1agiuGmPP1uegSaaFd8bdb7r6ENqXT X-Received: by 10.194.23.226 with SMTP id p2mr13563303wjf.131.1461831350917; Thu, 28 Apr 2016 01:15:50 -0700 (PDT) Received: from new-host-46.home (LMontsouris-657-1-37-90.w80-11.abo.wanadoo.fr. [80.11.198.90]) by smtp.gmail.com with ESMTPSA id h8sm12749860wmd.2.2016.04.28.01.15.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 28 Apr 2016 01:15:49 -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 Subject: [PATCH v8 8/8] iommu/arm-smmu: get/put the msi cookie Date: Thu, 28 Apr 2016 08:15:23 +0000 Message-Id: <1461831323-5480-9-git-send-email-eric.auger@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1461831323-5480-1-git-send-email-eric.auger@linaro.org> References: <1461831323-5480-1-git-send-email-eric.auger@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160428_011612_976299_3F375E6F X-CRM114-Status: GOOD ( 13.41 ) X-Spam-Score: -2.7 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: julien.grall@arm.com, patches@linaro.org, Jean-Philippe.Brucker@arm.com, p.fedin@samsung.com, linux-kernel@vger.kernel.org, Bharat.Bhushan@freescale.com, iommu@lists.linux-foundation.org, pranav.sawargaonkar@gmail.com MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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(-) 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);