From patchwork Thu Jul 26 10:05:23 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Lu X-Patchwork-Id: 173392 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 4FDBF2C0091 for ; Thu, 26 Jul 2012 20:09:17 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751868Ab2GZKIo (ORCPT ); Thu, 26 Jul 2012 06:08:44 -0400 Received: from ch1ehsobe006.messaging.microsoft.com ([216.32.181.186]:25415 "EHLO ch1outboundpool.messaging.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751582Ab2GZKGS (ORCPT ); Thu, 26 Jul 2012 06:06:18 -0400 Received: from mail110-ch1-R.bigfish.com (10.43.68.229) by CH1EHSOBE015.bigfish.com (10.43.70.65) with Microsoft SMTP Server id 14.1.225.23; Thu, 26 Jul 2012 10:06:17 +0000 Received: from mail110-ch1 (localhost [127.0.0.1]) by mail110-ch1-R.bigfish.com (Postfix) with ESMTP id C04724003CF; Thu, 26 Jul 2012 10:06:17 +0000 (UTC) X-Forefront-Antispam-Report: CIP:163.181.249.108; KIP:(null); UIP:(null); IPV:NLI; H:ausb3twp01.amd.com; RD:none; EFVD:NLI X-SpamScore: 0 X-BigFish: VPS0(zzzz1202hzz8275bhz2dh668h839hd24he5bhf0ah107ah) Received: from mail110-ch1 (localhost.localdomain [127.0.0.1]) by mail110-ch1 (MessageSwitch) id 1343297175977507_18904; Thu, 26 Jul 2012 10:06:15 +0000 (UTC) Received: from CH1EHSMHS019.bigfish.com (snatpool1.int.messaging.microsoft.com [10.43.68.241]) by mail110-ch1.bigfish.com (Postfix) with ESMTP id E928080045; Thu, 26 Jul 2012 10:06:15 +0000 (UTC) Received: from ausb3twp01.amd.com (163.181.249.108) by CH1EHSMHS019.bigfish.com (10.43.70.19) with Microsoft SMTP Server id 14.1.225.23; Thu, 26 Jul 2012 10:06:15 +0000 X-WSS-ID: 0M7RIQB-01-4HS-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 ausb3twp01.amd.com (Axway MailGate 3.8.1) with ESMTP id 23EDA1028143; Thu, 26 Jul 2012 05:06:10 -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; Thu, 26 Jul 2012 05:06:26 -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; Thu, 26 Jul 2012 05:06:10 -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:10 -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:08 -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 1/7] scsi: sr: check support for device busy class events Date: Thu, 26 Jul 2012 18:05:23 +0800 Message-ID: <1343297129-28174-2-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.0456 (UTC) FILETIME=[40D1DB80:01CD6B16] MIME-Version: 1.0 X-OriginatorOrg: amd.com Sender: linux-ide-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ide@vger.kernel.org Signed-off-by: Aaron Lu --- drivers/scsi/sr.c | 23 +++++++++++++++++++++++ drivers/scsi/sr.h | 1 + include/linux/cdrom.h | 43 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 67 insertions(+) diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c index 5fc97d2..abfefab 100644 --- a/drivers/scsi/sr.c +++ b/drivers/scsi/sr.c @@ -101,6 +101,7 @@ static DEFINE_MUTEX(sr_ref_mutex); static int sr_open(struct cdrom_device_info *, int); static void sr_release(struct cdrom_device_info *); +static void check_dbml(struct scsi_cd *); static void get_sectorsize(struct scsi_cd *); static void get_capabilities(struct scsi_cd *); @@ -728,6 +729,28 @@ fail: return error; } +static void check_dbml(struct scsi_cd *cd) +{ + struct packet_command cgc; + unsigned char buffer[16]; + struct rm_feature_desc *rfd; + + init_cdrom_command(&cgc, buffer, sizeof(buffer), CGC_DATA_READ); + cgc.cmd[0] = GPCMD_GET_CONFIGURATION; + cgc.cmd[3] = CDF_RM; + cgc.cmd[8] = sizeof(buffer); + cgc.quiet = 1; + + if (cd->cdi.ops->generic_packet(&cd->cdi, &cgc)) + return; + + rfd = (struct rm_feature_desc *)&buffer[sizeof(struct feature_header)]; + if (be16_to_cpu(rfd->feature_code) != CDF_RM) + return; + + if (rfd->dbml) + cd->dbml = 1; +} static void get_sectorsize(struct scsi_cd *cd) { diff --git a/drivers/scsi/sr.h b/drivers/scsi/sr.h index 37c8f6b..7cc40ad 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 dbml:1; /* generates device busy class events */ /* GET_EVENT spurious event handling, blk layer guarantees exclusion */ int tur_mismatch; /* nr of get_event TUR mismatches */ diff --git a/include/linux/cdrom.h b/include/linux/cdrom.h index dfd7f18..962be39 100644 --- a/include/linux/cdrom.h +++ b/include/linux/cdrom.h @@ -727,6 +727,7 @@ struct request_sense { /* * feature profile */ +#define CDF_RM 0x0003 /* "Removable Medium" */ #define CDF_RWRT 0x0020 /* "Random Writable" */ #define CDF_HWDM 0x0024 /* "Hardware Defect Management" */ #define CDF_MRW 0x0028 @@ -739,6 +740,48 @@ struct request_sense { #define CDM_MRW_BGFORMAT_ACTIVE 2 #define CDM_MRW_BGFORMAT_COMPLETE 3 +/* Removable medium feature descriptor */ +struct rm_feature_desc { + __be16 feature_code; +#if defined(__BIG_ENDIAN_BITFIELD) + __u8 reserved1 : 2; + __u8 feature_version : 4; + __u8 persistent : 1; + __u8 curr : 1; +#elif defined(__LITTLE_ENDIAN_BITFIELD) + __u8 curr : 1; + __u8 persistent : 1; + __u8 feature_version : 4; + __u8 reserved1 : 2; +#endif + __u8 add_len; +#if defined(__BIG_ENDIAN_BITFIELD) + __u8 mech_type : 3; + __u8 load : 1; + __u8 eject : 1; + __u8 pvnt_jmpr : 1; + __u8 dbml : 1; + __u8 lock : 1; +#elif defined(__LITTLE_ENDIAN_BITFIELD) + __u8 lock : 1; + __u8 dbml : 1; + __u8 pvnt_jmpr : 1; + __u8 eject : 1; + __u8 load : 1; + __u8 mech_type : 3; +#endif + __u8 reserved2; + __u8 reserved3; + __u8 reserved4; +}; + +struct device_busy_event_desc { + __u8 device_busy_event : 4; + __u8 reserved1 : 4; + __u8 device_busy_status; + __u8 time; +}; + /* * mrw address spaces */