From patchwork Mon Nov 4 12:40:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Orange Kao X-Patchwork-Id: 13861338 Received: from mail-lf1-f67.google.com (mail-lf1-f67.google.com [209.85.167.67]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1706E18DF85 for ; Mon, 4 Nov 2024 12:43:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.67 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730724189; cv=none; b=AU8oCHjmIboQ/efTBxtKT44p2MHdTbBA7tMW5AirK8VXepL++EqPDRHDS1bByG1r58kdT3mFL8IWWc6fqmMV5hH1fMIpORha5U8SzOVRyQbgBAUTTTyMSe/TztpXHXQ7uvNgAt3PMVqXNjk2vv/TTW96vPuYSwpo9qKYHhvhAFk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730724189; c=relaxed/simple; bh=y65Z9oR1AobPza3jObL8ZvTUxd4wiVcgtKvXh7x/n68=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mZhb5jT8nM9qbP63Ym3BkdajpIZD9NWId5y2UfpUuB4KlZfq6/IRKchLWhiT7VD+xy2SDO+c5fnpm5xJNP+Kfs5yEZJgCpTG52wwzeJQ19aPLWfZOrmXeBERxe1ygNtWDgoASXA5KrRbvYpjVHmbD7dh00n07t/NRCkGlqYsJzY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=aiven.io; spf=pass smtp.mailfrom=aiven.io; dkim=pass (1024-bit key) header.d=aiven.io header.i=@aiven.io header.b=sWq1ZFCj; arc=none smtp.client-ip=209.85.167.67 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=aiven.io Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=aiven.io Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=aiven.io header.i=@aiven.io header.b="sWq1ZFCj" Received: by mail-lf1-f67.google.com with SMTP id 2adb3069b0e04-539f72c8fc1so3188171e87.1 for ; Mon, 04 Nov 2024 04:43:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aiven.io; s=google; t=1730724186; x=1731328986; 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=HNTV90YBUHHTjeRnFlpu7gZOlU+a1vOHJ7xyySOcw8Y=; b=sWq1ZFCjsT0UCfcos+Fb4V2d1vp8qLVQl3WyJdrXUNQAQFPT4LrycZBLvREN0Wlv0L BA3f+1o1VLxLBYa4hJghHKjghEE8CNmMw5VPWqANSIoH1poOnbP1qUUKfZYZnYgrtgQr zsFL2dnvB38brlZwxyVXSEBmuA17hwPO/Jbx4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730724186; x=1731328986; 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=HNTV90YBUHHTjeRnFlpu7gZOlU+a1vOHJ7xyySOcw8Y=; b=hWwxLXoudiA5Gw4AUs3giH7gkNBVEY6yE/ivy5TUSzGpuDGGyI+0zrg7dZrTKVVWs3 Ph9obycbu/eILMdeJ8Yd2yzKnnVPIBu4am8hoxRhSwycpvjpzzSEy4dUnENWdhvl2rxn ivTYZ29tYeGJQU/fD7UBfqpmOFF5dk5LZtXLlKR6tqCTMrDGfhPVBtG/ESXiqz2/qYGm Qjk6izJiby21cQk+hyfQy7y6d+22dO7kl40etdAurynlzwqXzCYu7lealhIyMWBqSx7V CtwXIZpCMF1hKQT5xeK/d0CeOoK/vQ15HjiHjOHP83t1I/kwYFjQNvgZJN2trjsBDwyA EDTg== X-Forwarded-Encrypted: i=1; AJvYcCV05PUdu81zF6Y0ymYpx5v3B28+5zazvSYPIs4DUHAh2KaEk5GFGh7rZAVSUQf+FFVAThOHdCAcQyJU@vger.kernel.org X-Gm-Message-State: AOJu0Yz2golRzCWvo17A6qCGxpjmfcXPuJfyYPRH55Rfz/dvn//nio7v sFTnzY/e8r9jyVGLCUs8job2cRTbqrQkLDrE/xvy3rD3iIK2xHBzQYs6eLf7UXs= X-Google-Smtp-Source: AGHT+IEy6uobz47gBvKsl93Jub6o83LrpDnTRo9WUDj6iez5RGxE8Qorg13pXqCkFU93icg9uB8fTg== X-Received: by 2002:a05:6512:3195:b0:53a:1a81:f006 with SMTP id 2adb3069b0e04-53b7ecf3f38mr9840399e87.31.1730724186140; Mon, 04 Nov 2024 04:43:06 -0800 (PST) Received: from ox.aiven-management.aivencloud.com (n114-74-229-70.bla3.nsw.optusnet.com.au. [114.74.229.70]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-211057071fasm60567525ad.84.2024.11.04.04.43.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 04:43:05 -0800 (PST) From: Orange Kao To: tony.luck@intel.com, qiuxu.zhuo@intel.com Cc: bp@alien8.de, james.morse@arm.com, orange@kaosy.org, linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org, mchehab@kernel.org, rric@kernel.org, Orange Kao Subject: [PATCH 1/3] EDAC/igen6: Avoid segmentation fault when rmmod Date: Mon, 4 Nov 2024 12:40:52 +0000 Message-ID: <20241104124237.124109-2-orange@aiven.io> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241104124237.124109-1-orange@aiven.io> References: <20241104124237.124109-1-orange@aiven.io> Precedence: bulk X-Mailing-List: linux-edac@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The segmentation fault happens because During modprobe: 1. In igen6_probe(), igen6_pvt will be allocated with kzalloc() 2. In igen6_register_mci(), mci->pvt_info will point to &igen6_pvt->imc[mc] During rmmod: 1. In mci_release() in edac_mc.c, it will kfree(mci->pvt_info) 2. In igen6_remove(), it will kfree(igen6_pvt); Fix this issue by setting mci->pvt_info to NULL to avoid the double kfree. Fixes: 10590a9d4f23 ("EDAC/igen6: Add EDAC driver for Intel client SoCs using IBECC") Closes: https://bugzilla.kernel.org/show_bug.cgi?id=219360 Signed-off-by: Orange Kao --- drivers/edac/igen6_edac.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/edac/igen6_edac.c b/drivers/edac/igen6_edac.c index 189a2fc29e74..07dacf8c10be 100644 --- a/drivers/edac/igen6_edac.c +++ b/drivers/edac/igen6_edac.c @@ -1245,6 +1245,7 @@ static int igen6_register_mci(int mc, u64 mchbar, struct pci_dev *pdev) imc->mci = mci; return 0; fail3: + mci->pvt_info = NULL; kfree(mci->ctl_name); fail2: edac_mc_free(mci); @@ -1269,6 +1270,7 @@ static void igen6_unregister_mcis(void) edac_mc_del_mc(mci->pdev); kfree(mci->ctl_name); + mci->pvt_info = NULL; edac_mc_free(mci); iounmap(imc->window); } From patchwork Mon Nov 4 12:40:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Orange Kao X-Patchwork-Id: 13861339 Received: from mail-lf1-f47.google.com (mail-lf1-f47.google.com [209.85.167.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0556D18C025 for ; Mon, 4 Nov 2024 12:43:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730724206; cv=none; b=gD8e1qrLKUmFwzI8qTCFUsdeNvbdSBsY9hiYWTCZNWiR/cQPaFGYO+3V1q+iPBzMi4bKDN0nBt0oVYr8+ifRuM/vRkAbkvDE/tRBEwNTD6AamfkDMRTPIc+hb3F3XlCX8IZYx2CDrnmVpq6vwqCUVzQsUbNAkQo9xOwxWZUGm0M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730724206; c=relaxed/simple; bh=avSNu0jxcOX+JToYoKPOxXqXoAKAFU2u/PiZkiumz/U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kspQVOcT+IiHHnxF2wVLTDDrLhxdBijkCNwITc+s8KBXpqHDK/zlbRpxOfOqzUFsp8lXbJbOSrW3Uwkv0PFYrYuHNW0t5mle/0ej0zdHzaxFVBkX2BNvjmVKXL1hhDFg4RYFMP0yorb8PQ31jCOkCiar9fM0FFw7E4XSrX7LSu8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=aiven.io; spf=pass smtp.mailfrom=aiven.io; dkim=pass (1024-bit key) header.d=aiven.io header.i=@aiven.io header.b=JSZMFep2; arc=none smtp.client-ip=209.85.167.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=aiven.io Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=aiven.io Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=aiven.io header.i=@aiven.io header.b="JSZMFep2" Received: by mail-lf1-f47.google.com with SMTP id 2adb3069b0e04-539ebb5a20aso4248484e87.2 for ; Mon, 04 Nov 2024 04:43:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aiven.io; s=google; t=1730724203; x=1731329003; 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=2T1FnuxuOLfXTEuPhFAXlYWlJnV3S7rPr9KDCR50D/U=; b=JSZMFep2+hq9DcSVHC7sstW9ORzuhIYb/WjoZ2cCJ6lrxt6rYifb3rsYg5GkpApBKD MQ90KTEbs5TJ56mIECQxnd0PbegVvOibrVfP5LNQeCQvkS6k7sm8T6al34jEzBbiffeD 263ZDS7JSIOqADj6fbWImvjU8e8B5HhJE7YpE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730724203; x=1731329003; 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=2T1FnuxuOLfXTEuPhFAXlYWlJnV3S7rPr9KDCR50D/U=; b=o1qtr/hDsOWCCAn0PQ7Uos1XnHQxAdm4/m5xIAaXa6PgKRGODXXGPkdaY2anmOGW2t qL4UNk2+UimfSpRSX2CBzBWP8Db2/MypKuTKnUJpqCR6thSkIhhrVYnkKVUHOxQOsGuZ WWPKlJ8whpBO54WkXXLIEwbFiXsfFlRSERL8l5or21un3jLPZGDF5avDBwoHjGOSH2Gu CqFLeL+UhOdBDwp2JO8RUCeHcngb84ZIrcrpxonA/zan7ppNKBgpbOtU3KLhVJsfitHv VRXu6y35+JUfxJm48loHTsXIgMPjpi4beIcyAdhZV7X6f8NcBtI1NklvKEuEUyRZl2Ac 3mqQ== X-Forwarded-Encrypted: i=1; AJvYcCV1bJLk9DuIx99wxK6qMaCGgRYPxJNI5apQE1Hhd9f1eihxnk9kU+mPXuAZFceJ77Kv/klC/jR9vngX@vger.kernel.org X-Gm-Message-State: AOJu0YyWHupvV/rDBHzAC4IhTO2IR9lXEPZD4q1dyopi8dju2Jwph7RD QrcMkbRuuPnsntTT1XLO8GiOi1KoruzK0S3RYuDQP4BmtpHmc41VdaLWsrclPoA= X-Google-Smtp-Source: AGHT+IHy1cqxEDldE+jOPeivOL7psrHsxOIdD/UD+h/Dzy5pOzG/4GiogDeZsSMbjYh7bZiqKhM2FQ== X-Received: by 2002:a05:6512:1089:b0:539:959e:f0e8 with SMTP id 2adb3069b0e04-53d65de8ba0mr5390339e87.21.1730724203018; Mon, 04 Nov 2024 04:43:23 -0800 (PST) Received: from ox.aiven-management.aivencloud.com (n114-74-229-70.bla3.nsw.optusnet.com.au. [114.74.229.70]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-211057071fasm60567525ad.84.2024.11.04.04.43.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 04:43:22 -0800 (PST) From: Orange Kao To: tony.luck@intel.com, qiuxu.zhuo@intel.com Cc: bp@alien8.de, james.morse@arm.com, orange@kaosy.org, linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org, mchehab@kernel.org, rric@kernel.org Subject: [PATCH 2/3] EDAC/igen6: Initialize edac_op_state according to the configuration data Date: Mon, 4 Nov 2024 12:40:53 +0000 Message-ID: <20241104124237.124109-3-orange@aiven.io> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241104124237.124109-1-orange@aiven.io> References: <20241104124237.124109-1-orange@aiven.io> Precedence: bulk X-Mailing-List: linux-edac@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Qiuxu Zhuo Currently, igen6_edac sets edac_op_state to EDAC_OPSTATE_NMI, while the driver also supports memory errors reported from Machine Check. Initialize edac_op_state to the correct value according to the configuration data that the driver probed. Signed-off-by: Qiuxu Zhuo --- drivers/edac/igen6_edac.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/edac/igen6_edac.c b/drivers/edac/igen6_edac.c index 07dacf8c10be..fa488ba15059 100644 --- a/drivers/edac/igen6_edac.c +++ b/drivers/edac/igen6_edac.c @@ -1350,6 +1350,15 @@ static void unregister_err_handler(void) unregister_nmi_handler(NMI_SERR, IGEN6_NMI_NAME); } +static void opstate_set(struct res_config *cfg) +{ + /* Set the mode according to the configuration data. */ + if (cfg->machine_check) + edac_op_state = EDAC_OPSTATE_INT; + else + edac_op_state = EDAC_OPSTATE_NMI; +} + static int igen6_probe(struct pci_dev *pdev, const struct pci_device_id *ent) { u64 mchbar; @@ -1367,6 +1376,8 @@ static int igen6_probe(struct pci_dev *pdev, const struct pci_device_id *ent) if (rc) goto fail; + opstate_set(res_cfg); + for (i = 0; i < res_cfg->num_imc; i++) { rc = igen6_register_mci(i, mchbar, pdev); if (rc) @@ -1450,8 +1461,6 @@ static int __init igen6_init(void) if (owner && strncmp(owner, EDAC_MOD_STR, sizeof(EDAC_MOD_STR))) return -EBUSY; - edac_op_state = EDAC_OPSTATE_NMI; - rc = pci_register_driver(&igen6_driver); if (rc) return rc; From patchwork Mon Nov 4 12:40:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Orange Kao X-Patchwork-Id: 13861340 Received: from mail-lf1-f42.google.com (mail-lf1-f42.google.com [209.85.167.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A04FE1B0F33 for ; Mon, 4 Nov 2024 12:43:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730724219; cv=none; b=otQQRNbZ/FLN12DuzAoDN04Yo8gHcNZ0Wza8u9yXHhbm4LVIr7KfzBXHbvF56y1C4kaT6MIpkR1qQaUugn6Hmbchpo6O6vrXiYVg7jaoYiFrT24xuPT4Q0LXA6QiPH/jtrC5jbR11tb2w3NFUQ/ciqkNMesGCfkp4NlSBlVVZGI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730724219; c=relaxed/simple; bh=cKR4mIuxU+pZHomU02/B0JOA4nMGY2eIkkwjNLsRKNY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ecHxtX4rztw2qiDegfn56J7037dMbBLG9G0bUoj9KenkmUeEN+UIES1Dp9kqY+gAE7IhvQtjp2giusatE7yUnqXROp9llybtCDcceBLUqF/vkG1POkoefa6F2Syt29f/sSOo8v8PCrNlW+0sF/vjUJRcwIYasV8Y7vs8y1WetFg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=aiven.io; spf=pass smtp.mailfrom=aiven.io; dkim=pass (1024-bit key) header.d=aiven.io header.i=@aiven.io header.b=ex9uBBY5; arc=none smtp.client-ip=209.85.167.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=aiven.io Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=aiven.io Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=aiven.io header.i=@aiven.io header.b="ex9uBBY5" Received: by mail-lf1-f42.google.com with SMTP id 2adb3069b0e04-539f58c68c5so7462539e87.3 for ; Mon, 04 Nov 2024 04:43:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aiven.io; s=google; t=1730724216; x=1731329016; 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=1QxRN4fIUmMgqqmSgoGjRQ84Tw++DtIiEKSH0O+MnK4=; b=ex9uBBY5BoPmeZEYOkkqs5MmvLHPMHBW4wU5ueDB21fohSdWEnDsubzQe5oKZ4iP1S UeaoWNDwqPcucHQ/J1DoRwOZfk4J/1EUJKrAxyG4Vu3cCWvplxIGnwmwizXycFLGc0IC Z48WS0SXvsB5RJn4B+/aa0Ij/GIiJjj0djWGk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730724216; x=1731329016; 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=1QxRN4fIUmMgqqmSgoGjRQ84Tw++DtIiEKSH0O+MnK4=; b=BNfNW+dZwPmc173B2C9A2I3QCscuq011IkyLjS6YukPlBnRwfVJvZjg87mwZ+lmBSc CRJs3FUd4ZfVGTKlWvZ9tRSZWmqSKLHJBkb+Mu7KLISc8G5dztqDXs0YB3Er55UGt7cN 6h5pfURrqreLVZ2MBqX/KmtiDWptlWY2W8tc84yrAx9oSrmbseduBRkmmeB2x3dUpXCe 2s96UjuSt/zhld2+fYtiFs7FWU5xonemnAi7Tr8RgJ1frv786vbal4uTKS7RZ9Te6SQD NqKjX4rMkAth18AJzpaNLk2XSfYKPvirPbw1YODsZZFkTF+8xf67vvRNFUnjaB+VuXcE sUqg== X-Forwarded-Encrypted: i=1; AJvYcCWzaevyXP4u8sn78Chw/uDfV9fDflG9cB942T9hKe+nT0v8J9jWBchksbM4Bmwn9Y9hx5zNBfvAGQez@vger.kernel.org X-Gm-Message-State: AOJu0YzXYTJ35PaLW8oyu61pcPYPETfDQqIOJyJKGW4OK7QMW9tqASj5 GE4RmMShfST+URqmvwvFOvlVBze+obJQcXtPVcn+awqWCCBSzDwybw6W970+VWE= X-Google-Smtp-Source: AGHT+IGgBMF58yJeGdFQky+NLdR4fiA6k5ZEPcqTxWYN7oXWvE3Y7NIIuc+Tgxb0I33E3BFKHU/hWQ== X-Received: by 2002:a05:6512:2350:b0:53b:7ecc:5ddf with SMTP id 2adb3069b0e04-53d65df1a08mr7897714e87.26.1730724215737; Mon, 04 Nov 2024 04:43:35 -0800 (PST) Received: from ox.aiven-management.aivencloud.com (n114-74-229-70.bla3.nsw.optusnet.com.au. [114.74.229.70]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-211057071fasm60567525ad.84.2024.11.04.04.43.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 04:43:35 -0800 (PST) From: Orange Kao To: tony.luck@intel.com, qiuxu.zhuo@intel.com Cc: bp@alien8.de, james.morse@arm.com, orange@kaosy.org, linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org, mchehab@kernel.org, rric@kernel.org, Orange Kao Subject: [PATCH 3/3] EDAC/igen6: Add polling support Date: Mon, 4 Nov 2024 12:40:54 +0000 Message-ID: <20241104124237.124109-4-orange@aiven.io> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241104124237.124109-1-orange@aiven.io> References: <20241104124237.124109-1-orange@aiven.io> Precedence: bulk X-Mailing-List: linux-edac@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Some PCs with Intel N100 (with PCI device 8086:461c, DID_ADL_N_SKU4) experienced issues with error interrupts not working, even with the following configuration in the BIOS. In-Band ECC Support: Enabled In-Band ECC Operation Mode: 2 (make all requests protected and ignore range checks) IBECC Error Injection Control: Inject Correctable Error on insertion counter Error Injection Insertion Count: 251658240 (0xf000000) Add polling mode support for these machines to ensure that memory error events are handled. Signed-off-by: Orange Kao --- drivers/edac/igen6_edac.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/drivers/edac/igen6_edac.c b/drivers/edac/igen6_edac.c index fa488ba15059..eb783c6b77f1 100644 --- a/drivers/edac/igen6_edac.c +++ b/drivers/edac/igen6_edac.c @@ -1170,6 +1170,20 @@ static int igen6_pci_setup(struct pci_dev *pdev, u64 *mchbar) return -ENODEV; } +static void igen6_check(struct mem_ctl_info *mci) +{ + struct igen6_imc *imc = mci->pvt_info; + u64 ecclog; + + /* errsts_clear() isn't NMI-safe. Delay it in the IRQ context */ + ecclog = ecclog_read_and_clear(imc); + if (!ecclog) + return; + + if (!ecclog_gen_pool_add(imc->mc, ecclog)) + irq_work_queue(&ecclog_irq_work); +} + static int igen6_register_mci(int mc, u64 mchbar, struct pci_dev *pdev) { struct edac_mc_layer layers[2]; @@ -1211,6 +1225,8 @@ static int igen6_register_mci(int mc, u64 mchbar, struct pci_dev *pdev) mci->edac_cap = EDAC_FLAG_SECDED; mci->mod_name = EDAC_MOD_STR; mci->dev_name = pci_name(pdev); + if (edac_op_state == EDAC_OPSTATE_POLL) + mci->edac_check = igen6_check; mci->pvt_info = &igen6_pvt->imc[mc]; imc = mci->pvt_info; @@ -1352,6 +1368,10 @@ static void unregister_err_handler(void) static void opstate_set(struct res_config *cfg) { + /* Only the polling mode can be set via the module parameter. */ + if (edac_op_state == EDAC_OPSTATE_POLL) + return; + /* Set the mode according to the configuration data. */ if (cfg->machine_check) edac_op_state = EDAC_OPSTATE_INT; @@ -1483,3 +1503,6 @@ module_exit(igen6_exit); MODULE_LICENSE("GPL v2"); MODULE_AUTHOR("Qiuxu Zhuo"); MODULE_DESCRIPTION("MC Driver for Intel client SoC using In-Band ECC"); + +module_param(edac_op_state, int, 0444); +MODULE_PARM_DESC(edac_op_state, "EDAC Error Reporting state: 0=Poll, Others or default=Auto detect");