From patchwork Thu Feb 22 18:12:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 13567873 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 6AEECC54791 for ; Thu, 22 Feb 2024 18:21:00 +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=r6Dq5KPC1nIYkIWQRnZavVtyJeFX5aW9OgQB04/EZZM=; b=IUErIdMSjdFDM9 0w+751dYfiKVq3Mt7MOVNabGGGlRS/OCf62L9fatgEnpohrB0YLV8Z0si/H3RePcaH9YgyHwuug8a BWnPG/81sI+rhHKgREHHKhBGTq0/6jKn0jLn4luLVzsvqHq+/LLkpGoj/W6MeMt5EgBRjrAuSmvgA WwvBz/Zux5dVV3GA9+8erbXU+p5GKUnggxK5FHDUUUdPnauPWDPGOk+Wdv+R1J5Nh5BVIZKrCNmGH r9tMgVYjFIYTUuDzrzDnNSKXqxKK9/RuC4O3O5XfBtKFnmZifaANJUWAP8UF9N0Tuu4AhshCVJSF9 8XrJUCrm2BJ2q4c+2MEA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rdDgd-0000000600j-2Pqz; Thu, 22 Feb 2024 18:20:47 +0000 Received: from mail-lj1-x234.google.com ([2a00:1450:4864:20::234]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rdDap-00000005x9t-416Q for linux-arm-kernel@lists.infradead.org; Thu, 22 Feb 2024 18:14:59 +0000 Received: by mail-lj1-x234.google.com with SMTP id 38308e7fff4ca-2d208d0b282so1003731fa.0 for ; Thu, 22 Feb 2024 10:14:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708625684; x=1709230484; 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=f1rSLwnPGPRLZ8guN9SvY0oeLlNdJ+G5T4uaWdRND5Io1fAgqg3JSPk3RdX363bhye zQHhU3r2FHpiP5EcxcOxOwMtxDyVrKT35W4HpLj9nXMqJpG+FEjofbStPHuCBb/8Tvjy ttBNh/TRnksueAiZjL2NYCzJ1aSfi+POV6XfGtNJMWKD3PK8oZBoFgfOH/JPKJJKB72Y 0y4DXvoOaXUiNzFIFueDRhIr6bHoSBoAKgA9a5XtA3xR+VUP1ZmikIDDmlk4RNb81owT dxt/L4aCgj6n6QUMjATc9vQxgsTCaIaaDlJD95FIn08yJqt4IjaW5zFffgK8M/iNUahm /fXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708625684; x=1709230484; 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=ihge/sAaNKYhoR8E7JfxhSePZJR/55cSNm75FD6HF9taID9rZjvWDgsr3mBbW21WnY vMYTVO+cK8YbS3wFh3AuWQv7qtWvNApAO7F2LfSnaqd5AY2Xxpq/BILWZZ//7nmtsCtu Z88igpag6mwWaqB1LIxlNA3nd3CJ7uftUr6B10ruZKWyk9MVVuu9zI8yT/aMOHSO6Hzb 548FA/nqZNoviwP2F9iysFIrZNJ2GAOWCJu3VkmCrP+ywTKihJPD4vzlQCRdJ73iboX0 ME7MNl+0936KWAP4XrFxyOyE+4veXw01+X9MCjpF6g0LBIlDL8WVqNBPOctU+jVtIeWK TbGQ== X-Forwarded-Encrypted: i=1; AJvYcCVz4xfaGCTI3qK2qb6/y49xogURqh7DpfXtMqY8vSFtALLL42j56Vs0v5xyaCjiQvhmiJXFbE37lQM8ZXdItpu+0aJvXxJqQGH40O4gmFjCKiNr+50= X-Gm-Message-State: AOJu0YzZhHYmi41w+lAn5/Gqv+IByNPB8n9uaez8dQMKLMHw9AJxmKy7 DWZj1bMYd4mFM3B/IN6oaWEKJWV7DEqG95ctFsmzO2WxhVv/kcbDOSaHQoKzXvQ= X-Google-Smtp-Source: AGHT+IHujCBUf3uP+SOmn6mxJZA8UNgrf2Op4NXH3LML5XVClyL6ZZ2opxWdtVcY7NGtBDIbf+PxtA== X-Received: by 2002:a2e:8256:0:b0:2d2:5169:27f3 with SMTP id j22-20020a2e8256000000b002d2516927f3mr4079549ljh.34.1708625683925; Thu, 22 Feb 2024 10:14:43 -0800 (PST) Received: from localhost ([178.176.56.174]) by smtp.gmail.com with ESMTPSA id a16-20020a05651c211000b002d26782e8d9sm65176ljq.55.2024.02.22.10.14.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 10:14:43 -0800 (PST) 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 v5 13/20] EDAC/mc: Init DIMM labels in MC registration method Date: Thu, 22 Feb 2024 21:12:58 +0300 Message-ID: <20240222181324.28242-14-fancer.lancer@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240222181324.28242-1-fancer.lancer@gmail.com> References: <20240222181324.28242-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-20240222_101450_518900_8384E5C6 X-CRM114-Status: GOOD ( 16.82 ) 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;