Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp473841imu; Fri, 9 Nov 2018 00:25:56 -0800 (PST) X-Google-Smtp-Source: AJdET5e7abDXuqyByWHhjh5PqgjcjyUxcmHGRQsJcJOe/GzEvS/UNaTeF51s+7qCd8ONNl1gh3e5 X-Received: by 2002:a62:6d07:: with SMTP id i7-v6mr7507688pfc.146.1541751956658; Fri, 09 Nov 2018 00:25:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541751956; cv=none; d=google.com; s=arc-20160816; b=OGFaSvN4WQhrUMIwJmtr2F5VeFKuujax25WCXz5U3ddkiJxsF3V2iu8yVKSe9gEJB1 PARXZULfdbpsEhZQT3Bz4h8JCvbj04XZU8vDaWVBmqqllrmy/CZmsoBhHwI/GpzZEGyI qz9V4c6h2MOImJNm9si9RYNUXYyqz/uk9DhuGK34KSJ7u8VsyULgtdltJx6ZF51/i6HI qJwUQF6XfK4yXllOUvIIjiLDGXTIlH0miyiOUR0bFoVWBmIbzzkUXuxjqOiIbiXiootq 3USgY6mFavBr2cwYHdmpsWgOGxLNky+s43XoR0vYXfXEPT6AcsytuzHJyzyuOAYKsWry eZMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=yRFndY2zWJb5bN9k8QGyB+00poAzGsSVjzJBS2+e7OE=; b=g/GiY3yhDxpxJW1Wrzm3q/dCIkOAXEsDSINIDpgy4q2ZkV2aTu5mHqZ97Z0izsLMsP aeNsJRlRO06LPHpKk4wrolPhRdGPckCcGftBJ3HFoZ27cDCfqgJa0vcEGTobdRiph9s2 RuxFnA9xZ4Mdr1DfOU0MZjKAxfsSO+ep48kxX0Bf9AE3wh+fylpX/aC8IDrPNKrbpLIw Kv6kwwTEeR4QUxG32cQ/xsSrT+Zs9p4rj177kf0XS8o09+8XaLm0/7N5Dlh3hyHaDwcZ pe5qBx0d2QzxmZ5xJAddQMHqsBFUcwszVC12rrpgP1FTCSQGSnhi907bZIE/giEe1TZ8 +0VQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Iur53HJy; 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=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 1-v6si7971859pls.0.2018.11.09.00.25.41; Fri, 09 Nov 2018 00:25:56 -0800 (PST) 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=@chromium.org header.s=google header.b=Iur53HJy; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727819AbeKISEl (ORCPT + 99 others); Fri, 9 Nov 2018 13:04:41 -0500 Received: from mail-pg1-f193.google.com ([209.85.215.193]:38738 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727518AbeKISEk (ORCPT ); Fri, 9 Nov 2018 13:04:40 -0500 Received: by mail-pg1-f193.google.com with SMTP id f8-v6so553341pgq.5 for ; Fri, 09 Nov 2018 00:25:10 -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=pb92zYKZeRhCvWKCr/xwW2ro4Fos5LK+YzjsNI2mtw3i9MPuOa94RmlDfLlUwQQMGh VsX4pSNcdrlom1d59yokTVS0KQrUhd6ns+HzmDfT0N+1hgUklQp3lMervjNCJNhpO7KM UEwRmR6D+bt4g6wp/80J/XUF3Kl7FiSw09AheawB6osaj11LzLbbbWRZ6WCCj14+Fh0E 2sIVWGpgbXL5a3dCdDZEg4oilKSrAHBRkxo3L4/mJ6O7+pdxWIt/jZ4qz/QCnKviCVva 28TmLWHRNeKYKWtMOLrcfYfwuZXIrG/fb2voBb7jTlWI62z6N5hQBYngaqo0vbpxs01M X3fQ== X-Gm-Message-State: AGRZ1gKRWFR0YbseZbZ7g4NlT1sVyD6sdfL9L9R6W9jOP1wBsbXZyDbj +NNcZVIxDLqdtcAmXy12EssmcA== 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 Cc: Will Deacon , Joerg Roedel , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Vlastimil Babka , Michal Hocko , Mel Gorman , Levin Alexander , Huaisheng Ye , Mike Rapoport , linux-arm-kernel@lists.infradead.org, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Yong Wu , Matthias Brugger , Tomasz Figa , yingjoe.chen@mediatek.com 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 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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)) -- 2.19.1.930.g4563a0d9d0-goog