Linux SCSI subsystem development
 help / color / mirror / Atom feed
From: Sergio Callegari <sergio.callegari@gmail.com>
To: linux-scsi@vger.kernel.org
Subject: Re: Sd card race on resume with filesystem errors (possible data loss?)
Date: Sat, 24 Jan 2026 21:38:39 +0100	[thread overview]
Message-ID: <94ce4f7b-25dc-45d1-8467-f63eb15a3654@gmail.com> (raw)
In-Reply-To: <04811e0b-efc5-47ff-ac16-a97f49280bb7@gmail.com>

Made some tests with the purism patch:

Made some tests with the patch from the purism developers, that is the 
following one:

Signed-off-by: Sebastian Krzyszkowiak <sebastian.krzyszkowiak@puri.sm>
---
  drivers/scsi/sd.c | 39 +++++++++++++++++----------------------
  1 file changed, 17 insertions(+), 22 deletions(-)

diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 2c627deedc1f..c2353a260123 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -3968,11 +3968,28 @@ static int sd_resume(struct device *dev)
  static int sd_resume_common(struct device *dev, bool runtime)
  {
      struct scsi_disk *sdkp = dev_get_drvdata(dev);
+    struct scsi_device *sdp;
      int ret;

      if (!sdkp)    /* E.g.: runtime resume at the start of sd_probe() */
          return 0;

+    sdp = sdkp->device;
+
+    if (sdp->ignore_media_change) {
+        /* clear the device's sense data */
+        static const u8 cmd[10] = { REQUEST_SENSE };
+        const struct scsi_exec_args exec_args = {
+            .req_flags = BLK_MQ_REQ_PM,
+        };
+
+        if (scsi_execute_cmd(sdp, cmd, REQ_OP_DRV_IN, NULL, 0,
+                     sdp->request_queue->rq_timeout, 1,
+                     &exec_args))
+            sd_printk(KERN_NOTICE, sdkp,
+                  "Failed to clear sense data\n");
+    }
+
      if (!sd_do_start_stop(sdkp->device, runtime)) {
          sdkp->suspended = false;
          return 0;
@@ -4005,28 +4022,6 @@ static int sd_resume_system(struct device *dev)

  static int sd_resume_runtime(struct device *dev)
  {
-    struct scsi_disk *sdkp = dev_get_drvdata(dev);
-    struct scsi_device *sdp;
-
-    if (!sdkp)    /* E.g.: runtime resume at the start of sd_probe() */
-        return 0;
-
-    sdp = sdkp->device;
-
-    if (sdp->ignore_media_change) {
-        /* clear the device's sense data */
-        static const u8 cmd[10] = { REQUEST_SENSE };
-        const struct scsi_exec_args exec_args = {
-            .req_flags = BLK_MQ_REQ_PM,
-        };
-
-        if (scsi_execute_cmd(sdp, cmd, REQ_OP_DRV_IN, NULL, 0,
-                     sdp->request_queue->rq_timeout, 1,
-                     &exec_args))
-            sd_printk(KERN_NOTICE, sdkp,
-                  "Failed to clear sense data\n");
-    }
-
      return sd_resume_common(dev, true);
  }

--

Unfortunately, this patch does not seem to fix my issue.

There seems to be something wrong with the usb-persist mechanism, since 
there seems to be no way to delay the first access to the usb disk until 
it can be assumed to be ready.

Incidentally, my sd reader is by Genesys Logic 05e3:0751, in case this 
information is useful.

Best,

Sergio


      reply	other threads:[~2026-01-24 20:38 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-02  9:15 Sd card race on resume with filesystem errors (possible data loss?) Sergio Callegari
2026-01-09 20:57 ` Bart Van Assche
2026-01-20 12:19   ` Sergio Callegari
2026-01-24 20:38     ` Sergio Callegari [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=94ce4f7b-25dc-45d1-8467-f63eb15a3654@gmail.com \
    --to=sergio.callegari@gmail.com \
    --cc=linux-scsi@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox