Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp434413imu; Wed, 12 Dec 2018 20:48:32 -0800 (PST) X-Google-Smtp-Source: AFSGD/WIu9MyL8VnP+j22j948JA0IQJ7tNja0jEBV8/r3TPm215WQ8nkEUv2EMFYYzOCvwC3LMWv X-Received: by 2002:a63:4342:: with SMTP id q63mr20615140pga.63.1544676512718; Wed, 12 Dec 2018 20:48:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544676512; cv=none; d=google.com; s=arc-20160816; b=F6B3z6VJSTYxbQoYuHRn3oEtvxoZ8OF/FwOmeT+rNyPwzKmJL0ywaGy1Q5dv9/9/xI ZH4Dn9KPNmL6BCe+BeOQvueBsWFYhPQNEAqunlFFkQ6ZUkDU0+5+lKPKWHydkSfA48gZ 4750W4t+Ba3Ye1uUe+V7nEKWf5ZA62hgu9ui0Lj5DYyMC7BatTMF+oH/Df1+vikiYWDD S/wai3GWq6cNHF17efHK0HF3VBoZevUn+sDuM1xXR8982vz/Vigycz+mfVVRB2aSOu/A Yj+5evQIH+z8Xnhhkg4HBST0KPoODeXVPg4EazxekAQTrQOZqLO6depMZt1OX7CyGPQ+ 5sxw== 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=Cin/XC/Qfy5OxOCCW0IW7vWm6tW044Mymzw/aiR1wao=; b=uYbUM8+G2JvCNJxwkReBK3a1FpGcZmD+pX/eP2zCFmGRcumCyFdTrLPGechbjl2buO BsAcD5kaaIDBpkCSDXataCayjdqF49TmMnnbsMoFdNgAv0pA7M+w5FlTcsWhmLujjvUp St0qF0oloN0XQtq1uEDlb1H//3Er46iivcGhlB7BMNwW4SolkLFRH1HyH57Bc6impjoo h3s4l2SSt7AfzzLcdD6AHqxWf0nER6crErigM32glfgU827SRtGC4X0tT0vmJpkcQs++ x6Qe/mvqLZK1zw04/6heY3lnvdsEhraO9sxhEWhN2GRyjj0J42FoSDyM7eqPFZRvIE5y 7f0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=hz5xwo1J; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k6si648471pla.350.2018.12.12.20.48.18; Wed, 12 Dec 2018 20:48:32 -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=@kernel.org header.s=default header.b=hz5xwo1J; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728318AbeLMEqn (ORCPT + 99 others); Wed, 12 Dec 2018 23:46:43 -0500 Received: from mail.kernel.org ([198.145.29.99]:43438 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728311AbeLMEaf (ORCPT ); Wed, 12 Dec 2018 23:30:35 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id CEB3820879; Thu, 13 Dec 2018 04:30:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1544675434; bh=JEkotcbGwf+I+Otm/lT9frTIF8EJx2u46AOb8VUV01g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hz5xwo1JtnVG+89FN+QFpOg1BKUDSqo1dzKbmkO9EdgqTQlLds1e+t3OxOXdVXDlD opmci98jheFkY8IKqlHxH5rtISutysfsG/x278d5cp+fGjB/hjywJ3A1Z2hFF3PjfG cWcQ3eW/xFPjJQxAc73AbpdocE9Fs9OqJBCj1L4Y= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Dan Williams , Sasha Levin Subject: [PATCH AUTOSEL 4.19 60/73] tools/testing/nvdimm: Align test resources to 128M Date: Wed, 12 Dec 2018 23:28:25 -0500 Message-Id: <20181213042838.75160-60-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181213042838.75160-1-sashal@kernel.org> References: <20181213042838.75160-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dan Williams [ Upstream commit e3f5df762d4a6ef6326c3c09bc9f89ea8a2eab2c ] In preparation for libnvdimm growing new restrictions to detect section conflicts between persistent memory regions, enable nfit_test to allocate aligned resources. Use a gen_pool to allocate nfit_test's fake resources in a separate address space from the virtual translation of the same. Reviewed-by: Vishal Verma Tested-by: Vishal Verma Signed-off-by: Dan Williams Signed-off-by: Sasha Levin --- tools/testing/nvdimm/test/nfit.c | 35 ++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/tools/testing/nvdimm/test/nfit.c b/tools/testing/nvdimm/test/nfit.c index ec50d2a95076..fa763dbfdad7 100644 --- a/tools/testing/nvdimm/test/nfit.c +++ b/tools/testing/nvdimm/test/nfit.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -213,6 +214,8 @@ struct nfit_test { static struct workqueue_struct *nfit_wq; +static struct gen_pool *nfit_pool; + static struct nfit_test *to_nfit_test(struct device *dev) { struct platform_device *pdev = to_platform_device(dev); @@ -1130,6 +1133,9 @@ static void release_nfit_res(void *data) list_del(&nfit_res->list); spin_unlock(&nfit_test_lock); + if (resource_size(&nfit_res->res) >= DIMM_SIZE) + gen_pool_free(nfit_pool, nfit_res->res.start, + resource_size(&nfit_res->res)); vfree(nfit_res->buf); kfree(nfit_res); } @@ -1142,7 +1148,7 @@ static void *__test_alloc(struct nfit_test *t, size_t size, dma_addr_t *dma, GFP_KERNEL); int rc; - if (!buf || !nfit_res) + if (!buf || !nfit_res || !*dma) goto err; rc = devm_add_action(dev, release_nfit_res, nfit_res); if (rc) @@ -1162,6 +1168,8 @@ static void *__test_alloc(struct nfit_test *t, size_t size, dma_addr_t *dma, return nfit_res->buf; err: + if (*dma && size >= DIMM_SIZE) + gen_pool_free(nfit_pool, *dma, size); if (buf) vfree(buf); kfree(nfit_res); @@ -1170,9 +1178,16 @@ static void *__test_alloc(struct nfit_test *t, size_t size, dma_addr_t *dma, static void *test_alloc(struct nfit_test *t, size_t size, dma_addr_t *dma) { + struct genpool_data_align data = { + .align = SZ_128M, + }; void *buf = vmalloc(size); - *dma = (unsigned long) buf; + if (size >= DIMM_SIZE) + *dma = gen_pool_alloc_algo(nfit_pool, size, + gen_pool_first_fit_align, &data); + else + *dma = (unsigned long) buf; return __test_alloc(t, size, dma, buf); } @@ -2837,6 +2852,17 @@ static __init int nfit_test_init(void) goto err_register; } + nfit_pool = gen_pool_create(ilog2(SZ_4M), NUMA_NO_NODE); + if (!nfit_pool) { + rc = -ENOMEM; + goto err_register; + } + + if (gen_pool_add(nfit_pool, SZ_4G, SZ_4G, NUMA_NO_NODE)) { + rc = -ENOMEM; + goto err_register; + } + for (i = 0; i < NUM_NFITS; i++) { struct nfit_test *nfit_test; struct platform_device *pdev; @@ -2892,6 +2918,9 @@ static __init int nfit_test_init(void) return 0; err_register: + if (nfit_pool) + gen_pool_destroy(nfit_pool); + destroy_workqueue(nfit_wq); for (i = 0; i < NUM_NFITS; i++) if (instances[i]) @@ -2915,6 +2944,8 @@ static __exit void nfit_test_exit(void) platform_driver_unregister(&nfit_test_driver); nfit_test_teardown(); + gen_pool_destroy(nfit_pool); + for (i = 0; i < NUM_NFITS; i++) put_device(&instances[i]->pdev.dev); class_destroy(nfit_test_dimm); -- 2.19.1