diff options
author | David S. Miller <davem@sunset.davemloft.net> | 2007-07-12 16:47:50 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-07-16 07:04:28 -0400 |
commit | 43fdf27470b216ebdef47e09ff83bed2f2894b13 (patch) | |
tree | 76b9b838089e5679471026037c93325c228df84a /drivers | |
parent | 133f09a169f3022be3de671b29658b7ecb375022 (diff) |
[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 8dbbeace52a1..0f5e3caf85d7 100644 --- a/drivers/block/sunvdc.c +++ b/drivers/block/sunvdc.c | |||
@@ -750,7 +750,7 @@ static struct vio_driver_ops vdc_vio_ops = { | |||
750 | static int __devinit vdc_port_probe(struct vio_dev *vdev, | 750 | static int __devinit vdc_port_probe(struct vio_dev *vdev, |
751 | const struct vio_device_id *id) | 751 | const struct vio_device_id *id) |
752 | { | 752 | { |
753 | struct mdesc_node *endp; | 753 | struct mdesc_handle *hp; |
754 | struct vdc_port *port; | 754 | struct vdc_port *port; |
755 | unsigned long flags; | 755 | unsigned long flags; |
756 | struct vdc *vp; | 756 | struct vdc *vp; |
@@ -763,26 +763,24 @@ static int __devinit vdc_port_probe(struct vio_dev *vdev, | |||
763 | return -ENODEV; | 763 | return -ENODEV; |
764 | } | 764 | } |
765 | 765 | ||
766 | endp = vio_find_endpoint(vdev); | 766 | hp = mdesc_grab(); |
767 | if (!endp) { | ||
768 | printk(KERN_ERR PFX "Port lacks channel-endpoint.\n"); | ||
769 | return -ENODEV; | ||
770 | } | ||
771 | 767 | ||
772 | port_id = md_get_property(vdev->mp, "id", NULL); | 768 | port_id = mdesc_get_property(hp, vdev->mp, "id", NULL); |
769 | err = -ENODEV; | ||
773 | if (!port_id) { | 770 | if (!port_id) { |
774 | printk(KERN_ERR PFX "Port lacks id property.\n"); | 771 | printk(KERN_ERR PFX "Port lacks id property.\n"); |
775 | return -ENODEV; | 772 | goto err_out_release_mdesc; |
776 | } | 773 | } |
777 | if ((*port_id << PARTITION_SHIFT) & ~(u64)MINORMASK) { | 774 | if ((*port_id << PARTITION_SHIFT) & ~(u64)MINORMASK) { |
778 | printk(KERN_ERR PFX "Port id [%lu] too large.\n", *port_id); | 775 | printk(KERN_ERR PFX "Port id [%lu] too large.\n", *port_id); |
779 | return -ENODEV; | 776 | goto err_out_release_mdesc; |
780 | } | 777 | } |
781 | 778 | ||
782 | port = kzalloc(sizeof(*port), GFP_KERNEL); | 779 | port = kzalloc(sizeof(*port), GFP_KERNEL); |
780 | err = -ENOMEM; | ||
783 | if (!port) { | 781 | if (!port) { |
784 | printk(KERN_ERR PFX "Cannot allocate vdc_port.\n"); | 782 | printk(KERN_ERR PFX "Cannot allocate vdc_port.\n"); |
785 | return -ENOMEM; | 783 | goto err_out_release_mdesc; |
786 | } | 784 | } |
787 | 785 | ||
788 | port->vp = vp; | 786 | port->vp = vp; |
@@ -797,7 +795,7 @@ static int __devinit vdc_port_probe(struct vio_dev *vdev, | |||
797 | snprintf(port->disk_name, sizeof(port->disk_name), | 795 | snprintf(port->disk_name, sizeof(port->disk_name), |
798 | VDCBLK_NAME "%c", 'a' + (port->dev_no % 26)); | 796 | VDCBLK_NAME "%c", 'a' + (port->dev_no % 26)); |
799 | 797 | ||
800 | err = vio_driver_init(&port->vio, vdev, VDEV_DISK, endp, | 798 | err = vio_driver_init(&port->vio, vdev, VDEV_DISK, |
801 | vdc_versions, ARRAY_SIZE(vdc_versions), | 799 | vdc_versions, ARRAY_SIZE(vdc_versions), |
802 | &vdc_vio_ops, port->disk_name); | 800 | &vdc_vio_ops, port->disk_name); |
803 | if (err) | 801 | if (err) |
@@ -828,6 +826,8 @@ static int __devinit vdc_port_probe(struct vio_dev *vdev, | |||
828 | 826 | ||
829 | dev_set_drvdata(&vdev->dev, port); | 827 | dev_set_drvdata(&vdev->dev, port); |
830 | 828 | ||
829 | mdesc_release(hp); | ||
830 | |||
831 | return 0; | 831 | return 0; |
832 | 832 | ||
833 | err_out_free_tx_ring: | 833 | err_out_free_tx_ring: |
@@ -839,6 +839,8 @@ err_out_free_ldc: | |||
839 | err_out_free_port: | 839 | err_out_free_port: |
840 | kfree(port); | 840 | kfree(port); |
841 | 841 | ||
842 | err_out_release_mdesc: | ||
843 | mdesc_release(hp); | ||
842 | return err; | 844 | return err; |
843 | } | 845 | } |
844 | 846 | ||
diff --git a/drivers/net/sunvnet.c b/drivers/net/sunvnet.c index d764e4ccba56..8a667c13faef 100644 --- a/drivers/net/sunvnet.c +++ b/drivers/net/sunvnet.c | |||
@@ -892,7 +892,7 @@ const char *remote_macaddr_prop = "remote-mac-address"; | |||
892 | static int __devinit vnet_port_probe(struct vio_dev *vdev, | 892 | static int __devinit vnet_port_probe(struct vio_dev *vdev, |
893 | const struct vio_device_id *id) | 893 | const struct vio_device_id *id) |
894 | { | 894 | { |
895 | struct mdesc_node *endp; | 895 | struct mdesc_handle *hp; |
896 | struct vnet_port *port; | 896 | struct vnet_port *port; |
897 | unsigned long flags; | 897 | unsigned long flags; |
898 | struct vnet *vp; | 898 | struct vnet *vp; |
@@ -905,23 +905,21 @@ static int __devinit vnet_port_probe(struct vio_dev *vdev, | |||
905 | return -ENODEV; | 905 | return -ENODEV; |
906 | } | 906 | } |
907 | 907 | ||
908 | rmac = md_get_property(vdev->mp, remote_macaddr_prop, &len); | 908 | hp = mdesc_grab(); |
909 | |||
910 | rmac = mdesc_get_property(hp, vdev->mp, remote_macaddr_prop, &len); | ||
911 | err = -ENODEV; | ||
909 | if (!rmac) { | 912 | if (!rmac) { |
910 | printk(KERN_ERR PFX "Port lacks %s property.\n", | 913 | printk(KERN_ERR PFX "Port lacks %s property.\n", |
911 | remote_macaddr_prop); | 914 | remote_macaddr_prop); |
912 | return -ENODEV; | 915 | goto err_out_put_mdesc; |
913 | } | ||
914 | |||
915 | endp = vio_find_endpoint(vdev); | ||
916 | if (!endp) { | ||
917 | printk(KERN_ERR PFX "Port lacks channel-endpoint.\n"); | ||
918 | return -ENODEV; | ||
919 | } | 916 | } |
920 | 917 | ||
921 | port = kzalloc(sizeof(*port), GFP_KERNEL); | 918 | port = kzalloc(sizeof(*port), GFP_KERNEL); |
919 | err = -ENOMEM; | ||
922 | if (!port) { | 920 | if (!port) { |
923 | printk(KERN_ERR PFX "Cannot allocate vnet_port.\n"); | 921 | printk(KERN_ERR PFX "Cannot allocate vnet_port.\n"); |
924 | return -ENOMEM; | 922 | goto err_out_put_mdesc; |
925 | } | 923 | } |
926 | 924 | ||
927 | for (i = 0; i < ETH_ALEN; i++) | 925 | for (i = 0; i < ETH_ALEN; i++) |
@@ -929,7 +927,7 @@ static int __devinit vnet_port_probe(struct vio_dev *vdev, | |||
929 | 927 | ||
930 | port->vp = vp; | 928 | port->vp = vp; |
931 | 929 | ||
932 | err = vio_driver_init(&port->vio, vdev, VDEV_NETWORK, endp, | 930 | err = vio_driver_init(&port->vio, vdev, VDEV_NETWORK, |
933 | vnet_versions, ARRAY_SIZE(vnet_versions), | 931 | vnet_versions, ARRAY_SIZE(vnet_versions), |
934 | &vnet_vio_ops, vp->dev->name); | 932 | &vnet_vio_ops, vp->dev->name); |
935 | if (err) | 933 | if (err) |
@@ -947,7 +945,7 @@ static int __devinit vnet_port_probe(struct vio_dev *vdev, | |||
947 | INIT_LIST_HEAD(&port->list); | 945 | INIT_LIST_HEAD(&port->list); |
948 | 946 | ||
949 | switch_port = 0; | 947 | switch_port = 0; |
950 | if (md_get_property(vdev->mp, "switch-port", NULL) != NULL) | 948 | if (mdesc_get_property(hp, vdev->mp, "switch-port", NULL) != NULL) |
951 | switch_port = 1; | 949 | switch_port = 1; |
952 | 950 | ||
953 | spin_lock_irqsave(&vp->lock, flags); | 951 | spin_lock_irqsave(&vp->lock, flags); |
@@ -969,6 +967,8 @@ static int __devinit vnet_port_probe(struct vio_dev *vdev, | |||
969 | 967 | ||
970 | vio_port_up(&port->vio); | 968 | vio_port_up(&port->vio); |
971 | 969 | ||
970 | mdesc_release(hp); | ||
971 | |||
972 | return 0; | 972 | return 0; |
973 | 973 | ||
974 | err_out_free_ldc: | 974 | err_out_free_ldc: |
@@ -977,6 +977,8 @@ err_out_free_ldc: | |||
977 | err_out_free_port: | 977 | err_out_free_port: |
978 | kfree(port); | 978 | kfree(port); |
979 | 979 | ||
980 | err_out_put_mdesc: | ||
981 | mdesc_release(hp); | ||
980 | return err; | 982 | return err; |
981 | } | 983 | } |
982 | 984 | ||
@@ -1029,6 +1031,7 @@ static int __devinit vnet_probe(struct vio_dev *vdev, | |||
1029 | const struct vio_device_id *id) | 1031 | const struct vio_device_id *id) |
1030 | { | 1032 | { |
1031 | static int vnet_version_printed; | 1033 | static int vnet_version_printed; |
1034 | struct mdesc_handle *hp; | ||
1032 | struct net_device *dev; | 1035 | struct net_device *dev; |
1033 | struct vnet *vp; | 1036 | struct vnet *vp; |
1034 | const u64 *mac; | 1037 | const u64 *mac; |
@@ -1037,7 +1040,9 @@ static int __devinit vnet_probe(struct vio_dev *vdev, | |||
1037 | if (vnet_version_printed++ == 0) | 1040 | if (vnet_version_printed++ == 0) |
1038 | printk(KERN_INFO "%s", version); | 1041 | printk(KERN_INFO "%s", version); |
1039 | 1042 | ||
1040 | mac = md_get_property(vdev->mp, local_mac_prop, &len); | 1043 | hp = mdesc_grab(); |
1044 | |||
1045 | mac = mdesc_get_property(hp, vdev->mp, local_mac_prop, &len); | ||
1041 | if (!mac) { | 1046 | if (!mac) { |
1042 | printk(KERN_ERR PFX "vnet lacks %s property.\n", | 1047 | printk(KERN_ERR PFX "vnet lacks %s property.\n", |
1043 | local_mac_prop); | 1048 | local_mac_prop); |
@@ -1093,12 +1098,15 @@ static int __devinit vnet_probe(struct vio_dev *vdev, | |||
1093 | 1098 | ||
1094 | dev_set_drvdata(&vdev->dev, vp); | 1099 | dev_set_drvdata(&vdev->dev, vp); |
1095 | 1100 | ||
1101 | mdesc_release(hp); | ||
1102 | |||
1096 | return 0; | 1103 | return 0; |
1097 | 1104 | ||
1098 | err_out_free_dev: | 1105 | err_out_free_dev: |
1099 | free_netdev(dev); | 1106 | free_netdev(dev); |
1100 | 1107 | ||
1101 | err_out: | 1108 | err_out: |
1109 | mdesc_release(hp); | ||
1102 | return err; | 1110 | return err; |
1103 | } | 1111 | } |
1104 | 1112 | ||