Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1874996yba; Sun, 14 Apr 2019 23:31:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqyEjR8BuJ+g7PBb+fnAbuf/r1Zo4o6lQ+AfUWUJwavOgklAT+MqqFqgoRdYRYTyhrIcWO6S X-Received: by 2002:a63:30c5:: with SMTP id w188mr67650112pgw.76.1555309919043; Sun, 14 Apr 2019 23:31:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555309919; cv=none; d=google.com; s=arc-20160816; b=ZKuGcufGdBfzVP+KKjxvopkKR7Todv+ls7CciqSfXlE3PqOmCrlv3mDwdhWM7qfmD+ gWuXQnjO5293QfbZK2L7RlvIf2I2IiZWdYpMBJrBGxrW8CGxH98w67n+m03FnPR2UdPi 4shC97ktrXenPktVH0KnayDv/MRqYGKH6NqFenJUiihJndrdaBGHgJ4DDQ04oWdmI9FD 0CT7K8bKbG30RAuGu0jnIELg4rLx7yGyE/eFs6x2HODFiSZkcBAEGEuVkSX1k2JJXk3D y7Gb4opPol7WpLvVqT/daK3AGT3eKhtmzDPBMrQU87Ef3BauKKlzDuPIw9JOp5SkSjiN OZxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=sBvvwLAlcvN1BhPYhrP92KdhFk9vL6RzAU/eyQJbtN8=; b=RW/CjemknYhYST+XrWH93FWaxGt4wNFAfwznyrz11i1Xr3oVe8btn8uZhalJinswHh h+IQqXdhIBS1L+vx9oQMHETiksL0/N2SciIksrmhHghNGUyFLNIHqgl1hVfsxpYMOap9 8b+bWW/44T+3DhDQtfGlvg4RDyGvzrLdNXO8VbRCKJ3i9l320ZFj0o1HtuibsANjUTGo +vvld5V5kuR1YZXKug2kQu5a+uy63Mhq14Y2e094YtpwV9LMYmqAgUvneUOxI2zQ27jb otc6cu9io98pH2pnpe1u7N8XyOqMPcObvXOfpzngduuloGmW94SgOwqoWErNtP2SbnrQ 6rCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=Uoz1Da3E; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s9si44377716pgr.443.2019.04.14.23.31.42; Sun, 14 Apr 2019 23:31:59 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=Uoz1Da3E; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726087AbfDOGbE (ORCPT + 99 others); Mon, 15 Apr 2019 02:31:04 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:35674 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725777AbfDOGbE (ORCPT ); Mon, 15 Apr 2019 02:31:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Transfer-Encoding :Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Sender:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=sBvvwLAlcvN1BhPYhrP92KdhFk9vL6RzAU/eyQJbtN8=; b=Uoz1Da3E3lLPQy37LZAVYDF9N0 FSXo09rFri3MFfGg+C+zaoIiTI7eN36RlIbtThL04wK/u2kQpS2xzfhXM+Ud+O4Ct+mE1sfx7ZTFg YmGh5xTERnLVji2ukeZzbEtA7gINkw/hCLv2fzR/mRn8/McAi6nVF8zCRY5is1+KWsEqW5VdpA8qJ 1neN7XXNcoXfY+iGVJGDg0QR7gaRMbyt930ySxIkwJ6IO7xW1qOMsPn451/zLxJrBCFQj+TpZS2Vi Mv7oUB3ugC3VMfWlUJo8zpi1b7fWnvWe9VqLpJBcJK5xUt6D1uRNlNOdta55hpw7VtYEaJ4OCfOJb xVDQp4Hw==; Received: from hch by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1hFv8t-0001xP-1u; Mon, 15 Apr 2019 06:30:59 +0000 Date: Sun, 14 Apr 2019 23:30:58 -0700 From: Christoph Hellwig To: Tom Murphy Cc: iommu@lists.linux-foundation.org, Heiko Stuebner , Will Deacon , David Brown , linux-samsung-soc@vger.kernel.org, dima@arista.com, Krzysztof Kozlowski , linux-rockchip@lists.infradead.org, Kukjin Kim , Andy Gross , Marc Zyngier , linux-arm-msm@vger.kernel.org, linux-mediatek@lists.infradead.org, Matthias Brugger , Thomas Gleixner , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, murphyt7@tcd.ie, Robin Murphy Subject: Re: [PATCH 1/9] iommu/dma-iommu: Add iommu_map_atomic Message-ID: <20190415063058.GA1377@infradead.org> References: <20190411184741.27540-1-tmurphy@arista.com> <20190411184741.27540-2-tmurphy@arista.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20190411184741.27540-2-tmurphy@arista.com> User-Agent: Mutt/1.9.2 (2017-12-15) X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 11, 2019 at 07:47:30PM +0100, Tom Murphy via iommu wrote: > The iommu ops .map function (or the iommu_map function which calls it) > was always supposed to be sleepable (according to Joerg's comment in > this thread: https://lore.kernel.org/patchwork/patch/977520/ ) and so > should probably have had a "might_sleep()" since it was written. However > currently the dma-iommu api can call iommu_map in an atomic context, > which it shouldn't do. This doesn't cause any problems because any iommu > driver which uses the dma-iommu api uses gfp_atomic in it's iommu_ops > .map function. But doing this wastes the memory allocators atomic pools. > > Add a new function iommu_map_atomic, use it in the dma-iommu api and add > “might_sleep()” to the iommu_map function. > > After this change all drivers which use the dma-iommu api need to > implement the new iommu ops .map_atomic function. For the moment just > reuse the driver's iommus ops .map function for .map_atomic. Instead of duplicating the callchain shouldn't we just pass down a flag to indicate if the context can sleep or not? Especially as all the existing arm drivers already implement the atomic behavior, which is a majority of struct iommu_ops based iommu drivers.