Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp6911188imu; Mon, 21 Jan 2019 19:15:28 -0800 (PST) X-Google-Smtp-Source: ALg8bN58E90GMkGQHr6cpk/lZib+oyZNrYchvy7uy74CyffBzhuOLWyAvj0agBmED+DoCUm7aBOk X-Received: by 2002:a63:ce08:: with SMTP id y8mr30127426pgf.388.1548126928019; Mon, 21 Jan 2019 19:15:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548126927; cv=none; d=google.com; s=arc-20160816; b=h8blePwaOB9/DsNSacCilntYLjWZgFLO3lT4Eem/LOtlXJsS2r2LfCakis7fAtWWYV 8+gJKuPX++TyYXmvPadM3DVjC3w3khqDjbOnVNgwG+Wh3txT0RufdS4cpnBbQMk6oAwK XT6cFUFPB3QrkWLZVpiF5hv3xIIgn6gwq2FQzft26JagI1suLESLwBnFEWeIJIV7/dMY 8Jqkc87uCAOTR09hyPyItYFkgoNWNvSfK5jfTBeMlgphH619CMQvfJlHLktoy4vQmf6a lnD31Je2dZOrk4aJ0hyMcmQwrrObCfCiDdTf202kaKiyQfWfYMr1iVcFnkafm6qHehm/ im8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:reply-to:message-id :subject:cc:to:from:date; bh=pmkL/kerlLwSoezpIg5E40hue/To4gsczZylpogfT6k=; b=SvRGPoxImd6bq77L8T6EacxCQeHi+TCcxkhXyvmWRb3KphkyQUvhDnEHJYxLhxqdMA k5/SMDhAyxT+j+Xk57wNSDSQcwwtZEco7x50+vAJn6btfri90aYENXrYbBpYD9eQWQZn aGvuVHq4aXmgtH574eT6ZSfIDjOHR5mMFytKOxIEjQny6blV826U1gZcm6i7m6IhLaxq rVjmXSrc/R2PDBjN4vM8VATV1fUYpxWREUxcbYpXi9OYntKsAIb/FYB8z946+K1E9rhh F1/q0YDeZ/d+87JYnJwsDlXIXwpvnTSqsnYsuTpiaIu6pBK+oPXDJzA8TaE6NXFeDHii amMA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z17si16234253pgc.364.2019.01.21.19.15.12; Mon, 21 Jan 2019 19:15:27 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726875AbfAVDOI (ORCPT + 99 others); Mon, 21 Jan 2019 22:14:08 -0500 Received: from mga02.intel.com ([134.134.136.20]:39474 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726682AbfAVDOI (ORCPT ); Mon, 21 Jan 2019 22:14:08 -0500 X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Jan 2019 19:14:07 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,504,1539673200"; d="scan'208";a="293315290" Received: from richard.sh.intel.com (HELO localhost) ([10.239.159.37]) by orsmga005.jf.intel.com with ESMTP; 21 Jan 2019 19:14:06 -0800 Date: Tue, 22 Jan 2019 11:13:38 +0800 From: Wei Yang To: Dan Williams Cc: Wei Yang , linux-nvdimm , Linux Kernel Mailing List Subject: Re: [PATCH] libnvdimm: Clarify nd_pfn_init() flow Message-ID: <20190122031338.GA3983@richard> Reply-To: Wei Yang References: <154785884329.2202034.3295476681016958230.stgit@dwillia2-desk3.amr.corp.intel.com> <20190121075102.GA3758@richard> <20190122002915.GA5984@richard> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jan 21, 2019 at 04:45:46PM -0800, Dan Williams wrote: >On Mon, Jan 21, 2019 at 4:30 PM Wei Yang wrote: >> >> >> May I ask a question about the purpose to create these three device here? >> >> I see nd_pfn_create() doesn't allocate pfn_sb here, and the probe on these >> devices failed. Confused why we need these three devices. > >These allow for the namespace creation flow. Namespace creation with >the pfn personality, for example, goes like this: > >1/ Find available region capacity > >2/ Allocate capacity to a namespace > >3/ Assign that namespace to a free pfn instance >echo namespace0.0 > /sys/bus/nd/devices/pfn0.0/namespace > Here we use __nd_attach_ndns() connect pfn0.0 with namespace0.0 >4/ Start the pfn0.0 device >echo pfn0.0 > /sys/bus/nd/drivers/nd_pmem/bind > Here we trigger nd_pmem_probe() and call pmem_attach_disk() for device pfn0.0, because this is a pfn device. >5/ At this point nd_pfn_validate() returns -ENODEV, so the driver >writes the configuration to the device to be autodetected next time. > Then it go through pmem_attach_disk()->nvdimm_setup_pfn()->nd_pfn_init(). The return value -ENODEV leads nd_pfn_init() to configuration write. Everything looks good here, but I am lost at "Autodetected next time". Because the driver will continue to finish its work and attach pfn0.0. Do we need another autodetect? Or you mean after driver detach or reboot? So nd_pfn_validate() will not return -ENODEV, as it has already configured well. >This explicit force binding operation is how the driver determines the >difference between the namespace creation case and the namespace >auto-probing case at the next driver load. -- Wei Yang Help you, Help me