Skip to content

Commit 91ba3c2

Browse files
author
David S. Miller
committed
[SPARC64]: Fix handling of multiple vdc-port nodes.
The "id" property in vdc-port nodes are not unique, they are all zero. Therefore assign ID's using the parent's "cfg-handle" property which will be unique. Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 48db7b7 commit 91ba3c2

4 files changed

Lines changed: 88 additions & 23 deletions

File tree

‎arch/sparc64/kernel/mdesc.c‎

Lines changed: 52 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,25 @@ void mdesc_register_notifier(struct mdesc_notifier_client *client)
231231
mutex_unlock(&mdesc_mutex);
232232
}
233233

234+
static const u64 *parent_cfg_handle(struct mdesc_handle *hp, u64 node)
235+
{
236+
const u64 *id;
237+
u64 a;
238+
239+
id = NULL;
240+
mdesc_for_each_arc(a, hp, node, MDESC_ARC_TYPE_BACK) {
241+
u64 target;
242+
243+
target = mdesc_arc_target(hp, a);
244+
id = mdesc_get_property(hp, target,
245+
"cfg-handle", NULL);
246+
if (id)
247+
break;
248+
}
249+
250+
return id;
251+
}
252+
234253
/* Run 'func' on nodes which are in A but not in B. */
235254
static void invoke_on_missing(const char *name,
236255
struct mdesc_handle *a,
@@ -240,13 +259,42 @@ static void invoke_on_missing(const char *name,
240259
u64 node;
241260

242261
mdesc_for_each_node_by_name(a, node, name) {
243-
const u64 *id = mdesc_get_property(a, node, "id", NULL);
244-
int found = 0;
262+
int found = 0, is_vdc_port = 0;
263+
const char *name_prop;
264+
const u64 *id;
245265
u64 fnode;
246266

267+
name_prop = mdesc_get_property(a, node, "name", NULL);
268+
if (name_prop && !strcmp(name_prop, "vdc-port")) {
269+
is_vdc_port = 1;
270+
id = parent_cfg_handle(a, node);
271+
} else
272+
id = mdesc_get_property(a, node, "id", NULL);
273+
274+
if (!id) {
275+
printk(KERN_ERR "MD: Cannot find ID for %s node.\n",
276+
(name_prop ? name_prop : name));
277+
continue;
278+
}
279+
247280
mdesc_for_each_node_by_name(b, fnode, name) {
248-
const u64 *fid = mdesc_get_property(b, fnode,
249-
"id", NULL);
281+
const u64 *fid;
282+
283+
if (is_vdc_port) {
284+
name_prop = mdesc_get_property(b, fnode,
285+
"name", NULL);
286+
if (!name_prop ||
287+
strcmp(name_prop, "vdc-port"))
288+
continue;
289+
fid = parent_cfg_handle(b, fnode);
290+
if (!fid) {
291+
printk(KERN_ERR "MD: Cannot find ID "
292+
"for vdc-port node.\n");
293+
continue;
294+
}
295+
} else
296+
fid = mdesc_get_property(b, fnode,
297+
"id", NULL);
250298

251299
if (*id == *fid) {
252300
found = 1;

‎arch/sparc64/kernel/vio.c‎

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,27 @@ static struct vio_dev *vio_create_one(struct mdesc_handle *hp, u64 mp,
221221
return NULL;
222222
}
223223

224+
if (!strcmp(type, "vdc-port")) {
225+
u64 a;
226+
227+
id = NULL;
228+
mdesc_for_each_arc(a, hp, mp, MDESC_ARC_TYPE_BACK) {
229+
u64 target;
230+
231+
target = mdesc_arc_target(hp, a);
232+
id = mdesc_get_property(hp, target,
233+
"cfg-handle", NULL);
234+
if (id)
235+
break;
236+
}
237+
if (!id) {
238+
printk(KERN_ERR "VIO: vdc-prot lacks parent "
239+
"cfg-handle.\n");
240+
return NULL;
241+
}
242+
} else
243+
id = mdesc_get_property(hp, mp, "id", NULL);
244+
224245
bus_id_name = type;
225246
if (!strcmp(type, "domain-services-port"))
226247
bus_id_name = "ds";
@@ -260,13 +281,15 @@ static struct vio_dev *vio_create_one(struct mdesc_handle *hp, u64 mp,
260281

261282
vio_fill_channel_info(hp, mp, vdev);
262283

263-
id = mdesc_get_property(hp, mp, "id", NULL);
264-
if (!id)
284+
if (!id) {
265285
snprintf(vdev->dev.bus_id, BUS_ID_SIZE, "%s",
266286
bus_id_name);
267-
else
287+
vdev->dev_no = ~(u64)0;
288+
} else {
268289
snprintf(vdev->dev.bus_id, BUS_ID_SIZE, "%s-%lu",
269290
bus_id_name, *id);
291+
vdev->dev_no = *id;
292+
}
270293

271294
vdev->dev.parent = parent;
272295
vdev->dev.bus = &vio_bus_type;

‎drivers/block/sunvdc.c‎

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ struct vdc_port {
6464
u64 operations;
6565
u32 vdisk_size;
6666
u8 vdisk_type;
67-
u8 dev_no;
6867

6968
char disk_name[32];
7069

@@ -703,7 +702,7 @@ static int probe_disk(struct vdc_port *port)
703702
blk_queue_max_phys_segments(q, port->ring_cookies);
704703
blk_queue_max_sectors(q, port->max_xfer_size);
705704
g->major = vdc_major;
706-
g->first_minor = port->dev_no << PARTITION_SHIFT;
705+
g->first_minor = port->vio.vdev->dev_no << PARTITION_SHIFT;
707706
strcpy(g->disk_name, port->disk_name);
708707

709708
g->fops = &vdc_fops;
@@ -747,21 +746,16 @@ static int __devinit vdc_port_probe(struct vio_dev *vdev,
747746
{
748747
struct mdesc_handle *hp;
749748
struct vdc_port *port;
750-
const u64 *port_id;
751749
int err;
752750

753751
print_version();
754752

755753
hp = mdesc_grab();
756754

757-
port_id = mdesc_get_property(hp, vdev->mp, "id", NULL);
758755
err = -ENODEV;
759-
if (!port_id) {
760-
printk(KERN_ERR PFX "Port lacks id property.\n");
761-
goto err_out_release_mdesc;
762-
}
763-
if ((*port_id << PARTITION_SHIFT) & ~(u64)MINORMASK) {
764-
printk(KERN_ERR PFX "Port id [%lu] too large.\n", *port_id);
756+
if ((vdev->dev_no << PARTITION_SHIFT) & ~(u64)MINORMASK) {
757+
printk(KERN_ERR PFX "Port id [%lu] too large.\n",
758+
vdev->dev_no);
765759
goto err_out_release_mdesc;
766760
}
767761

@@ -772,16 +766,14 @@ static int __devinit vdc_port_probe(struct vio_dev *vdev,
772766
goto err_out_release_mdesc;
773767
}
774768

775-
port->dev_no = *port_id;
776-
777-
if (port->dev_no >= 26)
769+
if (vdev->dev_no >= 26)
778770
snprintf(port->disk_name, sizeof(port->disk_name),
779771
VDCBLK_NAME "%c%c",
780-
'a' + (port->dev_no / 26) - 1,
781-
'a' + (port->dev_no % 26));
772+
'a' + ((int)vdev->dev_no / 26) - 1,
773+
'a' + ((int)vdev->dev_no % 26));
782774
else
783775
snprintf(port->disk_name, sizeof(port->disk_name),
784-
VDCBLK_NAME "%c", 'a' + (port->dev_no % 26));
776+
VDCBLK_NAME "%c", 'a' + ((int)vdev->dev_no % 26));
785777

786778
err = vio_driver_init(&port->vio, vdev, VDEV_DISK,
787779
vdc_versions, ARRAY_SIZE(vdc_versions),

‎include/asm-sparc64/vio.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,8 @@ struct vio_dev {
275275
char compat[VIO_MAX_COMPAT_LEN];
276276
int compat_len;
277277

278+
u64 dev_no;
279+
278280
unsigned long channel_id;
279281

280282
unsigned int tx_irq;

0 commit comments

Comments
 (0)