Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp587820rwb; Thu, 1 Dec 2022 06:07:45 -0800 (PST) X-Google-Smtp-Source: AA0mqf7aMPLXdLKOagkLYnQ59y1hwFrmdZyw/u88BBhm+jWyfu8ctcdeGgqXppI0OKFGOpOPiYeu X-Received: by 2002:a17:902:8a90:b0:189:680e:ac3a with SMTP id p16-20020a1709028a9000b00189680eac3amr31590499plo.77.1669903664907; Thu, 01 Dec 2022 06:07:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669903664; cv=none; d=google.com; s=arc-20160816; b=DsumGbMv2zWmkY3EePnqaOP5uJZi9UTP/wRnW+Q+tdPfj4WK+tjrCRtrgV/ZN1+h8x r6OnUMBk6gVtCKWzOz69HxLW1sgQVHeMmeFeNmTpfdrQE3gUfGh9FmjEl3l80D0Ez0A+ qqf7bD9Wwkr4ErWAQ6Hxrg2QDVzsxnwEwmKoIUhM4K0lEA+OE74ZHE/L7z4nxs1Q6iCt Y/NqmUCUxznO34n+C3j8r2dLdKKBx+Z65p35vpcRQc8zsCP/HXpwHwchZBYxDK9iqu6N CayZcEosyTDbXD4/v4B3H508Hae3Y4z8/R5fW4Aps9Rf/8ysrv27kAqZaHVyA9NNv1MD nNZQ== 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=B18ML99eEBxHktRXuUW0AfzKJp9iNDu3pW3yMydfI6A=; b=a8+r7R9bvNdSFdq8OGFhg8wJTY7pflGFPSz6n/ihCd7seUZYGXv0wILnH/3sZfzaXJ EscCFynOclkbmAabYYpQTQZoN2hKZcI6jhau6UtebN8pv5jQNIP9OudPhAltGgyzOzow AG12xJHWIMSbhPpYkZ15Kf2LEby9JQEzHBtxOfAnfCl9ZwDGdV1M/BRs7HvL02D26Ej5 ZK38+ZJIz09/vhOhEFGucF+dqSaWfWie3qs8/8D3hC7Ua2rHhkWjDuYKOqM+Lqa/iw2R rJ8co821djfzffrMegfdsSQkEYzAgUBQpRbmFzk62TEbpkmm0yOUpR2iYkOk0KkJUrC7 8x8A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f27-20020aa7969b000000b005612b15a927si4426606pfk.181.2022.12.01.06.07.33; Thu, 01 Dec 2022 06:07:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230088AbiLANHD (ORCPT + 82 others); Thu, 1 Dec 2022 08:07:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49978 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229728AbiLANHC (ORCPT ); Thu, 1 Dec 2022 08:07:02 -0500 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F23366589; Thu, 1 Dec 2022 05:06:53 -0800 (PST) Received: from frapeml500001.china.huawei.com (unknown [172.18.147.207]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4NNGV90wjpz687L9; Thu, 1 Dec 2022 21:03:45 +0800 (CST) Received: from lhrpeml500005.china.huawei.com (7.191.163.240) by frapeml500001.china.huawei.com (7.182.85.94) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Thu, 1 Dec 2022 14:06:51 +0100 Received: from localhost (10.202.227.76) by lhrpeml500005.china.huawei.com (7.191.163.240) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Thu, 1 Dec 2022 13:06:50 +0000 Date: Thu, 1 Dec 2022 13:06:50 +0000 From: Jonathan Cameron To: CC: Dan Williams , Steven Rostedt , Alison Schofield , "Vishal Verma" , Ben Widawsky , Davidlohr Bueso , Dave Jiang , , Subject: Re: [PATCH V2 02/11] cxl/mem: Implement Get Event Records command Message-ID: <20221201130650.00007f3d@Huawei.com> In-Reply-To: <20221201002719.2596558-3-ira.weiny@intel.com> References: <20221201002719.2596558-1-ira.weiny@intel.com> <20221201002719.2596558-3-ira.weiny@intel.com> Organization: Huawei Technologies Research and Development (UK) Ltd. X-Mailer: Claws Mail 4.1.0 (GTK 3.24.33; x86_64-w64-mingw32) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.202.227.76] X-ClientProxiedBy: lhrpeml100001.china.huawei.com (7.191.160.183) To lhrpeml500005.china.huawei.com (7.191.163.240) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 30 Nov 2022 16:27:10 -0800 ira.weiny@intel.com wrote: > From: Ira Weiny > > CXL devices have multiple event logs which can be queried for CXL event > records. Devices are required to support the storage of at least one > event record in each event log type. > > Devices track event log overflow by incrementing a counter and tracking > the time of the first and last overflow event seen. > > Software queries events via the Get Event Record mailbox command; CXL > rev 3.0 section 8.2.9.2.2. > > Issue the Get Event Record mailbox command on driver load. Trace each > record found with a generic record trace. Trace any overflow > conditions. > > The device can return up to 1MB worth of event records per query. > Allocate a shared large buffer to handle the max number of records based > on the mailbox payload size. > > This patch traces a raw event record only and leaves the specific event > record types to subsequent patches. > > Macros are created to use for tracing the common CXL Event header > fields. > > Cc: Steven Rostedt > Signed-off-by: Ira Weiny Hi Ira, Looks good to me. A few trivial suggestions inline. Either way, Reviewed-by: Jonathan Cameron > diff --git a/drivers/cxl/core/mbox.c b/drivers/cxl/core/mbox.c > index 16176b9278b4..70b681027a3d 100644 > --- a/drivers/cxl/core/mbox.c > +++ b/drivers/cxl/core/mbox.c > @@ -7,6 +7,9 @@ ... > + > +static void cxl_mem_free_event_buffer(void *data) > +{ > + struct cxl_dev_state *cxlds = data; > + > + kvfree(cxlds->event_buf); Trivial, but why not just pass in the event_buf? > +} > + > +/* > + * There is a single buffer for reading event logs from the mailbox. All logs > + * share this buffer protected by the cxlds->event_buf_lock. > + */ > +static struct cxl_get_event_payload *alloc_event_buf(struct cxl_dev_state *cxlds) > +{ > + struct cxl_get_event_payload *buf; > + > + dev_dbg(cxlds->dev, "Allocating event buffer size %zu\n", > + cxlds->payload_size); > + > + buf = kvmalloc(cxlds->payload_size, GFP_KERNEL); huh. I assumed there would be a devm_kvmalloc() but apparently not.. Ah well - whilst it might makes sense to add one, let's not tie that up with this series. > + if (buf && devm_add_action_or_reset(cxlds->dev, > + cxl_mem_free_event_buffer, cxlds)) > + return NULL; Trivial, but I'd go for a more wordy but more conventional pattern of if (!buf) return NULL; if (devm_add_action_or_reset()) return NULL return buff; > + return buf; > +} > + ... > diff --git a/drivers/cxl/cxlmem.h b/drivers/cxl/cxlmem.h > index cd35f43fedd4..55d57f5a64bc 100644 > --- a/drivers/cxl/cxlmem.h > +++ b/drivers/cxl/cxlmem.h > @@ -4,6 +4,7 @@ > #define __CXL_MEM_H__ > #include > #include > +#include > #include "cxl.h" > > /* CXL 2.0 8.2.8.5.1.1 Memory Device Status Register */ > @@ -250,12 +251,16 @@ struct cxl_dev_state { > > bool msi_enabled; > > + struct cxl_get_event_payload *event_buf; Whilst it is obvious (and document at point of allocation), I think one of the static checkers still warns that all locks must have comments. Probably easier to add one now than wait for the inevitable warning report. > + struct mutex event_buf_lock; > + > int (*mbox_send)(struct cxl_dev_state *cxlds, struct cxl_mbox_cmd *cmd); > }; >