From patchwork Fri Aug 31 09:42:31 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Lu X-Patchwork-Id: 1392451 Return-Path: X-Original-To: patchwork-linux-acpi@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 918D73FF1B for ; Fri, 31 Aug 2012 09:43:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752173Ab2HaJnU (ORCPT ); Fri, 31 Aug 2012 05:43:20 -0400 Received: from mga02.intel.com ([134.134.136.20]:64686 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752137Ab2HaJnR (ORCPT ); Fri, 31 Aug 2012 05:43:17 -0400 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP; 31 Aug 2012 02:43:17 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.80,346,1344236400"; d="scan'208";a="194023764" Received: from aaronlu.sh.intel.com ([10.239.36.129]) by orsmga002.jf.intel.com with ESMTP; 31 Aug 2012 02:43:15 -0700 From: Aaron Lu To: Alan Stern , James Bottomley , Jeff Garzik Cc: linux-scsi@vger.kernel.org, linux-ide@vger.kernel.org, linux-pm@vger.kernel.org, linux-acpi@vger.kernel.org, Aaron Lu , Aaron Lu Subject: [PATCH v5 3/7] scsi: sr: block events checking when suspended for zpodd Date: Fri, 31 Aug 2012 17:42:31 +0800 Message-Id: <1346406155-4768-4-git-send-email-aaron.lu@intel.com> X-Mailer: git-send-email 1.7.11.5 In-Reply-To: <1346406155-4768-1-git-send-email-aaron.lu@intel.com> References: <1346406155-4768-1-git-send-email-aaron.lu@intel.com> Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org When ODD is runtime suspended and if it can be powered off(reflected by the can_power_off flag), we will block events checking for it so that it can stay in powered off state until resumed by: 1 user pressing the eject button or inserting a disc; 2 software opening the block device. But not by events checking that normally occurs every 2 seconds. Old versions of udisk will poll the ODD periodically, so it is advised to inhibit the polling: $ udisks --inhibit-polling /dev/sr0 Signed-off-by: Aaron Lu --- drivers/scsi/sr.c | 10 ++++++++++ drivers/scsi/sr.h | 1 + 2 files changed, 11 insertions(+) diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c index 04a658b..1acfe0e 100644 --- a/drivers/scsi/sr.c +++ b/drivers/scsi/sr.c @@ -204,6 +204,11 @@ static int sr_suspend(struct device *dev, pm_message_t msg) if (!suspend) return -EBUSY; + if (cd->device->can_power_off) { + cd->disk_events_blocked = 1; + disk_block_events(cd->disk); + } + return 0; } @@ -224,6 +229,11 @@ static int sr_resume(struct device *dev) sr_tray_move(&cd->cdi, 1); } + if (cd->disk_events_blocked) { + cd->disk_events_blocked = 0; + disk_unblock_events(cd->disk); + } + return 0; } diff --git a/drivers/scsi/sr.h b/drivers/scsi/sr.h index 37c8f6b..9d9a76f 100644 --- a/drivers/scsi/sr.h +++ b/drivers/scsi/sr.h @@ -41,6 +41,7 @@ typedef struct scsi_cd { unsigned readcd_known:1; /* drive supports READ_CD (0xbe) */ unsigned readcd_cdda:1; /* reading audio data using READ_CD */ unsigned media_present:1; /* media is present */ + unsigned disk_events_blocked:1; /* disk events is blocked */ /* GET_EVENT spurious event handling, blk layer guarantees exclusion */ int tur_mismatch; /* nr of get_event TUR mismatches */