From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D0423C433EF for ; Wed, 27 Apr 2022 17:55:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244464AbiD0R6U (ORCPT ); Wed, 27 Apr 2022 13:58:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44042 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229451AbiD0R6T (ORCPT ); Wed, 27 Apr 2022 13:58:19 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6115912ACC9; Wed, 27 Apr 2022 10:55:07 -0700 (PDT) Received: from fraeml745-chm.china.huawei.com (unknown [172.18.147.200]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4KpRCk0YZmz67KmH; Thu, 28 Apr 2022 01:52:18 +0800 (CST) Received: from lhreml710-chm.china.huawei.com (10.201.108.61) by fraeml745-chm.china.huawei.com (10.206.15.226) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Wed, 27 Apr 2022 19:55:05 +0200 Received: from localhost (10.81.200.74) 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.2375.24; Wed, 27 Apr 2022 18:55:04 +0100 Date: Wed, 27 Apr 2022 18:55:02 +0100 From: Jonathan Cameron To: CC: Dan Williams , Bjorn Helgaas , Alison Schofield , "Vishal Verma" , Ben Widawsky , , , Subject: Re: [PATCH V8 07/10] cxl/mem: Read CDAT table Message-ID: <20220427185502.00001fbf@Huawei.com> In-Reply-To: <20220414203237.2198665-8-ira.weiny@intel.com> References: <20220414203237.2198665-1-ira.weiny@intel.com> <20220414203237.2198665-8-ira.weiny@intel.com> Organization: Huawei Technologies Research and Development (UK) Ltd. X-Mailer: Claws Mail 4.0.0 (GTK+ 3.24.29; i686-w64-mingw32) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.81.200.74] 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-pci@vger.kernel.org On Thu, 14 Apr 2022 13:32:34 -0700 ira.weiny@intel.com wrote: > From: Jonathan Cameron > > The OS will need CDAT data from CXL devices to properly set up > interleave sets. Currently this is supported by a through a DOE mailbox > which supports CDAT. But any cxl_mem object can provide this data later > if need be, for example for testing. > > Cache the CDAT data for later parsing. Provide a sysfs binary attribute > to allow dumping of the CDAT. > > Binary dumping is modeled on /sys/firmware/ACPI/tables/ > > The ability to dump this table will be very useful for emulation of real > devices once they become available as QEMU CXL type 3 device emulation will > be able to load this file in. > > This does not support table updates at runtime. It will always provide > whatever was there when first cached. Handling of table updates can be > implemented later. > > Finally create a complete list of DOE defines within cdat.h for code > wishing to decode the CDAT table. > > Signed-off-by: Jonathan Cameron > Co-developed-by: Ira Weiny > Signed-off-by: Ira Weiny > I'd have left the introduction of callbacks until they were actually needed, but meh. That's minor. On trivial below. Reviewed-by: Jonathan Cameron ... > + > +static int read_cdat_data(struct cxl_dev_state *cxlds) > +{ > + struct device *dev = cxlds->dev; > + size_t cdat_length; > + int ret; > + > + if (cxl_mem_cdat_get_length(cxlds, &cdat_length)) > + return 0; > + > + cxlds->cdat.table = devm_kzalloc(dev, cdat_length, GFP_KERNEL); > + if (!cxlds->cdat.table) > + return -ENOMEM; Trivial but blank line here. > + cxlds->cdat.length = cdat_length; > + ret = cxl_mem_cdat_read_table(cxlds, &cxlds->cdat); > + if (ret) { > + devm_kfree(dev, cxlds->cdat.table); > + cxlds->cdat.table = NULL; > + cxlds->cdat.length = 0; > + } > + return ret; > +}