From patchwork Fri Nov 9 08:24:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Boichat X-Patchwork-Id: 10675511 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 0C82914D6 for ; Fri, 9 Nov 2018 08:25:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F13CA2E661 for ; Fri, 9 Nov 2018 08:25:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E4C1A2E664; Fri, 9 Nov 2018 08:25:29 +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=-3.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW autolearn=unavailable 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 95BA72E661 for ; Fri, 9 Nov 2018 08:25:29 +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: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=Mc4YzfrNTU9pWPmLngfwletxgxS8K8G00zClfmSXEB8=; b=XgWTFQcgHoc/vV A57avkTh0/+UBU/kubHaDtIeK8MB+W4f5Yt0YpA5Vy6pRUgRxv542lLLH6s+vjquiFtpnxvKdq1nP FvXkg4GZFao7U5yamNdUgbJzvumzvJyoP/jfI7leO+b78Qa0/dzY2HDEWlSfKCrwOGgT3HnmTkCkJ p53ClWt9EohuGFLb3yh9+wyT3My3KuucmPROXoHDi/Pf9OtAaE5lG+CdKYNBHHRGeo8N3QRnOw6ur bl/84dk4cz9nZX+TSGrayrCp4UzAggymxmTA6a4F/xfrW53JYNm3h6NBy1C+Sip9XjZxJatKl3b02 UCaQdcQc6NOgFFIhiLjw==; 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 1gL26T-0007XE-T1; Fri, 09 Nov 2018 08:25:21 +0000 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gL26L-0006IR-MD for linux-arm-kernel@lists.infradead.org; Fri, 09 Nov 2018 08:25:15 +0000 Received: by mail-pg1-x544.google.com with SMTP id q5-v6so565039pgv.0 for ; Fri, 09 Nov 2018 00:25:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=InnuhSOGBaveThAeEjWNNfjdxk+ZL+DS5Ky3lmpgzcQ=; b=MAme0Iyr8teK/Ki5Pc6avc9NyM1ZACSxW+qUvWNMrPDfd+5+hhO3XR+a7YzIULs9Xw LTuccIQILw7lwgZkGKEYJ8IkgnwH17FFLvdUjMzhtytWGx+RpaPlb9jroe0/Joy2LiKV ehgDDj7Tu9x1mC2VMBhEPgXrCnbFfg6c2FBlk= 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:mime-version:content-transfer-encoding; bh=InnuhSOGBaveThAeEjWNNfjdxk+ZL+DS5Ky3lmpgzcQ=; b=ibP19q8ro/rtN2r1ZLKpCpn7+G6xAgFJkRBF1YMTVL+B2mv/nuooHJCd1Aegslq1rC 54Zzyd4BxqP6uga5BsJKSL2RXIBRrmxa5aStfunV68JzdBTw5bfIb11u3OaBOSqDnlDl kpupnAkrbhPyAtTda+KmsbWD9jWbOCuYFDAKyr3iVLFEIb5qLyjIXHlPClI1ug0Jl5zb kQOhl1Gc0ikBe1b4hW4X64gyt+xV7FXNY3wfFuJUIJliUDD4p3J+jiElr2wdEfRDYoeN QUHtFjrddrXJa0XkCkZ//T2oS2lDQ+Tz2rkyedfSrcQCGDTYr9FDIa1XWB3C5GRJBpry uWXg== X-Gm-Message-State: AGRZ1gKwWAof88zUL1SZvbcSs+0UqC9EgoD13Z2MzGHkzO7h+itj9jVk 7BtV1L7Udj83FNiD2m1l9dX6/g== X-Google-Smtp-Source: AJdET5f+WYjZSeRCglfwtnuJ6P5AzPDF6WiYotJEhF1tiG0JcbiXu7QnCbiBFLT3EFeBo3Z6Nv0E6w== X-Received: by 2002:a62:5e83:: with SMTP id s125-v6mr7944253pfb.232.1541751902866; Fri, 09 Nov 2018 00:25:02 -0800 (PST) Received: from drinkcat2.tpe.corp.google.com ([2401:fa00:1:b:f659:7f17:ea11:4e8e]) by smtp.gmail.com with ESMTPSA id u2-v6sm6415667pfn.50.2018.11.09.00.24.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 09 Nov 2018 00:25:02 -0800 (PST) From: Nicolas Boichat To: Robin Murphy Subject: [PATCH RFC 1/3] mm: When CONFIG_ZONE_DMA32 is set, use DMA32 for SLAB_CACHE_DMA Date: Fri, 9 Nov 2018 16:24:46 +0800 Message-Id: <20181109082448.150302-2-drinkcat@chromium.org> X-Mailer: git-send-email 2.19.1.930.g4563a0d9d0-goog In-Reply-To: <20181109082448.150302-1-drinkcat@chromium.org> References: <20181109082448.150302-1-drinkcat@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181109_002513_725240_4F066530 X-CRM114-Status: GOOD ( 14.54 ) 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: Michal Hocko , Andrew Morton , Huaisheng Ye , Tomasz Figa , Joerg Roedel , Will Deacon , linux-kernel@vger.kernel.org, Levin Alexander , Pekka Enberg , linux-mm@kvack.org, iommu@lists.linux-foundation.org, Mike Rapoport , linux-arm-kernel@lists.infradead.org, David Rientjes , Matthias Brugger , yingjoe.chen@mediatek.com, Joonsoo Kim , Yong Wu , Mel Gorman , Christoph Lameter , Vlastimil Babka 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 Some callers, namely iommu/io-pgtable-arm-v7s, expect the physical address returned by kmem_cache_alloc with GFP_DMA parameter to be a 32-bit address. Instead of adding a separate SLAB_CACHE_DMA32 (and then audit all the calls to check if they require memory from DMA or DMA32 zone), we simply allocate SLAB_CACHE_DMA cache in DMA32 region, if CONFIG_ZONE_DMA32 is set. Fixes: ad67f5a6545f ("arm64: replace ZONE_DMA with ZONE_DMA32") Signed-off-by: Nicolas Boichat --- include/linux/slab.h | 13 ++++++++++++- mm/slab.c | 2 +- mm/slub.c | 2 +- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/include/linux/slab.h b/include/linux/slab.h index 918f374e7156f4..390afe90c5dec0 100644 --- a/include/linux/slab.h +++ b/include/linux/slab.h @@ -30,7 +30,7 @@ #define SLAB_POISON ((slab_flags_t __force)0x00000800U) /* Align objs on cache lines */ #define SLAB_HWCACHE_ALIGN ((slab_flags_t __force)0x00002000U) -/* Use GFP_DMA memory */ +/* Use GFP_DMA or GFP_DMA32 memory */ #define SLAB_CACHE_DMA ((slab_flags_t __force)0x00004000U) /* DEBUG: Store the last owner for bug hunting */ #define SLAB_STORE_USER ((slab_flags_t __force)0x00010000U) @@ -126,6 +126,17 @@ #define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) <= \ (unsigned long)ZERO_SIZE_PTR) +/* + * When ZONE_DMA32 is defined, have SLAB_CACHE_DMA allocate memory with + * GFP_DMA32 instead of GFP_DMA, as this is what some of the callers + * require (instead of duplicating cache for DMA and DMA32 zones). + */ +#ifdef CONFIG_ZONE_DMA32 +#define SLAB_CACHE_DMA_GFP GFP_DMA32 +#else +#define SLAB_CACHE_DMA_GFP GFP_DMA +#endif + #include struct mem_cgroup; diff --git a/mm/slab.c b/mm/slab.c index 2a5654bb3b3ff3..8810daa052dcdc 100644 --- a/mm/slab.c +++ b/mm/slab.c @@ -2121,7 +2121,7 @@ int __kmem_cache_create(struct kmem_cache *cachep, slab_flags_t flags) cachep->flags = flags; cachep->allocflags = __GFP_COMP; if (flags & SLAB_CACHE_DMA) - cachep->allocflags |= GFP_DMA; + cachep->allocflags |= SLAB_CACHE_DMA_GFP; if (flags & SLAB_RECLAIM_ACCOUNT) cachep->allocflags |= __GFP_RECLAIMABLE; cachep->size = size; diff --git a/mm/slub.c b/mm/slub.c index e3629cd7aff164..fdd05323e54cbd 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -3575,7 +3575,7 @@ static int calculate_sizes(struct kmem_cache *s, int forced_order) s->allocflags |= __GFP_COMP; if (s->flags & SLAB_CACHE_DMA) - s->allocflags |= GFP_DMA; + s->allocflags |= SLAB_CACHE_DMA_GFP; if (s->flags & SLAB_RECLAIM_ACCOUNT) s->allocflags |= __GFP_RECLAIMABLE; From patchwork Fri Nov 9 08:24:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Boichat X-Patchwork-Id: 10675513 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 AE8225A4 for ; Fri, 9 Nov 2018 08:25:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9C4D42DC42 for ; Fri, 9 Nov 2018 08:25:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8E9DD2E664; Fri, 9 Nov 2018 08:25:42 +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=-3.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW 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 090232E661 for ; Fri, 9 Nov 2018 08:25:42 +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: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=2CPrh5p77dnOttIYQTB2Gb2QYoaSo3AuK4iL0G1MKh4=; b=A02OjB1WIFupbB Ylb2mG8EO7zbsZI/agyFCDh+6c+149lOs5cJX5etaMJZBsQBec/gHn6C+PcsrHHEsHbm8D4uTCpxY zMdaIDNuOJipqtEB2+oLbCHVcG44G+xGrRK3ffXqw/cuFjVdpEFWAq+lZyIVnGM1ueiMDVd2yxXiB YRI6ozCDczPngHsK0gR9m1nmGxKDYYc5F1Wq3V2aGK3KOhQ0h8VddYOogPZEys6tFisl2peK4Jfj0 YYvemwo0Fy+U0s5b7MQiSvY32QEQzhEPQ1vBJyHEnYzVUnlZREdv7fWiygA0fDZdKjcxYFSALC67o MaVXEvj+46KUzlZCOtvQ==; 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 1gL26e-0007mF-Tq; Fri, 09 Nov 2018 08:25:32 +0000 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gL26P-0006zs-JF for linux-arm-kernel@lists.infradead.org; Fri, 09 Nov 2018 08:25:18 +0000 Received: by mail-pf1-x441.google.com with SMTP id e22-v6so601471pfn.8 for ; Fri, 09 Nov 2018 00:25:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=LemySw+6VGiamWvqm4d+lqoRj+4VmarF9XYWRMSCiY0=; b=kXRqBVeNEZdfgT3ytQbgbNo0uRTe3Xsc6d3oPkkEZhjcWlI18sIckVu6vbliNO90tc olUj5T/CnTthMuYB9ChqlAk12gsPARZ7DmsTtDZXCLYlzQAffFO20/PQnFgJJl2kYV6j 5FpNkBRpuQUMncbBrRoIectbjBfuwZzMPWSr8= 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:mime-version:content-transfer-encoding; bh=LemySw+6VGiamWvqm4d+lqoRj+4VmarF9XYWRMSCiY0=; b=F3QgYkY7TkulZoj1ddOvNRWeu0c2ImsqKtTEhjpLSp+oV6QdqGXFgjh31uA0dX5MaC 2S59ZPsf0jXIXQzIo1c9qYnY2nDIAdcsS/gwpJD6i9V3qus/wXjRT6OH5eoWdjwS/oPH Q1pnwhjsda0yi0a+a19teKcMic89nE0GedIoszWp5Vl9cI2CU73eGRiHFmud80mLahSI RBCreG4vLxf/s/WdHB+eVymEI7luSDx245XkGwQGfgOJumAKMf8ZgF0RcVicB3W+O9Kx tcmzfwopajufm79eLB6G0MIiNKCVWvO5nKH1a0q9QBDB1hU3OY0JbDsXlJLKaytYidIH FbXA== X-Gm-Message-State: AGRZ1gJxEyPTbrS6yeLGr0tGIVogNMueB/7vzJT5kxTGxk96x2TL5jKn Ei2hgu1vGS24P4WOIHWbeAUwfQ== X-Google-Smtp-Source: AJdET5eNDtelDWete20VE7bb/tq+ntm0saZaFjUUpOGpXNsrDwjhGsWR0JG3+RHsaoUhprmNgBhOCQ== X-Received: by 2002:a62:7514:: with SMTP id q20-v6mr8165586pfc.8.1541751906702; Fri, 09 Nov 2018 00:25:06 -0800 (PST) Received: from drinkcat2.tpe.corp.google.com ([2401:fa00:1:b:f659:7f17:ea11:4e8e]) by smtp.gmail.com with ESMTPSA id u2-v6sm6415667pfn.50.2018.11.09.00.25.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 09 Nov 2018 00:25:06 -0800 (PST) From: Nicolas Boichat To: Robin Murphy Subject: [PATCH RFC 2/3] include/linux/gfp.h: Add __get_dma32_pages macro Date: Fri, 9 Nov 2018 16:24:47 +0800 Message-Id: <20181109082448.150302-3-drinkcat@chromium.org> X-Mailer: git-send-email 2.19.1.930.g4563a0d9d0-goog In-Reply-To: <20181109082448.150302-1-drinkcat@chromium.org> References: <20181109082448.150302-1-drinkcat@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181109_002517_641435_76654804 X-CRM114-Status: GOOD ( 11.73 ) 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: Michal Hocko , Andrew Morton , Huaisheng Ye , Tomasz Figa , Joerg Roedel , Will Deacon , linux-kernel@vger.kernel.org, Levin Alexander , Pekka Enberg , linux-mm@kvack.org, iommu@lists.linux-foundation.org, Mike Rapoport , linux-arm-kernel@lists.infradead.org, David Rientjes , Matthias Brugger , yingjoe.chen@mediatek.com, Joonsoo Kim , Yong Wu , Mel Gorman , Christoph Lameter , Vlastimil Babka 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 Some callers (e.g. iommu/io-pgtable-arm-v7s) require DMA32 memory when calling __get_dma_pages. Add a new macro for that purpose. Fixes: ad67f5a6545f ("arm64: replace ZONE_DMA with ZONE_DMA32") Signed-off-by: Nicolas Boichat --- include/linux/gfp.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/gfp.h b/include/linux/gfp.h index 76f8db0b0e715c..50e04896b78017 100644 --- a/include/linux/gfp.h +++ b/include/linux/gfp.h @@ -535,6 +535,8 @@ void * __meminit alloc_pages_exact_nid(int nid, size_t size, gfp_t gfp_mask); #define __get_dma_pages(gfp_mask, order) \ __get_free_pages((gfp_mask) | GFP_DMA, (order)) +#define __get_dma32_pages(gfp_mask, order) \ + __get_free_pages((gfp_mask) | GFP_DMA32, (order)) extern void __free_pages(struct page *page, unsigned int order); extern void free_pages(unsigned long addr, unsigned int order); From patchwork Fri Nov 9 08:24:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Boichat X-Patchwork-Id: 10675515 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 94FA114D6 for ; Fri, 9 Nov 2018 08:25:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 859E028FBA for ; Fri, 9 Nov 2018 08:25:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7883B2E2F2; Fri, 9 Nov 2018 08:25:55 +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=-3.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW 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 19FF928FBA for ; Fri, 9 Nov 2018 08:25:55 +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: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=Y8VBHoaBT0i/akrIP9dwzhjQ9SSfQwWGMnYmwFz3E1I=; b=JB5HWJoLEp3b/D uYaoyx7NzxfoLryc4mx1mu3fR8s43eYeoESLPhk35XiZAmxQ0XwPW371gggVQzZU9sZeNwf67BT9x ocT9RaqGqm+sXNP0hpVxPmUDnooucq6WiojlKfZB1W6/S5UxgDe2Vt42qZ/4lBBxQhJE+nruZUSc5 RKfEMf75+RTRW22ko0L3BWFTd4lUBMAwEpFDWgnx6l2kBBgvO36dZOQ4hAGGnXaFreQL6hmDsNIjp 6TmQlwN5rCYFRESQJObi24ZWisAfYQ5VRgP6E2X7e9v0mJXzsT8jp5ouyvMIV6bYntlg+rl1g3Y/d qur9OLeuoPIeF74gDKeg==; 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 1gL26s-00083M-Ik; Fri, 09 Nov 2018 08:25:46 +0000 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gL26T-0007MR-6w for linux-arm-kernel@lists.infradead.org; Fri, 09 Nov 2018 08:25:22 +0000 Received: by mail-pf1-x442.google.com with SMTP id n11-v6so604836pfb.6 for ; Fri, 09 Nov 2018 00:25:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=yRFndY2zWJb5bN9k8QGyB+00poAzGsSVjzJBS2+e7OE=; b=Iur53HJyqMem/YVgQlfnZkpmkDpU75IDHa1psWcirqFy2J7OUTJYecd2nH/Tm1VU4Y wHD0Wj4ikT4n1v9ophkIXv8eHbTkqamS77yub3whxQJ3ALJ5ShBRCmalyGimLeM0OTKZ KD55YMwDGgVT3dwjemx/XmpVCxgR0pphrkUVY= 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:mime-version:content-transfer-encoding; bh=yRFndY2zWJb5bN9k8QGyB+00poAzGsSVjzJBS2+e7OE=; b=OOJlgafF9lgJEBt8A/P2WmPrV3Y+IqxiFB0EM0ch5LTjCD784wuEOle8TW0bsCrUax 9wnLVeEo7w6SCA3pyUCseSLpAqxk4KPeCwtEMYEe2cMve//PcHO3XbuWFF6+3F6O/q0S 11wgfe9SJm32gGYl96zow+gYrIhaQnjnnces0/+mg/zT+wNYFO1c0J/OiR8Pf3kOS0a6 jFjmgF3V6tr8q/5IOSU7E+4FrCqttqIkxndnT854h1PqDclEOkD2KBppnFCqlzQzEodY 0AVGVTdtqWn9mjvMKWZ5vK7YWeipdbZwvcIeyRoCRlmqvdMnV94sy1t4E+vgit1zofWS B5LQ== X-Gm-Message-State: AGRZ1gJjs/rsJ9ch8HHAlhXYm2vfMn9upta94+YXu4CD4FVwoPa7JozK nVKKIhMRWoFAgRKMlPol/SyWgopmh5t/3WUd X-Google-Smtp-Source: AJdET5dCO8mv60sae7fHIDtGCVEJeKFEfFmKIeaExlKA/10SNZoPYXI7O9H3owoxai+S1I+fmnLhmg== X-Received: by 2002:a63:6984:: with SMTP id e126mr6756085pgc.143.1541751910462; Fri, 09 Nov 2018 00:25:10 -0800 (PST) Received: from drinkcat2.tpe.corp.google.com ([2401:fa00:1:b:f659:7f17:ea11:4e8e]) by smtp.gmail.com with ESMTPSA id u2-v6sm6415667pfn.50.2018.11.09.00.25.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 09 Nov 2018 00:25:09 -0800 (PST) From: Nicolas Boichat To: Robin Murphy Subject: [PATCH RFC 3/3] iommu/io-pgtable-arm-v7s: Request DMA32 memory, and improve debugging Date: Fri, 9 Nov 2018 16:24:48 +0800 Message-Id: <20181109082448.150302-4-drinkcat@chromium.org> X-Mailer: git-send-email 2.19.1.930.g4563a0d9d0-goog In-Reply-To: <20181109082448.150302-1-drinkcat@chromium.org> References: <20181109082448.150302-1-drinkcat@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181109_002521_263957_6461A91F X-CRM114-Status: GOOD ( 16.31 ) 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: Michal Hocko , Andrew Morton , Huaisheng Ye , Tomasz Figa , Joerg Roedel , Will Deacon , linux-kernel@vger.kernel.org, Levin Alexander , Pekka Enberg , linux-mm@kvack.org, iommu@lists.linux-foundation.org, Mike Rapoport , linux-arm-kernel@lists.infradead.org, David Rientjes , Matthias Brugger , yingjoe.chen@mediatek.com, Joonsoo Kim , Yong Wu , Mel Gorman , Christoph Lameter , Vlastimil Babka 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 For level 1 pages, use __get_dma32_pages to make sure physical memory address is 32-bit. For level 2 pages, kmem_cache_zalloc with GFP_DMA has been modified in a previous patch to be allocated in DMA32 zone. Also, print an error when the physical address does not fit in 32-bit, to make debugging easier in the future. Fixes: ad67f5a6545f ("arm64: replace ZONE_DMA with ZONE_DMA32") Signed-off-by: Nicolas Boichat --- drivers/iommu/io-pgtable-arm-v7s.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/iommu/io-pgtable-arm-v7s.c b/drivers/iommu/io-pgtable-arm-v7s.c index 445c3bde04800c..862fd404de84d8 100644 --- a/drivers/iommu/io-pgtable-arm-v7s.c +++ b/drivers/iommu/io-pgtable-arm-v7s.c @@ -198,13 +198,15 @@ static void *__arm_v7s_alloc_table(int lvl, gfp_t gfp, void *table = NULL; if (lvl == 1) - table = (void *)__get_dma_pages(__GFP_ZERO, get_order(size)); + table = (void *)__get_dma32_pages(__GFP_ZERO, get_order(size)); else if (lvl == 2) table = kmem_cache_zalloc(data->l2_tables, gfp | GFP_DMA); phys = virt_to_phys(table); - if (phys != (arm_v7s_iopte)phys) + if (phys != (arm_v7s_iopte)phys) { /* Doesn't fit in PTE */ + dev_err(dev, "Page table does not fit: %pa", &phys); goto out_free; + } if (table && !(cfg->quirks & IO_PGTABLE_QUIRK_NO_DMA)) { dma = dma_map_single(dev, table, size, DMA_TO_DEVICE); if (dma_mapping_error(dev, dma))