Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1274826pxu; Mon, 23 Nov 2020 16:45:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJwomRk0bsvAZWacJ9o2tG9kO3ZNTY0oCl+ya7XugaC3AmyNJyMer9Ss7cEkljPuQ1Xb5Rfq X-Received: by 2002:a05:6402:1cb8:: with SMTP id cz24mr1769457edb.34.1606178712161; Mon, 23 Nov 2020 16:45:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606178712; cv=none; d=google.com; s=arc-20160816; b=sg5B3Uqd8vcjl3dQoutKTCGWP6w9ZjtTW336f+W3XcHnL8EFZcaO68j8cH98Zcitvu ydFS3P0bGj1Ulvg5XVQ3q/dT9mZ4sOD3adoLgER2ZLZrTp/aQIylbYPLvx3/qaWjMqyv wzec23qxL/v/f5b0TqIKgGUGLF35Z6C6a1CnGf+bU2/njzR6rDCbzMgCseqbN4ftWJvW Q1N5G2YtkihF5t//YWWV7pxuIsin7mLGl79b1o9OrlnjEIHP8rp1VtLSlU0hR6iyp+2i qq2Was6VOg/9Q4Ga+3PdPxGnjcRQfaLNxDmah2NsGj55rmsv/1hXPDRxKylhD7uPWOcJ a7PQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:ironport-sdr :ironport-sdr; bh=5XxZeai4U3l2f/bBRn5Ojdb0FRZnb7drhhNLboqVb/k=; b=AU0ynqaaGMLio9ZXPrvsp5B+Fu7lB/M0vo/Xb/l+PPmgfMha67/p4Fe/hQB9K0ix2O 6I3V89Fh7hKqK5kzBuvZ6S0b0D4AGo8ncLJurGx72iOuHVi3RVQ0r9fGu+Qp65I0V98u ycuCrq4YOvT4iWnJMRhxsR0S+B5KkORGyjw816dblMEaMSg+2s7cEx65uD9s4vCtwIr6 oNnY2noGmdJtWKgZxHHvRst0k6zHpbqvojC36Qvs2qP8fyEZhlVEuMAVzqYXXhwsQqxF 80nLSbREGyDarfkUeMa/1w8kiHIySNETlkGVCpHvusI+kn3rVwI9kE9dhC1aBxYlPAt1 7tUw== 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 z7si7636820edm.477.2020.11.23.16.44.49; Mon, 23 Nov 2020 16:45:12 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729004AbgKXAR6 (ORCPT + 99 others); Mon, 23 Nov 2020 19:17:58 -0500 Received: from mga07.intel.com ([134.134.136.100]:22729 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726745AbgKXAR6 (ORCPT ); Mon, 23 Nov 2020 19:17:58 -0500 IronPort-SDR: h/P8m5SANIsheky63hBHV2HCKKlCQg6Xo5qxkC2nXcmfYR8EmXlGxmx89R02SJA2fWG4h9C0lA CkFGkI8caFZw== X-IronPort-AV: E=McAfee;i="6000,8403,9814"; a="236005070" X-IronPort-AV: E=Sophos;i="5.78,364,1599548400"; d="scan'208";a="236005070" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Nov 2020 16:17:56 -0800 IronPort-SDR: qbW+WwGzLA8+eSg5GGNT6me0DMfLWg1G8/paGswTGz2dXhdExFobeq/Qb6sf6WTrtqCA5F8SfF k+MwQe1cGyhw== X-IronPort-AV: E=Sophos;i="5.78,364,1599548400"; d="scan'208";a="546615424" Received: from laloy-mobl1.amr.corp.intel.com (HELO intel.com) ([10.252.133.93]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Nov 2020 16:17:56 -0800 Date: Mon, 23 Nov 2020 16:17:54 -0800 From: Ben Widawsky To: Jonathan Cameron Cc: linux-cxl@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, linux-acpi@vger.kernel.org, Dan Williams , Ira Weiny , Vishal Verma , "Kelley, Sean V" , Bjorn Helgaas , "Rafael J . Wysocki" Subject: Re: [RFC PATCH 5/9] cxl/mem: Find device capabilities Message-ID: <20201124001754.465xfzv5r2q4l52o@intel.com> References: <20201111054356.793390-1-ben.widawsky@intel.com> <20201111054356.793390-6-ben.widawsky@intel.com> <20201117151519.000069d2@Huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201117151519.000069d2@Huawei.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 20-11-17 15:15:19, Jonathan Cameron wrote: > On Tue, 10 Nov 2020 21:43:52 -0800 > Ben Widawsky wrote: > > > CXL devices contain an array of capabilities that describe the > > interactions software can interact with the device, or firmware running > > on the device. A CXL compliant device must implement the device status > > and the mailbox capability. A CXL compliant memory device must implement > > the memory device capability. > > > > Each of the capabilities can [will] provide an offset within the MMIO > > region for interacting with the CXL device. > > > > Signed-off-by: Ben Widawsky > > A few really minor things in this one. > > Jonathan > > > --- > > drivers/cxl/cxl.h | 89 +++++++++++++++++++++++++++++++++++++++++++++++ > > drivers/cxl/mem.c | 58 +++++++++++++++++++++++++++--- > > 2 files changed, 143 insertions(+), 4 deletions(-) > > create mode 100644 drivers/cxl/cxl.h > > > > diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h > > new file mode 100644 > > index 000000000000..02858ae63d6d > > --- /dev/null > > +++ b/drivers/cxl/cxl.h > > @@ -0,0 +1,89 @@ > > +// SPDX-License-Identifier: GPL-2.0-only > > +// Copyright(c) 2020 Intel Corporation. All rights reserved. > > + > > +#ifndef __CXL_H__ > > +#define __CXL_H__ > > + > > +/* Device */ > > +#define CXLDEV_CAP_ARRAY_REG 0x0 > > +#define CXLDEV_CAP_ARRAY_CAP_ID 0 > > +#define CXLDEV_CAP_ARRAY_ID(x) ((x) & 0xffff) > > +#define CXLDEV_CAP_ARRAY_COUNT(x) (((x) >> 32) & 0xffff) > > + > > +#define CXL_CAPABILITIES_CAP_ID_DEVICE_STATUS 1 > > I'm not sure what you can do about consistent naming, but > perhaps this really does need to be > CXLDEV_CAP_CAP_ID_x however silly that looks. > > It's a funny exercise I've only seen done once in a spec, but > I wish everyone would try working out what their fully expanded > field names will end up as and make sure the long form naming shortens > to something sensible. It definitely helps with clarity! > > > +#define CXL_CAPABILITIES_CAP_ID_PRIMARY_MAILBOX 2 > > +#define CXL_CAPABILITIES_CAP_ID_SECONDARY_MAILBOX 3 > > +#define CXL_CAPABILITIES_CAP_ID_MEMDEV 0x4000 > > + > > +/* Mailbox */ > > +#define CXLDEV_MB_CAPS 0x00 > > Elsewhere you've used _OFFSET postfix. That's useful so I'd do it here > as well. Cross references to the spec section always appreciated as well! > > > +#define CXLDEV_MB_CAP_PAYLOAD_SIZE(cap) ((cap) & 0x1F) > > +#define CXLDEV_MB_CTRL 0x04 > > +#define CXLDEV_MB_CMD 0x08 > > +#define CXLDEV_MB_STATUS 0x10 > > +#define CXLDEV_MB_BG_CMD_STATUS 0x18 > > + > > +struct cxl_mem { > > + struct pci_dev *pdev; > > + void __iomem *regs; > > + > > + /* Cap 0000h */ > > What are the numbers here? These capabilities have too > many indexes associated with them in different ways for it > to be obvious, so perhaps more detail in the comments? This comment was a bug. The cap is 0001h actually. I've added the hash define for its cap id as part of the comment. Everything else is accepted. > > > + struct { > > + void __iomem *regs; > > + } status; > > + > > + /* Cap 0002h */ > > + struct { > > + void __iomem *regs; > > + size_t payload_size; > > + } mbox; > > + > > + /* Cap 0040h */ > > + struct { > > + void __iomem *regs; > > + } mem; > > +};