Skip to content

Commit 43fdf27

Browse files
author
David S. Miller
committed
[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>
1 parent 133f09a commit 43fdf27

9 files changed

Lines changed: 553 additions & 474 deletions

File tree

‎arch/sparc64/kernel/ds.c‎

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <asm/ldc.h>
1616
#include <asm/vio.h>
1717
#include <asm/power.h>
18+
#include <asm/mdesc.h>
1819

1920
#define DRV_MODULE_NAME "ds"
2021
#define PFX DRV_MODULE_NAME ": "
@@ -170,8 +171,7 @@ static void md_update_data(struct ldc_channel *lp,
170171

171172
rp = (struct ds_md_update_req *) (dpkt + 1);
172173

173-
printk(KERN_ERR PFX "MD update REQ [%lx] len=%d\n",
174-
rp->req_num, len);
174+
printk(KERN_ERR PFX "Machine description update.\n");
175175

176176
memset(&pkt, 0, sizeof(pkt));
177177
pkt.data.tag.type = DS_DATA;
@@ -181,6 +181,8 @@ static void md_update_data(struct ldc_channel *lp,
181181
pkt.res.result = DS_OK;
182182

183183
ds_send(lp, &pkt, sizeof(pkt));
184+
185+
mdesc_update();
184186
}
185187

186188
struct ds_shutdown_req {
@@ -555,28 +557,18 @@ static int __devinit ds_probe(struct vio_dev *vdev,
555557
const struct vio_device_id *id)
556558
{
557559
static int ds_version_printed;
558-
struct mdesc_node *endp;
559560
struct ldc_channel_config ds_cfg = {
560561
.event = ds_event,
561562
.mtu = 4096,
562563
.mode = LDC_MODE_STREAM,
563564
};
564565
struct ldc_channel *lp;
565566
struct ds_info *dp;
566-
const u64 *chan_id;
567567
int err;
568568

569569
if (ds_version_printed++ == 0)
570570
printk(KERN_INFO "%s", version);
571571

572-
endp = vio_find_endpoint(vdev);
573-
if (!endp)
574-
return -ENODEV;
575-
576-
chan_id = md_get_property(endp, "id", NULL);
577-
if (!chan_id)
578-
return -ENODEV;
579-
580572
dp = kzalloc(sizeof(*dp), GFP_KERNEL);
581573
err = -ENOMEM;
582574
if (!dp)
@@ -588,10 +580,10 @@ static int __devinit ds_probe(struct vio_dev *vdev,
588580

589581
dp->rcv_buf_len = 4096;
590582

591-
ds_cfg.tx_irq = endp->irqs[0];
592-
ds_cfg.rx_irq = endp->irqs[1];
583+
ds_cfg.tx_irq = vdev->tx_irq;
584+
ds_cfg.rx_irq = vdev->rx_irq;
593585

594-
lp = ldc_alloc(*chan_id, &ds_cfg, dp);
586+
lp = ldc_alloc(vdev->channel_id, &ds_cfg, dp);
595587
if (IS_ERR(lp)) {
596588
err = PTR_ERR(lp);
597589
goto out_free_rcv_buf;

‎arch/sparc64/kernel/ldc.c‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2335,15 +2335,20 @@ EXPORT_SYMBOL(ldc_free_exp_dring);
23352335

23362336
static int __init ldc_init(void)
23372337
{
2338-
struct mdesc_node *mp;
23392338
unsigned long major, minor;
2339+
struct mdesc_handle *hp;
23402340
const u64 *v;
2341+
u64 mp;
23412342

2342-
mp = md_find_node_by_name(NULL, "platform");
2343-
if (!mp)
2343+
hp = mdesc_grab();
2344+
if (!hp)
23442345
return -ENODEV;
23452346

2346-
v = md_get_property(mp, "domaining-enabled", NULL);
2347+
mp = mdesc_node_by_name(hp, MDESC_NODE_NULL, "platform");
2348+
if (mp == MDESC_NODE_NULL)
2349+
return -ENODEV;
2350+
2351+
v = mdesc_get_property(hp, mp, "domaining-enabled", NULL);
23472352
if (!v)
23482353
return -ENODEV;
23492354

0 commit comments

Comments
 (0)