From patchwork Tue Mar 26 22:49:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolin Chen X-Patchwork-Id: 10872283 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 C407F14DE for ; Tue, 26 Mar 2019 22:50:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AC5CC28D6A for ; Tue, 26 Mar 2019 22:50:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A01A828D8A; Tue, 26 Mar 2019 22:50:54 +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 564DE28D6A for ; Tue, 26 Mar 2019 22:50:54 +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=Qy+BqyG+A9NQ/s9em1qZXNR4LQ Dzb9pOEpv042LNSmyUDfV0mn04qguRj+iiBaCwWBl7T+2Rk09vMJ8MpoWR18PB3CCrchF17PVplha tw+hn8myxQaSUrajm3Xi/BVS1QEe6BnQW6A9enl7rLYnCQo9E5ttBa6GmnKHXt9+tOJOvAUikXu4M ePcS+D7wha4QW3pJYN5ovuNGN7xbLBgk7Pag/wf45BwpJs12xsmZr5wZMzSNU4VCAPIk82NYvH80m KJXp51SBM//bj3lAHp8MaHkOpqcYLYntrfQrBtZENqdTGsexCXzxd5ORvsScVY6+YVTd6luxhNue0 /rndmpNw==; 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 1h8uu2-0005c8-II; Tue, 26 Mar 2019 22:50:42 +0000 Received: from mail-pg1-x541.google.com ([2607:f8b0:4864:20::541]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h8utX-0004xE-LH for linux-arm-kernel@lists.infradead.org; Tue, 26 Mar 2019 22:50:18 +0000 Received: by mail-pg1-x541.google.com with SMTP id p6so8943033pgh.9 for ; Tue, 26 Mar 2019 15:50:11 -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=d8d9SI6Uzq+6pA3O9Jx8nnoiwqY60LZWCoNccnt0K7MvApqO2DcuOeGIS12uMabsmD AVNmdPvCM7YIMEcl2cUEIm2v9GWUIyfQq9VG+d5LIXDM4dW0NLdPhncvUSknr3U/9kFv NDLoqxOvdImnulMbZg6hbB3W4gLKeKa1F8iu6zS2HhLmr/NnNhgeNlY7fledAXgxev9y TUKEYIvrbQeYpqZ0jx6tqnDs+MD2mKsVgClr2Ru08YK55y7RZffVEdSLFwTeeI0kGzpF Dkf3kQo7NldEVDFowISnKphyjF7fLk1CnVMtcNyC6K65TDNcCjNEW7qeXDngWOVlHObv /sJg== 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=L3wkGUyEYRdXJyOM2Fs2uj3NALmxvGoM1q+6tiJwpq767wZGmp5mCW/0Z2mkfBrPL8 NEMgQlkfCQGaFXVGfvtGwNPSf+8Rb3pCw9IvIo3Th0oskYW+PeGvfrLH3NzahfqLWXDS 1nOh4BxWocpukhNOMntDuRajHz3U4fNhSWfyZ6WX3ZFtVeWTZDLLDCfEZTpar7BDpxkS 8ZTeuDLDbJ/inp/0Ck516ylacHynVmUmpXjJZ8ayOuYjjpDR/n3uTIppvtCIADGizgfJ OSE6gnumJeHSP0BrCJLLM0qWKE0/1MCkMDndlQukZuzggymzgiZh3Ohmp7brrsZU3aH7 ECoQ== X-Gm-Message-State: APjAAAWn349/d4sPdLSKDbBW+yFc3vyvMjt07SLhY+YfH/YrlcY7OAjh CcR+m7zmaM7C7Ai7XkOwbZI= X-Google-Smtp-Source: APXvYqxjrn23ApvCQzafM7tMebJ15yXX6D1flXgkxPRKN9E+zV3h/+BemsDAd4R1MIaYDAjaf6LTwg== X-Received: by 2002:a63:4620:: with SMTP id t32mr29273831pga.363.1553640610294; Tue, 26 Mar 2019 15:50:10 -0700 (PDT) Received: from Asurada-Nvidia.nvidia.com (thunderhill.nvidia.com. [216.228.112.22]) by smtp.gmail.com with ESMTPSA id 8sm56937368pfs.50.2019.03.26.15.50.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 26 Mar 2019 15:50:09 -0700 (PDT) From: Nicolin Chen To: hch@lst.de, robin.murphy@arm.com Subject: [PATCH RFC/RFT 3/5] iommu: amd_iommu: Add fallback normal page allocations Date: Tue, 26 Mar 2019 15:49:57 -0700 Message-Id: <20190326224959.9656-4-nicoleotsuka@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190326224959.9656-1-nicoleotsuka@gmail.com> References: <20190326224959.9656-1-nicoleotsuka@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190326_155011_700153_A43F7F0F X-CRM114-Status: GOOD ( 12.05 ) 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; }