if (unlikely(channel->state != EVTCHNL_STATE_CONNECTED)) return IRQ_HANDLED;
mutex_lock(&channel->ring_io_lock);
again:
rp = channel->u.req.ring.sring->rsp_prod; /* Ensure we see queued responses up to rp. */
rmb();
/* * Assume that the backend is trusted to always write sane values * to the ring counters, so no overflow checks on frontend side * are required.
*/ for (i = channel->u.req.ring.rsp_cons; i != rp; i++) {
resp = RING_GET_RESPONSE(&channel->u.req.ring, i); if (resp->id != channel->evt_id) continue; switch (resp->operation) { case XENSND_OP_OPEN: case XENSND_OP_CLOSE: case XENSND_OP_READ: case XENSND_OP_WRITE: case XENSND_OP_TRIGGER:
channel->u.req.resp_status = resp->status;
complete(&channel->u.req.completion); break; case XENSND_OP_HW_PARAM_QUERY:
channel->u.req.resp_status = resp->status;
channel->u.req.resp.hw_param =
resp->resp.hw_param;
complete(&channel->u.req.completion); break;
default:
dev_err(&front_info->xb_dev->dev, "Operation %d is not supported\n",
resp->operation); break;
}
}
channel->u.req.ring.rsp_cons = i; if (i != channel->u.req.ring.req_prod_pvt) { int more_to_do;
RING_FINAL_CHECK_FOR_RESPONSES(&channel->u.req.ring,
more_to_do); if (more_to_do) goto again;
} else {
channel->u.req.ring.sring->rsp_event = i + 1;
}
if (unlikely(channel->state != EVTCHNL_STATE_CONNECTED)) return IRQ_HANDLED;
mutex_lock(&channel->ring_io_lock);
prod = page->in_prod; /* Ensure we see ring contents up to prod. */
virt_rmb(); if (prod == page->in_cons) goto out;
/* * Assume that the backend is trusted to always write sane values * to the ring counters, so no overflow checks on frontend side * are required.
*/ for (cons = page->in_cons; cons != prod; cons++) { struct xensnd_evt *event;
event = &XENSND_IN_RING_REF(page, cons); if (unlikely(event->id != channel->evt_id++)) continue;
switch (event->type) { case XENSND_EVT_CUR_POS:
xen_snd_front_alsa_handle_cur_pos(channel,
event->op.cur_pos.position); break;
}
}
page->in_cons = cons; /* Ensure ring contents. */
virt_wmb();
channel->state = EVTCHNL_STATE_DISCONNECTED; if (channel->type == EVTCHNL_TYPE_REQ) { /* Release all who still waits for response if any. */
channel->u.req.resp_status = -EIO;
complete_all(&channel->u.req.completion);
}
if (channel->irq)
unbind_from_irqhandler(channel->irq, channel);
if (channel->port)
xenbus_free_evtchn(front_info->xb_dev, channel->port);
/* End access and free the page. */
xenbus_teardown_ring(&page, 1, &channel->gref);
memset(channel, 0, sizeof(*channel));
}
void xen_snd_front_evtchnl_free_all(struct xen_snd_front_info *front_info)
{ int i;
if (!front_info->evt_pairs) return;
for (i = 0; i < front_info->num_evt_pairs; i++) {
evtchnl_free(front_info, &front_info->evt_pairs[i].req);
evtchnl_free(front_info, &front_info->evt_pairs[i].evt);
}
ret = xenbus_alloc_evtchn(xb_dev, &channel->port); if (ret < 0) goto fail;
ret = bind_evtchn_to_irq(channel->port); if (ret < 0) {
dev_err(&xb_dev->dev, "Failed to bind IRQ for domid %d port %d: %d\n",
front_info->xb_dev->otherend_id, channel->port, ret); goto fail;
}
channel->irq = ret;
ret = request_threaded_irq(channel->irq, NULL, handler,
IRQF_ONESHOT, handler_name, channel); if (ret < 0) {
dev_err(&xb_dev->dev, "Failed to request IRQ %d: %d\n",
channel->irq, ret); goto fail;
}
int xen_snd_front_evtchnl_create_all(struct xen_snd_front_info *front_info, int num_streams)
{ struct xen_front_cfg_card *cfg = &front_info->cfg; struct device *dev = &front_info->xb_dev->dev; int d, ret = 0;
front_info->evt_pairs =
kcalloc(num_streams, sizeof(struct xen_snd_front_evtchnl_pair),
GFP_KERNEL); if (!front_info->evt_pairs) return -ENOMEM;
/* Iterate over devices and their streams and create event channels. */ for (d = 0; d < cfg->num_pcm_instances; d++) { struct xen_front_cfg_pcm_instance *pcm_instance; int s, index;
pcm_instance = &cfg->pcm_instances[d];
for (s = 0; s < pcm_instance->num_streams_pb; s++) {
index = pcm_instance->streams_pb[s].index;
ret = evtchnl_alloc(front_info, index,
&front_info->evt_pairs[index].req,
EVTCHNL_TYPE_REQ); if (ret < 0) {
dev_err(dev, "Error allocating control channel\n"); goto fail;
}
ret = evtchnl_alloc(front_info, index,
&front_info->evt_pairs[index].evt,
EVTCHNL_TYPE_EVT); if (ret < 0) {
dev_err(dev, "Error allocating in-event channel\n"); goto fail;
}
}
for (s = 0; s < pcm_instance->num_streams_cap; s++) {
index = pcm_instance->streams_cap[s].index;
ret = evtchnl_alloc(front_info, index,
&front_info->evt_pairs[index].req,
EVTCHNL_TYPE_REQ); if (ret < 0) {
dev_err(dev, "Error allocating control channel\n"); goto fail;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.