Skip to content

Instantly share code, notes, and snippets.

@jasonrm
Last active May 12, 2021 21:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasonrm/cdbab6f961ffb1b8ddfd80895c40140a to your computer and use it in GitHub Desktop.
Save jasonrm/cdbab6f961ffb1b8ddfd80895c40140a to your computer and use it in GitHub Desktop.
Force Dell MD1200 / MD1220 enclosures as SES-enabled, e.g. /sys/class/enclosure/
From f9e8eaf3226009531b769635a6114f87da08291b Mon Sep 17 00:00:00 2001
From: "Jason R. McNeil" <jason@mcneil.dev>
Date: Wed, 12 May 2021 01:16:35 -0700
Subject: [PATCH] drivers/scsi/ses: Dell MD12XX enclosures support SES, despite
EncServ=0 as claimed by the device
---
drivers/scsi/ses.c | 26 +++++++++++++++++++++++---
1 file changed, 23 insertions(+), 3 deletions(-)
diff --git a/drivers/scsi/ses.c b/drivers/scsi/ses.c
index c2afba2a5..cfb7b6a39 100644
--- a/drivers/scsi/ses.c
+++ b/drivers/scsi/ses.c
@@ -620,6 +620,26 @@ static void ses_match_to_enclosure(struct enclosure_device *edev,
}
}
+static int ses_device_enclosure(struct scsi_device *sdev)
+{
+ int sde = scsi_device_enclosure(sdev);
+ if (sde)
+ return sde;
+
+ if (sdev->type != TYPE_ENCLOSURE)
+ return 0;
+
+ if (strncmp(sdev->vendor, "DELL ", 5) == 0) {
+ if ((strncmp(sdev->model, "MD1200 ", 7) == 0)
+ || (strncmp(sdev->model, "MD1220 ", 7) == 0)) {
+ sdev_printk(KERN_NOTICE, sdev, "Enclosure supports SES, ignoring EncServ=0 as claimed by the device\n");
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
static int ses_intf_add(struct device *cdev,
struct class_interface *intf)
{
@@ -634,7 +654,7 @@ static int ses_intf_add(struct device *cdev,
struct enclosure_device *edev;
struct ses_component *scomp = NULL;
- if (!scsi_device_enclosure(sdev)) {
+ if (!ses_device_enclosure(sdev)) {
/* not an enclosure, but might be in one */
struct enclosure_device *prev = NULL;
@@ -753,7 +773,7 @@ static int ses_intf_add(struct device *cdev,
/* see if there are any devices matching before
* we found the enclosure */
shost_for_each_device(tmp_sdev, sdev->host) {
- if (tmp_sdev->lun != 0 || scsi_device_enclosure(tmp_sdev))
+ if (tmp_sdev->lun != 0 || ses_device_enclosure(tmp_sdev))
continue;
ses_match_to_enclosure(edev, tmp_sdev, 0);
}
@@ -824,7 +844,7 @@ static void ses_intf_remove(struct device *cdev,
{
struct scsi_device *sdev = to_scsi_device(cdev->parent);
- if (!scsi_device_enclosure(sdev))
+ if (!ses_device_enclosure(sdev))
ses_intf_remove_component(sdev);
else
ses_intf_remove_enclosure(sdev);
--
2.31.1
nix-build '<nixpkgs>' -A linuxPackages_latest.kernel.dev
nix-shell '<nixpkgs>' -A linuxPackages_latest.kernel
# $ unpackPhase
# $ cd linux-*
lsmod | grep -E '(ses|enclosure)'
rmmod ses
rmmod enclosure
make -C $dev/lib/modules/*/build M=$(pwd)/drivers/scsi ses.ko || exit 1
make -C $dev/lib/modules/*/build M=$(pwd)/drivers/misc enclosure.ko || exit 1
insmod ./drivers/misc/enclosure.ko
insmod ./drivers/scsi/ses.ko
lsmod | grep -E '(ses|enclosure)'
ls -la /sys/class/enclosure/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment