From patchwork Wed Sep 20 19:10:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 13393264 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E566DC04FF0 for ; Wed, 20 Sep 2023 19:12:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=QeT2IwzmL2Ra/+sH/EqYHZyBB8y7Ps4LJszJB09/lrE=; b=iOnZQrr4pY1yRS SU6FeBmr9Y5G/47uFzVb21HCi50nPh4SQ2f36rZ16PPwgPFDuOO8cLDNE/V5vzBJij1MfAVeYJYt4 mvUbjJiiOuOL+Jz5Ed1A0IhxyD/z7CdWeKUW2eekqEHSQe9wWkEkCbT31NZT8pyRy/WP4tN1z7+WT kUfw8cpoX5b0PhCfC7XdLHfvX11EWfl2c2M/0uE7dDBDqGfbU1LQat3hEPKRrOOMQxFKWlfhvvAEH SZvhL7utThG3IkWbAm5LGji5Divnc6h+ksnSWaFjuSQZXPI/OxkMN5VEIwPeK5tvMuAnjAsFs9QKU IosXQb+bhg5tMv3yh3Dg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qj2cf-003xZu-1g; Wed, 20 Sep 2023 19:12:29 +0000 Received: from mail-lf1-x136.google.com ([2a00:1450:4864:20::136]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qj2c9-003xA8-11 for linux-arm-kernel@lists.infradead.org; Wed, 20 Sep 2023 19:11:58 +0000 Received: by mail-lf1-x136.google.com with SMTP id 2adb3069b0e04-50337b43ee6so360525e87.3 for ; Wed, 20 Sep 2023 12:11:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695237116; x=1695841916; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=v+zg14s+8ZGl4N+E2RwxXEDbGvXikDYsUs+6iexwq0A=; b=DtbwFNaOn7rCNw2ShikdrYS7O1dopSw6KMjG1Z4NPiAbT+j6VLIT1Su/k+onFSOZAi TFnmKJq9BCJ+FMkwYp+CrQuTqy6APvIiYo0kK/CrDfk+vLBiT+5AU8M5oVcb96YF7EIL qo5Af4fFNbRQ8Xi0rahkYEfvLQoQVXsPkLeKSKBMnO6s6sv1SjoFJgRZACKJkWvitulT KXz3/zKookV2vluVoPyeZZJHmxh8QhNPGTikUkfOrdzVPob6NnZi1vMMKk6mJJf4Ktpj p//gev7g6+arfNhMsCWQUreyhS5axXEGYkmuqVTMlnBQhhqeU6+MBvageB7/oUm3QERv nmPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695237116; x=1695841916; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=v+zg14s+8ZGl4N+E2RwxXEDbGvXikDYsUs+6iexwq0A=; b=OYy9wjT1kPaGFqi0DN330GAgJQrnhXbH6022300YuTjWpfzJ3L6Rn2sAC290sD2tVK ePgMNAyORlNiA8UXN/rWUB5gbeVgt/WrqB02sj7CRuqL2W1tSggXDuFfBcJFRoHC7FzT Nf6v4xRonYzZVckc8VBVsIeXAOWHPPzi0Z/AXzD/UhuPeZRDvaVCsXJATPm7nA0GVhXo iZVMQbioemtEFuyryHWoEKhTp97JlUHAb87+QguqJras5jgL2vdGmwxXiYZRoMnd26Cc vMCKLaD/2UUSnqxMWu8P630GiyvvYGxfTVCh6ULQLFA7cavEo/+gawuBDmpwQE1cD7co pKIA== X-Gm-Message-State: AOJu0YwyVRpDaJ2mTKjHNNIXzySdgv9MeEVwld91ZJYJcNy7EUcf+RqY 4d7iYR6h1w/NYs6iUXGwB7M= X-Google-Smtp-Source: AGHT+IEKgVoHipql50H/RhjNA6phuGUygs8P02VerAp2mt48qJNC1iDtdTfRSAEsH+etmBYaawlTjg== X-Received: by 2002:a19:a410:0:b0:503:3890:ca3a with SMTP id q16-20020a19a410000000b005033890ca3amr2685854lfc.66.1695237115765; Wed, 20 Sep 2023 12:11:55 -0700 (PDT) Received: from localhost ([85.26.234.178]) by smtp.gmail.com with ESMTPSA id p19-20020ac246d3000000b00504230986fbsm95145lfo.52.2023.09.20.12.11.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Sep 2023 12:11:55 -0700 (PDT) From: Serge Semin To: Michal Simek , Alexander Stein , Borislav Petkov , Tony Luck , James Morse , Mauro Carvalho Chehab , Robert Richter Cc: Serge Semin , Punnaiah Choudary Kalluri , Dinh Nguyen , Arnd Bergmann , Greg Kroah-Hartman , linux-arm-kernel@lists.infradead.org, linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 13/20] EDAC/mc: Init DIMM labels in MC registration method Date: Wed, 20 Sep 2023 22:10:37 +0300 Message-ID: <20230920191059.28395-14-fancer.lancer@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230920191059.28395-1-fancer.lancer@gmail.com> References: <20230920191059.28395-1-fancer.lancer@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230920_121157_423447_AEFD2436 X-CRM114-Status: GOOD ( 17.32 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Move the DIMM labels initialization to the memory controller registration method as a preparation before adding the generic procedure to allocate an unique MC index. It's required because the DIMM labels contain the MC index as the "mc%u" part of the string, which in case of the auto-generated index isn't available at the moment of the MCI/csrow/dimms descriptor allocation. Signed-off-by: Serge Semin --- drivers/edac/edac_mc.c | 48 +++++++++++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 17 deletions(-) diff --git a/drivers/edac/edac_mc.c b/drivers/edac/edac_mc.c index 6faeb2ab3960..24814839d885 100644 --- a/drivers/edac/edac_mc.c +++ b/drivers/edac/edac_mc.c @@ -256,7 +256,6 @@ static int edac_mc_alloc_dimms(struct mem_ctl_info *mci) unsigned int pos[EDAC_MAX_LAYERS]; unsigned int row, chn, idx; int layer; - void *p; /* * Allocate and fill the dimm structs @@ -271,7 +270,6 @@ static int edac_mc_alloc_dimms(struct mem_ctl_info *mci) for (idx = 0; idx < mci->tot_dimms; idx++) { struct dimm_info *dimm; struct rank_info *chan; - int n, len; chan = mci->csrows[row]->channels[chn]; @@ -282,22 +280,9 @@ static int edac_mc_alloc_dimms(struct mem_ctl_info *mci) dimm->mci = mci; dimm->idx = idx; - /* - * Copy DIMM location and initialize it. - */ - len = sizeof(dimm->label); - p = dimm->label; - n = scnprintf(p, len, "mc#%u", mci->mc_idx); - p += n; - len -= n; - for (layer = 0; layer < mci->n_layers; layer++) { - n = scnprintf(p, len, "%s#%u", - edac_layer_name[mci->layers[layer].type], - pos[layer]); - p += n; - len -= n; + /* Copy DIMM location */ + for (layer = 0; layer < mci->n_layers; layer++) dimm->location[layer] = pos[layer]; - } /* Link it to the csrows old API data */ chan->dimm = dimm; @@ -510,6 +495,33 @@ void edac_mc_reset_delay_period(unsigned long value) +/** + * edac_mc_init_labels() - Initialize DIMM labels + * + * @mci: pointer to the mci structure which DIMM labels need to be initialized + * + * .. note:: + * locking model: must be called with the mem_ctls_mutex lock held + */ +static void edac_mc_init_labels(struct mem_ctl_info *mci) +{ + int n, len, layer; + unsigned int idx; + char *p; + + for (idx = 0; idx < mci->tot_dimms; idx++) { + len = sizeof(mci->dimms[idx]->label); + p = mci->dimms[idx]->label; + + n = scnprintf(p, len, "mc#%u", mci->mc_idx); + for (layer = 0; layer < mci->n_layers; layer++) { + n += scnprintf(p + n, len - n, "%s#%u", + edac_layer_name[mci->layers[layer].type], + mci->dimms[idx]->location[layer]); + } + } +} + /* Return 0 on success, 1 on failure. * Before calling this function, caller must * assign a unique value to mci->mc_idx. @@ -637,6 +649,8 @@ int edac_mc_add_mc_with_groups(struct mem_ctl_info *mci, goto fail0; } + edac_mc_init_labels(mci); + if (add_mc_to_global_list(mci)) goto fail0;