From patchwork Thu Jun 27 17:32:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 13714944 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 D7754C3064D for ; Thu, 27 Jun 2024 17:34: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:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=+o0t5l+gbhBR5sr353Zx4OwnR+/NtUKsRVbiL7FnCuk=; b=iw4G0rdax90cgH8wHxl+SXF7dh 9rag2S3/znknUnGp+g09exAA657wjit5WUB4hpzCN8H5RSgJ02i6kHpyjuhdl2LA1omWc26Oj+W7S NP6XZ0xdMfFuoiMEuwWpuppbW5P/ev/VUpOrQUHs8qEOrfakPQYfC8Wh5Ubwe/5qexsM3o1hAA9o8 u0d95X/8LLwna4usNPnLGoSixmk1OQ9FPSo/6o6+GWb1K5it5v3mOz6/R9oTWkASTpt3KvnHuA34D IHtZ0FEUr1G0eJs7Frf2gHGMj+T3X0y4+h6ttDRxXPV4Ab7q0D+Ng9lV9Sf0SZP9xB5JhyCM4wxle lKXOmO9Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sMt1A-0000000BENJ-19oh; Thu, 27 Jun 2024 17:34:44 +0000 Received: from mail-lf1-x12d.google.com ([2a00:1450:4864:20::12d]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sMszr-0000000BDYl-29ds for linux-arm-kernel@lists.infradead.org; Thu, 27 Jun 2024 17:33:25 +0000 Received: by mail-lf1-x12d.google.com with SMTP id 2adb3069b0e04-52cdf2c7454so10656729e87.1 for ; Thu, 27 Jun 2024 10:33:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719509602; x=1720114402; 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=+o0t5l+gbhBR5sr353Zx4OwnR+/NtUKsRVbiL7FnCuk=; b=eChIGeiBG2/ApN03LJEpETUvZ6lqH2evsxZWt6ftDSUExWOWsQal3jXF7Srz2PSJCG kHb7qMiVOTOAToeK9qnoWezvHO4SOZgagGclnHlKnzdotmYpMwrItqGNj5xUBJ6B7bC3 YK0dSVhyMk2eLYvXZ8WBZRDMLAg6Z13wp3EhhZlLQ1oLt1gDayMU4iQi4TY/OGEZB0Ve B+qq8I4dxLeSVzZNkHQErzlxfPMX04ixbpvkXE2KSfRRix1C9L/aPuHNGU0CVJjVcxBr vDEBVmaRg9WoHr0Y+mgY+Pp9cZq+c4GeAetpu/47og3XeiG1LIPCJR2Uxl9CsYtXGZiz OAqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719509602; x=1720114402; 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=+o0t5l+gbhBR5sr353Zx4OwnR+/NtUKsRVbiL7FnCuk=; b=Ewg55REQzwtNTFzIluZxa6yp9NsPKAawogHCC/0EDXZxy112OvYzNpsgP8KmgiAP/L 3RUpI6Uls375edYHNLZoJUYYbveqcYehhLN4wDx2W1kq/Y92j2/+IV4g4zJjg4d5/j71 E5G5GyUy4fCeMPAOgsp0YOH+SsGFg3G5Wy4p9n9RRZZGFey3eZXHF5C1RUm2C/ApWrX1 UzTzR5IwfVgba4A4VwRU1KuE3w3J03tB1fsdqHj0rHlGJPYNNwnqC5/ioMb2+kZRkLsW 8LmZsNXsE4nqI2ANhj8bsuv4yRthSvMLgvtPXbZj2p7SUTtx3KqV/U4zhJcbN8CxZGfD NOiQ== X-Forwarded-Encrypted: i=1; AJvYcCUT868QmF6f4eCaKlEfUg77RS8YXfYJubLPA6coxk3UU9Vd7wLEl/QOS/3wyAXgZMDfIIgFRh+2vY+4grmtIVbEdyjZBTynuP+rZTT1CLQc8vOsSR8= X-Gm-Message-State: AOJu0YwS35wjdzlqV5uy0O7Q7Vs9pZy3/WHzJMBWRnPYeV1cdxsvflP/ kdhJ9x3ezeUddxSegsUGjEit3GdHvhsFojFyzCrDK7ZBr1wBlwji X-Google-Smtp-Source: AGHT+IFghayRhLz4uxIDL4vu9rwoG8YPDZ1hjqc0Z7OjlBf0v3MkYxcg9EZV6XH6LzZ4yQcswu6v3g== X-Received: by 2002:ac2:5e79:0:b0:52c:8909:bd35 with SMTP id 2adb3069b0e04-52ce182bc95mr10723507e87.10.1719509601911; Thu, 27 Jun 2024 10:33:21 -0700 (PDT) Received: from localhost ([213.79.110.82]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-52e7ab27b81sm30e87.163.2024.06.27.10.33.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jun 2024 10:33:21 -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 , Shubhrajyoti Datta , Arnd Bergmann , Greg Kroah-Hartman , linux-arm-kernel@lists.infradead.org, linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH RESEND v6 11/18] EDAC/mc: Init DIMM labels in MC registration method Date: Thu, 27 Jun 2024 20:32:18 +0300 Message-ID: <20240627173251.25718-12-fancer.lancer@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240627173251.25718-1-fancer.lancer@gmail.com> References: <20240627173251.25718-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-20240627_103323_590241_A40F27ED X-CRM114-Status: GOOD ( 16.34 ) 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 d6eed727b0cd..c0b36349999f 100644 --- a/drivers/edac/edac_mc.c +++ b/drivers/edac/edac_mc.c @@ -257,7 +257,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 @@ -272,7 +271,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]; @@ -283,22 +281,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; @@ -511,6 +496,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. @@ -638,6 +650,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;