summaryrefslogtreecommitdiff
path: root/drivers/ptp/ptp_clock.c
diff options
context:
space:
mode:
authorXabier Marquiegui <reibax@gmail.com>2023-10-12 00:39:56 +0200
committerDavid S. Miller <davem@davemloft.net>2023-10-15 20:07:52 +0100
commitc5a445b1e9347b14752b01f1a304bd7a2f260acc (patch)
tree52baa7d81f8a107faf818fdb2ee06ed9550ca747 /drivers/ptp/ptp_clock.c
parent8f5de6fb245326704f37d91780b9a10253a8a100 (diff)
ptp: support event queue reader channel masks
On systems with multiple timestamp event channels, some readers might want to receive only a subset of those channels. Add the necessary modifications to support timestamp event channel filtering, including two IOCTL operations: - Clear all channels - Enable one channel The mask modification operations will be applied exclusively on the event queue assigned to the file descriptor used on the IOCTL operation, so the typical procedure to have a reader receiving only a subset of the enabled channels would be: - Open device file - ioctl: clear all channels - ioctl: enable one channel - start reading Calling the enable one channel ioctl more than once will result in multiple enabled channels. Signed-off-by: Xabier Marquiegui <reibax@gmail.com> Suggested-by: Richard Cochran <richardcochran@gmail.com> Suggested-by: Vinicius Costa Gomes <vinicius.gomes@intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/ptp/ptp_clock.c')
-rw-r--r--drivers/ptp/ptp_clock.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/drivers/ptp/ptp_clock.c b/drivers/ptp/ptp_clock.c
index 74f1ce2dbccb..ed16d9787ce9 100644
--- a/drivers/ptp/ptp_clock.c
+++ b/drivers/ptp/ptp_clock.c
@@ -183,6 +183,7 @@ static void ptp_clock_release(struct device *dev)
spin_lock_irqsave(&tsevq->lock, flags);
list_del(&tsevq->qlist);
spin_unlock_irqrestore(&tsevq->lock, flags);
+ bitmap_free(tsevq->mask);
kfree(tsevq);
ida_free(&ptp_clocks_map, ptp->index);
kfree(ptp);
@@ -243,6 +244,10 @@ struct ptp_clock *ptp_clock_register(struct ptp_clock_info *info,
if (!queue)
goto no_memory_queue;
list_add_tail(&queue->qlist, &ptp->tsevqs);
+ queue->mask = bitmap_alloc(PTP_MAX_CHANNELS, GFP_KERNEL);
+ if (!queue->mask)
+ goto no_memory_bitmap;
+ bitmap_set(queue->mask, 0, PTP_MAX_CHANNELS);
spin_lock_init(&queue->lock);
mutex_init(&ptp->pincfg_mux);
mutex_init(&ptp->n_vclocks_mux);
@@ -346,6 +351,8 @@ no_mem_for_vclocks:
kworker_err:
mutex_destroy(&ptp->pincfg_mux);
mutex_destroy(&ptp->n_vclocks_mux);
+ bitmap_free(queue->mask);
+no_memory_bitmap:
list_del(&queue->qlist);
kfree(queue);
no_memory_queue:
@@ -400,9 +407,10 @@ void ptp_clock_event(struct ptp_clock *ptp, struct ptp_clock_event *event)
break;
case PTP_CLOCK_EXTTS:
- /* Enqueue timestamp on all queues */
+ /* Enqueue timestamp on selected queues */
list_for_each_entry(tsevq, &ptp->tsevqs, qlist) {
- enqueue_external_timestamp(tsevq, event);
+ if (test_bit((unsigned int)event->index, tsevq->mask))
+ enqueue_external_timestamp(tsevq, event);
}
wake_up_interruptible(&ptp->tsev_wq);
break;