From patchwork Mon Jul 9 12:19:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 141399 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp2600203ljj; Mon, 9 Jul 2018 05:20:44 -0700 (PDT) X-Google-Smtp-Source: AAOMgpc9OlJ3NnDKr87rQsBy6K/N8kOLdN+jsJUWrZWzJrc86x+ThGfkk7ogKaegzR2L2CbrrERW X-Received: by 2002:a63:4d47:: with SMTP id n7-v6mr18713449pgl.270.1531138844507; Mon, 09 Jul 2018 05:20:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531138844; cv=none; d=google.com; s=arc-20160816; b=XRl1Kfa4PRPnru7WChNPK0Tzkh0TMiLRM00ishsk1wOnZMoOAa8mmQQkK9hOo+JTvR JPnKsmjINQSBqSEOCMez3cI2+2QrOPwOFUDyeJ0s8D38JyTkV+Nk7RzG8KKCKYz+M4Pn SJQxzGYqQNSh41Vtlnc6el5Rc+p2rIiSyT6DL0pSedjLZO3cvYYXpe70YlmlFXqv0jYN ZBOuO6XhAgcy+ZHiofDayrYswPluFVENoTL0Eb63gqtuA93yrkv51T+4GItQjjSyEJUX r6iopFqin+9hUKwWuGcYFVfZvT07w+TDxzUnXBp6v1Nbfi7xqfrdLEvhr74pztlAyIcO hacw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:cms-type:message-id :in-reply-to:date:subject:cc:to:from:dkim-signature:dkim-filter :arc-authentication-results; bh=7a8sDyhqOTgN/n1BR+E2/tqwrVB55JiXnhqmVV0jYcU=; b=tTjAl8TYTUbwWXvXBmr9gvoPXmHtSCbFpxEdaw7/x0bHb3pcZw+dPjgkoPBOU7AuMv byhrCxrojS2OGXPKbY8IkohXysXkkNmJH/wdwMYH+aKtg5pHB2/MQCH3WKl7EZWiZv4h 7j8VgrtOD67y5B827zvGzsEX5ntJCnBiKlzUrII9oJmJsTbP88otPCEO08nkr+iKzaIb x8vTIdqa3jn+uWF5JL8N/szJKGP26Xvxqs8o6NUZOHBKDjkTkAui3WZadCe9eb8oWGkt B51uuhd7kDDiqlF5GG9NxrLs37kxiq+h6vGuiJS0dqcc1jZ1kRVcU7LlPhw8xFxMwzzv bEVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=NgJvOrr8; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e7-v6si13828770pgf.317.2018.07.09.05.20.44; Mon, 09 Jul 2018 05:20:44 -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=pass header.i=@samsung.com header.s=mail20170921 header.b=NgJvOrr8; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933179AbeGIMUn (ORCPT + 31 others); Mon, 9 Jul 2018 08:20:43 -0400 Received: from mailout1.w1.samsung.com ([210.118.77.11]:45182 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932949AbeGIMUX (ORCPT ); Mon, 9 Jul 2018 08:20:23 -0400 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20180709122021euoutp013608d91fdc270b0f990a552d5bc1e004~-sqVtcZV61581215812euoutp01B for ; Mon, 9 Jul 2018 12:20:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20180709122021euoutp013608d91fdc270b0f990a552d5bc1e004~-sqVtcZV61581215812euoutp01B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1531138821; bh=7a8sDyhqOTgN/n1BR+E2/tqwrVB55JiXnhqmVV0jYcU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NgJvOrr80+oWDTOCw5nJJRFQ2v3+WvB9B30qQ1AI3cRXU8Haks9FMbdXauDhFo5o9 miduJJ4SGtgmKHds6Bzd7siifhU93GiDjuV2fuNfA/EAVUlqa3/5srWt0DY+Cj8SFX 4FukRs5F68iD5pxTgICBgEHw/S8ZQx/pHGw7LhYs= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20180709122019eucas1p10f2fc51b8ede3712f7610523227ffe36~-sqT6-lew1760617606eucas1p1U; Mon, 9 Jul 2018 12:20:19 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id C4.58.05700.303534B5; Mon, 9 Jul 2018 13:20:19 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20180709122019eucas1p2340da484acfcc932537e6014f4fd2c29~-sqTPJKij2939229392eucas1p2j; Mon, 9 Jul 2018 12:20:19 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20180709122018eusmtrp20e11a2eb9793fdd2a5091b39dfd5f9e2~-sqS-oKnB0639506395eusmtrp2k; Mon, 9 Jul 2018 12:20:18 +0000 (GMT) X-AuditID: cbfec7f2-1dbff70000011644-d0-5b4353035db5 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 25.CF.04183.203534B5; Mon, 9 Jul 2018 13:20:18 +0100 (BST) Received: from AMDC2765.digital.local (unknown [106.116.147.25]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20180709122018eusmtip23ae66e3c343425162a095093782a0b9f~-sqSHyKj91870018700eusmtip22; Mon, 9 Jul 2018 12:20:18 +0000 (GMT) From: Marek Szyprowski To: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, iommu@lists.linux-foundation.org Cc: Marek Szyprowski , Andrew Morton , Michal Nazarewicz , Joonsoo Kim , Vlastimil Babka , Christoph Hellwig , Michal Hocko , Russell King , Catalin Marinas , Will Deacon , Paul Mackerras , Benjamin Herrenschmidt , Chris Zankel , Martin Schwidefsky , Joerg Roedel , Sumit Semwal , Robin Murphy , Laura Abbott , linaro-mm-sig@lists.linaro.org Subject: [PATCH 1/2] mm/cma: remove unsupported gfp_mask parameter from cma_alloc() Date: Mon, 9 Jul 2018 14:19:55 +0200 X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180709121956.20200-1-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA0WSe0yNcRzG/d57cex1snwXGzvmLmmYH1ku2fw2/7SZ/qgNJ71LU+G8KpeN dHRxpLkMSXSRcuqkpFoXt3OkY0UptEwJZXNrHZIO0XFer8t/n+d5vs+e3969Aq1N5XyEqNjd kiFWH63jPJnqxm8tvvSGoLCFpc3zcXaZhcOOpGQaDxSmI3w0v4jD5pJ7FDYfNXI493YAPnK+ nMfmG04Kf3nyisIVvR0sflyXzeEXFheLbadvIjwyPMri0oZuHvdkrMK59sMsvpDt5LDV0cfi wZYUHjd1D/L4/KEMhN99us+sAtJnvUgRy0ULIo872mhifW3jSPrHwyyp+HySJ6b+JxTp6rjB kfuZIwy5XnCQPB/tpcmpziJEWjPzEK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eukahj5RaNpOUxDE2N91DoXfka gZ48zEGfNyw4uj3ZCJC5/D5ALz4ZKNS6/hVDxo8jdNSeGOVRnTZDL3ikaEV9qCJWBf2UqmCo 9AsIVqr81WdD/AIVPmFHk4S01ExB5xOWoEzpnm+jL3QfvlRsziUMoMBTAs4MxwZwH+ottARc GDn7CHCDc7m0Q9jHDZYZSAd25dbHJcphsgEud9i2LVCsipOWHYIb+wBwK5sj5NaAs79JzlJR TkiAYVzZaK5rSbMVINgDXO3bMmyLlrGhXMvqIceC/VxT+2t8CzuzYVxt3+Y2ltstBUtDRCnY VQecHgM3IUPUJGtEP6XIa8SM9GRlolbTAexHfv529WknkL5HmwDLAMVOmfXisVg5yWeKWRoT 4Bhc4SbjQ+yULInPuizotPG6jDRBNIFAe6ebuPvuRK39ZdL18apAlRoGq9T+av8gqNgrM/tm xcjZZF4vnBeEC4Lufw5jnN0NYCLihjKyckda3GRqdA8tXYma7bS2xK2dnlSUxOaHr8SfKYwI 9po+0RWeMhCRPZWTfTegpghVnBs2nGotDK1eeN+VndP07GDODXXd2vllo3laG+Lk88Yj6N6A zbfhJBqMJ/tLPa0fLCBvuICfCm1JMHtPtA5FSscmjmTPdWx+y1QQYgqv8sJ1Iv8Pb7wBTvoC AAA= Message-Id: <20180709122019eucas1p2340da484acfcc932537e6014f4fd2c29~-sqTPJKij2939229392eucas1p2j@eucas1p2.samsung.com> X-CMS-MailID: 20180709122019eucas1p2340da484acfcc932537e6014f4fd2c29 X-Msg-Generator: CA X-RootMTR: 20180709122019eucas1p2340da484acfcc932537e6014f4fd2c29 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20180709122019eucas1p2340da484acfcc932537e6014f4fd2c29 References: <20180709121956.20200-1-m.szyprowski@samsung.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org cma_alloc() function doesn't really support gfp flags other than __GFP_NOWARN, so convert gfp_mask parameter to boolean no_warn parameter. This will help to avoid giving false feeling that this function supports standard gfp flags and callers can pass __GFP_ZERO to get zeroed buffer, what has already been an issue: see commit dd65a941f6ba ("arm64: dma-mapping: clear buffers allocated with FORCE_CONTIGUOUS flag"). Signed-off-by: Marek Szyprowski --- arch/powerpc/kvm/book3s_hv_builtin.c | 2 +- drivers/s390/char/vmcp.c | 2 +- drivers/staging/android/ion/ion_cma_heap.c | 2 +- include/linux/cma.h | 2 +- kernel/dma/contiguous.c | 3 ++- mm/cma.c | 8 ++++---- mm/cma_debug.c | 2 +- 7 files changed, 11 insertions(+), 10 deletions(-) -- 2.17.1 Acked-by: Michal Hocko Acked-by: Laura Abbott Acked-by: Vlastimil Babka Reviewed-by: Christoph Hellwig diff --git a/arch/powerpc/kvm/book3s_hv_builtin.c b/arch/powerpc/kvm/book3s_hv_builtin.c index d4a3f4da409b..fc6bb9630a9c 100644 --- a/arch/powerpc/kvm/book3s_hv_builtin.c +++ b/arch/powerpc/kvm/book3s_hv_builtin.c @@ -77,7 +77,7 @@ struct page *kvm_alloc_hpt_cma(unsigned long nr_pages) VM_BUG_ON(order_base_2(nr_pages) < KVM_CMA_CHUNK_ORDER - PAGE_SHIFT); return cma_alloc(kvm_cma, nr_pages, order_base_2(HPT_ALIGN_PAGES), - GFP_KERNEL); + false); } EXPORT_SYMBOL_GPL(kvm_alloc_hpt_cma); diff --git a/drivers/s390/char/vmcp.c b/drivers/s390/char/vmcp.c index 948ce82a7725..0fa1b6b1491a 100644 --- a/drivers/s390/char/vmcp.c +++ b/drivers/s390/char/vmcp.c @@ -68,7 +68,7 @@ static void vmcp_response_alloc(struct vmcp_session *session) * anymore the system won't work anyway. */ if (order > 2) - page = cma_alloc(vmcp_cma, nr_pages, 0, GFP_KERNEL); + page = cma_alloc(vmcp_cma, nr_pages, 0, false); if (page) { session->response = (char *)page_to_phys(page); session->cma_alloc = 1; diff --git a/drivers/staging/android/ion/ion_cma_heap.c b/drivers/staging/android/ion/ion_cma_heap.c index 49718c96bf9e..3fafd013d80a 100644 --- a/drivers/staging/android/ion/ion_cma_heap.c +++ b/drivers/staging/android/ion/ion_cma_heap.c @@ -39,7 +39,7 @@ static int ion_cma_allocate(struct ion_heap *heap, struct ion_buffer *buffer, if (align > CONFIG_CMA_ALIGNMENT) align = CONFIG_CMA_ALIGNMENT; - pages = cma_alloc(cma_heap->cma, nr_pages, align, GFP_KERNEL); + pages = cma_alloc(cma_heap->cma, nr_pages, align, false); if (!pages) return -ENOMEM; diff --git a/include/linux/cma.h b/include/linux/cma.h index bf90f0bb42bd..190184b5ff32 100644 --- a/include/linux/cma.h +++ b/include/linux/cma.h @@ -33,7 +33,7 @@ extern int cma_init_reserved_mem(phys_addr_t base, phys_addr_t size, const char *name, struct cma **res_cma); extern struct page *cma_alloc(struct cma *cma, size_t count, unsigned int align, - gfp_t gfp_mask); + bool no_warn); extern bool cma_release(struct cma *cma, const struct page *pages, unsigned int count); extern int cma_for_each_area(int (*it)(struct cma *cma, void *data), void *data); diff --git a/kernel/dma/contiguous.c b/kernel/dma/contiguous.c index d987dcd1bd56..19ea5d70150c 100644 --- a/kernel/dma/contiguous.c +++ b/kernel/dma/contiguous.c @@ -191,7 +191,8 @@ struct page *dma_alloc_from_contiguous(struct device *dev, size_t count, if (align > CONFIG_CMA_ALIGNMENT) align = CONFIG_CMA_ALIGNMENT; - return cma_alloc(dev_get_cma_area(dev), count, align, gfp_mask); + return cma_alloc(dev_get_cma_area(dev), count, align, + gfp_mask & __GFP_NOWARN); } /** diff --git a/mm/cma.c b/mm/cma.c index 5809bbe360d7..4cb76121a3ab 100644 --- a/mm/cma.c +++ b/mm/cma.c @@ -395,13 +395,13 @@ static inline void cma_debug_show_areas(struct cma *cma) { } * @cma: Contiguous memory region for which the allocation is performed. * @count: Requested number of pages. * @align: Requested alignment of pages (in PAGE_SIZE order). - * @gfp_mask: GFP mask to use during compaction + * @no_warn: Avoid printing message about failed allocation * * This function allocates part of contiguous memory on specific * contiguous memory area. */ struct page *cma_alloc(struct cma *cma, size_t count, unsigned int align, - gfp_t gfp_mask) + bool no_warn) { unsigned long mask, offset; unsigned long pfn = -1; @@ -447,7 +447,7 @@ struct page *cma_alloc(struct cma *cma, size_t count, unsigned int align, pfn = cma->base_pfn + (bitmap_no << cma->order_per_bit); mutex_lock(&cma_mutex); ret = alloc_contig_range(pfn, pfn + count, MIGRATE_CMA, - gfp_mask); + GFP_KERNEL | (no_warn ? __GFP_NOWARN : 0)); mutex_unlock(&cma_mutex); if (ret == 0) { page = pfn_to_page(pfn); @@ -466,7 +466,7 @@ struct page *cma_alloc(struct cma *cma, size_t count, unsigned int align, trace_cma_alloc(pfn, page, count, align); - if (ret && !(gfp_mask & __GFP_NOWARN)) { + if (ret && !no_warn) { pr_err("%s: alloc failed, req-size: %zu pages, ret: %d\n", __func__, count, ret); cma_debug_show_areas(cma); diff --git a/mm/cma_debug.c b/mm/cma_debug.c index f23467291cfb..ad6723e9d110 100644 --- a/mm/cma_debug.c +++ b/mm/cma_debug.c @@ -139,7 +139,7 @@ static int cma_alloc_mem(struct cma *cma, int count) if (!mem) return -ENOMEM; - p = cma_alloc(cma, count, 0, GFP_KERNEL); + p = cma_alloc(cma, count, 0, false); if (!p) { kfree(mem); return -ENOMEM; From patchwork Mon Jul 9 12:19:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 141398 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp2600195ljj; Mon, 9 Jul 2018 05:20:44 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdVbtK5KQHf/xf48hQ3rwuzj8Ve0ZsgYUKRN9f/tx+4vQCpzeeHoRzxwFrwHGnXlA4fVkCM X-Received: by 2002:a63:f18:: with SMTP id e24-v6mr18931641pgl.320.1531138844090; Mon, 09 Jul 2018 05:20:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531138844; cv=none; d=google.com; s=arc-20160816; b=c86B+c3zQhij2cqkJw9BOyy1Z1KLLKqrPH/3SBvZOct2Y2E+Cq3b7wEh8N5ZeDMZCZ ss4VrrrwGcqXSnNXubYIE5xdKQwUwFCG7smp9Q/Oefs9Y8aK8DoZ/gQ69xVzeGEF8sLZ oz5EmPa6qXkOuw8+uzunuHAFgcwT+X9LccPREzbu1BcsJVmfWjjAWJbcw1aoIkN6RpYo mXLSJF6M89BKq/nlp7hhKxztiJaOxjDx6cX1nh3rX8JtHJW0aK+WAdURwjspEAgCODIf lV5V6zvGF2utTMKFQDkdElLNRMhu57lVIKHCt+8X87c09iisQ9XZnHpxMfQSNPECvAsH xTfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:cms-type:message-id :in-reply-to:date:subject:cc:to:from:dkim-signature:dkim-filter :arc-authentication-results; bh=/sGu62G34gZWe6yiP8J3NnQCnvipI839Mo7SBSyiJog=; b=AO4ASZqJ2KmMUSnUwJAr9/Z8piZRKY0HxUm52+szDUEtFYj5MXgoa+s91pu0F0mG/S xTa9qABJWYc9a18rK+OHQQpLUIJ0ngI3KjcnaDy0kPR5YdHlz0aRHNkPN6q2DsrzUpQe kBEQxZEvN2IxV0LgzyTYpjDkDBx2JMxPw4BuKSJULs+8zFfycIouNREPspe5pw70Aa2q ipw+QYWYCVsG7w3tPR0vVGijWIIM0OEdoZiPqscQYTRGorLr6bnIzBvlVNLsvRzRJY2N J6eQgSNPENMbie1D5sLR1QAs8iDFn9IXHGRonA52estrbetqlUGX+6D1jOEWV1ibqmD9 6+eg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=DXa1Vnwr; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e7-v6si13828770pgf.317.2018.07.09.05.20.43; Mon, 09 Jul 2018 05:20:44 -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=pass header.i=@samsung.com header.s=mail20170921 header.b=DXa1Vnwr; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933136AbeGIMUl (ORCPT + 31 others); Mon, 9 Jul 2018 08:20:41 -0400 Received: from mailout2.w1.samsung.com ([210.118.77.12]:32957 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933027AbeGIMUY (ORCPT ); Mon, 9 Jul 2018 08:20:24 -0400 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20180709122022euoutp0237a9e985b945105be3364a26347ea47f~-sqV8kSsX0090600906euoutp02P for ; Mon, 9 Jul 2018 12:20:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20180709122022euoutp0237a9e985b945105be3364a26347ea47f~-sqV8kSsX0090600906euoutp02P DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1531138822; bh=/sGu62G34gZWe6yiP8J3NnQCnvipI839Mo7SBSyiJog=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DXa1Vnwr3+Gd3Z5A+tkIYpwVtLdlmYBvyeS1zhfqn1K+nzc+/SQATiIdjHJW4g2jD IZpqNQNh3uufQnhOaIVAlpshHEjR8W8CYWKDQ5I05F/2CUaIAYNwSj7J6By9l0rIsC WNLR9eTI/FL7+v+K/aLoUBsDH4Vsj7+b+TJfJp3M= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20180709122021eucas1p1236151189c3e5f127406642f222b5591~-sqVFbf4M0876608766eucas1p1I; Mon, 9 Jul 2018 12:20:21 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 2E.B9.17380.403534B5; Mon, 9 Jul 2018 13:20:20 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20180709122020eucas1p21a71b092975cb4a3b9954ffc63f699d1~-sqUFoa-h2939329393eucas1p2Y; Mon, 9 Jul 2018 12:20:20 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20180709122019eusmtrp2e92e421e7a90a8ce48dd7b32d05f5277~-sqT2K2fn0663106631eusmtrp2K; Mon, 9 Jul 2018 12:20:19 +0000 (GMT) X-AuditID: cbfec7f4-713ff700000043e4-f8-5b4353047272 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id D6.CF.04183.303534B5; Mon, 9 Jul 2018 13:20:19 +0100 (BST) Received: from AMDC2765.digital.local (unknown [106.116.147.25]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20180709122018eusmtip2d6617189d863d5e3ed86a7dbc1296e3a~-sqS-S3QW1821818218eusmtip2I; Mon, 9 Jul 2018 12:20:18 +0000 (GMT) From: Marek Szyprowski To: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, iommu@lists.linux-foundation.org Cc: Marek Szyprowski , Andrew Morton , Michal Nazarewicz , Joonsoo Kim , Vlastimil Babka , Christoph Hellwig , Michal Hocko , Russell King , Catalin Marinas , Will Deacon , Paul Mackerras , Benjamin Herrenschmidt , Chris Zankel , Martin Schwidefsky , Joerg Roedel , Sumit Semwal , Robin Murphy , Laura Abbott , linaro-mm-sig@lists.linaro.org Subject: [PATCH 2/2] dma: remove unsupported gfp_mask parameter from dma_alloc_from_contiguous() Date: Mon, 9 Jul 2018 14:19:56 +0200 X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180709121956.20200-1-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA0VSe0hTURjv3Lv7cDS5zsrTA6KFoj3sSRwyKrPoEL0wKOi97DKlzdluakWU r8o2lR5UYmtaaGrNB8tKbVabrkmBZaVpT0v/sEjzsV40XNuu1X/f7/X9Dh+HJeUn6UlsQuIB XpeoVCtoqeT2w19PZks2xWyb2/1yMTJWmWk0kHGcRF+v5QBkuFpKo/IbDgKVGzJpVHQ/Cp26 VM2gcutPArlefCCQpbudQs/rjTR6Z/ZQyH6+AaDfP0YoVNH0lkHv85ajImcWhS4bf9LINtBD oeGWEwx69HaYQZfS8wD6NNgsWQ5xj81EYLPJDPDz9lYS2z7aaZzzJYvClqGzDNb3vSDwm3Yr jZvzf0vwzeJj+PVIN4nPdZQC/CT/CsB3O9NoXOn+TODyZ63MxglbpUv28uqEFF43Z+luabyx cUNS76KDtuISOg18naUHASzkFsIz7S5KD6SsnCsDsKY/kxCBC8ChiyW0CIYBrDZUkX8jafeK R12lAGZXDUpE8A3ASquF8blobh7U9+n98XFcIYBdtgx/C8n1ULDXo/e7grk9MLsu3b9XwoVC 87d0IHZMhTeqH/j5AG4pLGzykL4w5KwsfF3zlPIJMi4Fll747n0I6xVWwlfvVGI2GH521jDi PAV66goJMZsJ4Mn8AkYEOQDeMtbSoisKNjpbKd8ikouAVfVzRDoamm+ZRvcHwo6+IB9Nesez ty+SIi2D2SfkojsMFjgr/9Xanj4bPReGWQ1ORrzQGQBzrLXkaTC14H9ZEQDXQQifLGhUvDA/ k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7EaAp01ERmKdHkfGCaySuJNzQ1NLewNDQ3Njc2s1AS5z1vUBklJJCeWJKa nZpakFoE08fEwSnVwGgWckyvu6FQeQPzPK0jpq9/Xt1h7xtrtvLqPcmXK4/snm31tzGR3fXx jJ0/5KMP8TfvNtR/W/h7/3euTOPgf7pLQ790/Yvz3ua56bqc/MHHixYWTH3jlP1I6tXulLxN 2idL3FVSHCYd/XlYsvB38oTVf1U4RTWMPp2oXZe0WXFv9l2H9dxFezcpsRRnJBpqMRcVJwIA Yashu/sCAAA= Message-Id: <20180709122020eucas1p21a71b092975cb4a3b9954ffc63f699d1~-sqUFoa-h2939329393eucas1p2Y@eucas1p2.samsung.com> X-CMS-MailID: 20180709122020eucas1p21a71b092975cb4a3b9954ffc63f699d1 X-Msg-Generator: CA X-RootMTR: 20180709122020eucas1p21a71b092975cb4a3b9954ffc63f699d1 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20180709122020eucas1p21a71b092975cb4a3b9954ffc63f699d1 References: <20180709121956.20200-1-m.szyprowski@samsung.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The CMA memory allocator doesn't support standard gfp flags for memory allocation, so there is no point having it as a parameter for dma_alloc_from_contiguous() function. Replace it by a boolean no_warn argument, which covers all the underlaying cma_alloc() function supports. This will help to avoid giving false feeling that this function supports standard gfp flags and callers can pass __GFP_ZERO to get zeroed buffer, what has already been an issue: see commit dd65a941f6ba ("arm64: dma-mapping: clear buffers allocated with FORCE_CONTIGUOUS flag"). Signed-off-by: Marek Szyprowski --- arch/arm/mm/dma-mapping.c | 5 +++-- arch/arm64/mm/dma-mapping.c | 4 ++-- arch/xtensa/kernel/pci-dma.c | 2 +- drivers/iommu/amd_iommu.c | 2 +- drivers/iommu/intel-iommu.c | 3 ++- include/linux/dma-contiguous.h | 4 ++-- kernel/dma/contiguous.c | 7 +++---- kernel/dma/direct.c | 3 ++- 8 files changed, 16 insertions(+), 14 deletions(-) -- 2.17.1 Acked-by: Vlastimil Babka Reviewed-by: Christoph Hellwig diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c index be0fa7e39c26..121c6c3ba9e0 100644 --- a/arch/arm/mm/dma-mapping.c +++ b/arch/arm/mm/dma-mapping.c @@ -594,7 +594,7 @@ static void *__alloc_from_contiguous(struct device *dev, size_t size, struct page *page; void *ptr = NULL; - page = dma_alloc_from_contiguous(dev, count, order, gfp); + page = dma_alloc_from_contiguous(dev, count, order, gfp & __GFP_NOWARN); if (!page) return NULL; @@ -1294,7 +1294,8 @@ static struct page **__iommu_alloc_buffer(struct device *dev, size_t size, unsigned long order = get_order(size); struct page *page; - page = dma_alloc_from_contiguous(dev, count, order, gfp); + page = dma_alloc_from_contiguous(dev, count, order, + gfp & __GFP_NOWARN); if (!page) goto error; diff --git a/arch/arm64/mm/dma-mapping.c b/arch/arm64/mm/dma-mapping.c index 61e93f0b5482..072c51fb07d7 100644 --- a/arch/arm64/mm/dma-mapping.c +++ b/arch/arm64/mm/dma-mapping.c @@ -355,7 +355,7 @@ static int __init atomic_pool_init(void) if (dev_get_cma_area(NULL)) page = dma_alloc_from_contiguous(NULL, nr_pages, - pool_size_order, GFP_KERNEL); + pool_size_order, false); else page = alloc_pages(GFP_DMA32, pool_size_order); @@ -573,7 +573,7 @@ static void *__iommu_alloc_attrs(struct device *dev, size_t size, struct page *page; page = dma_alloc_from_contiguous(dev, size >> PAGE_SHIFT, - get_order(size), gfp); + get_order(size), gfp & __GFP_NOWARN); if (!page) return NULL; diff --git a/arch/xtensa/kernel/pci-dma.c b/arch/xtensa/kernel/pci-dma.c index ba4640cc0093..b2c7ba91fb08 100644 --- a/arch/xtensa/kernel/pci-dma.c +++ b/arch/xtensa/kernel/pci-dma.c @@ -137,7 +137,7 @@ static void *xtensa_dma_alloc(struct device *dev, size_t size, if (gfpflags_allow_blocking(flag)) page = dma_alloc_from_contiguous(dev, count, get_order(size), - flag); + flag & __GFP_NOWARN); if (!page) page = alloc_pages(flag, get_order(size)); diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c index 64cfe854e0f5..5ec97ffb561a 100644 --- a/drivers/iommu/amd_iommu.c +++ b/drivers/iommu/amd_iommu.c @@ -2622,7 +2622,7 @@ static void *alloc_coherent(struct device *dev, size_t size, return NULL; page = dma_alloc_from_contiguous(dev, size >> PAGE_SHIFT, - get_order(size), flag); + get_order(size), flag & __GFP_NOWARN); if (!page) return NULL; } diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c index 869321c594e2..dd2d343428ab 100644 --- a/drivers/iommu/intel-iommu.c +++ b/drivers/iommu/intel-iommu.c @@ -3746,7 +3746,8 @@ static void *intel_alloc_coherent(struct device *dev, size_t size, if (gfpflags_allow_blocking(flags)) { unsigned int count = size >> PAGE_SHIFT; - page = dma_alloc_from_contiguous(dev, count, order, flags); + page = dma_alloc_from_contiguous(dev, count, order, + flags & __GFP_NOWARN); if (page && iommu_no_mapping(dev) && page_to_phys(page) + size > dev->coherent_dma_mask) { dma_release_from_contiguous(dev, page, count); diff --git a/include/linux/dma-contiguous.h b/include/linux/dma-contiguous.h index 3c5a4cb3eb95..f247e8aa5e3d 100644 --- a/include/linux/dma-contiguous.h +++ b/include/linux/dma-contiguous.h @@ -112,7 +112,7 @@ static inline int dma_declare_contiguous(struct device *dev, phys_addr_t size, } struct page *dma_alloc_from_contiguous(struct device *dev, size_t count, - unsigned int order, gfp_t gfp_mask); + unsigned int order, bool no_warn); bool dma_release_from_contiguous(struct device *dev, struct page *pages, int count); @@ -145,7 +145,7 @@ int dma_declare_contiguous(struct device *dev, phys_addr_t size, static inline struct page *dma_alloc_from_contiguous(struct device *dev, size_t count, - unsigned int order, gfp_t gfp_mask) + unsigned int order, bool no_warn) { return NULL; } diff --git a/kernel/dma/contiguous.c b/kernel/dma/contiguous.c index 19ea5d70150c..286d82329eb0 100644 --- a/kernel/dma/contiguous.c +++ b/kernel/dma/contiguous.c @@ -178,7 +178,7 @@ int __init dma_contiguous_reserve_area(phys_addr_t size, phys_addr_t base, * @dev: Pointer to device for which the allocation is performed. * @count: Requested number of pages. * @align: Requested alignment of pages (in PAGE_SIZE order). - * @gfp_mask: GFP flags to use for this allocation. + * @no_warn: Avoid printing message about failed allocation. * * This function allocates memory buffer for specified device. It uses * device specific contiguous memory area if available or the default @@ -186,13 +186,12 @@ int __init dma_contiguous_reserve_area(phys_addr_t size, phys_addr_t base, * function. */ struct page *dma_alloc_from_contiguous(struct device *dev, size_t count, - unsigned int align, gfp_t gfp_mask) + unsigned int align, bool no_warn) { if (align > CONFIG_CMA_ALIGNMENT) align = CONFIG_CMA_ALIGNMENT; - return cma_alloc(dev_get_cma_area(dev), count, align, - gfp_mask & __GFP_NOWARN); + return cma_alloc(dev_get_cma_area(dev), count, align, no_warn); } /** diff --git a/kernel/dma/direct.c b/kernel/dma/direct.c index 8be8106270c2..e0241beeb645 100644 --- a/kernel/dma/direct.c +++ b/kernel/dma/direct.c @@ -78,7 +78,8 @@ void *dma_direct_alloc(struct device *dev, size_t size, dma_addr_t *dma_handle, again: /* CMA can be used only in the context which permits sleeping */ if (gfpflags_allow_blocking(gfp)) { - page = dma_alloc_from_contiguous(dev, count, page_order, gfp); + page = dma_alloc_from_contiguous(dev, count, page_order, + gfp & __GFP_NOWARN); if (page && !dma_coherent_ok(dev, page_to_phys(page), size)) { dma_release_from_contiguous(dev, page, count); page = NULL;