From patchwork Thu Jul 26 10:05:28 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: aaron lu X-Patchwork-Id: 1241011 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 5E7CB3FC5A for ; Thu, 26 Jul 2012 10:06:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751691Ab2GZKGS (ORCPT ); Thu, 26 Jul 2012 06:06:18 -0400 Received: from va3ehsobe004.messaging.microsoft.com ([216.32.180.14]:15739 "EHLO va3outboundpool.messaging.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750834Ab2GZKGQ (ORCPT ); Thu, 26 Jul 2012 06:06:16 -0400 Received: from mail56-va3-R.bigfish.com (10.7.14.239) by VA3EHSOBE007.bigfish.com (10.7.40.11) with Microsoft SMTP Server id 14.1.225.23; Thu, 26 Jul 2012 10:06:13 +0000 Received: from mail56-va3 (localhost [127.0.0.1]) by mail56-va3-R.bigfish.com (Postfix) with ESMTP id 20130420258; Thu, 26 Jul 2012 10:06:13 +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 mail56-va3 (localhost.localdomain [127.0.0.1]) by mail56-va3 (MessageSwitch) id 134329717156412_13088; Thu, 26 Jul 2012 10:06:11 +0000 (UTC) Received: from VA3EHSMHS027.bigfish.com (unknown [10.7.14.236]) by mail56-va3.bigfish.com (Postfix) with ESMTP id F37B42E02BC; Thu, 26 Jul 2012 10:06:10 +0000 (UTC) Received: from ausb3twp02.amd.com (163.181.249.109) by VA3EHSMHS027.bigfish.com (10.7.99.37) with Microsoft SMTP Server id 14.1.225.23; Thu, 26 Jul 2012 10:06:10 +0000 X-WSS-ID: 0M7RIQ7-02-3OX-02 X-M-MSG: Received: from sausexedgep01.amd.com (sausexedgep01-ext.amd.com [163.181.249.72]) (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 212F4C8156; Thu, 26 Jul 2012 05:06:06 -0500 (CDT) Received: from sausexhtp01.amd.com (163.181.3.165) by sausexedgep01.amd.com (163.181.36.54) with Microsoft SMTP Server (TLS) id 8.3.192.1; Thu, 26 Jul 2012 05:06:22 -0500 Received: from sausexmb1.amd.com (163.181.3.156) by sausexhtp01.amd.com (163.181.3.165) with Microsoft SMTP Server id 8.3.213.0; Thu, 26 Jul 2012 05:06:06 -0500 Received: from storexbh1.amd.com ([10.1.1.17]) by sausexmb1.amd.com with Microsoft SMTPSVC(6.0.3790.3959); Thu, 26 Jul 2012 05:06:06 -0500 Received: from sshaexmb1.amd.com ([10.237.2.11]) by storexbh1.amd.com with Microsoft SMTPSVC(6.0.3790.4675); Thu, 26 Jul 2012 06:06:05 -0400 Received: from aarontestpc.amd.com ([10.237.73.70]) by sshaexmb1.amd.com with Microsoft SMTPSVC(6.0.3790.4675); Thu, 26 Jul 2012 18:05:58 +0800 From: Aaron Lu To: James Bottomley , Alan Stern CC: Jeff Garzik , Lin Ming , Jeff Wu , , , , , Aaron Lu , Aaron Lu Subject: [PATCH v3 6/7] scsi: sr: balance sr disk events block depth Date: Thu, 26 Jul 2012 18:05:28 +0800 Message-ID: <1343297129-28174-7-git-send-email-aaron.lu@amd.com> X-Mailer: git-send-email 1.7.11.3 In-Reply-To: <1343297129-28174-1-git-send-email-aaron.lu@amd.com> References: <1343297129-28174-1-git-send-email-aaron.lu@amd.com> X-OriginalArrivalTime: 26 Jul 2012 10:05:58.0534 (UTC) FILETIME=[40DDC260:01CD6B16] 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 When the ODD is resumed, disk_unblock_events should be called when: 1 The ODD is runtime resumed; 2 System is resuming from S3 and the ODD is runtime suspended before S3; But not when the system is resuming from S3 and the ODD is runtime active before S3. So seperate the resume calls, one for system resume and one for runtime resume to do different things accordingly. Signed-off-by: Aaron Lu --- drivers/scsi/sr.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c index fd1c2f6..b8c2f9d 100644 --- a/drivers/scsi/sr.c +++ b/drivers/scsi/sr.c @@ -82,6 +82,11 @@ static int sr_remove(struct device *); static int sr_done(struct scsi_cmnd *); static int sr_suspend(struct device *dev, pm_message_t msg); static int sr_resume(struct device *dev); +static int sr_runtime_resume(struct device *dev); + +static struct dev_pm_ops sr_pm_ops = { + .runtime_resume = sr_runtime_resume, +}; static struct scsi_driver sr_template = { .owner = THIS_MODULE, @@ -91,6 +96,7 @@ static struct scsi_driver sr_template = { .remove = sr_remove, .suspend = sr_suspend, .resume = sr_resume, + .pm = &sr_pm_ops, }, .done = sr_done, }; @@ -211,6 +217,21 @@ static int sr_suspend(struct device *dev, pm_message_t msg) static int sr_resume(struct device *dev) { + struct scsi_cd *cd = dev_get_drvdata(dev); + + /* + * If ODD is runtime suspended before system pm, unblock disk + * events now since on system resume, we will fully resume it + * and set its rumtime status to active. + */ + if (pm_runtime_suspended(dev)) + disk_unblock_events(cd->disk); + + return 0; +} + +static int sr_runtime_resume(struct device *dev) +{ struct scsi_cd *cd; struct scsi_sense_hdr sshdr;