From: Milton Miller <miltonm@bga.com>
To: Geert Uytterhoeven <Geert.Uytterhoeven@sonycom.com>
Cc: ppcdev <linuxppc-dev@ozlabs.org>
Subject: Re: [patch 5/6] ps3: ROM Storage Driver
Date: Mon, 18 Jun 2007 11:30:39 -0500 [thread overview]
Message-ID: <d46c75da8a86ab5cd83b63f9dbfee33f@bga.com> (raw)
In-Reply-To: <20070615120848.454492000@pademelon.sonytel.be>
> From: Geert Uytterhoeven <Geert.Uytterhoeven@sonycom.com>
>
> Add a CD/DVD/BD Storage Driver for the PS3:
> - Implemented as a SCSI device driver
> - Uses software scatter-gather with a 64 KiB bounce buffer as the
> hypervisor
> doesn't support scatter-gather
>
>
> +config PS3_ROM
> + tristate "PS3 ROM Storage Driver"
> + depends on PPC_PS3 && BLK_DEV_SR
> + select PS3_STORAGE
> + help
> + Include support for the PS3 ROM Storage.
> +
> + This support is required to access the PS3 BD/DVD/CD-ROM drive.
> + In general, all users will say Y or M.
> +
When I think ROM I usually dont' start with optical media.
Have you condered calling this the optical driver?
Or at least putting BD?DVD?CD-ROM on the prompt.
Why does it depend on BLK_DEV_SR?
...
> +
> +#include <linux/cdrom.h>
> +#include <linux/highmem.h>
> +#include <linux/interrupt.h>
> +#include <linux/kthread.h>
> +
> +#include <scsi/scsi.h>
> +#include <scsi/scsi_cmnd.h>
> +#include <scsi/scsi_dbg.h>
> +#include <scsi/scsi_device.h>
> +#include <scsi/scsi_host.h>
> +
> +#include <asm/lv1call.h>
> +#include <asm/ps3stor.h>
> +
> +
> +#define DEVICE_NAME "ps3rom"
> +
> +#define BOUNCE_SIZE (64*1024)
> +
> +#define PS3ROM_MAX_SECTORS (BOUNCE_SIZE / CD_FRAMESIZE)
> +
the above describes the device
> +#define LV1_STORAGE_SEND_ATAPI_COMMAND (1)
> +
>
while this one is part of the hypervisor ABI.
> +
> +struct ps3rom_private {
> + struct ps3_storage_device *dev;
> + struct scsi_cmnd *cmd;
> +};
> +#define ps3rom_priv(dev) ((dev)->sbd.core.driver_data)
>
The above is driver defined.
> +
> +struct lv1_atapi_cmnd_block {
> + u8 pkt[32]; /* packet command block */
> + u32 pktlen; /* should be 12 for ATAPI 8020 */
> + u32 blocks;
> + u32 block_size;
> + u32 proto; /* transfer mode */
> + u32 in_out; /* transfer direction */
> + u64 buffer; /* parameter except command block */
> + u32 arglen; /* length above */
> +};
> +
Its minor, but I'd probably put the define down here with the rest of
the ABI contants vs all defines then structs then enums.
> +enum lv1_atapi_proto {
> + NON_DATA_PROTO = 0,
> + PIO_DATA_IN_PROTO = 1,
> + PIO_DATA_OUT_PROTO = 2,
> + DMA_PROTO = 3
> +};
> +
> +enum lv1_atapi_in_out {
> + DIR_WRITE = 0, /* memory -> device */
> + DIR_READ = 1 /* device -> memory */
> +};
> +
>
...
> +
> +static int __devinit ps3rom_probe(struct ps3_system_bus_device *_dev)
> +{
> + struct ps3_storage_device *dev = to_ps3_storage_device(&_dev->core);
> + int error;
> + struct Scsi_Host *host;
> + struct ps3rom_private *priv;
> +
> + if (dev->blk_size != CD_FRAMESIZE) {
> + dev_err(&dev->sbd.core,
> + "%s:%u: cannot handle block size %lu\n", __func__,
> + __LINE__, dev->blk_size);
> + return -EINVAL;
> + }
> +
> + dev->bounce_size = BOUNCE_SIZE;
> + dev->bounce_buf = kmalloc(BOUNCE_SIZE, GFP_DMA);
> + if (!dev->bounce_buf) {
> + return -ENOMEM;
> + }
> +
> + error = ps3stor_setup(dev);
> + if (error)
> + goto fail_free_bounce;
> +
> + /* override the interrupt handler */
> + free_irq(dev->irq, dev);
> + error = request_irq(dev->irq, ps3rom_interrupt, IRQF_DISABLED,
> + dev->sbd.core.driver->name, dev);
> + if (error) {
> + dev_err(&dev->sbd.core, "%s:%u: request_irq failed %d\n",
> + __func__, __LINE__, error);
> + goto fail_teardown;
> + }
> +
Somebody's help isn't helpful? Layering problem?
> + host = scsi_host_alloc(&ps3rom_host_template,
> + sizeof(struct ps3rom_private));
> + if (!host) {
> + dev_err(&dev->sbd.core, "%s:%u: scsi_host_alloc failed\n",
> + __func__, __LINE__);
> + goto fail_teardown;
> + }
> +
> + priv = (struct ps3rom_private *)host->hostdata;
> + ps3rom_priv(dev) = host;
> + priv->dev = dev;
>
Is there code to clear ->priv when failing or unregistering? Usually
these fields are set to NULL to avoid accidental use of stale pointers
to freed memory. Discovering a NULL pointer defereence is usually
easier than a stale usage.
> +
> + /* One device/LUN per SCSI bus */
> + host->max_id = 1;
> + host->max_lun = 1;
> +
> + error = scsi_add_host(host, &dev->sbd.core);
> + if (error) {
> + dev_err(&dev->sbd.core, "%s:%u: scsi_host_alloc failed %d\n",
> + __func__, __LINE__, error);
> + error = -ENODEV;
> + goto fail_host_put;
> + }
> +
> + scsi_scan_host(host);
> + return 0;
> +
> +fail_host_put:
> + scsi_host_put(host);
> +fail_teardown:
> + ps3stor_teardown(dev);
> +fail_free_bounce:
> + kfree(dev->bounce_buf);
> + return error;
> +}
>
next prev parent reply other threads:[~2007-06-18 16:30 UTC|newest]
Thread overview: 84+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-15 11:39 [patch 0/6] PS3 Storage Drivers for 2.6.23, take 2 Geert Uytterhoeven
2007-06-15 11:39 ` Geert Uytterhoeven
2007-06-15 11:39 ` Geert Uytterhoeven
2007-06-15 11:39 ` [patch 1/6] ps3: Preallocate bootmem memory for the PS3 FLASH ROM storage driver Geert Uytterhoeven
2007-06-15 11:39 ` Geert Uytterhoeven
2007-06-15 11:39 ` Geert Uytterhoeven
2007-06-15 13:27 ` Benjamin Herrenschmidt
2007-06-15 13:27 ` Benjamin Herrenschmidt
2007-06-15 13:32 ` Geert Uytterhoeven
2007-06-15 13:32 ` Geert Uytterhoeven
2007-06-18 16:25 ` [patch 1/6] ps3: Preallocate bootmem memory for the PS3 FLASH Milton Miller
2007-06-19 11:36 ` Geert Uytterhoeven
2007-06-15 11:39 ` [patch 2/6] ps3: Storage Driver Core Geert Uytterhoeven
2007-06-15 11:39 ` Geert Uytterhoeven
2007-06-15 11:39 ` Geert Uytterhoeven
2007-06-15 11:39 ` [patch 3/6] PS3: Storage device registration routines Geert Uytterhoeven
2007-06-15 11:39 ` Geert Uytterhoeven
2007-06-15 11:39 ` Geert Uytterhoeven
2007-06-15 11:39 ` [patch 4/6] ps3: Disk Storage Driver Geert Uytterhoeven
2007-06-15 11:39 ` Geert Uytterhoeven
2007-06-15 11:39 ` Geert Uytterhoeven
2007-06-15 14:35 ` David Woodhouse
2007-06-15 14:35 ` David Woodhouse
2007-06-15 14:41 ` Arnd Bergmann
2007-06-15 14:41 ` Arnd Bergmann
2007-06-15 14:41 ` Arnd Bergmann
2007-06-15 14:43 ` Geert Uytterhoeven
2007-06-15 16:15 ` Alan Cox
2007-06-15 16:15 ` Alan Cox
2007-06-15 18:05 ` Geert Uytterhoeven
2007-06-15 21:19 ` David Miller
2007-06-15 21:19 ` David Miller
2007-06-15 22:40 ` James Bottomley
2007-06-15 22:40 ` James Bottomley
2007-06-15 23:08 ` David Miller
2007-06-15 23:08 ` David Miller
2007-06-15 23:28 ` James Bottomley
2007-06-15 23:28 ` James Bottomley
2007-06-15 23:37 ` David Miller
2007-06-15 23:37 ` David Miller
2007-06-19 5:56 ` Christoph Hellwig
2007-06-19 6:07 ` David Miller
2007-06-19 8:15 ` Christoph Hellwig
2007-06-19 8:15 ` Christoph Hellwig
2007-06-15 23:11 ` Alan Cox
2007-06-15 23:11 ` Alan Cox
2007-06-16 6:21 ` Geert Uytterhoeven
2007-06-16 6:21 ` Geert Uytterhoeven
2007-06-19 5:53 ` Christoph Hellwig
2007-06-19 5:53 ` Christoph Hellwig
2007-06-19 6:03 ` David Miller
2007-06-19 6:03 ` David Miller
2007-06-19 7:06 ` Geert Uytterhoeven
2007-06-19 7:06 ` Geert Uytterhoeven
2007-06-15 21:17 ` David Miller
2007-06-15 21:17 ` David Miller
2007-06-15 21:28 ` Jeff Garzik
2007-06-15 21:28 ` Jeff Garzik
2007-06-15 21:37 ` David Miller
2007-06-15 21:37 ` David Miller
2007-06-15 21:50 ` Jeff Garzik
2007-06-15 21:50 ` Jeff Garzik
2007-06-15 21:55 ` David Miller
2007-06-15 21:55 ` David Miller
2007-06-19 5:43 ` Christoph Hellwig
2007-06-19 5:43 ` Christoph Hellwig
2007-06-19 12:51 ` Geert Uytterhoeven
2007-06-19 12:51 ` Geert Uytterhoeven
2007-06-19 17:19 ` Christoph Hellwig
2007-06-19 17:19 ` Christoph Hellwig
2007-06-15 11:39 ` [patch 5/6] ps3: ROM " Geert Uytterhoeven
2007-06-15 11:39 ` Geert Uytterhoeven
2007-06-15 11:39 ` Geert Uytterhoeven
2007-06-18 16:30 ` Milton Miller [this message]
2007-06-19 5:44 ` Christoph Hellwig
2007-06-19 12:29 ` Geert Uytterhoeven
2007-06-20 12:16 ` Milton Miller
2007-06-19 5:51 ` Christoph Hellwig
2007-06-19 5:51 ` Christoph Hellwig
2007-06-15 11:39 ` [patch 6/6] ps3: FLASH " Geert Uytterhoeven
2007-06-15 11:39 ` Geert Uytterhoeven
2007-06-15 11:39 ` Geert Uytterhoeven
2007-06-18 16:30 ` Milton Miller
2007-06-19 12:02 ` Geert Uytterhoeven
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d46c75da8a86ab5cd83b63f9dbfee33f@bga.com \
--to=miltonm@bga.com \
--cc=Geert.Uytterhoeven@sonycom.com \
--cc=linuxppc-dev@ozlabs.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.