From: Andrew Morton <akpm@linux-foundation.org>
To: Geert Uytterhoeven <Geert.Uytterhoeven@sonycom.com>
Cc: Jens Axboe <axboe@kernel.dk>,
"James E.J. Bottomley" <James.Bottomley@SteelEye.com>,
linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org,
Alessandro Rubini <rubini@vision.unipv.it>,
linuxppc-dev@ozlabs.org, Paul Mackerras <paulus@samba.org>
Subject: Re: [patch 2/3] ps3: BD/DVD/CD-ROM Storage Driver
Date: Wed, 18 Jul 2007 16:43:51 -0700 [thread overview]
Message-ID: <20070718164351.a92ec032.akpm@linux-foundation.org> (raw)
In-Reply-To: <20070716162206.529280000@pademelon.sonytel.be>
On Mon, 16 Jul 2007 18:15:41 +0200
Geert Uytterhoeven <Geert.Uytterhoeven@sonycom.com> wrote:
> From: Geert Uytterhoeven <Geert.Uytterhoeven@sonycom.com>
>
> Add a BD/DVD/CD-ROM 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
>
> --- /dev/null
> +++ b/drivers/scsi/ps3rom.c
> @@ -0,0 +1,538 @@
> +/*
> + * PS3 BD/DVD/CD-ROM Storage Driver
> + *
> + * Copyright (C) 2007 Sony Computer Entertainment Inc.
> + * Copyright 2007 Sony Corp.
> + *
> + * This program is free software; you can redistribute it and/or modify it
> + * under the terms of the GNU General Public License as published
> + * by the Free Software Foundation; version 2 of the License.
> + *
> + * This program is distributed in the hope that it will be useful, but
> + * WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + * General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License along
> + * with this program; if not, write to the Free Software Foundation, Inc.,
> + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
> + */
> +
> +#include <linux/cdrom.h>
> +#include <linux/highmem.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)
> +
> +
> +struct ps3rom_private {
> + struct ps3_storage_device *dev;
> + struct scsi_cmnd *curr_cmd;
> +};
> +#define ps3rom_priv(dev) ((dev)->sbd.core.driver_data)
> +
Someone should invent a keyboard which delivers an electric shock when the
operator types "#define". In the meanwhile, I get to do the honours.
Please don't implement in a macro anything which can be implemented in C.
> +
> +#define LV1_STORAGE_SEND_ATAPI_COMMAND (1)
> +
> +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 */
> +};
> +
> +enum lv1_atapi_proto {
> + NON_DATA_PROTO = 0,
> + PIO_DATA_IN_PROTO = 1,
> + PIO_DATA_OUT_PROTO = 2,
> + DMA_PROTO = 3
> +};
> +
>
> ...
>
> +/*
> + * copy data from device into scatter/gather buffer
> + */
> +static int fill_from_dev_buffer(struct scsi_cmnd *cmd, const void *buf)
> +{
> + int k, req_len, act_len, len, active;
> + void *kaddr;
> + struct scatterlist *sgpnt;
> + unsigned int buflen;
> +
> + buflen = cmd->request_bufflen;
> + if (!buflen)
> + return 0;
> +
> + if (!cmd->request_buffer)
> + return -1;
> +
> + sgpnt = cmd->request_buffer;
> + active = 1;
> + for (k = 0, req_len = 0, act_len = 0; k < cmd->use_sg; ++k, ++sgpnt) {
> + if (active) {
> + kaddr = kmap_atomic(sgpnt->page, KM_IRQ0);
> + if (!kaddr)
> + return -1;
kmap_atomic() cannot fail. On i386, at least. If it can fail on any other
arch then we have a biiiiig problem. (Multiple instances of this)
> + len = sgpnt->length;
> + if ((req_len + len) > buflen) {
> + active = 0;
> + len = buflen - req_len;
> + }
> + memcpy(kaddr + sgpnt->offset, buf + req_len, len);
> + flush_kernel_dcache_page(sgpnt->page);
> + kunmap_atomic(kaddr, KM_IRQ0);
> + act_len += len;
> + }
> + req_len += sgpnt->length;
> + }
> + cmd->resid = req_len - act_len;
> + return 0;
> +}
> +
WARNING: multiple messages have this Message-ID (diff)
From: Andrew Morton <akpm@linux-foundation.org>
To: Geert Uytterhoeven <Geert.Uytterhoeven@sonycom.com>
Cc: Paul Mackerras <paulus@samba.org>, Jens Axboe <axboe@kernel.dk>,
"James E.J. Bottomley" <James.Bottomley@SteelEye.com>,
Alessandro Rubini <rubini@vision.unipv.it>,
linuxppc-dev@ozlabs.org, linux-kernel@vger.kernel.org,
linux-scsi@vger.kernel.org,
Geoff Levand <geoffrey.levand@am.sony.com>
Subject: Re: [patch 2/3] ps3: BD/DVD/CD-ROM Storage Driver
Date: Wed, 18 Jul 2007 16:43:51 -0700 [thread overview]
Message-ID: <20070718164351.a92ec032.akpm@linux-foundation.org> (raw)
In-Reply-To: <20070716162206.529280000@pademelon.sonytel.be>
On Mon, 16 Jul 2007 18:15:41 +0200
Geert Uytterhoeven <Geert.Uytterhoeven@sonycom.com> wrote:
> From: Geert Uytterhoeven <Geert.Uytterhoeven@sonycom.com>
>
> Add a BD/DVD/CD-ROM 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
>
> --- /dev/null
> +++ b/drivers/scsi/ps3rom.c
> @@ -0,0 +1,538 @@
> +/*
> + * PS3 BD/DVD/CD-ROM Storage Driver
> + *
> + * Copyright (C) 2007 Sony Computer Entertainment Inc.
> + * Copyright 2007 Sony Corp.
> + *
> + * This program is free software; you can redistribute it and/or modify it
> + * under the terms of the GNU General Public License as published
> + * by the Free Software Foundation; version 2 of the License.
> + *
> + * This program is distributed in the hope that it will be useful, but
> + * WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + * General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License along
> + * with this program; if not, write to the Free Software Foundation, Inc.,
> + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
> + */
> +
> +#include <linux/cdrom.h>
> +#include <linux/highmem.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)
> +
> +
> +struct ps3rom_private {
> + struct ps3_storage_device *dev;
> + struct scsi_cmnd *curr_cmd;
> +};
> +#define ps3rom_priv(dev) ((dev)->sbd.core.driver_data)
> +
Someone should invent a keyboard which delivers an electric shock when the
operator types "#define". In the meanwhile, I get to do the honours.
Please don't implement in a macro anything which can be implemented in C.
> +
> +#define LV1_STORAGE_SEND_ATAPI_COMMAND (1)
> +
> +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 */
> +};
> +
> +enum lv1_atapi_proto {
> + NON_DATA_PROTO = 0,
> + PIO_DATA_IN_PROTO = 1,
> + PIO_DATA_OUT_PROTO = 2,
> + DMA_PROTO = 3
> +};
> +
>
> ...
>
> +/*
> + * copy data from device into scatter/gather buffer
> + */
> +static int fill_from_dev_buffer(struct scsi_cmnd *cmd, const void *buf)
> +{
> + int k, req_len, act_len, len, active;
> + void *kaddr;
> + struct scatterlist *sgpnt;
> + unsigned int buflen;
> +
> + buflen = cmd->request_bufflen;
> + if (!buflen)
> + return 0;
> +
> + if (!cmd->request_buffer)
> + return -1;
> +
> + sgpnt = cmd->request_buffer;
> + active = 1;
> + for (k = 0, req_len = 0, act_len = 0; k < cmd->use_sg; ++k, ++sgpnt) {
> + if (active) {
> + kaddr = kmap_atomic(sgpnt->page, KM_IRQ0);
> + if (!kaddr)
> + return -1;
kmap_atomic() cannot fail. On i386, at least. If it can fail on any other
arch then we have a biiiiig problem. (Multiple instances of this)
> + len = sgpnt->length;
> + if ((req_len + len) > buflen) {
> + active = 0;
> + len = buflen - req_len;
> + }
> + memcpy(kaddr + sgpnt->offset, buf + req_len, len);
> + flush_kernel_dcache_page(sgpnt->page);
> + kunmap_atomic(kaddr, KM_IRQ0);
> + act_len += len;
> + }
> + req_len += sgpnt->length;
> + }
> + cmd->resid = req_len - act_len;
> + return 0;
> +}
> +
next prev parent reply other threads:[~2007-07-18 23:43 UTC|newest]
Thread overview: 87+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-07-16 16:15 [patch 0/3] PS3 Storage Drivers for 2.6.23, take 5 Geert Uytterhoeven
2007-07-16 16:15 ` Geert Uytterhoeven
2007-07-16 16:15 ` Geert Uytterhoeven
2007-07-16 16:15 ` [patch 1/3] ps3: Disk Storage Driver Geert Uytterhoeven
2007-07-16 16:15 ` Geert Uytterhoeven
2007-07-16 16:15 ` Geert Uytterhoeven
2007-07-18 14:32 ` Jan Engelhardt
2007-07-18 14:32 ` Jan Engelhardt
2007-07-18 14:32 ` Jan Engelhardt
2007-07-18 15:36 ` Geert Uytterhoeven
2007-07-18 15:36 ` Geert Uytterhoeven
2007-07-18 23:36 ` Andrew Morton
2007-07-18 23:36 ` Andrew Morton
2007-07-19 5:33 ` Jens Axboe
2007-07-19 5:33 ` Jens Axboe
2007-07-19 7:15 ` Geert Uytterhoeven
2007-07-19 7:15 ` Geert Uytterhoeven
2007-07-19 7:15 ` Geert Uytterhoeven
2007-07-19 8:57 ` Geert Uytterhoeven
2007-07-19 8:57 ` Geert Uytterhoeven
2007-07-19 8:57 ` Geert Uytterhoeven
2007-07-19 9:10 ` Andrew Morton
2007-07-19 9:10 ` Andrew Morton
2007-07-19 13:52 ` [patch 0/4] PS3 storage driver updates (was: Re: [patch 1/3] ps3: Disk Storage Driver) Geert Uytterhoeven
2007-07-19 13:52 ` Geert Uytterhoeven
2007-07-19 13:53 ` [patch 1/4] ps3disk: use correct bio vector size Geert Uytterhoeven
2007-07-19 13:53 ` Geert Uytterhoeven
2007-07-19 13:54 ` [patch 2/4] ps3disk: updates after final review Geert Uytterhoeven
2007-07-19 13:54 ` Geert Uytterhoeven
2007-07-19 13:54 ` [patch 3/4] ps3rom: " Geert Uytterhoeven
2007-07-19 13:54 ` Geert Uytterhoeven
2007-07-19 13:55 ` [patch 4/4] ps3flash: " Geert Uytterhoeven
2007-07-19 13:55 ` Geert Uytterhoeven
2007-07-19 9:26 ` [patch 1/3] ps3: Disk Storage Driver Cornelia Huck
2007-07-19 9:26 ` Cornelia Huck
2007-07-19 9:36 ` Geert Uytterhoeven
2007-07-19 9:36 ` Geert Uytterhoeven
2007-07-19 12:00 ` Cornelia Huck
2007-07-19 12:00 ` Cornelia Huck
2007-07-19 12:13 ` Geert Uytterhoeven
2007-07-19 12:13 ` Geert Uytterhoeven
2007-07-19 12:52 ` Cornelia Huck
2007-07-19 12:52 ` Cornelia Huck
2007-07-24 11:44 ` Andy Whitcroft
2007-07-24 11:44 ` Andy Whitcroft
2007-07-24 12:37 ` Jeff Garzik
2007-07-24 12:37 ` Jeff Garzik
2007-07-24 12:52 ` Andreas Schwab
2007-07-24 12:52 ` Andreas Schwab
2007-07-24 12:52 ` Andreas Schwab
2007-07-24 13:44 ` Jeff Garzik
2007-07-24 13:44 ` Jeff Garzik
2007-07-24 16:43 ` Andrew Morton
2007-07-24 16:43 ` Andrew Morton
2007-07-24 16:43 ` Andrew Morton
2007-07-25 1:09 ` Paul Mackerras
2007-07-25 1:09 ` Paul Mackerras
2007-07-25 1:21 ` Andrew Morton
2007-07-25 1:21 ` Andrew Morton
2007-07-16 16:15 ` [patch 2/3] ps3: BD/DVD/CD-ROM " Geert Uytterhoeven
2007-07-16 16:15 ` Geert Uytterhoeven
2007-07-16 16:15 ` Geert Uytterhoeven
2007-07-18 23:43 ` Andrew Morton [this message]
2007-07-18 23:43 ` Andrew Morton
2007-07-19 9:02 ` Geert Uytterhoeven
2007-07-19 9:02 ` Geert Uytterhoeven
2007-07-19 9:02 ` Geert Uytterhoeven
2007-07-19 9:17 ` Andrew Morton
2007-07-19 9:17 ` Andrew Morton
2007-07-19 9:39 ` Geert Uytterhoeven
2007-07-19 9:39 ` Geert Uytterhoeven
2007-07-19 9:41 ` Jens Axboe
2007-07-19 9:41 ` Jens Axboe
2007-07-19 9:47 ` Andrew Morton
2007-07-19 9:47 ` Andrew Morton
2007-07-19 9:47 ` Andrew Morton
2007-07-19 17:56 ` Rene Herman
2007-07-19 17:56 ` Rene Herman
2007-07-16 16:15 ` [patch 3/3] ps3: FLASH ROM " Geert Uytterhoeven
2007-07-16 16:15 ` Geert Uytterhoeven
2007-07-16 16:15 ` Geert Uytterhoeven
2007-07-18 23:52 ` Andrew Morton
2007-07-18 23:52 ` Andrew Morton
2007-07-19 11:25 ` Geert Uytterhoeven
2007-07-19 11:25 ` Geert Uytterhoeven
2007-07-19 6:40 ` [patch 0/3] PS3 Storage Drivers for 2.6.23, take 5 Alessandro Rubini
2007-07-19 6:40 ` Alessandro Rubini
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=20070718164351.a92ec032.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=Geert.Uytterhoeven@sonycom.com \
--cc=James.Bottomley@SteelEye.com \
--cc=axboe@kernel.dk \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=linuxppc-dev@ozlabs.org \
--cc=paulus@samba.org \
--cc=rubini@vision.unipv.it \
/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.