From: Stephen Rothwell <sfr@canb.auug.org.au>
To: Andrew Morton <akpm@osdl.org>
Cc: torvalds@osdl.org, linux-kernel@vger.kernel.org,
boutcher@us.ibm.com, katzj@redhat.com, ipseries-list@redhat.com,
linuxppc64-dev@lists.linuxppc.org
Subject: [PATCH] 3/5 PPC64 - viodasd integration
Date: Tue, 29 Jun 2004 02:38:25 +1000 [thread overview]
Message-ID: <20040629023825.01a629de.sfr@canb.auug.org.au> (raw)
In-Reply-To: <20040629023509.295d70dc.sfr@canb.auug.org.au>
[-- Attachment #1: Type: text/plain, Size: 6054 bytes --]
[Just realised I forgot the signed-off-by stuff]
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-bk9.base.sysvio.2/arch/ppc64/kernel/vio.c 2.6.7-bk9.base.sysvio.3/arch/ppc64/kernel/vio.c
--- 2.6.7-bk9.base.sysvio.2/arch/ppc64/kernel/vio.c 2004-06-29 01:20:18.000000000 +1000
+++ 2.6.7-bk9.base.sysvio.3/arch/ppc64/kernel/vio.c 2004-06-29 01:31:21.000000000 +1000
@@ -233,6 +233,8 @@
/* veth is special and has it own iommu_table */
viodev->iommu_table = &veth_iommu_table;
}
+ for (i = 0; i < HVMAXARCHITECTEDVIRTUALDISKS; i++)
+ vio_register_device_iseries("viodasd", i);
}
#endif
diff -ruN 2.6.7-bk9.base.sysvio.2/drivers/block/viodasd.c 2.6.7-bk9.base.sysvio.3/drivers/block/viodasd.c
--- 2.6.7-bk9.base.sysvio.2/drivers/block/viodasd.c 2004-06-27 20:30:00.000000000 +1000
+++ 2.6.7-bk9.base.sysvio.3/drivers/block/viodasd.c 2004-06-27 20:33:23.000000000 +1000
@@ -68,7 +68,7 @@
enum {
PARTITION_SHIFT = 3,
- MAX_DISKNO = 32,
+ MAX_DISKNO = HVMAXARCHITECTEDVIRTUALDISKS,
MAX_DISK_NAME = sizeof(((struct gendisk *)0)->disk_name)
};
@@ -168,6 +168,7 @@
int read_only;
spinlock_t q_lock;
struct gendisk *disk;
+ struct device *dev;
} viodasd_devices[MAX_DISKNO];
/*
@@ -342,7 +343,7 @@
/* Now build the scatter-gather list */
nsg = blk_rq_map_sg(req->q, req, sg);
- nsg = dma_map_sg(iSeries_vio_dev, sg, nsg, direction);
+ nsg = dma_map_sg(d->dev, sg, nsg, direction);
spin_lock_irqsave(&viodasd_spinlock, flags);
num_req_outstanding++;
@@ -422,7 +423,7 @@
error_ret:
num_req_outstanding--;
spin_unlock_irqrestore(&viodasd_spinlock, flags);
- dma_unmap_sg(iSeries_vio_dev, sg, nsg, direction);
+ dma_unmap_sg(d->dev, sg, nsg, direction);
return -1;
}
@@ -557,6 +558,7 @@
g->fops = &viodasd_fops;
g->queue = q;
g->private_data = d;
+ g->driverfs_dev = d->dev;
set_capacity(g, d->size >> 9);
printk(VIOD_KERN_INFO "disk %d: %lu sectors (%lu MB) "
@@ -623,7 +625,7 @@
struct scatterlist sg[VIOMAXBLOCKDMA];
struct HvLpEvent *event = &bevent->event;
unsigned long irq_flags;
- int device_no;
+ struct viodasd_device *d;
int error;
spinlock_t *qlock;
@@ -633,7 +635,10 @@
pci_direction = DMA_FROM_DEVICE;
else
pci_direction = DMA_TO_DEVICE;
- dma_unmap_sg(iSeries_vio_dev, sg, num_sg, pci_direction);
+ req = (struct request *)bevent->event.xCorrelationToken;
+ d = req->rq_disk->private_data;
+
+ dma_unmap_sg(d->dev, sg, num_sg, pci_direction);
/*
* Since this is running in interrupt mode, we need to make sure
@@ -643,9 +648,6 @@
num_req_outstanding--;
spin_unlock_irqrestore(&viodasd_spinlock, irq_flags);
- req = (struct request *)bevent->event.xCorrelationToken;
- device_no = DEVICE_NO(req->rq_disk->private_data);
-
error = event->xRc != HvLpEvent_Rc_Good;
if (error) {
const struct vio_error_entry *err;
@@ -660,7 +662,7 @@
spin_unlock_irqrestore(qlock, irq_flags);
/* Finally, try to get more requests off of this device's queue */
- viodasd_restart_all_queues_starting_from(device_no);
+ viodasd_restart_all_queues_starting_from(DEVICE_NO(d));
return 0;
}
@@ -744,8 +746,47 @@
}
static DRIVER_ATTR(probe, S_IWUSR, NULL, probe_disks);
+static int viodasd_probe(struct vio_dev *vdev, const struct vio_device_id *id)
+{
+ struct viodasd_device *d = &viodasd_devices[vdev->unit_address];
+
+ d->dev = &vdev->dev;
+ probe_disk(d);
+ if (d->disk == NULL)
+ return -ENODEV;
+ return 0;
+}
+
+static int viodasd_remove(struct vio_dev *vdev)
+{
+ struct viodasd_device *d;
+
+ d = &viodasd_devices[vdev->unit_address];
+ if (d->disk) {
+ del_gendisk(d->disk);
+ put_disk(d->disk);
+ blk_cleanup_queue(d->disk->queue);
+ d->disk = NULL;
+ }
+ d->dev = NULL;
+ return 0;
+}
+
+/**
+ * viodasd_device_table: Used by vio.c to match devices that we
+ * support.
+ */
+static struct vio_device_id viodasd_device_table[] __devinitdata = {
+ { "viodasd", "" },
+ { 0, }
+};
+
+MODULE_DEVICE_TABLE(vio, viodasd_device_table);
static struct vio_driver viodasd_driver = {
- .name = "viodasd"
+ .name = "viodasd",
+ .id_table = viodasd_device_table,
+ .probe = viodasd_probe,
+ .remove = viodasd_remove
};
/*
@@ -754,7 +795,7 @@
*/
static int __init viodasd_init(void)
{
- int i;
+ int rc;
/* Try to open to our host lp */
if (viopath_hostLp == HvLpIndexInvalid)
@@ -788,33 +829,17 @@
/* Initialize our request handler */
vio_setHandler(viomajorsubtype_blockio, handle_block_event);
- for (i = 0; i < MAX_DISKNO; i++)
- probe_disk(&viodasd_devices[i]);
-
- vio_register_driver(&viodasd_driver); /* FIX ME - error checking */
- driver_create_file(&viodasd_driver.driver, &driver_attr_probe);
-
- return 0;
+ rc = vio_register_driver(&viodasd_driver);
+ if (rc == 0)
+ driver_create_file(&viodasd_driver.driver, &driver_attr_probe);
+ return rc;
}
module_init(viodasd_init);
void viodasd_exit(void)
{
- int i;
- struct viodasd_device *d;
-
driver_remove_file(&viodasd_driver.driver, &driver_attr_probe);
vio_unregister_driver(&viodasd_driver);
-
- for (i = 0; i < MAX_DISKNO; i++) {
- d = &viodasd_devices[i];
- if (d->disk) {
- del_gendisk(d->disk);
- put_disk(d->disk);
- blk_cleanup_queue(d->disk->queue);
- d->disk = NULL;
- }
- }
vio_clearHandler(viomajorsubtype_blockio);
unregister_blkdev(VIODASD_MAJOR, VIOD_GENHD_NAME);
viopath_close(viopath_hostLp, viomajorsubtype_blockio, VIOMAXREQ + 2);
diff -ruN 2.6.7-bk9.base.sysvio.2/include/asm-ppc64/iSeries/HvTypes.h 2.6.7-bk9.base.sysvio.3/include/asm-ppc64/iSeries/HvTypes.h
--- 2.6.7-bk9.base.sysvio.2/include/asm-ppc64/iSeries/HvTypes.h 2004-06-29 01:23:21.000000000 +1000
+++ 2.6.7-bk9.base.sysvio.3/include/asm-ppc64/iSeries/HvTypes.h 2004-06-29 01:39:53.000000000 +1000
@@ -66,6 +66,7 @@
#define HVMAXARCHITECTEDLPS 32
#define HVMAXARCHITECTEDVIRTUALLANS 16
+#define HVMAXARCHITECTEDVIRTUALDISKS 32
#define HVCHUNKSIZE 256 * 1024
#define HVPAGESIZE 4 * 1024
#define HVLPMINMEGSPRIMARY 256
[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
next prev parent reply other threads:[~2004-06-28 16:38 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-06-28 16:28 [PATCH] 0/5 PPC64 - make iSeries virtual devices/drivers appear in sysfs Stephen Rothwell
2004-06-28 16:33 ` [PATCH] 1/5 PPC64 - vio infrastructure modifications Stephen Rothwell
2004-06-28 16:35 ` [PATCH] 2/5 PPC64 - iseries_veth integration Stephen Rothwell
2004-06-28 16:38 ` Stephen Rothwell [this message]
2004-06-28 16:39 ` [PATCH] 4/5 PPC64 - viocd integration Stephen Rothwell
2004-06-28 16:41 ` [PATCH] 5/5 PPC64 - viotape integration Stephen Rothwell
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=20040629023825.01a629de.sfr@canb.auug.org.au \
--to=sfr@canb.auug.org.au \
--cc=akpm@osdl.org \
--cc=boutcher@us.ibm.com \
--cc=ipseries-list@redhat.com \
--cc=katzj@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc64-dev@lists.linuxppc.org \
--cc=torvalds@osdl.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®