Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp1831367rdb; Tue, 20 Feb 2024 08:13:01 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVKonsoq3wdvNj7wCc8z1BoNBYtClZlCLr/VNNqrgL59RzXBfLxcrX257NN1nHuXcZQEswaTEiwrb5bnDk9K9LwXNNnQxSDlvUqa8Cjlw== X-Google-Smtp-Source: AGHT+IHektUSVNnxefKBP4YgpGsTMH7PcOfuM3NGpYEi1U/NbFEeXRhy2OINu8e9vHtpA3/4NRy6 X-Received: by 2002:a05:6a20:d38f:b0:19e:a1ae:944e with SMTP id iq15-20020a056a20d38f00b0019ea1ae944emr15256679pzb.37.1708445581306; Tue, 20 Feb 2024 08:13:01 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708445581; cv=pass; d=google.com; s=arc-20160816; b=s2d9ZXDK9PvK1Z4Eia54w5KBStsRq45pbvqpASR0jxfSLXzsfdfrrBPxccull61swf dYyW+nxvE8Nl2dy6Z8Fw4Yk5ZrzJFgrur1qunw63T3QCQw+/IZ20ghoAThHw1ATTazYJ hH6BHF/GENOxfXR+2z9wgbBdgHSldOK4UNcAQ4pi2uziHl83slOPsWBkUBvHmeEtH/tJ OKrh8qNWj1epjcq6AkAFhNTDTG5kKwvSNEs9OZIItvSaj7MuRJm+Y4xfZIUAWRF+tleG suwrkb+igPlGlSMhwcx6WLFCjm1CZPo8FJVjlaewBmiHGwHD4ZUmPN4pB026g8TDykne 36+w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:organization:references :in-reply-to:message-id:subject:cc:to:from:date; bh=ccsxJstrPxfuWrt52fAHJBKE9sdZ7PogctGew5I7nsQ=; fh=ehmdxMaNn1e64k03FAUDGH5ufF0BMazsqKtQWl0yC7M=; b=Gea1etd8818b/CWhNh10sJCyp0KBrzJoaa46GYZli+QbGLb7zJpLMTFGCQ5osZfO6i 59qjazZRLq02PhMyWpmo0binJzGzsVyBx5xhgIB0EXJma+YZs3u95ftJZrHVXaFyDX3u OLHLT9D3Av6m9iRObOEBW4KmEjBQ/rvAgRsV6YnhQL6UUgGc1moR26dDXsPElGo2wqBQ zUx/7xi3/j1Qd1Ld61iqEU2hjco7+w1S6pCRnE0aD2e4LD/i+3udxz39gRwudXVRoht+ P5QuN3utP9vkdgFFnmqfvmr5ha2M/eqf5ZV9Hy3cgZN7q17PdJpPHakp7j7mYO0o4J14 rh7A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-73314-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-73314-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id b7-20020a631b07000000b005cdfb96ea62si6375233pgb.243.2024.02.20.08.13.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Feb 2024 08:13:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-73314-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-73314-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-73314-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id F34A12844A0 for ; Tue, 20 Feb 2024 16:13:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4F4DC763F7; Tue, 20 Feb 2024 16:12:41 +0000 (UTC) Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BB4AB768FA; Tue, 20 Feb 2024 16:12:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.176.79.56 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708445560; cv=none; b=Aohs+BqGzUSwtPO0qXZkTN7uFrCZiSjKUl39rI5u1ie0cgP25l3Sv7ksdWG+orBMQF08rQDXp8PiN6CS48Xc5g9fRtsAjq+VQG86X7Dd/WwJN8yGFp5jp48d39xpx2yteburfhWICqOnHMShV2RIDLQoTeEToHKE5QfLD79vcU0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708445560; c=relaxed/simple; bh=WZwcnRFd8AxpgMn/ncUH7HuyNVf1CJoD2fIOANFeZdk=; h=Date:From:To:CC:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=pAE2XePKwjdm8jTqf2SuZMcjLPq6SBGDyTE7JYUpA1mxtsb8m8R3Qgtf5aEqS/rhPXydnj7DYWveMs2VxtVDSpZLH9hlSLXu7NF62sCTQdphXjPicnBlxZ2SPemmLyxkV4LUQ8buSs0gSkc586KIYQm5IegNSSb3ONZ1wthic+w= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=Huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=185.176.79.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=Huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.18.186.231]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4TfPTZ58hwz6K635; Wed, 21 Feb 2024 00:08:34 +0800 (CST) Received: from lhrpeml500005.china.huawei.com (unknown [7.191.163.240]) by mail.maildlp.com (Postfix) with ESMTPS id B9642140B54; Wed, 21 Feb 2024 00:12:34 +0800 (CST) 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.2507.35; Tue, 20 Feb 2024 16:12:33 +0000 Date: Tue, 20 Feb 2024 16:12:32 +0000 From: Jonathan Cameron To: CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: Re: [RFC PATCH v6 12/12] memory: RAS2: Add memory RAS2 driver Message-ID: <20240220161232.00000496@Huawei.com> In-Reply-To: <20240215111455.1462-13-shiju.jose@huawei.com> References: <20240215111455.1462-1-shiju.jose@huawei.com> <20240215111455.1462-13-shiju.jose@huawei.com> Organization: Huawei Technologies Research and Development (UK) Ltd. X-Mailer: Claws Mail 4.1.0 (GTK 3.24.33; x86_64-w64-mingw32) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: lhrpeml500005.china.huawei.com (7.191.163.240) To lhrpeml500005.china.huawei.com (7.191.163.240) On Thu, 15 Feb 2024 19:14:54 +0800 wrote: > From: Shiju Jose >=20 > Memory RAS2 driver binds to the platform device add by the ACPI RAS2 > driver. > Driver registers the PCC channel for communicating with the ACPI compliant > platform that contains RAS2 command support in the hardware. >=20 > Add interface functions to support configuring the parameters of HW patrol > scrubs in the system, which exposed to the kernel via the RAS2 and PCC, > using the RAS2 commands. >=20 > Add support for RAS2 platform devices to register with scrub subsystem > driver. This enables user to configure the parameters of HW patrol scrubs, > which exposed to the kernel via the RAS2 table, through the scrub sysfs > attributes. >=20 > Open Question: > Sysfs scrub control attribute "enable_background_scrub" is added for RAS2, > based on the feedback from Bill Schwartz on v4 to enable/disable the background_scrubbing in the platform as defin= ed in the > =E2=80=9CConfigure Scrub Parameters [INPUT]=E2=80=9C field in RAS2 Table= 5.87: Parameter Block > Structure for PATROL_SCRUB. > Is it a right approach to support "enable_background_scrub" in the sysfs > scrub control? Does anyone know what this means? IIUC patrol scrub is always background... >=20 > Signed-off-by: Shiju Jose A few minor comments inline. Rushed review as out of time for today though so may have missed stuff. > diff --git a/drivers/memory/rasf_common.c b/drivers/memory/rasf_common.c > new file mode 100644 > index 000000000000..85f67308698d > --- /dev/null > +++ b/drivers/memory/rasf_common.c > @@ -0,0 +1,269 @@ > +// SPDX-License-Identifier: GPL-2.0-or-later > +/* > + * rasf_common.c - Common functions for memory RASF driver > + * > + * Copyright (c) 2023 HiSilicon Limited. > + * > + * This driver implements call back functions for the scrub > + * configure driver to configure the parameters of the hw patrol > + * scrubbers in the system, which exposed via the ACPI RASF/RAS2 > + * table and PCC. > + */ > + > +#define pr_fmt(fmt) "MEMORY RASF COMMON: " fmt > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include of.h Shouldn't be here in an ACPI driver! > +#include > + > +#include > +#include > + > +static int enable_write(struct rasf_context *rasf_ctx, long val) > +{ > + int ret; > + bool enable =3D val; > + > + ret =3D rasf_ctx->ops->enable_scrub(rasf_ctx, enable); > + if (ret) { > + pr_err("enable patrol scrub fail, enable=3D%d ret=3D%d\n", > + enable, ret); dev_err(rasf_ctx->dev,... > + return ret; > + } > + > + return 0; > +} > + > +/** > + * rasf_hw_scrub_is_visible() - Callback to return attribute visibility > + * @drv_data: Pointer to driver-private data structure passed > + * as argument to devm_scrub_device_register(). > + * @attr_id: Scrub attribute > + * @region_id: ID of the memory region > + * > + * Returns: 0 on success, an error otherwise > + */ > +umode_t rasf_hw_scrub_is_visible(struct device *dev, u32 attr_id, int re= gion_id) > +{ > + switch (attr_id) { > + case scrub_rate_available: > + return 0444; > + case scrub_enable: > + case scrub_enable_background_scrub: > + return 0200; > + case scrub_addr_base: > + case scrub_addr_size: > + case scrub_rate: > + return 0644; As before, I'd prefer to see this passed the current permissions then just return those rather than encoding them here and in the attributes where they may end up out of sync > + default: > + return 0; > + } > +} > + > +/** > + * rasf_hw_scrub_read_strings() - Read callback for string attributes > + * @device: Pointer to scrub device > + * @attr_id: Scrub attribute > + * @region_id: ID of the memory region > + * @buf: Pointer to the buffer for copying returned string > + * > + * Returns: 0 on success, an error otherwise > + */ > +int rasf_hw_scrub_read_strings(struct device *device, u32 attr_id, int r= egion_id, > + char *buf) dev maybe instead of device. Shorter lines and it's very common shorthand. > +{ > + struct rasf_context *rasf_ctx; > + > + rasf_ctx =3D dev_get_drvdata(device); struct rasf_context *rasf_ctx =3D dev_get_drvdata(dev); Same throughout. > + > + switch (attr_id) { > + case scrub_rate_available: > + return rate_available_read(rasf_ctx, buf); > + default: > + return -ENOTSUPP; > + } > +}