Skip to content

Commit

Permalink
[SPARC64]: Abstract out mdesc accesses for better MD update handling.
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
David S. Miller committed Jul 16, 2007
1 parent 133f09a commit 43fdf27
Show file tree
Hide file tree
Showing 9 changed files with 553 additions and 474 deletions.
22 changes: 7 additions & 15 deletions arch/sparc64/kernel/ds.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <asm/ldc.h>
#include <asm/vio.h>
#include <asm/power.h>
#include <asm/mdesc.h>

#define DRV_MODULE_NAME "ds"
#define PFX DRV_MODULE_NAME ": "
Expand Down Expand Up @@ -170,8 +171,7 @@ static void md_update_data(struct ldc_channel *lp,

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

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

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

ds_send(lp, &pkt, sizeof(pkt));

mdesc_update();
}

struct ds_shutdown_req {
Expand Down Expand Up @@ -555,28 +557,18 @@ static int __devinit ds_probe(struct vio_dev *vdev,
const struct vio_device_id *id)
{
static int ds_version_printed;
struct mdesc_node *endp;
struct ldc_channel_config ds_cfg = {
.event = ds_event,
.mtu = 4096,
.mode = LDC_MODE_STREAM,
};
struct ldc_channel *lp;
struct ds_info *dp;
const u64 *chan_id;
int err;

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

endp = vio_find_endpoint(vdev);
if (!endp)
return -ENODEV;

chan_id = md_get_property(endp, "id", NULL);
if (!chan_id)
return -ENODEV;

dp = kzalloc(sizeof(*dp), GFP_KERNEL);
err = -ENOMEM;
if (!dp)
Expand All @@ -588,10 +580,10 @@ static int __devinit ds_probe(struct vio_dev *vdev,

dp->rcv_buf_len = 4096;

ds_cfg.tx_irq = endp->irqs[0];
ds_cfg.rx_irq = endp->irqs[1];
ds_cfg.tx_irq = vdev->tx_irq;
ds_cfg.rx_irq = vdev->rx_irq;

lp = ldc_alloc(*chan_id, &ds_cfg, dp);
lp = ldc_alloc(vdev->channel_id, &ds_cfg, dp);
if (IS_ERR(lp)) {
err = PTR_ERR(lp);
goto out_free_rcv_buf;
Expand Down
13 changes: 9 additions & 4 deletions arch/sparc64/kernel/ldc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2335,15 +2335,20 @@ EXPORT_SYMBOL(ldc_free_exp_dring);

static int __init ldc_init(void)
{
struct mdesc_node *mp;
unsigned long major, minor;
struct mdesc_handle *hp;
const u64 *v;
u64 mp;

mp = md_find_node_by_name(NULL, "platform");
if (!mp)
hp = mdesc_grab();
if (!hp)
return -ENODEV;

v = md_get_property(mp, "domaining-enabled", NULL);
mp = mdesc_node_by_name(hp, MDESC_NODE_NULL, "platform");
if (mp == MDESC_NODE_NULL)
return -ENODEV;

v = mdesc_get_property(hp, mp, "domaining-enabled", NULL);
if (!v)
return -ENODEV;

Expand Down
Loading

0 comments on commit 43fdf27

Please sign in to comment.