mirror of
https://github.com/nxp-imx/linux-imx.git
synced 2025-07-07 18:05:21 +02:00
firewire: cdev: implement new event to notify response subaction with time stamp
The callback function now receives an argument for time stamps relevant to asynchronous transaction. This commit implements a new event to notify response subaction with the time stamps for user space. Link: https://lore.kernel.org/r/20230529113406.986289-10-o-takashi@sakamocchi.jp Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
This commit is contained in:
parent
fc2b52cf2e
commit
d8527cab6c
|
@ -172,6 +172,7 @@ struct outbound_transaction_event {
|
||||||
struct outbound_transaction_resource r;
|
struct outbound_transaction_resource r;
|
||||||
union {
|
union {
|
||||||
struct fw_cdev_event_response without_tstamp;
|
struct fw_cdev_event_response without_tstamp;
|
||||||
|
struct fw_cdev_event_response2 with_tstamp;
|
||||||
} rsp;
|
} rsp;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -538,41 +539,64 @@ static void release_transaction(struct client *client,
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
static void complete_transaction(struct fw_card *card, int rcode,
|
static void complete_transaction(struct fw_card *card, int rcode, u32 request_tstamp,
|
||||||
void *payload, size_t length, void *data)
|
u32 response_tstamp, void *payload, size_t length, void *data)
|
||||||
{
|
{
|
||||||
struct outbound_transaction_event *e = data;
|
struct outbound_transaction_event *e = data;
|
||||||
struct fw_cdev_event_response *rsp = &e->rsp.without_tstamp;
|
|
||||||
struct client *client = e->client;
|
struct client *client = e->client;
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
|
|
||||||
if (length < rsp->length)
|
|
||||||
rsp->length = length;
|
|
||||||
if (rcode == RCODE_COMPLETE)
|
|
||||||
memcpy(rsp->data, payload, rsp->length);
|
|
||||||
|
|
||||||
spin_lock_irqsave(&client->lock, flags);
|
spin_lock_irqsave(&client->lock, flags);
|
||||||
idr_remove(&client->resource_idr, e->r.resource.handle);
|
idr_remove(&client->resource_idr, e->r.resource.handle);
|
||||||
if (client->in_shutdown)
|
if (client->in_shutdown)
|
||||||
wake_up(&client->tx_flush_wait);
|
wake_up(&client->tx_flush_wait);
|
||||||
spin_unlock_irqrestore(&client->lock, flags);
|
spin_unlock_irqrestore(&client->lock, flags);
|
||||||
|
|
||||||
rsp->type = FW_CDEV_EVENT_RESPONSE;
|
switch (e->rsp.without_tstamp.type) {
|
||||||
|
case FW_CDEV_EVENT_RESPONSE:
|
||||||
|
{
|
||||||
|
struct fw_cdev_event_response *rsp = &e->rsp.without_tstamp;
|
||||||
|
|
||||||
|
if (length < rsp->length)
|
||||||
|
rsp->length = length;
|
||||||
|
if (rcode == RCODE_COMPLETE)
|
||||||
|
memcpy(rsp->data, payload, rsp->length);
|
||||||
|
|
||||||
rsp->rcode = rcode;
|
rsp->rcode = rcode;
|
||||||
|
|
||||||
/*
|
// In the case that sizeof(*rsp) doesn't align with the position of the
|
||||||
* In the case that sizeof(*rsp) doesn't align with the position of the
|
// data, and the read is short, preserve an extra copy of the data
|
||||||
* data, and the read is short, preserve an extra copy of the data
|
// to stay compatible with a pre-2.6.27 bug. Since the bug is harmless
|
||||||
* to stay compatible with a pre-2.6.27 bug. Since the bug is harmless
|
// for short reads and some apps depended on it, this is both safe
|
||||||
* for short reads and some apps depended on it, this is both safe
|
// and prudent for compatibility.
|
||||||
* and prudent for compatibility.
|
|
||||||
*/
|
|
||||||
if (rsp->length <= sizeof(*rsp) - offsetof(typeof(*rsp), data))
|
if (rsp->length <= sizeof(*rsp) - offsetof(typeof(*rsp), data))
|
||||||
queue_event(client, &e->event, rsp, sizeof(*rsp),
|
queue_event(client, &e->event, rsp, sizeof(*rsp), rsp->data, rsp->length);
|
||||||
rsp->data, rsp->length);
|
|
||||||
else
|
else
|
||||||
queue_event(client, &e->event, rsp, sizeof(*rsp) + rsp->length,
|
queue_event(client, &e->event, rsp, sizeof(*rsp) + rsp->length, NULL, 0);
|
||||||
NULL, 0);
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case FW_CDEV_EVENT_RESPONSE2:
|
||||||
|
{
|
||||||
|
struct fw_cdev_event_response2 *rsp = &e->rsp.with_tstamp;
|
||||||
|
|
||||||
|
if (length < rsp->length)
|
||||||
|
rsp->length = length;
|
||||||
|
if (rcode == RCODE_COMPLETE)
|
||||||
|
memcpy(rsp->data, payload, rsp->length);
|
||||||
|
|
||||||
|
rsp->rcode = rcode;
|
||||||
|
rsp->request_tstamp = request_tstamp;
|
||||||
|
rsp->response_tstamp = response_tstamp;
|
||||||
|
|
||||||
|
queue_event(client, &e->event, rsp, sizeof(*rsp) + rsp->length, NULL, 0);
|
||||||
|
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
WARN_ON(1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Drop the idr's reference */
|
/* Drop the idr's reference */
|
||||||
client_put(client);
|
client_put(client);
|
||||||
|
@ -583,7 +607,6 @@ static int init_request(struct client *client,
|
||||||
int destination_id, int speed)
|
int destination_id, int speed)
|
||||||
{
|
{
|
||||||
struct outbound_transaction_event *e;
|
struct outbound_transaction_event *e;
|
||||||
struct fw_cdev_event_response *rsp;
|
|
||||||
void *payload;
|
void *payload;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
@ -600,10 +623,21 @@ static int init_request(struct client *client,
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
e->client = client;
|
e->client = client;
|
||||||
|
|
||||||
rsp = &e->rsp.without_tstamp;
|
if (client->version < FW_CDEV_VERSION_EVENT_ASYNC_TSTAMP) {
|
||||||
|
struct fw_cdev_event_response *rsp = &e->rsp.without_tstamp;
|
||||||
|
|
||||||
|
rsp->type = FW_CDEV_EVENT_RESPONSE;
|
||||||
rsp->length = request->length;
|
rsp->length = request->length;
|
||||||
rsp->closure = request->closure;
|
rsp->closure = request->closure;
|
||||||
payload = rsp->data;
|
payload = rsp->data;
|
||||||
|
} else {
|
||||||
|
struct fw_cdev_event_response2 *rsp = &e->rsp.with_tstamp;
|
||||||
|
|
||||||
|
rsp->type = FW_CDEV_EVENT_RESPONSE2;
|
||||||
|
rsp->length = request->length;
|
||||||
|
rsp->closure = request->closure;
|
||||||
|
payload = rsp->data;
|
||||||
|
}
|
||||||
|
|
||||||
if (request->data && copy_from_user(payload, u64_to_uptr(request->data), request->length)) {
|
if (request->data && copy_from_user(payload, u64_to_uptr(request->data), request->length)) {
|
||||||
ret = -EFAULT;
|
ret = -EFAULT;
|
||||||
|
@ -615,9 +649,9 @@ static int init_request(struct client *client,
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto failed;
|
goto failed;
|
||||||
|
|
||||||
fw_send_request(client->device->card, &e->r.transaction, request->tcode, destination_id,
|
fw_send_request_with_tstamp(client->device->card, &e->r.transaction, request->tcode,
|
||||||
request->generation, speed, request->offset, payload, request->length,
|
destination_id, request->generation, speed, request->offset,
|
||||||
complete_transaction, e);
|
payload, request->length, complete_transaction, e);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
failed:
|
failed:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user