From nobody Sat Feb 7 10:07:55 2026 Received: from mail-pf1-f179.google.com (mail-pf1-f179.google.com [209.85.210.179]) (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 1B7DE1B532F for ; Sun, 1 Feb 2026 03:31:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769916685; cv=none; b=fqQORzTzgpsWunm4Ci5pmXJntKNG20Lc8MqepLDc/ht0bqaD7EI1sOjhepmlRPDdhvHB4HUypO9MDsioR4LQ+103XK2pP6BNfHJY6fj+iom6zez+MvIvAUPl6UhQt7A4wZkB4fdy3UuT6QlkWZV5pQ94RJD/ezHVjIbN1tGp6GA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769916685; c=relaxed/simple; bh=hLQNZt7neDC3Eu0yqb2A/11Pitd7n2KuvK8pghcMxZs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nk1g32hs1aiqFjZdiRFeDFIVJpLLcKAOQ7UhDtHvThUdqaipiQqvBFAW4Jc4ItRmSrtT09LozZzFbo0Bwr/xjZq5jXUgTSvtBaEvQ3fMS6kv2IMZJfjNMoqJwNEmPbpWA/wQVTAUCODGt4L9T6eMSfDMdG+MtJOGPqjXg4wstLw= 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=iwGSYCqs; arc=none smtp.client-ip=209.85.210.179 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="iwGSYCqs" Received: by mail-pf1-f179.google.com with SMTP id d2e1a72fcca58-823075fed75so2041736b3a.1 for ; Sat, 31 Jan 2026 19:31:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1769916683; x=1770521483; 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=8OW6YK/7zWKCsYWYbcpNBYGrHBCbd+EbSHR5nwi0Y6U=; b=iwGSYCqseEXifrISDZEzwJ0gcjrqMQpO4hCpzm0dhEZEtiIu6kEBfA7/Ii7iY+gcEj zzmcZgAzCADLJsSkm27dXYfEcEmLIP1Cd6T9LDaQuxDH5OE/68hfsFNu9BmpwG76k0D8 dyiy91hhJonCQthizQpyWpm/mzY4eDj3o5FlfcpJy/5o3FgQpISyG6qRMpK6U8XqYtWu LKkkVnu9cl6MuTrOhaDXFkR2uEGb/oaROoQrQy3MxhMSY1LOK4tAj+6fzcCBx70bcNtV nwrV3qFXPHx+0mtMsBZoMvvUhzHPYC+9zYVulE50ZI3t22ksHFqWb/Juu+9ZW0RT+EfB 1eMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769916683; x=1770521483; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=8OW6YK/7zWKCsYWYbcpNBYGrHBCbd+EbSHR5nwi0Y6U=; b=vlM5dFSL2oBq92fLsigcRwnNWRhMHljg3TZhwWYlRsTQ26EyqenZ7DNbisMfSQ3DoV SEvhPyNzadQjEX13/WHfx1HNvO+wjc0hzaMDM5WwuJ/B08o30po3yI0sDWYN5ZFG3V5R /2/GZXe9mJFG5fb4DWai9ORiKHP3gfKdYv1BbUxyCCmCmPNzVRNON0hhJKgkvro1gnPH 1GxHbzq9HnHrrF/uWbSu2UBFAxMTyMAGIwoDzPIty7Ktc9XtMU/fXnhAEDhfiX+ojx1B qIliC5wdKL7g8ooxIiovI7hWsuxkedJpVSCBgOu71LoMq2Xx370qpzjKe/eiGu+kXrd2 frPw== X-Forwarded-Encrypted: i=1; AJvYcCX/dGQ3uG9MAZUKr3JBrKT5CEsXDcQgEnkqRBPvGqr8kj9w3gfhZ7UT1UcG+izN4dqmHsfX9aztXK6a8TU=@vger.kernel.org X-Gm-Message-State: AOJu0YxKHhcOgd5JObV5y4Cr/Od3oZjgixFXFIeNhTSIXGLgOWehHlaQ eAus8eOgfdsMpi9xZag/dzvCTVvjE0a3IH9LZP7XX69C4EE3+5MiCU1c X-Gm-Gg: AZuq6aJkk6G0QiQK3pbzIVY1bwMO1JddsEs64jXD7wQ93/jcHK6mqynnfUg3iQzaD1H +QlvBdl8Zu8QiuoMtmY6Zs7kBganp9vtrSY23kcYjCuSdlBI8G0d5Ei3XZWULoq7LkU2v4dfpXI 7Uv+HxMRDV9dNybBfSY6Ohv2Ib3VfhtiSPPwJJTRRTSBLGECftFrlG4s7c5zMzMKlf1mxp6JDGe Sr8AgPAnLl1fGeJUWGFDh1iLEGOnpHUdZAKxRHgn1xhTwIy/fpzWoB6wVJvlwbIhnPN/ZN0TEI3 qj/6TheH8fs5Rij5zO/2aT15NpbfgF2vV4NcrXCwU8Wv7mmNncqMGexhawWNJQKlnPvtWdJYAo7 7RjQ5xDa8A6Qbb8OzbKRpFSV/nTq7kUPgIiwXisvo+blf4TLa1Ddd+LkXv05/YAJO4eK5x5dx74 /bC1RIuVdWMtF8AMnVxbXS8s0wpYn5SNjzmiPLwEyGIw== X-Received: by 2002:a05:6a00:1742:b0:80f:4667:a94a with SMTP id d2e1a72fcca58-82392069529mr9860928b3a.10.1769916683494; Sat, 31 Jan 2026 19:31:23 -0800 (PST) Received: from localhost.localdomain ([113.218.252.120]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-82379b6b2bdsm11831817b3a.30.2026.01.31.19.31.18 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sat, 31 Jan 2026 19:31:22 -0800 (PST) From: chengkaitao To: kashyap.desai@broadcom.com, sumit.saxena@broadcom.com, shivasharan.srikanteshwara@broadcom.com, chandrakanth.patil@broadcom.com, James.Bottomley@HansenPartnership.com, martin.petersen@oracle.com Cc: megaraidlinux.pdl@broadcom.com, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Chengkaitao , Zheng tan Subject: [RFC RESEND 1/2] megaraid: Fix the issue of erroneous reset of Words in reply_desc Date: Sun, 1 Feb 2026 11:31:09 +0800 Message-ID: <20260201033110.34297-2-pilgrimtao@gmail.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260201033110.34297-1-pilgrimtao@gmail.com> References: <20260201033110.34297-1-pilgrimtao@gmail.com> 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" From: Chengkaitao The following panic occurred on kernel 6.6 (arch: loongarch): Call Trace: complete_cmd_fusion+0x180/0x7c8 [megaraid_sas] megasas_isr_fusion+0xd4/0xf0 [megaraid_sas] __handle_irq_event_percpu+0x70/0x228 handle_irq_event+0x44/0xf8 handle_edge_irq+0xe8/0x328 avecintc_irq_dispatch+0x68/0x120 handle_irq_desc+0x5c/0x78 handle_cpu_irq+0x6c/0xa8 handle_loongarch_irq+0x2c/0x48 do_vint+0x7c/0xd0 sched_update_worker+0x8/0x90 worker_thread+0x218/0x480 kthread+0xf0/0xf8 ret_from_kernel_thread+0x28/0xc8 ret_from_kernel_thread_asm+0xc/0xa0 Observed symptoms during the issue: complete_cmd_fusion(struct megasas_instance *instance, u32 MSIxIndex, struct megasas_irq_context *irq_context) { ****** while (d_val.u.low !=3D cpu_to_le32(UINT_MAX) && d_val.u.high !=3D cpu_to_le32(UINT_MAX)) { /** When the issue occurs: d_val.u.low =3D=3D 60293120 d_val.u.high =3D=3D 0 reply_desc->SMID =3D=3D 0xffff **/ smid =3D le16_to_cpu(reply_desc->SMID); cmd_fusion =3D fusion->cmd_list[smid - 1]; scsi_io_req =3D (struct MPI2_RAID_SCSI_IO_REQUEST *) cmd_fusion->io_request; /** cmd_fusion becomes an invalid pointer **/ ****** } In the complete_cmd_fusion function, the following assignment exists: d_val.word =3D desc->Words; Thus, reply_desc->SMID =3D=3D 0xffff may be caused by a concurrency-related corruption. Reproduction probability is very low. After code review, I suspect the following race condition scenario: interrupt(complete_cmd_fusion) cpu1(megasas_reset_reply_desc) while (d_val.u.low !=3D *****) { scsi_io_req =3D cmd_fusion->io_request; d_val.word =3D desc->Words; reply_desc->Words =3D cpu_to_le64(ULLONG_MAX); } Note: This is a proposed patch for discussion only. It has not been verified to resolve the issue. If you have alternative suggestions, please join the discussion. Signed-off-by: Chengkaitao Reported-by: Zheng tan --- drivers/scsi/megaraid/megaraid_sas_fusion.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c b/drivers/scsi/meg= araid/megaraid_sas_fusion.c index a6794f49e9fa..3d3480b19734 100644 --- a/drivers/scsi/megaraid/megaraid_sas_fusion.c +++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c @@ -4282,16 +4282,23 @@ void megasas_reset_reply_desc(struct megasas_insta= nce *instance) int i, j, count; struct fusion_context *fusion; union MPI2_REPLY_DESCRIPTORS_UNION *reply_desc; + struct megasas_irq_context *irq_context; =20 fusion =3D instance->ctrl_context; count =3D instance->msix_vectors > 0 ? instance->msix_vectors : 1; count +=3D instance->iopoll_q_count; =20 for (i =3D 0 ; i < count ; i++) { + irq_context =3D &instance->irq_context[i]; + while (!access_irq_context(irq_context)) + cpu_relax(); + fusion->last_reply_idx[i] =3D 0; reply_desc =3D fusion->reply_frames_desc[i]; for (j =3D 0 ; j < fusion->reply_q_depth; j++, reply_desc++) reply_desc->Words =3D cpu_to_le64(ULLONG_MAX); + + release_irq_context(irq_context); } } =20 --=20 2.50.1 (Apple Git-155)