Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1392759pxk; Fri, 25 Sep 2020 13:36:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxXNgfzdN0qlV2KH1onXxCBdXYMApMjf7dB0G5OpV9X2zWZtgDCjT4CMQ1cwMfQNownhkK0 X-Received: by 2002:a50:ed94:: with SMTP id h20mr3334423edr.184.1601066173816; Fri, 25 Sep 2020 13:36:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601066173; cv=none; d=google.com; s=arc-20160816; b=A9C3mJrYIKY83VTet0rK8pVOGXr9aLUgVruiQ4cEQqTfNxn9bfx7FzRcVtv9jAph8f TfT1Zfro0jt1QbI3S1QPzySqzSRjFcpoQIF+dUCc3Ptp58wctyJznhhBii1NpzOMeF6y GZYaVnoprY6yq+neLNqM4cWNjCtCh7ajEcmm9WngQ3R8soqOkbzT0V9KcP3ZNBriyebw 9c7UhMF3+tdX+REo78SJ9zp7UDcVrPISHhavY1nLD1QXhF2eYV/KpD7RaozdBQsKRLt4 r5lKSD2LRE5Kp7CzR+JEME6CSVCUDzqXLFOOYYV8RfDrG+osIjS/9xIS8BGmv8JxY4dN bH/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:cc:to:from :subject:ironport-sdr:ironport-sdr; bh=2PI/ApwpD//zSNBP2Ocfyd/HxX4eSbPgFWNH3BMsSBw=; b=mrvjoP33VvcvrqJ6YnJOUTbWWTQEyas4e0GlTCaRsOsv1gK7PJBDTCFIswne5MHImG G1B6rKpWBPj5CgDgKLeT2/95X3OM4L6dmwtG5OhjZBPSH+52lYjjhhZDoKkKi7DPtHHj Nxbu+Jo7fQywK1qs6I8iGj88pgymjarMUwVegoY4LuIQNv4HkrAqgAE4OLkFGgYqWi5H hN/eUi29xdVZyvnYE1cbesvWXlNAhOLadyIyF0FOsdHTwJVBQLbJq9xGi54oIYCDBFbt 9whufOUXnnvSmR56nHJXdmKSu3p5ZzT0jDLUt076key0urWtNm5xmH6FUCborpd+3lMR D9ew== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g3si2613875ejw.227.2020.09.25.13.35.50; Fri, 25 Sep 2020 13:36:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727519AbgIYUdx (ORCPT + 99 others); Fri, 25 Sep 2020 16:33:53 -0400 Received: from mga02.intel.com ([134.134.136.20]:18986 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729021AbgIYUda (ORCPT ); Fri, 25 Sep 2020 16:33:30 -0400 IronPort-SDR: bO8vPEwqDqlC7aJ/OsfHW5VBbHkMqkIf1iVZdwQXXk5SUeLWlnAaBYXVcstQc682RMk+RMBwAW Ir+wIBVxTZNw== X-IronPort-AV: E=McAfee;i="6000,8403,9755"; a="149272041" X-IronPort-AV: E=Sophos;i="5.77,303,1596524400"; d="scan'208";a="149272041" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Sep 2020 12:30:17 -0700 IronPort-SDR: yKtywSJjUB9ZKmM9Dm1/NkFLNg6UOlkygXJcF325A3yOAu1vGWmcg+N6lHh5/cpo3GZoAsM8yX +euzea32KQbw== X-IronPort-AV: E=Sophos;i="5.77,303,1596524400"; d="scan'208";a="512356606" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.16]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Sep 2020 12:30:17 -0700 Subject: [PATCH v5 03/17] device-dax/kmem: move resource name tracking to drvdata From: Dan Williams To: akpm@linux-foundation.org Cc: David Hildenbrand , Vishal Verma , Dave Hansen , Pavel Tatashin , Brice Goglin , Dave Jiang , David Hildenbrand , Ira Weiny , Jia He , Joao Martins , Jonathan Cameron , linux-mm@kvack.org, linux-nvdimm@lists.01.org, linux-kernel@vger.kernel.org Date: Fri, 25 Sep 2020 12:11:56 -0700 Message-ID: <160106111639.30709.17624822766862009183.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: <160106109960.30709.7379926726669669398.stgit@dwillia2-desk3.amr.corp.intel.com> References: <160106109960.30709.7379926726669669398.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: StGit/0.18-3-g996c MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Towards removing the mode specific @dax_kmem_res attribute from the generic 'struct dev_dax', and preparing for multi-range support, move resource name tracking to driver data. The memory for the resource name needs to have its own lifetime separate from the device bind lifetime for cases where the driver is unbound, but the kmem range could not be unplugged from the page allocator. Cc: David Hildenbrand Cc: Vishal Verma Cc: Dave Hansen Cc: Pavel Tatashin Cc: Brice Goglin Cc: Dave Jiang Cc: David Hildenbrand Cc: Ira Weiny Cc: Jia He Cc: Joao Martins Cc: Jonathan Cameron Signed-off-by: Dan Williams --- drivers/dax/kmem.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/dax/kmem.c b/drivers/dax/kmem.c index b0d6a99cf12d..6fe2cb1c5f7c 100644 --- a/drivers/dax/kmem.c +++ b/drivers/dax/kmem.c @@ -34,7 +34,7 @@ int dev_dax_kmem_probe(struct device *dev) struct dev_dax *dev_dax = to_dev_dax(dev); struct range range = dax_kmem_range(dev_dax); struct resource *new_res; - const char *new_res_name; + char *res_name; int numa_node; int rc; @@ -51,15 +51,15 @@ int dev_dax_kmem_probe(struct device *dev) return -EINVAL; } - new_res_name = kstrdup(dev_name(dev), GFP_KERNEL); - if (!new_res_name) + res_name = kstrdup(dev_name(dev), GFP_KERNEL); + if (!res_name) return -ENOMEM; /* Region is permanently reserved if hotremove fails. */ - new_res = request_mem_region(range.start, range_len(&range), new_res_name); + new_res = request_mem_region(range.start, range_len(&range), res_name); if (!new_res) { dev_warn(dev, "could not reserve region [%#llx-%#llx]\n", range.start, range.end); - kfree(new_res_name); + kfree(res_name); return -EBUSY; } @@ -80,9 +80,11 @@ int dev_dax_kmem_probe(struct device *dev) if (rc) { release_resource(new_res); kfree(new_res); - kfree(new_res_name); + kfree(res_name); return rc; } + + dev_set_drvdata(dev, res_name); dev_dax->dax_kmem_res = new_res; return 0; @@ -94,7 +96,7 @@ static int dev_dax_kmem_remove(struct device *dev) struct dev_dax *dev_dax = to_dev_dax(dev); struct range range = dax_kmem_range(dev_dax); struct resource *res = dev_dax->dax_kmem_res; - const char *res_name = res->name; + const char *res_name = dev_get_drvdata(dev); int rc; /*