From patchwork Tue Mar 26 23:01:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolin Chen X-Patchwork-Id: 10872295 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EDA52139A for ; Tue, 26 Mar 2019 23:02:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D959D28D92 for ; Tue, 26 Mar 2019 23:02:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C91F428DA0; Tue, 26 Mar 2019 23:02:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 45F1328D92 for ; Tue, 26 Mar 2019 23:02:23 +0000 (UTC) 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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: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=+0Vt6Dbkm2jC4sCULzH4TeTeDsmgUNh0IVOX/+w6sgY=; b=eAVOZJhWYznyxhDDRAZHSsXqVQ 5texd6UH5oyKthtbZtanLp7g+x4EMtlh3m3lZJhX6Q0iaU9QJSPyHsVXi+5PkN3f952rRaxcRjTVv KR7ZPEmhK9yZHmCdd5IeazTaEhaz4n4Iy7GYXTbKnUOp/uyL5uy6MzAMhNjFTl2X8d0LGugsrcgac oh9hZZ/HBthiH5z3CaNlZ7HnRrKcoBTy/LNNAOpipcnR9/WoXe6V/Ozoe3rFc97zeuAU97oZYwvt5 3TELRtFLGG0avTITxBY8mHpNlTFRPA4x2Ttt40SkAHVG1tAN6dIdxRFWO7PBlhkJnK1CBmgtxe2qn gCqw7FNA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1h8v5B-0001sL-7C; Tue, 26 Mar 2019 23:02:13 +0000 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h8v4g-0001L1-H7 for linux-arm-kernel@lists.infradead.org; Tue, 26 Mar 2019 23:01:44 +0000 Received: by mail-pf1-x444.google.com with SMTP id c207so8762700pfc.7 for ; Tue, 26 Mar 2019 16:01: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; bh=Pbdwi/63Agi4s6Tt6RAM0FtL+bzJWgpn5Dncpfelpvo=; b=VEl0Z5RabQr/GpMe+VeLFsQb1j8S9dkjTJrD73RCdjoxt/+64vqdmHwA3oCGAU3Rao muG6Fg1gGNy4yTM2ISm6Gf3H5J7n1jKEiVHPSGMKodZ0bbiuQWDa8gw1fkXV8HsU5ery mpeAb6v/5rSdYG4hg+7ZETItqEadoofzRSDWxISNsQUrrUVE7NPHPampAmcd89uvOBnV ILhZtuXSENh2o4CATQZwLUHukCRjgN4ODRK3DJXp21AKe0LehF7+/VJaueNzwuYtNAkD OQ53fK3oOGDrCaQw0Syk2v6ZUm+nJiznA+UTVRMM49uxpitTBcIJ45aavdT9RDkG7MNG OkxA== 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; bh=Pbdwi/63Agi4s6Tt6RAM0FtL+bzJWgpn5Dncpfelpvo=; b=dMqeTrXXnE9eZIVgScmm7zkFo+uTIUXUrma9mC0f9Fk7fWLiEFmZaZk9f+d+igdt4C B3K1zXsxIXJj3+c6cb5dv1H3eOdma/Jp7KItJ+YETDGQ48KPpxvBTGHIwqsPKXMfYf5s bvWAm0SZe4c7aA5okg5oQ4A4LnMhK6D1XFWgi4oKoGClV4RjSU8/zVHBhjqo+Ock4qf5 OtMhzNnnS5MCVvRVO4Xgl6G0UGV3gL6/rZuIy4UB7KifjSCz9YBDTHqfpqFonV4fHhjQ r2rSh3TttimPrAZWQUsiuDyQZ1QzXPv70j6JCHl4LYMfuR50/QflGAu7qZZyc1pJY8Kn 63jA== X-Gm-Message-State: APjAAAU5DLzQww3uMadouYVqGkvzLosL3Fv3sqv14ZglxRWVQkg78IgJ q7qESZh8dw7kOSFhjRHqBX0= X-Google-Smtp-Source: APXvYqzI4KLCbPz8UxICZ051Zm3uWTFPxOlGhyODzocBuOSnWTYCxGRTIeA0rPSHp3VHcl/fsSnMcw== X-Received: by 2002:a62:388d:: with SMTP id f135mr17894178pfa.103.1553641301996; Tue, 26 Mar 2019 16:01:41 -0700 (PDT) Received: from Asurada-Nvidia.nvidia.com (thunderhill.nvidia.com. [216.228.112.22]) by smtp.gmail.com with ESMTPSA id n24sm43832587pfi.123.2019.03.26.16.01.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 26 Mar 2019 16:01:41 -0700 (PDT) From: Nicolin Chen To: hch@lst.de, robin.murphy@arm.com Subject: [PATCH v2 RFC/RFT 3/5] iommu: amd_iommu: Add fallback normal page allocations Date: Tue, 26 Mar 2019 16:01:29 -0700 Message-Id: <20190326230131.16275-4-nicoleotsuka@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190326230131.16275-1-nicoleotsuka@gmail.com> References: <20190326230131.16275-1-nicoleotsuka@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190326_160142_808404_77B2F821 X-CRM114-Status: GOOD ( 12.27 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: tony@atomide.com, catalin.marinas@arm.com, joro@8bytes.org, will.deacon@arm.com, linux@armlinux.org.uk, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, m.szyprowski@samsung.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-Virus-Scanned: ClamAV using ClamSMTP The CMA allocation will skip allocations of single pages to save CMA resource. This requires its callers to rebound those page allocations from normal area. So this patch adds fallback routines. Note: amd_iommu driver uses dma_alloc_from_contiguous() as a fallback allocation and uses alloc_pages() as its first round allocation. This's in reverse order than other callers. So the alloc_pages() added by this change becomes a second fallback, though it likely won't succeed since the alloc_pages() has failed once. Signed-off-by: Nicolin Chen --- drivers/iommu/amd_iommu.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c index 21cb088d6687..2aa4818f5249 100644 --- a/drivers/iommu/amd_iommu.c +++ b/drivers/iommu/amd_iommu.c @@ -2701,6 +2701,9 @@ static void *alloc_coherent(struct device *dev, size_t size, page = dma_alloc_from_contiguous(dev, size >> PAGE_SHIFT, get_order(size), flag & __GFP_NOWARN); + if (!page) + page = alloc_pages(flag | __GFP_NOWARN, + get_order(size)); if (!page) return NULL; }