Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp398494pxb; Thu, 14 Jan 2021 08:30:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJxt/nNOrSFvWIbteHWlRYkrvwxh717cW/GrVRfRK/1NJSVlcxI86Nk1gVepnIghoJcrrCJT X-Received: by 2002:a17:906:48c:: with SMTP id f12mr764510eja.431.1610641849914; Thu, 14 Jan 2021 08:30:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610641849; cv=none; d=google.com; s=arc-20160816; b=LWrXym3euxpIxb415l60Kl2j2C0VCpM+WidFYuH3Rm7esQ9dZEUEf9Rl9dV6wdRwrt FKQZsIT50+h5ro+nF9CMW/itVlzkQcb5zcShGmoqDaMa+Ti/Fxiw6gBkz6+4w99IKBPq JKLmgpRF8HykJW27M6ullVgmliYa8jmitnpT75PFyoK5A+3+mdnZ75QMhdMDf5ZNG+mk B7KhNZ0aTl+R+hKeIwEc7R27u5M0HyL6sWuLrWymCKvNpcHEQ40h6ers4YQ0A+ad7bhU yPdDQlbPfOeWo8GwLw2HX5fMxL8bz8VrW9qGARHN/hNMHquRYNNO7GvLSO49F/TssXar TwTg== 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 :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=psUY9XhnQGIcL5hy0y8XLvck0UGvCOY8DDx35qCfHoQ=; b=eA/NF0T/EFmnckXQOzY/UAb1HS9mOdxnzqbEB7fPn4Mqb+aY+Ex8QH/oPnx8VjwYSD 1aPQkOFma5RkJk5a0GP1oV5FrHqISapOhp2mldus9bLfAEijq+4Jy+PaNZ6kltBUymWf kYSoObYB6BXmRoquNLteoM/vp0uTiJ9TvoLTZiWYWzuKTHsY2Lbof0hMTNjc4AikfeQa 0vH13pqB5BVer6cUSIbFmFGCy9RuLoUyvA+gvmTiAmLRehcQH3AmB1psabDXGhbhde4X r7/in//1pCeK6MLLtL2PCwaVkC0AzjJ4sytJTt5MFsmpC+nrFgdQXf1vZJokzn5im5TB Rjgw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p1si775909edm.218.2021.01.14.08.30.25; Thu, 14 Jan 2021 08:30:49 -0800 (PST) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726501AbhANQ3p (ORCPT + 99 others); Thu, 14 Jan 2021 11:29:45 -0500 Received: from frasgout.his.huawei.com ([185.176.79.56]:2345 "EHLO frasgout.his.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725957AbhANQ3o (ORCPT ); Thu, 14 Jan 2021 11:29:44 -0500 Received: from fraeml741-chm.china.huawei.com (unknown [172.18.147.207]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4DGqPf5XMQz67ZHx; Fri, 15 Jan 2021 00:23:50 +0800 (CST) Received: from lhreml710-chm.china.huawei.com (10.201.108.61) by fraeml741-chm.china.huawei.com (10.206.15.222) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2; Thu, 14 Jan 2021 17:29:02 +0100 Received: from localhost (10.47.30.252) by lhreml710-chm.china.huawei.com (10.201.108.61) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2106.2; Thu, 14 Jan 2021 16:29:01 +0000 Date: Thu, 14 Jan 2021 16:28:22 +0000 From: Jonathan Cameron To: Ben Widawsky CC: , Dan Williams , , , "linux-acpi@vger.kernel.org, Ira Weiny" , Vishal Verma , "Kelley, Sean V" , Rafael Wysocki , Bjorn Helgaas , Jon Masters , Chris Browy , Randy Dunlap , "Christoph Hellwig" , Subject: Re: [RFC PATCH v3 08/16] cxl/mem: Register CXL memX devices Message-ID: <20210114162822.00002797@Huawei.com> In-Reply-To: <20210111225121.820014-9-ben.widawsky@intel.com> References: <20210111225121.820014-1-ben.widawsky@intel.com> <20210111225121.820014-9-ben.widawsky@intel.com> Organization: Huawei Technologies Research and Development (UK) Ltd. X-Mailer: Claws Mail 3.17.4 (GTK+ 2.24.32; i686-w64-mingw32) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.47.30.252] X-ClientProxiedBy: lhreml709-chm.china.huawei.com (10.201.108.58) To lhreml710-chm.china.huawei.com (10.201.108.61) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 11 Jan 2021 14:51:12 -0800 Ben Widawsky wrote: > From: Dan Williams > > Create the /sys/bus/cxl hierarchy to enumerate memory devices > (per-endpoint control devices), memory address space devices (platform > address ranges with interleaving, performance, and persistence > attributes), and memory regions (active provisioned memory from an > address space device that is in use as System RAM or delegated to > libnvdimm as Persistent Memory regions). > > For now, only the per-endpoint control devices are registered on the > 'cxl' bus. > > Signed-off-by: Dan Williams > Signed-off-by: Ben Widawsky Don't hide the driver core change inside a patch doing other stuff. (it is a nice change though!) Otherwise, just a request for units in the sysfs ABI docs. Jonathan > --- > Documentation/ABI/testing/sysfs-bus-cxl | 26 +++ > Documentation/cxl/memory-devices.rst | 3 + > drivers/base/core.c | 14 ++ > drivers/cxl/Makefile | 2 + > drivers/cxl/bus.c | 54 +++++ > drivers/cxl/bus.h | 8 + > drivers/cxl/cxl.h | 3 + > drivers/cxl/mem.c | 282 +++++++++++++++++++++++- > include/linux/device.h | 1 + > 9 files changed, 392 insertions(+), 1 deletion(-) > create mode 100644 Documentation/ABI/testing/sysfs-bus-cxl > create mode 100644 drivers/cxl/bus.c > create mode 100644 drivers/cxl/bus.h > > diff --git a/Documentation/ABI/testing/sysfs-bus-cxl b/Documentation/ABI/testing/sysfs-bus-cxl > new file mode 100644 > index 000000000000..fe7b87eba988 > --- /dev/null > +++ b/Documentation/ABI/testing/sysfs-bus-cxl > @@ -0,0 +1,26 @@ > +What: /sys/bus/cxl/devices/memX/firmware_version > +Date: December, 2020 > +KernelVersion: v5.12 > +Contact: linux-cxl@vger.kernel.org > +Description: > + (RO) "FW Revision" string as reported by the Identify > + Memory Device Output Payload in the CXL-2.0 > + specification. > + > +What: /sys/bus/cxl/devices/memX/ram/size > +Date: December, 2020 > +KernelVersion: v5.12 > +Contact: linux-cxl@vger.kernel.org > +Description: > + (RO) "Volatile Only Capacity" as reported by the > + Identify Memory Device Output Payload in the CXL-2.0 > + specification. Nice to see the format /units of these described in this doc as well as the spec. Section number etc also good if you can add it to these docs. > + > +What: /sys/bus/cxl/devices/memX/pmem/size > +Date: December, 2020 > +KernelVersion: v5.12 > +Contact: linux-cxl@vger.kernel.org > +Description: > + (RO) "Persistent Only Capacity" as reported by the > + Identify Memory Device Output Payload in the CXL-2.0 > + specification. > diff --git a/Documentation/cxl/memory-devices.rst b/Documentation/cxl/memory-devices.rst > index 134c9b6b4ff4..5f723c25382b 100644 > --- a/Documentation/cxl/memory-devices.rst > +++ b/Documentation/cxl/memory-devices.rst > @@ -37,3 +37,6 @@ External Interfaces > > .. kernel-doc:: drivers/cxl/acpi.c > :export: > + > +.. kernel-doc:: drivers/cxl/bus.c > + :export: > diff --git a/drivers/base/core.c b/drivers/base/core.c > index 25e08e5f40bd..33432a4cbe23 100644 > --- a/drivers/base/core.c > +++ b/drivers/base/core.c > @@ -3179,6 +3179,20 @@ struct device *get_device(struct device *dev) > } > EXPORT_SYMBOL_GPL(get_device); > > +/** > + * get_live_device() - increment reference count for device iff !dead > + * @dev: device. > + * > + * Forward the call to get_device() if the device is still alive. If > + * this is called with the device_lock() held then the device is > + * guaranteed to not die until the device_lock() is dropped. > + */ I like the idea of a nice generic wrapper for this but definitely not deep inside a patch doing something else. > +struct device *get_live_device(struct device *dev) > +{ > + return dev && !dev->p->dead ? get_device(dev) : NULL; > +} > +EXPORT_SYMBOL_GPL(get_live_device); > + ...