static struct mic_device_desc *get_device_desc(struct mic_info *mic, int type) { struct mic_device_desc *d; int i; void *dp = get_dp(mic, type); for (i = sizeof(struct mic_bootparam); i < PAGE_SIZE; i += mic_total_desc_size(d)) { d = dp + i; /* End of list */ if (d->type == 0) break; if (d->type == -1) continue; mpsslog("%s %s d-> type %d d %p\n", mic->name, __func__, d->type, d); if (d->type == (__u8)type) return d; } mpsslog("%s %s %d not found\n", mic->name, __func__, type); assert(0); return NULL; }
static void mic_scan_devices(struct mic_driver *mdrv, bool remove) { s8 type; unsigned int i; struct mic_device_desc __iomem *d; struct mic_device_ctrl __iomem *dc; struct device *dev; int ret; for (i = sizeof(struct mic_bootparam); i < MIC_DP_SIZE; i += mic_total_desc_size(d)) { d = mdrv->dp + i; dc = (void __iomem *)d + mic_aligned_desc_size(d); /* * This read barrier is paired with the corresponding write * barrier on the host which is inserted before adding or * removing a virtio device descriptor, by updating the type. */ rmb(); type = ioread8(&d->type); /* end of list */ if (type == 0) break; if (type == -1) continue; /* device already exists */ dev = device_find_child(mdrv->dev, (void __force *)d, mic_match_desc); if (dev) { if (remove) iowrite8(MIC_VIRTIO_PARAM_DEV_REMOVE, &dc->config_change); put_device(dev); mic_handle_config_change(d, i, mdrv); ret = mic_remove_device(d, i, mdrv); if (!ret && !remove) iowrite8(-1, &d->type); if (remove) { iowrite8(0, &dc->config_change); iowrite8(0, &dc->guest_ack); } continue; } /* new device */ dev_dbg(mdrv->dev, "%s %d Adding new virtio device %p\n", __func__, __LINE__, d); if (!remove) mic_add_device(d, i, mdrv); } }