diff options
author | David S. Miller <davem@sunset.davemloft.net> | 2007-07-12 20:47:50 (GMT) |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-07-16 11:04:28 (GMT) |
commit | 43fdf27470b216ebdef47e09ff83bed2f2894b13 (patch) | |
tree | 76b9b838089e5679471026037c93325c228df84a /drivers | |
parent | 133f09a169f3022be3de671b29658b7ecb375022 (diff) | |
download | linux-43fdf27470b216ebdef47e09ff83bed2f2894b13.tar.xz |
[SPARC64]: Abstract out mdesc accesses for better MD update handling.
Since we have to be able to handle MD updates, having an in-tree
set of data structures representing the MD objects actually makes
things more painful.
The MD itself is easy to parse, and we can implement the existing
interfaces using direct parsing of the MD binary image.
The MD is now reference counted, so accesses have to now take the
form:
handle = mdesc_grab();
... operations on MD ...
mdesc_release(handle);
The only remaining issue are cases where code holds on to references
to MD property values. mdesc_get_property() returns a direct pointer
to the property value, most cases just pull in the information they
need and discard the pointer, but there are few that use the pointer
directly over a long lifetime. Those will be fixed up in a subsequent
changeset.
A preliminary handler for MD update events from domain services is
there, it is rudimentry but it works and handles all of the reference
counting. It does not check the generation number of the MDs,
and it does not generate a "add/delete" list for notification to
interesting parties about MD changes but that will be forthcoming.
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/block/sunvdc.c | 24 | ||||
-rw-r--r-- | drivers/net/sunvnet.c | 34 |
2 files changed, 34 insertions, 24 deletions
diff --git a/drivers/block/sunvdc.c b/drivers/block/sunvdc.c index 8dbbeac..0f5e3ca 100644 --- a/drivers/block/sunvdc.c +++ b/drivers/block/sunvdc.c @@ -750,7 +750,7 @@ static struct vio_driver_ops vdc_vio_ops = { static int __devinit vdc_port_probe(struct vio_dev *vdev, const struct vio_device_id *id) { - struct mdesc_node *endp; + struct mdesc_handle *hp; struct vdc_port *port; unsigned long flags; struct vdc *vp; @@ -763,26 +763,24 @@ static int __devinit vdc_port_probe(struct vio_dev *vdev, return -ENODEV; } - endp = vio_find_endpoint(vdev); - if (!endp) { - printk(KERN_ERR PFX "Port lacks channel-endpoint.\n"); - return -ENODEV; - } + hp = mdesc_grab(); - port_id = md_get_property(vdev->mp, "id", NULL); + port_id = mdesc_get_property(hp, vdev->mp, "id", NULL); + err = -ENODEV; if (!port_id) { printk(KERN_ERR PFX "Port lacks id property.\n"); - return -ENODEV; + goto err_out_release_mdesc; } if ((*port_id << PARTITION_SHIFT) & ~(u64)MINORMASK) { printk(KERN_ERR PFX "Port id [%lu] too large.\n", *port_id); - return -ENODEV; + goto err_out_release_mdesc; } port = kzalloc(sizeof(*port), GFP_KERNEL); + err = -ENOMEM; if (!port) { printk(KERN_ERR PFX "Cannot allocate vdc_port.\n"); - return -ENOMEM; + goto err_out_release_mdesc; } port->vp = vp; @@ -797,7 +795,7 @@ static int __devinit vdc_port_probe(struct vio_dev *vdev, snprintf(port->disk_name, sizeof(port->disk_name), VDCBLK_NAME "%c", 'a' + (port->dev_no % 26)); - err = vio_driver_init(&port->vio, vdev, VDEV_DISK, endp, + err = vio_driver_init(&port->vio, vdev, VDEV_DISK, vdc_versions, ARRAY_SIZE(vdc_versions), &vdc_vio_ops, port->disk_name); if (err) @@ -828,6 +826,8 @@ static int __devinit vdc_port_probe(struct vio_dev *vdev, dev_set_drvdata(&vdev->dev, port); + mdesc_release(hp); + return 0; err_out_free_tx_ring: @@ -839,6 +839,8 @@ err_out_free_ldc: err_out_free_port: kfree(port); +err_out_release_mdesc: + mdesc_release(hp); return err; } diff --git a/drivers/net/sunvnet.c b/drivers/net/sunvnet.c index d764e4c..8a667c1 100644 --- a/drivers/net/sunvnet.c +++ b/drivers/net/sunvnet.c @@ -892,7 +892,7 @@ const char *remote_macaddr_prop = "remote-mac-address"; static int __devinit vnet_port_probe(struct vio_dev *vdev, const struct vio_device_id *id) { - struct mdesc_node *endp; + struct mdesc_handle *hp; struct vnet_port *port; unsigned long flags; struct vnet *vp; @@ -905,23 +905,21 @@ static int __devinit vnet_port_probe(struct vio_dev *vdev, return -ENODEV; } - rmac = md_get_property(vdev->mp, remote_macaddr_prop, &len); + hp = mdesc_grab(); + + rmac = mdesc_get_property(hp, vdev->mp, remote_macaddr_prop, &len); + err = -ENODEV; if (!rmac) { printk(KERN_ERR PFX "Port lacks %s property.\n", remote_macaddr_prop); - return -ENODEV; - } - - endp = vio_find_endpoint(vdev); - if (!endp) { - printk(KERN_ERR PFX "Port lacks channel-endpoint.\n"); - return -ENODEV; + goto err_out_put_mdesc; } port = kzalloc(sizeof(*port), GFP_KERNEL); + err = -ENOMEM; if (!port) { printk(KERN_ERR PFX "Cannot allocate vnet_port.\n"); - return -ENOMEM; + goto err_out_put_mdesc; } for (i = 0; i < ETH_ALEN; i++) @@ -929,7 +927,7 @@ static int __devinit vnet_port_probe(struct vio_dev *vdev, port->vp = vp; - err = vio_driver_init(&port->vio, vdev, VDEV_NETWORK, endp, + err = vio_driver_init(&port->vio, vdev, VDEV_NETWORK, vnet_versions, ARRAY_SIZE(vnet_versions), &vnet_vio_ops, vp->dev->name); if (err) @@ -947,7 +945,7 @@ static int __devinit vnet_port_probe(struct vio_dev *vdev, INIT_LIST_HEAD(&port->list); switch_port = 0; - if (md_get_property(vdev->mp, "switch-port", NULL) != NULL) + if (mdesc_get_property(hp, vdev->mp, "switch-port", NULL) != NULL) switch_port = 1; spin_lock_irqsave(&vp->lock, flags); @@ -969,6 +967,8 @@ static int __devinit vnet_port_probe(struct vio_dev *vdev, vio_port_up(&port->vio); + mdesc_release(hp); + return 0; err_out_free_ldc: @@ -977,6 +977,8 @@ err_out_free_ldc: err_out_free_port: kfree(port); +err_out_put_mdesc: + mdesc_release(hp); return err; } @@ -1029,6 +1031,7 @@ static int __devinit vnet_probe(struct vio_dev *vdev, const struct vio_device_id *id) { static int vnet_version_printed; + struct mdesc_handle *hp; struct net_device *dev; struct vnet *vp; const u64 *mac; @@ -1037,7 +1040,9 @@ static int __devinit vnet_probe(struct vio_dev *vdev, if (vnet_version_printed++ == 0) printk(KERN_INFO "%s", version); - mac = md_get_property(vdev->mp, local_mac_prop, &len); + hp = mdesc_grab(); + + mac = mdesc_get_property(hp, vdev->mp, local_mac_prop, &len); if (!mac) { printk(KERN_ERR PFX "vnet lacks %s property.\n", local_mac_prop); @@ -1093,12 +1098,15 @@ static int __devinit vnet_probe(struct vio_dev *vdev, dev_set_drvdata(&vdev->dev, vp); + mdesc_release(hp); + return 0; err_out_free_dev: free_netdev(dev); err_out: + mdesc_release(hp); return err; } |