From patchwork Fri Jul 27 09:00:45 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: aaron lu X-Patchwork-Id: 1247541 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id C42DE3FC5A for ; Fri, 27 Jul 2012 09:04:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752875Ab2G0JCu (ORCPT ); Fri, 27 Jul 2012 05:02:50 -0400 Received: from co1ehsobe003.messaging.microsoft.com ([216.32.180.186]:17275 "EHLO co1outboundpool.messaging.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752275Ab2G0JCU (ORCPT ); Fri, 27 Jul 2012 05:02:20 -0400 Received: from mail129-co1-R.bigfish.com (10.243.78.230) by CO1EHSOBE007.bigfish.com (10.243.66.70) with Microsoft SMTP Server id 14.1.225.23; Fri, 27 Jul 2012 09:02:19 +0000 Received: from mail129-co1 (localhost [127.0.0.1]) by mail129-co1-R.bigfish.com (Postfix) with ESMTP id A237B8012F; Fri, 27 Jul 2012 09:02:19 +0000 (UTC) X-Forefront-Antispam-Report: CIP:163.181.249.109; KIP:(null); UIP:(null); IPV:NLI; H:ausb3twp02.amd.com; RD:none; EFVD:NLI X-SpamScore: 0 X-BigFish: VPS0(zzzz1202hzz8275bhz2dh668h839hd24he5bhf0ah107ah) Received: from mail129-co1 (localhost.localdomain [127.0.0.1]) by mail129-co1 (MessageSwitch) id 1343379738164156_27821; Fri, 27 Jul 2012 09:02:18 +0000 (UTC) Received: from CO1EHSMHS010.bigfish.com (unknown [10.243.78.251]) by mail129-co1.bigfish.com (Postfix) with ESMTP id 1B1509C004A; Fri, 27 Jul 2012 09:02:18 +0000 (UTC) Received: from ausb3twp02.amd.com (163.181.249.109) by CO1EHSMHS010.bigfish.com (10.243.66.20) with Microsoft SMTP Server id 14.1.225.23; Fri, 27 Jul 2012 09:02:18 +0000 X-WSS-ID: 0M7TAFR-02-6OO-02 X-M-MSG: Received: from sausexedgep02.amd.com (sausexedgep02-ext.amd.com [163.181.249.73]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by ausb3twp02.amd.com (Axway MailGate 3.8.1) with ESMTP id 2513EC815D; Fri, 27 Jul 2012 04:02:14 -0500 (CDT) Received: from sausexhtp02.amd.com (163.181.3.152) by sausexedgep02.amd.com (163.181.36.59) with Microsoft SMTP Server (TLS) id 8.3.192.1; Fri, 27 Jul 2012 04:02:34 -0500 Received: from sausexmb1.amd.com (163.181.3.156) by sausexhtp02.amd.com (163.181.3.152) with Microsoft SMTP Server id 8.3.213.0; Fri, 27 Jul 2012 04:02:15 -0500 Received: from storexbh1.amd.com ([10.1.1.17]) by sausexmb1.amd.com with Microsoft SMTPSVC(6.0.3790.3959); Fri, 27 Jul 2012 04:02:15 -0500 Received: from sshaexmb1.amd.com ([10.237.2.11]) by storexbh1.amd.com with Microsoft SMTPSVC(6.0.3790.4675); Fri, 27 Jul 2012 05:02:13 -0400 Received: from aarontestpc.amd.com ([10.237.73.134]) by sshaexmb1.amd.com with Microsoft SMTPSVC(6.0.3790.4675); Fri, 27 Jul 2012 17:01:59 +0800 From: Aaron Lu To: James Bottomley , Jeff Garzik , Alan Stern , Sergei Shtylyov , Oliver Neukum CC: Jeff Wu , Lin Ming , , , , , Aaron Lu , Aaron Lu Subject: [PATCH v4 2/7] scsi: pm: add interface to autosuspend scsi device Date: Fri, 27 Jul 2012 17:00:45 +0800 Message-ID: <1343379650-2867-3-git-send-email-aaron.lu@amd.com> X-Mailer: git-send-email 1.7.11.3 In-Reply-To: <1343379650-2867-1-git-send-email-aaron.lu@amd.com> References: <1343379650-2867-1-git-send-email-aaron.lu@amd.com> X-OriginalArrivalTime: 27 Jul 2012 09:01:59.0252 (UTC) FILETIME=[7AE39140:01CD6BD6] MIME-Version: 1.0 X-OriginatorOrg: amd.com Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Add a new interface scsi_autopm_put_device_autosuspend to mark last busy for the device and then put autosuspend the device. Signed-off-by: Aaron Lu --- drivers/scsi/scsi_pm.c | 7 +++++++ include/scsi/scsi_device.h | 2 ++ 2 files changed, 9 insertions(+) diff --git a/drivers/scsi/scsi_pm.c b/drivers/scsi/scsi_pm.c index dc0ad85..83edb93 100644 --- a/drivers/scsi/scsi_pm.c +++ b/drivers/scsi/scsi_pm.c @@ -201,6 +201,13 @@ void scsi_autopm_put_device(struct scsi_device *sdev) } EXPORT_SYMBOL_GPL(scsi_autopm_put_device); +void scsi_autopm_put_device_autosuspend(struct scsi_device *sdev) +{ + pm_runtime_mark_last_busy(&sdev->sdev_gendev); + pm_runtime_put_autosuspend(&sdev->sdev_gendev); +} +EXPORT_SYMBOL_GPL(scsi_autopm_put_device_autosuspend); + void scsi_autopm_get_target(struct scsi_target *starget) { pm_runtime_get_sync(&starget->dev); diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h index 9895f69..3636146 100644 --- a/include/scsi/scsi_device.h +++ b/include/scsi/scsi_device.h @@ -395,9 +395,11 @@ extern int scsi_execute_req(struct scsi_device *sdev, const unsigned char *cmd, #ifdef CONFIG_PM_RUNTIME extern int scsi_autopm_get_device(struct scsi_device *); extern void scsi_autopm_put_device(struct scsi_device *); +extern void scsi_autopm_put_device_autosuspend(struct scsi_device *); #else static inline int scsi_autopm_get_device(struct scsi_device *d) { return 0; } static inline void scsi_autopm_put_device(struct scsi_device *d) {} +static inline void scsi_autopm_put_device_autosuspend(struct scsi_device *d) {} #endif /* CONFIG_PM_RUNTIME */ static inline int __must_check scsi_device_reprobe(struct scsi_device *sdev)