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: 142565 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp4371422vqi; Wed, 20 Sep 2023 12:21:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGpZPQMChifzM1tSHXeJEUoEpVJ2i3w2CZUTGwH4dl2PeOvwisjCqZ4OHtCFKspbIc4TQsL X-Received: by 2002:a05:6870:6487:b0:1c8:bf19:e1e4 with SMTP id cz7-20020a056870648700b001c8bf19e1e4mr3577043oab.37.1695237701488; Wed, 20 Sep 2023 12:21:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695237701; cv=none; d=google.com; s=arc-20160816; b=APtL0mbgycfJf54h7fi7MeP5BxKIbEj+k11XrXJ6F1vcmvW401kx34Y5ydsgrRlcXP GXj+kplY2MX2UR3+dJea8mlNR/Ijjc544gV3xuKjSr7RaDo0fBKP+D+gzboN3++BShGm AqZHAWambnBwUt9Ito+l8eYTDnSuhrRIGq3blulknl/+FSljUpmp8BPNb2cFEjvZIw4Z l0vmU+IiW7fjH287tHwQhUfVtgUWMeFVfkGHWwP2G71QwA4rwUVBYhwkmTKTW6iIiezy UoNWFrNNBw+lm8kZuGxOd1Mbqhi/eJoiPafho0fykU4T9+g24rEAd5ApLFEPqRXT4GXJ vRcg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=v+zg14s+8ZGl4N+E2RwxXEDbGvXikDYsUs+6iexwq0A=; fh=Dnqcu1G7YxMiPJ+rEGjOOR/MtvfjezykDSRJXQQtmAE=; b=vFSkmAa8KO63ZiTlLQdE9R62yGbPU/x6MlM7iUg4HtdZJuenZSm6RNNONjXHzs7bZV N4778Hho2xy1Jex9r9ojFDvbY8J1mWIYH0jyGAAQoi0KA3mgarat4d/Jaa0A2ty6YAyr Qwja/GVO4Sm38v+RjYyNN0CTJJgO1Bz1Bgzo5YRbwMDK+Rjb7Cu0umQhSEAi8fHqpKyp +qsNQ/Oz33u6Z+8CQAEvXgll80+olFkeD7ITVIdWZkLAeZcNDFMLLWxjDhWaNWCul5XN l/Z2UCrpR8bVpgwgKo2UkBIvAII05PP3P6uEgbQw/F4sVnaAWWjDXVYuiL1gUFxqhPzy jxvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="iMpwe/bG"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id j191-20020a638bc8000000b00578bacd7fc7si3509136pge.713.2023.09.20.12.21.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Sep 2023 12:21:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="iMpwe/bG"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 903078039DE7; Wed, 20 Sep 2023 12:12:52 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229764AbjITTMe (ORCPT + 27 others); Wed, 20 Sep 2023 15:12:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230018AbjITTMU (ORCPT ); Wed, 20 Sep 2023 15:12:20 -0400 Received: from mail-lf1-x130.google.com (mail-lf1-x130.google.com [IPv6:2a00:1450:4864:20::130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C4CE518B; Wed, 20 Sep 2023 12:11:57 -0700 (PDT) Received: by mail-lf1-x130.google.com with SMTP id 2adb3069b0e04-503056c8195so383855e87.1; 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=vger.kernel.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=iMpwe/bGXZgSZUkhwQLh+QsCvlqioCJQEkzOK12DeX8qUVnQAQP0D1khwkclsOrqdQ iOPK1yuxBSH5rHfbw08zJFXS7+EgKTuY3sNbY6S0Lfl58asxXAeh+j952+4VBZv7Az1Z HwrciRcEm8p8j9Ksl732ua9xEhm9nl4TXtD5Hgy+QpbjPXjZdg30TgHz2b8jAIDGk4sd jrLTClyUDsVd8nJaJV+RwkDD/cktS7jdmg9sBC5U9/tUaDwtOrYhnmWd4KV1tzbzRs0/ BaWlswllYHGw5ziY1W4Z/JDYp/8KzRNEDQZPPfj8WK5ONVbB4DocVmS2aTat3hxr/Jxl qLqA== 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=Lrae2a1q3Ila5JelJGw2uDLoBH2BHX0OK81LN9Ox/8L+iyvgTQrRdo3CM6wtdLIj8X 5OBLbDF6WkrmrUt+kuzp1VZss+B2oEUZ2CeO93xrx06RW2j5gMg/NJqKVwDmjJPsR+EC 6R3VlXJY8goJWuXBYnD9F9eUXh9oObiT7cNClEYivxG4P+fm3ykzQw7QemTYFo2Tgp4B qGUcmDeQZCy5mywC45oj+4YwwbuRtK1QLgcuJzrJrRm5RGfCLKUzqx6m0ab0k6cbq7uI 9FkH5DioF9WYPBf+O1DAg68WN06233eacu8OEKigMFPRnlV+OUXPfyF9f87zHGWk+okb toog== X-Gm-Message-State: AOJu0YzjqUESjmokuc6bnBVtB4rjIcnYQz/QdB8blYT1xqnSbDhcoN6j FY4kV9ldAnn8uBdyWcRYu28= 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-Spam-Status: No, score=0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_SORBS_WEB, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Wed, 20 Sep 2023 12:12:52 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777585568092924376 X-GMAIL-MSGID: 1777585568092924376 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;