Commit 8251b4c4 authored by Stephen Rothwell's avatar Stephen Rothwell Committed by Paul Mackerras

[POWERPC] iSeries: Move viodasd probing

This way we only have entries in the device tree for disks that actually
exist.  A slight complication is that disks may be attached to LPARs
at runtime.
Signed-off-by: default avatarStephen Rothwell <sfr@canb.auug.org.au>
Acked-by: default avatarJens Axboe <jens.axboe@oracle.com>
Signed-off-by: default avatarPaul Mackerras <paulus@samba.org>
parent 7465ce0d
...@@ -72,7 +72,6 @@ static char __initdata device_type_cpu[] = "cpu"; ...@@ -72,7 +72,6 @@ static char __initdata device_type_cpu[] = "cpu";
static char __initdata device_type_memory[] = "memory"; static char __initdata device_type_memory[] = "memory";
static char __initdata device_type_serial[] = "serial"; static char __initdata device_type_serial[] = "serial";
static char __initdata device_type_network[] = "network"; static char __initdata device_type_network[] = "network";
static char __initdata device_type_block[] = "block";
static char __initdata device_type_pci[] = "pci"; static char __initdata device_type_pci[] = "pci";
static char __initdata device_type_vdevice[] = "vdevice"; static char __initdata device_type_vdevice[] = "vdevice";
static char __initdata device_type_vscsi[] = "vscsi"; static char __initdata device_type_vscsi[] = "vscsi";
...@@ -374,11 +373,6 @@ static void __init dt_vdevices(struct iseries_flat_dt *dt) ...@@ -374,11 +373,6 @@ static void __init dt_vdevices(struct iseries_flat_dt *dt)
dt_end_node(dt); dt_end_node(dt);
} }
reg += HVMAXARCHITECTEDVIRTUALLANS;
for (i = 0; i < HVMAXARCHITECTEDVIRTUALDISKS; i++)
dt_do_vdevice(dt, "viodasd", reg, i, device_type_block,
"IBM,iSeries-viodasd", 1);
dt_end_node(dt); dt_end_node(dt);
} }
......
This diff is collapsed.
...@@ -74,53 +74,9 @@ enum { ...@@ -74,53 +74,9 @@ enum {
static DEFINE_SPINLOCK(viodasd_spinlock); static DEFINE_SPINLOCK(viodasd_spinlock);
#define VIOMAXREQ 16 #define VIOMAXREQ 16
#define VIOMAXBLOCKDMA 12
#define DEVICE_NO(cell) ((struct viodasd_device *)(cell) - &viodasd_devices[0]) #define DEVICE_NO(cell) ((struct viodasd_device *)(cell) - &viodasd_devices[0])
struct open_data {
u64 disk_size;
u16 max_disk;
u16 cylinders;
u16 tracks;
u16 sectors;
u16 bytes_per_sector;
};
struct rw_data {
u64 offset;
struct {
u32 token;
u32 reserved;
u64 len;
} dma_info[VIOMAXBLOCKDMA];
};
struct vioblocklpevent {
struct HvLpEvent event;
u32 reserved;
u16 version;
u16 sub_result;
u16 disk;
u16 flags;
union {
struct open_data open_data;
struct rw_data rw_data;
u64 changed;
} u;
};
#define vioblockflags_ro 0x0001
enum vioblocksubtype {
vioblockopen = 0x0001,
vioblockclose = 0x0002,
vioblockread = 0x0003,
vioblockwrite = 0x0004,
vioblockflush = 0x0005,
vioblockcheck = 0x0007
};
struct viodasd_waitevent { struct viodasd_waitevent {
struct completion com; struct completion com;
int rc; int rc;
...@@ -429,7 +385,7 @@ static void do_viodasd_request(struct request_queue *q) ...@@ -429,7 +385,7 @@ static void do_viodasd_request(struct request_queue *q)
* Probe a single disk and fill in the viodasd_device structure * Probe a single disk and fill in the viodasd_device structure
* for it. * for it.
*/ */
static void probe_disk(struct viodasd_device *d) static int probe_disk(struct viodasd_device *d)
{ {
HvLpEvent_Rc hvrc; HvLpEvent_Rc hvrc;
struct viodasd_waitevent we; struct viodasd_waitevent we;
...@@ -453,14 +409,14 @@ retry: ...@@ -453,14 +409,14 @@ retry:
0, 0, 0); 0, 0, 0);
if (hvrc != 0) { if (hvrc != 0) {
printk(VIOD_KERN_WARNING "bad rc on HV open %d\n", (int)hvrc); printk(VIOD_KERN_WARNING "bad rc on HV open %d\n", (int)hvrc);
return; return 0;
} }
wait_for_completion(&we.com); wait_for_completion(&we.com);
if (we.rc != 0) { if (we.rc != 0) {
if (flags != 0) if (flags != 0)
return; return 0;
/* try again with read only flag set */ /* try again with read only flag set */
flags = vioblockflags_ro; flags = vioblockflags_ro;
goto retry; goto retry;
...@@ -490,15 +446,32 @@ retry: ...@@ -490,15 +446,32 @@ retry:
if (hvrc != 0) { if (hvrc != 0) {
printk(VIOD_KERN_WARNING printk(VIOD_KERN_WARNING
"bad rc sending event to OS/400 %d\n", (int)hvrc); "bad rc sending event to OS/400 %d\n", (int)hvrc);
return; return 0;
} }
if (d->dev == NULL) {
/* this is when we reprobe for new disks */
if (vio_create_viodasd(dev_no) == NULL) {
printk(VIOD_KERN_WARNING
"cannot allocate virtual device for disk %d\n",
dev_no);
return 0;
}
/*
* The vio_create_viodasd will have recursed into this
* routine with d->dev set to the new vio device and
* will finish the setup of the disk below.
*/
return 1;
}
/* create the request queue for the disk */ /* create the request queue for the disk */
spin_lock_init(&d->q_lock); spin_lock_init(&d->q_lock);
q = blk_init_queue(do_viodasd_request, &d->q_lock); q = blk_init_queue(do_viodasd_request, &d->q_lock);
if (q == NULL) { if (q == NULL) {
printk(VIOD_KERN_WARNING "cannot allocate queue for disk %d\n", printk(VIOD_KERN_WARNING "cannot allocate queue for disk %d\n",
dev_no); dev_no);
return; return 0;
} }
g = alloc_disk(1 << PARTITION_SHIFT); g = alloc_disk(1 << PARTITION_SHIFT);
if (g == NULL) { if (g == NULL) {
...@@ -506,7 +479,7 @@ retry: ...@@ -506,7 +479,7 @@ retry:
"cannot allocate disk structure for disk %d\n", "cannot allocate disk structure for disk %d\n",
dev_no); dev_no);
blk_cleanup_queue(q); blk_cleanup_queue(q);
return; return 0;
} }
d->disk = g; d->disk = g;
...@@ -538,6 +511,7 @@ retry: ...@@ -538,6 +511,7 @@ retry:
/* register us in the global list */ /* register us in the global list */
add_disk(g); add_disk(g);
return 1;
} }
/* returns the total number of scatterlist elements converted */ /* returns the total number of scatterlist elements converted */
...@@ -718,8 +692,7 @@ static int viodasd_probe(struct vio_dev *vdev, const struct vio_device_id *id) ...@@ -718,8 +692,7 @@ static int viodasd_probe(struct vio_dev *vdev, const struct vio_device_id *id)
struct viodasd_device *d = &viodasd_devices[vdev->unit_address]; struct viodasd_device *d = &viodasd_devices[vdev->unit_address];
d->dev = &vdev->dev; d->dev = &vdev->dev;
probe_disk(d); if (!probe_disk(d))
if (d->disk == NULL)
return -ENODEV; return -ENODEV;
return 0; return 0;
} }
......
...@@ -51,6 +51,51 @@ ...@@ -51,6 +51,51 @@
*/ */
#define VIO_MAX_SUBTYPES 8 #define VIO_MAX_SUBTYPES 8
#define VIOMAXBLOCKDMA 12
struct open_data {
u64 disk_size;
u16 max_disk;
u16 cylinders;
u16 tracks;
u16 sectors;
u16 bytes_per_sector;
};
struct rw_data {
u64 offset;
struct {
u32 token;
u32 reserved;
u64 len;
} dma_info[VIOMAXBLOCKDMA];
};
struct vioblocklpevent {
struct HvLpEvent event;
u32 reserved;
u16 version;
u16 sub_result;
u16 disk;
u16 flags;
union {
struct open_data open_data;
struct rw_data rw_data;
u64 changed;
} u;
};
#define vioblockflags_ro 0x0001
enum vioblocksubtype {
vioblockopen = 0x0001,
vioblockclose = 0x0002,
vioblockread = 0x0003,
vioblockwrite = 0x0004,
vioblockflush = 0x0005,
vioblockcheck = 0x0007
};
struct viocdlpevent { struct viocdlpevent {
struct HvLpEvent event; struct HvLpEvent event;
u32 reserved; u32 reserved;
...@@ -133,6 +178,8 @@ extern void vio_set_hostlp(void); ...@@ -133,6 +178,8 @@ extern void vio_set_hostlp(void);
extern void *vio_get_event_buffer(int subtype); extern void *vio_get_event_buffer(int subtype);
extern void vio_free_event_buffer(int subtype, void *buffer); extern void vio_free_event_buffer(int subtype, void *buffer);
extern struct vio_dev *vio_create_viodasd(u32 unit);
extern HvLpIndex viopath_hostLp; extern HvLpIndex viopath_hostLp;
extern HvLpIndex viopath_ourLp; extern HvLpIndex viopath_ourLp;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment