public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] PPC64 iSeries virtual DVD-RAM
@ 2004-06-08 12:46 Stephen Rothwell
  2004-06-08 15:52 ` Jeff Garzik
  0 siblings, 1 reply; 5+ messages in thread
From: Stephen Rothwell @ 2004-06-08 12:46 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Linus, linuxppc64-dev, LKML

[-- Attachment #1: Type: text/plain, Size: 4230 bytes --]

Hi Andrew, Linus,

This patch enables access to DVD-RAM devices on iSeries boxes.  It also
adds some more device ids for some newer DVD-RAM drives.

Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
-- 
Cheers,
Stephen Rothwell                    sfr@canb.auug.org.au
http://www.canb.auug.org.au/~sfr/

diff -ruN 2.6.7-rc3/drivers/cdrom/viocd.c 2.6.7-rc3.dvd/drivers/cdrom/viocd.c
--- 2.6.7-rc3/drivers/cdrom/viocd.c	2004-05-10 15:31:08.000000000 +1000
+++ 2.6.7-rc3.dvd/drivers/cdrom/viocd.c	2004-06-08 22:28:43.000000000 +1000
@@ -120,7 +120,10 @@
 };
 
 static struct capability_entry capability_table[] __initdata = {
-	{ "6330", CDC_LOCK | CDC_DVD_RAM },
+	{ "6330", CDC_LOCK | CDC_DVD_RAM | CDC_RAM },
+	{ "6331", CDC_LOCK | CDC_DVD_RAM | CDC_RAM },
+	{ "6333", CDC_LOCK | CDC_DVD_RAM | CDC_RAM },
+	{ "632A", CDC_LOCK | CDC_DVD_RAM | CDC_RAM },
 	{ "6321", CDC_LOCK },
 	{ "632B", 0 },
 	{ NULL  , CDC_LOCK },
@@ -330,10 +333,19 @@
 	struct disk_info *diskinfo = req->rq_disk->private_data;
 	u64 len;
 	dma_addr_t dmaaddr;
+	int direction;
+	u16 cmd;
 	struct scatterlist sg;
 
 	BUG_ON(req->nr_phys_segments > 1);
-	BUG_ON(rq_data_dir(req) != READ);
+
+	if (rq_data_dir(req) == READ) {
+		direction = DMA_FROM_DEVICE;
+		cmd = viomajorsubtype_cdio | viocdread;
+	} else {
+		direction = DMA_TO_DEVICE;
+		cmd = viomajorsubtype_cdio | viocdwrite;
+	}
 
         if (blk_rq_map_sg(req->q, req, &sg) == 0) {
 		printk(VIOCD_KERN_WARNING
@@ -341,7 +353,7 @@
 		return -1;
 	}
 
-	if (dma_map_sg(iSeries_vio_dev, &sg, 1, DMA_FROM_DEVICE) == 0) {
+	if (dma_map_sg(iSeries_vio_dev, &sg, 1, direction) == 0) {
 		printk(VIOCD_KERN_WARNING "error allocating sg tce\n");
 		return -1;
 	}
@@ -349,8 +361,7 @@
 	len = sg_dma_len(&sg);
 
 	hvrc = HvCallEvent_signalLpEventFast(viopath_hostLp,
-			HvLpEvent_Type_VirtualIo,
-			viomajorsubtype_cdio | viocdread,
+			HvLpEvent_Type_VirtualIo, cmd,
 			HvLpEvent_AckInd_DoAck,
 			HvLpEvent_AckType_ImmediateAck,
 			viopath_sourceinst(viopath_hostLp),
@@ -455,6 +466,35 @@
 	return 0;
 }
 
+static int viocd_packet(struct cdrom_device_info *cdi,
+		struct packet_command *cgc)
+{
+	unsigned int buflen = cgc->buflen;
+	int ret = -ENOTTY;
+
+	switch (cgc->cmd[0]) {
+	case GPCMD_READ_DISC_INFO:
+		{
+			disc_information *di = (disc_information *)cgc->buffer;
+
+			if (buflen >= 2) {
+				di->disc_information_length = cpu_to_be16(1);
+				ret = 0;
+			}
+			if (buflen >= 3)
+				di->erasable =
+					(cdi->ops->capability & ~cdi->mask
+					 & (CDC_DVD_RAM | CDC_RAM)) != 0;
+		}
+		break;
+	default:
+		break;
+	}
+
+	cgc->stat = ret;
+	return ret;
+}
+
 /* This routine handles incoming CD LP events */
 static void vio_handle_cd_event(struct HvLpEvent *event)
 {
@@ -508,6 +548,7 @@
 	case viocdclose:
 		break;
 
+	case viocdwrite:
 	case viocdread:
 		/*
 		 * Since this is running in interrupt mode, we need to
@@ -515,7 +556,8 @@
 		 */
 		spin_lock_irqsave(&viocd_reqlock, flags);
 		dma_unmap_single(iSeries_vio_dev, bevent->token, bevent->len,
-				DMA_FROM_DEVICE);
+				((event->xSubtype & VIOMINOR_SUBTYPE_MASK) == viocdread)
+				?  DMA_FROM_DEVICE : DMA_TO_DEVICE);
 		req = (struct request *)bevent->event.xCorrelationToken;
 		rwreq--;
 
@@ -552,14 +594,15 @@
 	.release = viocd_release,
 	.media_changed = viocd_media_changed,
 	.lock_door = viocd_lock_door,
-	.capability = CDC_CLOSE_TRAY | CDC_OPEN_TRAY | CDC_LOCK | CDC_SELECT_SPEED | CDC_SELECT_DISC | CDC_MULTI_SESSION | CDC_MCN | CDC_MEDIA_CHANGED | CDC_PLAY_AUDIO | CDC_RESET | CDC_IOCTLS | CDC_DRIVE_STATUS | CDC_GENERIC_PACKET | CDC_CD_R | CDC_CD_RW | CDC_DVD | CDC_DVD_R | CDC_DVD_RAM
+	.generic_packet = viocd_packet,
+	.capability = CDC_CLOSE_TRAY | CDC_OPEN_TRAY | CDC_LOCK | CDC_SELECT_SPEED | CDC_SELECT_DISC | CDC_MULTI_SESSION | CDC_MCN | CDC_MEDIA_CHANGED | CDC_PLAY_AUDIO | CDC_RESET | CDC_IOCTLS | CDC_DRIVE_STATUS | CDC_GENERIC_PACKET | CDC_CD_R | CDC_CD_RW | CDC_DVD | CDC_DVD_R | CDC_DVD_RAM | CDC_RAM
 };
 
 static int __init find_capability(const char *type)
 {
 	struct capability_entry *entry;
 
-	for(entry = capability_table; entry->type; ++entry)
+	for (entry = capability_table; entry->type; ++entry)
 		if(!strncmp(entry->type, type, 4))
 			break;
 	return entry->capability;

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] PPC64 iSeries virtual DVD-RAM
  2004-06-08 12:46 [PATCH] PPC64 iSeries virtual DVD-RAM Stephen Rothwell
@ 2004-06-08 15:52 ` Jeff Garzik
  2004-06-09  1:30   ` Stephen Rothwell
       [not found]   ` <20040609115035.2167efee.sfr@canb.auug.org.au>
  0 siblings, 2 replies; 5+ messages in thread
From: Jeff Garzik @ 2004-06-08 15:52 UTC (permalink / raw)
  To: Stephen Rothwell; +Cc: Andrew Morton, Linus, linuxppc64-dev, LKML, Jens Axboe

Stephen Rothwell wrote:
> Hi Andrew, Linus,
> 
> This patch enables access to DVD-RAM devices on iSeries boxes.  It also
> adds some more device ids for some newer DVD-RAM drives.
> 
> Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>

Has Jens, our cdrom maintainer, reviewed this?

I'm a bit curious why you handle GPCMD_READ_DISC_INFO and not let the 
underlying device handle it, for example.

	Jeff



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] PPC64 iSeries virtual DVD-RAM
  2004-06-08 15:52 ` Jeff Garzik
@ 2004-06-09  1:30   ` Stephen Rothwell
       [not found]   ` <20040609115035.2167efee.sfr@canb.auug.org.au>
  1 sibling, 0 replies; 5+ messages in thread
From: Stephen Rothwell @ 2004-06-09  1:30 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: akpm, torvalds, linuxppc64-dev, linux-kernel, axboe

[-- Attachment #1: Type: text/plain, Size: 421 bytes --]

On Tue, 08 Jun 2004 11:52:45 -0400 Jeff Garzik <jgarzik@pobox.com> wrote:
>
> I'm a bit curious why you handle GPCMD_READ_DISC_INFO and not let the
> underlying device handle it, for example.

Because the underlying *virtual* device doesn't handle it ... in fact
doesn't handle anything but open/close/read/write ...

-- 
Cheers,
Stephen Rothwell                    sfr@canb.auug.org.au
http://www.canb.auug.org.au/~sfr/

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] PPC64 iSeries virtual DVD-RAM
       [not found]     ` <20040609061227.GR13836@suse.de>
@ 2004-08-20  7:38       ` Stephen Rothwell
  2004-08-23 15:43         ` Jens Axboe
  0 siblings, 1 reply; 5+ messages in thread
From: Stephen Rothwell @ 2004-08-20  7:38 UTC (permalink / raw)
  To: Andrew Morton; +Cc: jgarzik, Jens Axboe, ppc64-dev, LKML, olh

[-- Attachment #1: Type: text/plain, Size: 4638 bytes --]

Hi Andrew,

This patch adds the ability to use DVD-RAM drives to the iSeries virtual
cdrom driver.  This version adresses (hopefully) Jens comments on the
previous one.

The patch is against 2.6.8.1 but sould apply to just about anything. 
Please apply to your tree and Linus'.  There is no clash with the patches
that Paulus has been sending you.

Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
-- 
Cheers,
Stephen Rothwell                    sfr@canb.auug.org.au
http://www.canb.auug.org.au/~sfr/

diff -ruNp 2.6.8.1/drivers/cdrom/viocd.c 2.6.8.1-dvdram.1/drivers/cdrom/viocd.c
--- 2.6.8.1/drivers/cdrom/viocd.c	2004-08-19 17:02:02.000000000 +1000
+++ 2.6.8.1-dvdram.1/drivers/cdrom/viocd.c	2004-08-20 00:38:40.000000000 +1000
@@ -121,7 +121,10 @@ struct capability_entry {
 };
 
 static struct capability_entry capability_table[] __initdata = {
-	{ "6330", CDC_LOCK | CDC_DVD_RAM },
+	{ "6330", CDC_LOCK | CDC_DVD_RAM | CDC_RAM },
+	{ "6331", CDC_LOCK | CDC_DVD_RAM | CDC_RAM },
+	{ "6333", CDC_LOCK | CDC_DVD_RAM | CDC_RAM },
+	{ "632A", CDC_LOCK | CDC_DVD_RAM | CDC_RAM },
 	{ "6321", CDC_LOCK },
 	{ "632B", 0 },
 	{ NULL  , CDC_LOCK },
@@ -332,10 +335,19 @@ static int send_request(struct request *
 	struct disk_info *diskinfo = req->rq_disk->private_data;
 	u64 len;
 	dma_addr_t dmaaddr;
+	int direction;
+	u16 cmd;
 	struct scatterlist sg;
 
 	BUG_ON(req->nr_phys_segments > 1);
-	BUG_ON(rq_data_dir(req) != READ);
+
+	if (rq_data_dir(req) == READ) {
+		direction = DMA_FROM_DEVICE;
+		cmd = viomajorsubtype_cdio | viocdread;
+	} else {
+		direction = DMA_TO_DEVICE;
+		cmd = viomajorsubtype_cdio | viocdwrite;
+	}
 
         if (blk_rq_map_sg(req->q, req, &sg) == 0) {
 		printk(VIOCD_KERN_WARNING
@@ -343,7 +355,7 @@ static int send_request(struct request *
 		return -1;
 	}
 
-	if (dma_map_sg(diskinfo->dev, &sg, 1, DMA_FROM_DEVICE) == 0) {
+	if (dma_map_sg(diskinfo->dev, &sg, 1, direction) == 0) {
 		printk(VIOCD_KERN_WARNING "error allocating sg tce\n");
 		return -1;
 	}
@@ -351,8 +363,7 @@ static int send_request(struct request *
 	len = sg_dma_len(&sg);
 
 	hvrc = HvCallEvent_signalLpEventFast(viopath_hostLp,
-			HvLpEvent_Type_VirtualIo,
-			viomajorsubtype_cdio | viocdread,
+			HvLpEvent_Type_VirtualIo, cmd,
 			HvLpEvent_AckInd_DoAck,
 			HvLpEvent_AckType_ImmediateAck,
 			viopath_sourceinst(viopath_hostLp),
@@ -457,6 +468,41 @@ static int viocd_lock_door(struct cdrom_
 	return 0;
 }
 
+static int viocd_packet(struct cdrom_device_info *cdi,
+		struct packet_command *cgc)
+{
+	unsigned int buflen = cgc->buflen;
+	int ret = -EIO;
+
+	switch (cgc->cmd[0]) {
+	case GPCMD_READ_DISC_INFO:
+		{
+			disc_information *di = (disc_information *)cgc->buffer;
+
+			if (buflen >= 2) {
+				di->disc_information_length = cpu_to_be16(1);
+				ret = 0;
+			}
+			if (buflen >= 3)
+				di->erasable =
+					(cdi->ops->capability & ~cdi->mask
+					 & (CDC_DVD_RAM | CDC_RAM)) != 0;
+		}
+		break;
+	default:
+		if (cgc->sense) {
+			/* indicate Unknown code */
+			cgc->sense->sense_key = 0x05;
+			cgc->sense->asc = 0x20;
+			cgc->sense->ascq = 0x00;
+		}
+		break;
+	}
+
+	cgc->stat = ret;
+	return ret;
+}
+
 /* This routine handles incoming CD LP events */
 static void vio_handle_cd_event(struct HvLpEvent *event)
 {
@@ -510,6 +556,7 @@ return_complete:
 	case viocdclose:
 		break;
 
+	case viocdwrite:
 	case viocdread:
 		/*
 		 * Since this is running in interrupt mode, we need to
@@ -518,7 +565,8 @@ return_complete:
 		di = &viocd_diskinfo[bevent->disk];
 		spin_lock_irqsave(&viocd_reqlock, flags);
 		dma_unmap_single(di->dev, bevent->token, bevent->len,
-				DMA_FROM_DEVICE);
+				((event->xSubtype & VIOMINOR_SUBTYPE_MASK) == viocdread)
+				?  DMA_FROM_DEVICE : DMA_TO_DEVICE);
 		req = (struct request *)bevent->event.xCorrelationToken;
 		rwreq--;
 
@@ -555,7 +603,8 @@ static struct cdrom_device_ops viocd_dop
 	.release = viocd_release,
 	.media_changed = viocd_media_changed,
 	.lock_door = viocd_lock_door,
-	.capability = CDC_CLOSE_TRAY | CDC_OPEN_TRAY | CDC_LOCK | CDC_SELECT_SPEED | CDC_SELECT_DISC | CDC_MULTI_SESSION | CDC_MCN | CDC_MEDIA_CHANGED | CDC_PLAY_AUDIO | CDC_RESET | CDC_IOCTLS | CDC_DRIVE_STATUS | CDC_GENERIC_PACKET | CDC_CD_R | CDC_CD_RW | CDC_DVD | CDC_DVD_R | CDC_DVD_RAM
+	.generic_packet = viocd_packet,
+	.capability = CDC_CLOSE_TRAY | CDC_OPEN_TRAY | CDC_LOCK | CDC_SELECT_SPEED | CDC_SELECT_DISC | CDC_MULTI_SESSION | CDC_MCN | CDC_MEDIA_CHANGED | CDC_PLAY_AUDIO | CDC_RESET | CDC_IOCTLS | CDC_DRIVE_STATUS | CDC_GENERIC_PACKET | CDC_CD_R | CDC_CD_RW | CDC_DVD | CDC_DVD_R | CDC_DVD_RAM | CDC_RAM
 };
 
 static int __init find_capability(const char *type)


[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] PPC64 iSeries virtual DVD-RAM
  2004-08-20  7:38       ` Stephen Rothwell
@ 2004-08-23 15:43         ` Jens Axboe
  0 siblings, 0 replies; 5+ messages in thread
From: Jens Axboe @ 2004-08-23 15:43 UTC (permalink / raw)
  To: Stephen Rothwell; +Cc: Andrew Morton, jgarzik, ppc64-dev, LKML, olh

On Fri, Aug 20 2004, Stephen Rothwell wrote:
> Hi Andrew,
> 
> This patch adds the ability to use DVD-RAM drives to the iSeries virtual
> cdrom driver.  This version adresses (hopefully) Jens comments on the
> previous one.
> 
> The patch is against 2.6.8.1 but sould apply to just about anything. 
> Please apply to your tree and Linus'.  There is no clash with the patches
> that Paulus has been sending you.

Looks fine.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2004-08-23 15:49 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-06-08 12:46 [PATCH] PPC64 iSeries virtual DVD-RAM Stephen Rothwell
2004-06-08 15:52 ` Jeff Garzik
2004-06-09  1:30   ` Stephen Rothwell
     [not found]   ` <20040609115035.2167efee.sfr@canb.auug.org.au>
     [not found]     ` <20040609061227.GR13836@suse.de>
2004-08-20  7:38       ` Stephen Rothwell
2004-08-23 15:43         ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox