From patchwork Sun Nov 11 09:03:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Boichat X-Patchwork-Id: 10677527 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 6077114E2 for ; Sun, 11 Nov 2018 09:04:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 520912B08D for ; Sun, 11 Nov 2018 09:04:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 455572B098; Sun, 11 Nov 2018 09:04:18 +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.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BEB862B08D for ; Sun, 11 Nov 2018 09:04:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 34CDD6B0007; Sun, 11 Nov 2018 04:04:16 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 2FC176B0008; Sun, 11 Nov 2018 04:04:16 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 19DCF6B000A; Sun, 11 Nov 2018 04:04:16 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f198.google.com (mail-pf1-f198.google.com [209.85.210.198]) by kanga.kvack.org (Postfix) with ESMTP id CD1286B0007 for ; Sun, 11 Nov 2018 04:04:15 -0500 (EST) Received: by mail-pf1-f198.google.com with SMTP id g63-v6so5174423pfc.9 for ; Sun, 11 Nov 2018 01:04:15 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=J3drSXNEQad/j7zI+ID7YdbI6KhfStGY6vScO313iR4=; b=ai5FbDAS4CKZ4ignbhc04OH75IbpUxVMVbskarDgrrprQv8mLtwPfwTpmCtdKV/oRs qz4n2ERg/47WR4K44NolIOmfCR7Dh/QmnLNn5WfcOgzdlHY19a8N/MXOk2tXGMIEWzb5 V0iK7Lfz9FVS3oFDMgBTLh8a0bPsGOW8exy+nqieMRqDTcc1osmoMPzVzRB39Gn+dyIT MyeWuNNwVi4ISh2tc75PlF4gkznjFxLTkl0F2rfn+YG95HZXOhu4LpPbY2+2YW55G8so C1wXb7SN6B0TyribuWh4vSTZg2d9fNz95S7uW0s6V0chujMUBXe4VTZ6mfjoGiF1nFzA ZOsQ== X-Gm-Message-State: AGRZ1gKfFPfO6lYy+RJYvBegDUhjaOmpsRkb1ki5DLwqyDJl08COig64 Ra5Z4N+AoRxQYn8ESMT7r7jRaHzXJo5Jq9wH5isipUTYAaTy+XWfJl6qWaUMjaXBeqZNS/9Yg+g PRK3e7/L/RDeRmml084qf3RG03MIt1ijbgrdaDLHh9mS5epEzXe0ZuTwLT38MRHGgCnm02sTLnN YN/9ah6c2ADFum4MiHNO9DmrCzaUYykGbLwzvOIbQEWKb9skRmejTFowPi77TQ56HGAj91LOaQa WZxjJ0D7gOgjpZXmSYj/nusGJhiPhE0PQhAcC0PK8QSP1BeJhpMzF2tIi/IK/Sw9aoIZFSpKO2c IIsu8qs/Jo9kVuWKOrWaeGzn11WR6uPG2Ph9+qZ+zpPrDcDtUrXDD00QUGx/ap6uLUhNk89uh4p 5 X-Received: by 2002:a63:9dca:: with SMTP id i193-v6mr12537068pgd.98.1541927055480; Sun, 11 Nov 2018 01:04:15 -0800 (PST) X-Received: by 2002:a63:9dca:: with SMTP id i193-v6mr12537033pgd.98.1541927054717; Sun, 11 Nov 2018 01:04:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541927054; cv=none; d=google.com; s=arc-20160816; b=kYbGJdSr2v9Rsc+UKK+5eA9s3vF7Lhmcz3B51CYcWvUTDox/5S2R3q6le67HJIQ3Su s0hLHh4ZO+D+Poi4f5F01a1fhc3DxoIVsnaeXtvE6avQp0fAJ03J8rBRxgocZCxcQqzJ FEjvBb6r065SmGqiPKvA71YZOsXh8RVsadqI7bi2m/yYGxDjLaTGWiRC60lZlp/MXFrj gN7BKp1fElrZeuRJwAFD7DWwIdN0CgE1IEGEztBPDrP+fPrVywLETotBixS6hFYVtNRC TAvkyTMF+svKLSmByrAhbLC8xJ9YU5aMGLN/252tuSDOeKYNP9ERITSyv7eP40GolWj4 Fw/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=J3drSXNEQad/j7zI+ID7YdbI6KhfStGY6vScO313iR4=; b=Sn9Mq1KSCE+9MDosrBGjMQf5aMpI2Ev0hpzFE9v4PJWPHz3QvMNbv0s/6ksQRgyT33 wzvBYnP9Ie4MSVUvKUQ7EXCtVNk4GEigFpoK8GqTqeZhmDuyqazW1Y13gEE+sN/0pQWy 8wbhD4tHn1yU2Fo0CP/5IvLhmVN1chGuapxzgSmOjQ4iLACcTOaopnKE4SBWzrDgKKsi Er89CnAtzSi6wIzmIh1m0Uw1TvwxTaoHVtygcQA3e35FGJlPl7sy8981NfJJ8B3Hp/tV OsMWOiHNR+oANSPCzxo8SPMt7w7MEemSyekUcu36qTPwHY826LXUllvSy/QVQcYDEDYc rd7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=DcjG9kTD; spf=pass (google.com: domain of drinkcat@chromium.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=drinkcat@chromium.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id p18sor14026140pgl.33.2018.11.11.01.04.14 for (Google Transport Security); Sun, 11 Nov 2018 01:04:14 -0800 (PST) Received-SPF: pass (google.com: domain of drinkcat@chromium.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=DcjG9kTD; spf=pass (google.com: domain of drinkcat@chromium.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=drinkcat@chromium.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org 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=J3drSXNEQad/j7zI+ID7YdbI6KhfStGY6vScO313iR4=; b=DcjG9kTDXB4SQ7VqcCMrX/L11oHaZNfPg9bG1SMflAXtx7Sdu1dqaoGyXOCoJ27tqZ TXk+rgHoUJbj9EsRYITf58Qh9ZhpgwOmxbxRHsI9hfkN3Wuw3up8qbfLy+xDMg7VZc+c e1b6fwI4rwon3DJdb6ZCA5AYTpsyukkQJdy20= X-Google-Smtp-Source: AJdET5d2kWGbhQDjOrVfaAjb6eaSaPcg2FtnCOnFt4V3Lsv/PQqo/3P8/Z+UfUKpHSPr81IYnMgzzw== X-Received: by 2002:a63:f141:: with SMTP id o1mr13637587pgk.134.1541927054240; Sun, 11 Nov 2018 01:04:14 -0800 (PST) Received: from drinkcat2.tpe.corp.google.com ([2401:fa00:1:b:f659:7f17:ea11:4e8e]) by smtp.gmail.com with ESMTPSA id 69sm8107956pgg.86.2018.11.11.01.04.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 11 Nov 2018 01:04:13 -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 v2 3/3] iommu/io-pgtable-arm-v7s: Request DMA32 memory, and improve debugging Date: Sun, 11 Nov 2018 17:03:41 +0800 Message-Id: <20181111090341.120786-4-drinkcat@chromium.org> X-Mailer: git-send-email 2.19.1.930.g4563a0d9d0-goog In-Reply-To: <20181111090341.120786-1-drinkcat@chromium.org> References: <20181111090341.120786-1-drinkcat@chromium.org> MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP For level 1/2 pages, ensure GFP_DMA32 is used if CONFIG_ZONE_DMA32 is defined (e.g. on arm64 platforms). For level 2 pages, allocate a slab cache in SLAB_CACHE_DMA32. 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 --- Changes since v1: - Changed approach to use SLAB_CACHE_DMA32 added by the previous commit. - Use DMA or DMA32 depending on the architecture (DMA for arm, DMA32 for arm64). drivers/iommu/io-pgtable-arm-v7s.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/drivers/iommu/io-pgtable-arm-v7s.c b/drivers/iommu/io-pgtable-arm-v7s.c index 445c3bde04800c..996f7b6d00b44a 100644 --- a/drivers/iommu/io-pgtable-arm-v7s.c +++ b/drivers/iommu/io-pgtable-arm-v7s.c @@ -161,6 +161,14 @@ #define ARM_V7S_TCR_PD1 BIT(5) +#ifdef CONFIG_ZONE_DMA32 +#define ARM_V7S_TABLE_GFP_DMA GFP_DMA32 +#define ARM_V7S_TABLE_SLAB_CACHE SLAB_CACHE_DMA32 +#else +#define ARM_V7S_TABLE_GFP_DMA GFP_DMA +#define ARM_V7S_TABLE_SLAB_CACHE SLAB_CACHE_DMA +#endif + typedef u32 arm_v7s_iopte; static bool selftest_running; @@ -198,13 +206,17 @@ 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_free_pages( + __GFP_ZERO | ARM_V7S_TABLE_GFP_DMA, get_order(size)); else if (lvl == 2) - table = kmem_cache_zalloc(data->l2_tables, gfp | GFP_DMA); + table = kmem_cache_zalloc(data->l2_tables, + gfp | ARM_V7S_TABLE_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 in PTE: %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)) @@ -737,7 +749,7 @@ static struct io_pgtable *arm_v7s_alloc_pgtable(struct io_pgtable_cfg *cfg, data->l2_tables = kmem_cache_create("io-pgtable_armv7s_l2", ARM_V7S_TABLE_SIZE(2), ARM_V7S_TABLE_SIZE(2), - SLAB_CACHE_DMA, NULL); + ARM_V7S_TABLE_SLAB_CACHE, NULL); if (!data->l2_tables) goto out_free_data;