Re: Mass storage suspend questions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Am Donnerstag, 12. Januar 2012, 22:50:14 schrieb Sarah Sharp:

> The problem is that since the BMC actually attaches to the host
> controller, it can impact system power management if all the emulated
> devices aren't suspended.  A couple of Intel server vendors have gotten
> really cranky about the power management on systems with the EHCI rate
> matching hub and a BMC.  Apparently power management is much worse for
> unsuspended HIDs under EHCI than under UHCI, since the EHCI periodic
> frame list keeps getting polled by the EHCI hardware, making the CPU
> come out of C states, etc.  Async endpoints don't cause as big a power
> draw, but it would benefit system power management overall if they were
> able to be suspended.

I sense a volunteer tester.

>From 827e677b7127dff9738cf18aed4a426d8e5ca494 Mon Sep 17 00:00:00 2001
From: Oliver Neukum <oliver@xxxxxxxxxx>
Date: Fri, 13 Jan 2012 08:27:51 +0100
Subject: [PATCH] SCSI:implement PM for sr

This implements basic power management for SCSI disks.

Signed-off-by: Oliver Neukum <oneukum@xxxxxxx>
---
 drivers/scsi/sr.c |   28 ++++++++++++++++++++++++++--
 1 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c
index 5fc97d2..1a21540 100644
--- a/drivers/scsi/sr.c
+++ b/drivers/scsi/sr.c
@@ -508,16 +508,29 @@ static int sr_prep_fn(struct request_queue *q, struct request *rq)
 
 static int sr_block_open(struct block_device *bdev, fmode_t mode)
 {
+	struct scsi_device *sdev;
 	struct scsi_cd *cd;
 	int ret = -ENXIO;
+	int err;
 
 	mutex_lock(&sr_mutex);
 	cd = scsi_cd_get(bdev->bd_disk);
+	sdev = cd->device;
+
+	err = scsi_autopm_get_device(sdev);
+	if (err) {
+		ret = -EIO;
+		goto err_out;
+	}
+
 	if (cd) {
 		ret = cdrom_open(&cd->cdi, bdev, mode);
-		if (ret)
+		if (ret) {
 			scsi_cd_put(cd);
+			scsi_autopm_put_device(sdev);
+		}
 	}
+err_out:
 	mutex_unlock(&sr_mutex);
 	return ret;
 }
@@ -525,9 +538,12 @@ static int sr_block_open(struct block_device *bdev, fmode_t mode)
 static int sr_block_release(struct gendisk *disk, fmode_t mode)
 {
 	struct scsi_cd *cd = scsi_cd(disk);
+	struct scsi_device *sdev = cd->device;
+
 	mutex_lock(&sr_mutex);
 	cdrom_release(&cd->cdi, mode);
 	scsi_cd_put(cd);
+	scsi_autopm_put_device(sdev);
 	mutex_unlock(&sr_mutex);
 	return 0;
 }
@@ -615,6 +631,11 @@ static int sr_open(struct cdrom_device_info *cdi, int purpose)
 	struct scsi_device *sdev = cd->device;
 	int retval;
 
+	retval = scsi_autopm_get_device(sdev);
+	if (retval) {
+		retval = -EIO;
+		goto pm_error_out;
+	}
 	/*
 	 * If the device is in error recovery, wait until it is done.
 	 * If the device is offline, then disallow any access to it.
@@ -626,16 +647,19 @@ static int sr_open(struct cdrom_device_info *cdi, int purpose)
 	return 0;
 
 error_out:
+	scsi_autopm_put_device(sdev);
+pm_error_out:
 	return retval;	
 }
 
 static void sr_release(struct cdrom_device_info *cdi)
 {
 	struct scsi_cd *cd = cdi->handle;
+	struct scsi_device *sdev = cd->device;
 
 	if (cd->device->sector_size > 2048)
 		sr_set_blocklength(cd, 2048);
-
+	scsi_autopm_put_device(sdev);
 }
 
 static int sr_probe(struct device *dev)
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux