From patchwork Tue Sep 4 14:24:36 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Lu X-Patchwork-Id: 181586 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 03F132C009A for ; Wed, 5 Sep 2012 00:25:43 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932251Ab2IDOZj (ORCPT ); Tue, 4 Sep 2012 10:25:39 -0400 Received: from mail-pb0-f46.google.com ([209.85.160.46]:44458 "EHLO mail-pb0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932244Ab2IDOZh (ORCPT ); Tue, 4 Sep 2012 10:25:37 -0400 Received: by mail-pb0-f46.google.com with SMTP id rr13so9559178pbb.19 for ; Tue, 04 Sep 2012 07:25:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=9Vwgpq4hGL+Ibi39R1NQh8n6+4fxX0uuSfBq9voHz44=; b=ELAfyNgFZjeiHDmFwp1EXu3wKdla+xDJBIHC3rOiC4MHkXgKaE7WFqVnvwEITA46z/ CIKC+1+kGGrQVrCx5cT6nbwP1KebEr9A/3QwxSRniPiCa7OSVkMOupLBA93TbnTgH/K6 URtpDH23VXdS6zR2gY4qduu+zO2VErmP4pSiF2b22vymJHh+3bMIb+cxgo1rebFypy85 4inBHiDGkXcppKzuAOv69ctUFILpWD4VIx0Z72cRsJLKo74NnBGr532SblxuuzKEB5Ly TdoK7v8jn/vnhx21U+ppYZQqUnrivlXywOPilaajH7ryEcge2ZkAEKQyYjYka8mJNXr0 00sw== Received: by 10.68.234.7 with SMTP id ua7mr46983942pbc.91.1346768736614; Tue, 04 Sep 2012 07:25:36 -0700 (PDT) Received: from localhost.localdomain.localdomain ([180.157.93.243]) by mx.google.com with ESMTPS id lb1sm12311440pbc.47.2012.09.04.07.25.30 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 04 Sep 2012 07:25:35 -0700 (PDT) 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 v6 3/7] scsi: sr: block events checking when suspended for zpodd Date: Tue, 4 Sep 2012 22:24:36 +0800 Message-Id: <1346768680-7287-4-git-send-email-aaron.lwe@gmail.com> X-Mailer: git-send-email 1.7.11.3 In-Reply-To: <1346768680-7287-1-git-send-email-aaron.lwe@gmail.com> References: <1346768680-7287-1-git-send-email-aaron.lwe@gmail.com> Sender: linux-ide-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ide@vger.kernel.org From: Aaron Lu 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 637f4ca..a5bb687 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 */