From mboxrd@z Thu Jan 1 00:00:00 1970 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=-6.5 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=ham 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 E560CC3A59B for ; Sat, 17 Aug 2019 03:40:19 +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 B941F21721 for ; Sat, 17 Aug 2019 03:40:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="tjBUZoA4" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B941F21721 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sina.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-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.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=rdMXYld8zRPj22CVvvJkX6LZXhOd5v4GlSajmJ83QbQ=; b=tjBUZoA4VThbaU zsg3uA7pqqAejma/vQhlBRYO7ceiDfWhO4knCKIrEe0YHl3oOh9HqX9puicddG7gqQUImqD+0W7en T6i89HiR/L0MUqjtaZZFXVQ9I0JBO0cP68ujGJB9OfuX+1qNwbthFw5WpmfnmMptjK9jZ3P+TR54y jAgPyopx9vf5uJWiujSuWs8zXxCPeu1ytDqGJ7lKLEw5wE4urPXUnvSNpJxELz9rxCKMzA1o8jRQx 2mjclagVqWFWGq2l3Ju+H1cAqwJC6hXgQ+zZj41geSHjEOKWEOyo5Zr3IC3mfZA+tfYm2OTsRh7Zx ne+tE9H4W/MqG51uj/7g==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hypZa-0005hD-18; Sat, 17 Aug 2019 03:40:10 +0000 Received: from mail3-165.sinamail.sina.com.cn ([202.108.3.165]) by bombadil.infradead.org with smtp (Exim 4.92 #3 (Red Hat Linux)) id 1hypZW-0005Nv-LT for linux-arm-kernel@lists.infradead.org; Sat, 17 Aug 2019 03:40:08 +0000 Received: from unknown (HELO localhost.localdomain)([222.131.78.247]) by sina.com with ESMTP id 5D5776EB00008B47; Sat, 17 Aug 2019 11:39:27 +0800 (CST) X-Sender: hdanton@sina.com X-Auth-ID: hdanton@sina.com X-SMAIL-MID: 426700329115 From: Hillf Danton To: Tom Murphy Subject: Re: [PATCH V5 3/5] iommu/dma-iommu: Handle deferred devices Date: Sat, 17 Aug 2019 11:39:14 +0800 Message-Id: <20190817033914.4812-1-hdanton@sina.com> In-Reply-To: <20190815110944.3579-1-murphyt7@tcd.ie> References: <20190815110944.3579-1-murphyt7@tcd.ie> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190816_204006_893923_1A984DD0 X-CRM114-Status: GOOD ( 12.72 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Heiko Stuebner , virtualization@lists.linux-foundation.org, linux-tegra@vger.kernel.org, Thierry Reding , Will Deacon , Marek Szyprowski , Jean-Philippe Brucker , linux-samsung-soc@vger.kernel.org, Joerg Roedel , iommu@lists.linux-foundation.org, Krzysztof Kozlowski , Jonathan Hunter , linux-rockchip@lists.infradead.org, Andy Gross , Gerald Schaefer , linux-s390@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-mediatek@lists.infradead.org, Matthias Brugger , linux-arm-kernel@lists.infradead.org, David Woodhouse , linux-kernel@vger.kernel.org, Rob Clark , Kukjin Kim , Robin Murphy Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, 15 Aug 2019 12:09:41 +0100 Tom Murphy wrote: > > Handle devices which defer their attach to the iommu in the dma-iommu api > > Signed-off-by: Tom Murphy > --- > drivers/iommu/dma-iommu.c | 27 ++++++++++++++++++++++++++- > 1 file changed, 26 insertions(+), 1 deletion(-) > > diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c > index 2712fbc68b28..906b7fa14d3c 100644 > --- a/drivers/iommu/dma-iommu.c > +++ b/drivers/iommu/dma-iommu.c > @@ -22,6 +22,7 @@ > #include > #include > #include > +#include > > struct iommu_dma_msi_page { > struct list_head list; > @@ -351,6 +352,21 @@ static int iommu_dma_init_domain(struct iommu_domain *domain, dma_addr_t base, > return iova_reserve_iommu_regions(dev, domain); > } > > +static int handle_deferred_device(struct device *dev, > + struct iommu_domain *domain) > +{ > + const struct iommu_ops *ops = domain->ops; > + > + if (!is_kdump_kernel()) > + return 0; > + > + if (unlikely(ops->is_attach_deferred && > + ops->is_attach_deferred(domain, dev))) > + return iommu_attach_device(domain, dev); > + > + return 0; > +} > + > /** > * dma_info_to_prot - Translate DMA API directions and attributes to IOMMU API > * page flags. > @@ -463,6 +479,9 @@ static dma_addr_t __iommu_dma_map(struct device *dev, phys_addr_t phys, > size_t iova_off = iova_offset(iovad, phys); > dma_addr_t iova; > > + if (unlikely(handle_deferred_device(dev, domain))) > + return DMA_MAPPING_ERROR; > + > size = iova_align(iovad, size + iova_off); > > iova = iommu_dma_alloc_iova(domain, size, dma_get_mask(dev), dev); iommu_map_atomic() is applied to __iommu_dma_map() in 2/5. Is it an atomic context currently given the mutex_lock() in iommu_attach_device()? _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel