From nobody Tue Jun 16 20:59:20 2026 Received: from mail-pg1-f176.google.com (mail-pg1-f176.google.com [209.85.215.176]) (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 9C286347503 for ; Wed, 29 Apr 2026 09:50:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777456242; cv=none; b=kmyjPXL0HM7gluPKQSA/E4qGNd8UVzkxC3M+EO5F/nVU9J3h3OVauQ2BNwBlrAsDGmdSefZK7dgUEgCOJeFwIp8RIfPU3Np6AUN1NqgVo5KtiJ9u0KKIlrPE3UgYuE5rYH2dFQ4cwOpbv8LADbQhCwbsFBWrh2tSgPGaf5nu1B4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777456242; c=relaxed/simple; bh=Xhf/E0dxLek4yeW5CvMEoss1W02Z/T1jPt0aJBE2XZA=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=sXEi3MErro1ZqWGWISDElJILluyDLYJCA8omyd/PZZxDZQ4lRjfnfMto9Wj/tGe7Q2bzadynkP/uLUOPErFn3kqZPsEzRHVnWaqw8V5h6I+n8XsO58j6Pw00v44jqMUL4zgm1UxO0bljoRJSHUyEk0t9DO3jcaDmg5wIpR2lUcc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=fV52e1Ds; arc=none smtp.client-ip=209.85.215.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fV52e1Ds" Received: by mail-pg1-f176.google.com with SMTP id 41be03b00d2f7-c70f91776fcso4931729a12.0 for ; Wed, 29 Apr 2026 02:50:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777456241; x=1778061041; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=KIidhZXldSX5FAAxW3beAM77uagDnufRMwCN2vwXbC4=; b=fV52e1DsoTZ8Nvni6zS0C2yizP+E2lka5hqfOCv3W3mXp3w/DWKyHqfit6RLRZVc4u Lwb3Irc9fLIVasi97o2BsxEneyK/EMkJot7mhf5bGnZJveLkk+B2sGDdiBFuK7Rw0uPU Zx0bcDk7vzzRtDf2LVFMFhfDT309gImdk+WyRdKPergSzKqPbED25QxLCV3QxhWTma3B p+Uo+hfqK9jdCpSLXDRzdYfsT0WkjIBarv3xYdBMATq2SGNvoKy/lMVHfDpcnMZ0nGW5 xtaXmQYOYnK3h3Ci8kyhEEWVNdhn3ngHLLZuIB3Gkp5bSxq5lThbQXUx4XLwkm0xR91h xbmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777456241; x=1778061041; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=KIidhZXldSX5FAAxW3beAM77uagDnufRMwCN2vwXbC4=; b=k9XI4DYHmKxdCrb6F7rx/OjT/xiDFwVW6R0J7wzJ2yYKdc8NeiSentKxh2Yhj7V1EB i38Hzhdr8iWmuYWxqvqo1R7KbV/fRyuH/I+tTU6t8zmhiB/U9JgsOQ2G9+z9iON3edgV rR2MwpPqj8YCcCk6Y19PJ/kMYJF5jlNHug12oLjjUMShDcp/GApIlXP0H8LWr1uhS7wF V+GAYnAMtBsbtHUnPQ0cIL3HnMLYMq6ps7z7HQd+2gTtpuRNO+KTk2YBKt88aACzbjvk /Sl7tPO//V0TsrB0RpzqPbiXJVwXpFK9cV+OUjyKQuTQ94It7M1WBRD+pEoeHCfoo7HY ImfA== X-Forwarded-Encrypted: i=1; AFNElJ8vxSN/MMwX5FTxgO4bhKcZCAtH+prs/Z9vbgvJzyFTfNGOL2yUgLVtmSBm3OXXrxQyPbVoAsMyNt0fAMs=@vger.kernel.org X-Gm-Message-State: AOJu0YwR+FsDpeYbyVr5OQI8dbv4zhuslBT1YuKYt7Vv8+Y85bWPWYnn 88hCyPzLcw+AmZR0AgUT4wiLjisABQ90LGrsxfZYplYEULc9bETUl5Tz X-Gm-Gg: AeBDieuBk5sXgBUGtqGv3u0weRUL24cDZdJMTKl79aRoGKzGS2N7euJdayBCGk3mZHP Eh+uJrjYr4vJDHXuDRrfEi+6R8XNfC/k6GoL3DpEE3dnqPq1rMly3fkK653SLwZv9rzLwj5DwSE OBvhzH8OTrGb5xr0026tK848XJRvohEezMR9NRmRzbBefOABqAItlEHP2B7NjvDtCNLelSEFITI DQmwA7Vs+uz8FzAg+gfCh3YQCM1x1r2BxCJh7cHk4viJCSHGAn8/KAqiFM3ZymxXfzIFLmLJfiD e60vAmNg+mcdRrxjpoqN4sOxX1wqmHr8NrK7ASD9UQ37CVLR/CLMuNa1uVOc89YdxUaWe1NgbOW QgFVIB7t8LSW8YcSbCEToIdfzgAyz4F26yzGffSvUhbmGrZ9rJc2b+Wsr8PE/XQSed2DHA9BmM9 ejonJwEVVAhO34P/ordwK7HSJQHGdR0LOvP5wJAYI7fI+MShrt51vhyfpPKjOjpomPKKZ7lHE= X-Received: by 2002:a17:903:38cd:b0:2ad:d0ff:2ed4 with SMTP id d9443c01a7336-2b98730ca9emr30202235ad.6.1777456240930; Wed, 29 Apr 2026 02:50:40 -0700 (PDT) Received: from pop-os.. ([103.100.151.4]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2b98893fbbbsm16906765ad.41.2026.04.29.02.50.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Apr 2026 02:50:40 -0700 (PDT) From: Tushar Tibude To: mchehab@kernel.org, bp@alien8.de, tony.luck@intel.com, linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org Cc: qiuxu.zhuo@intel.com, Tushar Tibude Subject: [PATCH v3] EDAC: i7300: disable error reporting if init fails and refactor helper Date: Wed, 29 Apr 2026 15:18:06 +0530 Message-ID: <20260429094806.25097-1-tushar.tibude1000@gmail.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" If error reporting is enabled during initialization but initialization fails immediately after, or during normal driver exit, error reporting is left enabled in the mask register even after exit. Replace i7300_enable_error_reporting() with i7300_set_error_reporting() to combine enabling/disabling. Disable reporting at initialization failure and driver exit, before call to i7300_put_devices() for cleanup. Add enabled reporting flag to i7300_pvt. This ensures clean hardware handling by disabling any unused error reporting bits before exiting. Signed-off-by: Tushar Tibude --- v2: - Replace disable function with i7300_set_error_reporting - Disable reporting at normal driver exit - Move enabled_error_reporting flag initialization v3: - Move enabled_error_reporting flag to i7300_pvt struct - Conditionally disable error reporting at normal driver exit drivers/edac/i7300_edac.c | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/drivers/edac/i7300_edac.c b/drivers/edac/i7300_edac.c index 69068f8d0..64bc2d805 100644 --- a/drivers/edac/i7300_edac.c +++ b/drivers/edac/i7300_edac.c @@ -111,6 +111,9 @@ struct i7300_pvt { =20 /* Temporary buffer for use when preparing error messages */ char *tmp_prt_buffer; + + /* Hardware error reporting status */ + bool enabled_error_reporting; }; =20 /* FIXME: Why do we need to have this static? */ @@ -550,11 +553,12 @@ static void i7300_clear_error(struct mem_ctl_info *mc= i) } =20 /** - * i7300_enable_error_reporting() - Enable the memory reporting logic at t= he + * i7300_set_error_reporting() - Enable or disable the memory reporting lo= gic at the * hardware * @mci: struct mem_ctl_info pointer + * @enable: enables if 'true', disables if 'false' */ -static void i7300_enable_error_reporting(struct mem_ctl_info *mci) +static void i7300_set_error_reporting(struct mem_ctl_info *mci, bool enabl= e) { struct i7300_pvt *pvt =3D mci->pvt_info; u32 fbd_error_mask; @@ -563,8 +567,11 @@ static void i7300_enable_error_reporting(struct mem_ct= l_info *mci) pci_read_config_dword(pvt->pci_dev_16_1_fsb_addr_map, EMASK_FBD, &fbd_error_mask); =20 - /* Enable with a '0' */ - fbd_error_mask &=3D ~(EMASK_FBD_ERR_MASK); + /* Enable with 0, disable with 1 */ + if (enable) + fbd_error_mask &=3D ~(EMASK_FBD_ERR_MASK); + else + fbd_error_mask |=3D EMASK_FBD_ERR_MASK; =20 pci_write_config_dword(pvt->pci_dev_16_1_fsb_addr_map, EMASK_FBD, fbd_error_mask); @@ -1087,17 +1094,19 @@ static int i7300_init_one(struct pci_dev *pdev, con= st struct pci_device_id *id) if (i7300_get_mc_regs(mci)) { edac_dbg(0, "MC: Setting mci->edac_cap to EDAC_FLAG_NONE because i7300_i= nit_csrows() returned nonzero value\n"); mci->edac_cap =3D EDAC_FLAG_NONE; /* no csrows found */ + pvt->enabled_error_reporting =3D false; } else { edac_dbg(1, "MC: Enable error reporting now\n"); - i7300_enable_error_reporting(mci); + i7300_set_error_reporting(mci, true); + pvt->enabled_error_reporting =3D true; } =20 /* add this new MC control structure to EDAC's list of MCs */ if (edac_mc_add_mc(mci)) { edac_dbg(0, "MC: failed edac_mc_add_mc()\n"); - /* FIXME: perhaps some code should go here that disables error - * reporting if we just enabled it - */ + /* Disable error reporting if we just enabled it */ + if (pvt->enabled_error_reporting) + i7300_set_error_reporting(mci, false); goto fail1; } =20 @@ -1134,6 +1143,7 @@ static int i7300_init_one(struct pci_dev *pdev, const= struct pci_device_id *id) static void i7300_remove_one(struct pci_dev *pdev) { struct mem_ctl_info *mci; + struct i7300_pvt *pvt; char *tmp; =20 edac_dbg(0, "\n"); @@ -1145,7 +1155,12 @@ static void i7300_remove_one(struct pci_dev *pdev) if (!mci) return; =20 - tmp =3D ((struct i7300_pvt *)mci->pvt_info)->tmp_prt_buffer; + pvt =3D (struct i7300_pvt *)mci->pvt_info; + tmp =3D pvt->tmp_prt_buffer; + + /* Disable error reporting before unregistering device */ + if (pvt->enabled_error_reporting) + i7300_set_error_reporting(mci, false); =20 /* retrieve references to resources, and free those resources */ i7300_put_devices(mci); --=20 2.43.0