From patchwork Mon Oct 22 20:13:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Hansen X-Patchwork-Id: 10652437 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 399F05BB5 for ; Mon, 22 Oct 2018 20:18:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 222F72916E for ; Mon, 22 Oct 2018 20:18:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 165AB29182; Mon, 22 Oct 2018 20:18:53 +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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=unavailable 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 AB88D2917A for ; Mon, 22 Oct 2018 20:18:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 283AD6B000C; Mon, 22 Oct 2018 16:18:44 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 1C3276B000D; Mon, 22 Oct 2018 16:18:44 -0400 (EDT) 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 E8E8A6B000E; Mon, 22 Oct 2018 16:18:43 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f199.google.com (mail-pg1-f199.google.com [209.85.215.199]) by kanga.kvack.org (Postfix) with ESMTP id A7DD46B000C for ; Mon, 22 Oct 2018 16:18:43 -0400 (EDT) Received: by mail-pg1-f199.google.com with SMTP id v10-v6so1561067pgs.15 for ; Mon, 22 Oct 2018 13:18:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:subject:to:cc :from:date:references:in-reply-to:message-id; bh=FRRrQjEcKq6x+c2W4XjZQcqv8HzLEXVryuBMi8jnFbI=; b=NUm0XJ2JzDZseQYHP4/z3tdMENEcms0qj7KIwpzCemfs51AWOMtDL5OpsZ3sUVHd8N 5mVUjn5aRN4WKtk0nZeeLCWCTJbZ7hlfh4C9oWFoFhO/CL5wbyBTEAKxpJTg3WjpZnF5 l5uVH3s0g9Td+kkXkSv2IUFV0CqNmUO38s+Bm6ggnDBys+NXIvU9HmXAlL5q88xbkdnw Ok63x9cTBpXz8EsYW6conzyeKnqnHRfQM/c79+CWLe35Q8FosslWPhZMGahf20/lTVSy pw0qWvNBPSN1UmQR4eksD6/ho3ONZUF47Hv7GHgW+3nGu8dPJaKn7c0qWrDPjtr9AKvY r5Ww== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of dave.hansen@linux.intel.com designates 192.55.52.43 as permitted sender) smtp.mailfrom=dave.hansen@linux.intel.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Gm-Message-State: ABuFfoiGec1am0gduVfv4stx3PBQxzR772qeAFpDwweMzVBH9xwJ/zdV 1vDeY/7h+qkvaI4VGKkYLpoBqfazMKm6xrMRcOPQFxkh42lZRKyT4TitZSiiJv62+Z7yeyItivV LO+t1jEC7XaNLNDC6aZqeRVYT1Tq0dnRu8uRQ6VofKMnnHhUfGcsLz3qYgoiF2d+Tsg== X-Received: by 2002:a63:a119:: with SMTP id b25-v6mr44024142pgf.186.1540239523362; Mon, 22 Oct 2018 13:18:43 -0700 (PDT) X-Google-Smtp-Source: ACcGV62I6E/w0slUWBoqw668dU5P+rpmB+/kRaGBl+0oC5XHDDNo0izHbHSt3X/baz39YhD+jQYS X-Received: by 2002:a63:a119:: with SMTP id b25-v6mr44024113pgf.186.1540239522746; Mon, 22 Oct 2018 13:18:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540239522; cv=none; d=google.com; s=arc-20160816; b=MFKCFdW8eG94tezpKLyA3o/NUXT6W2Fr2Sd51mIB14TOEnnfBFInqCGVGVUukWLAKh exPRST2EZ85algIA183FdD/OIQK1HAdrFFVuDdHBlzIfb6KejvoGlcSMOiJn2Jt7etWL tYorC0wAXVVorBuE6si4cCGLYnZfvcB55jDR+vgRWWEy0zXuHOnZLCQWhaPU2Q36t0Nk aC0f51NecMWUoHHxZrpmLUjBoHkHIVmBDkPguTVuYthAEWcpBkPqKjeMYoMp8dQCw3kr +UspRsTQ0rXZxLUj+tpsR3WoRz3PljZvyeNKKm8aahnHwtVBp++PHmTUjnmvwdijQGp9 BXRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:in-reply-to:references:date:from:cc:to:subject; bh=FRRrQjEcKq6x+c2W4XjZQcqv8HzLEXVryuBMi8jnFbI=; b=ys81HZgu7isaq85vctxTtoH6oXCCf4jnZjZTRJiXg4et/PnGKQhCNbE8qcdW3kndgd u6Ezg4UaTZMV+zf4tDLV5uwpd2gUM966NPEI1rwjKjlZUD9V9KfqyagdH1xNmKd9TS1c 1V9JRXhnrLp6nFVQVsfgZXv/ULXo5gsqapWLHSXxHHUVIESLucdDDvSdPvjoQt+iuxEo Pph2sVIeVeAIFqLmwCHNR6b5dni5PjrBxvRMz6Ah4tIG0DenSBo4bXW0dAlNDvhjtekb F2CjH7v9xONd0SongzeX66TJRc8fCxfzoPiB05KVdiNifDxP/iRaS9nzg4wQCeBjBkso UITg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of dave.hansen@linux.intel.com designates 192.55.52.43 as permitted sender) smtp.mailfrom=dave.hansen@linux.intel.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga05.intel.com (mga05.intel.com. [192.55.52.43]) by mx.google.com with ESMTPS id r15-v6si34776466pgh.88.2018.10.22.13.18.42 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Oct 2018 13:18:42 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of dave.hansen@linux.intel.com designates 192.55.52.43 as permitted sender) client-ip=192.55.52.43; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of dave.hansen@linux.intel.com designates 192.55.52.43 as permitted sender) smtp.mailfrom=dave.hansen@linux.intel.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Oct 2018 13:18:42 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,413,1534834800"; d="scan'208";a="80737009" Received: from viggo.jf.intel.com (HELO localhost.localdomain) ([10.54.77.144]) by fmsmga008.fm.intel.com with ESMTP; 22 Oct 2018 13:18:41 -0700 Subject: [PATCH 4/9] dax/kmem: allow PMEM devices to bind to KMEM driver To: linux-kernel@vger.kernel.org Cc: Dave Hansen ,dan.j.williams@intel.com,dave.jiang@intel.com,zwisler@kernel.org,vishal.l.verma@intel.com,thomas.lendacky@amd.com,akpm@linux-foundation.org,mhocko@suse.com,linux-nvdimm@lists.01.org,linux-mm@kvack.org,ying.huang@intel.com,fengguang.wu@intel.com From: Dave Hansen Date: Mon, 22 Oct 2018 13:13:24 -0700 References: <20181022201317.8558C1D8@viggo.jf.intel.com> In-Reply-To: <20181022201317.8558C1D8@viggo.jf.intel.com> Message-Id: <20181022201324.EBB64302@viggo.jf.intel.com> 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 Currently, a persistent memory device's mode must be coordinated with the driver to which it needs to bind. To change it from the fsdax to the device-dax driver, you first change the mode of the device itself. Instead of adding a new device mode, allow the PMEM mode to also bind to the KMEM driver. As I write this, I'm realizing that it might have just been better to add a new device mode, rather than hijacking the PMEM eode. If this is the case, please speak up, NVDIMM folks. :) Cc: Dan Williams Cc: Dave Jiang Cc: Ross Zwisler Cc: Vishal Verma Cc: Tom Lendacky Cc: Andrew Morton Cc: Michal Hocko Cc: linux-nvdimm@lists.01.org Cc: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org Cc: Huang Ying Cc: Fengguang Wu --- b/drivers/nvdimm/bus.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff -puN drivers/nvdimm/bus.c~dax-kmem-try-again-2018-3-bus-match-override drivers/nvdimm/bus.c --- a/drivers/nvdimm/bus.c~dax-kmem-try-again-2018-3-bus-match-override 2018-10-22 13:12:22.522930391 -0700 +++ b/drivers/nvdimm/bus.c 2018-10-22 13:12:22.525930391 -0700 @@ -464,11 +464,24 @@ static struct nd_device_driver nd_bus_dr static int nvdimm_bus_match(struct device *dev, struct device_driver *drv) { struct nd_device_driver *nd_drv = to_nd_device_driver(drv); + bool match; if (is_nvdimm_bus(dev) && nd_drv == &nd_bus_driver) return true; - return !!test_bit(to_nd_device_type(dev), &nd_drv->type); + match = !!test_bit(to_nd_device_type(dev), &nd_drv->type); + + /* + * We allow PMEM devices to be bound to the KMEM driver. + * Force a match if we detect a PMEM device type but + * a KMEM device driver. + */ + if (!match && + (to_nd_device_type(dev) == ND_DEVICE_DAX_PMEM) && + (nd_drv->type == ND_DRIVER_DAX_KMEM)) + match = true; + + return match; } static ASYNC_DOMAIN_EXCLUSIVE(nd_async_domain);