diff options
| author | Takashi Sakamoto <o-takashi@sakamocchi.jp> | 2026-05-01 22:58:20 +0900 |
|---|---|---|
| committer | Takashi Sakamoto <o-takashi@sakamocchi.jp> | 2026-05-03 20:44:21 +0900 |
| commit | 834b33f9c95174606b25848b43b32432a3e98713 (patch) | |
| tree | e5167a52540ed4e07ed1d8fbf2d22da2c706995a /drivers/firewire/core-cdev.c | |
| parent | 6dbe7653fa01edeefc77b4d7c063562eb3debd48 (diff) | |
| download | linux-next-834b33f9c95174606b25848b43b32432a3e98713.tar.gz linux-next-834b33f9c95174606b25848b43b32432a3e98713.zip | |
firewire: core: reduce critical section duration in pre-processing of isoc resource management in cdev
It is preferable for the critical section to be as small as possible.
Current implementation of iso_resource_auto_work() function uses a
spinlock to control concurrent access to members of fw_card, fw_device,
iso_resource_auto structures, however the locking duration could be
reduced.
This commit refactors to shorten that duration.
Link: https://lore.kernel.org/r/20260501135823.241940-2-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Diffstat (limited to 'drivers/firewire/core-cdev.c')
| -rw-r--r-- | drivers/firewire/core-cdev.c | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/drivers/firewire/core-cdev.c b/drivers/firewire/core-cdev.c index bcfb20b770df..887783e4bd52 100644 --- a/drivers/firewire/core-cdev.c +++ b/drivers/firewire/core-cdev.c @@ -1329,32 +1329,36 @@ static void iso_resource_auto_work(struct work_struct *work) struct iso_resource_auto *r = from_work(r, work, work.work); struct client *client = r->client; unsigned long index = r->resource.handle; - int generation, channel, bandwidth, todo; + int current_generation, resource_generation, channel, bandwidth, todo; + u64 reset_jiffies; bool skip, free, success; scoped_guard(spinlock_irq, &client->lock) { - generation = client->device->generation; + reset_jiffies = client->device->card->reset_jiffies; + current_generation = client->device->generation; + resource_generation = r->params.generation; + r->params.generation = current_generation; todo = r->todo; - // Allow 1000ms grace period for other reallocations. - if (todo == ISO_RES_AUTO_ALLOC && - time_is_after_jiffies64(client->device->card->reset_jiffies + secs_to_jiffies(1))) { - schedule_iso_resource_auto(r, msecs_to_jiffies(333)); - skip = true; - } else { - // We could be called twice within the same generation. - skip = todo == ISO_RES_AUTO_REALLOC && - r->params.generation == generation; - } - free = todo == ISO_RES_AUTO_DEALLOC; - r->params.generation = generation; } + // Allow 1000ms grace period for other reallocations. + if (todo == ISO_RES_AUTO_ALLOC && + time_is_after_jiffies64(reset_jiffies + secs_to_jiffies(1))) { + schedule_iso_resource_auto(r, msecs_to_jiffies(333)); + skip = true; + } else { + // We could be called twice within the same generation. + skip = todo == ISO_RES_AUTO_REALLOC && + resource_generation == current_generation; + } + free = todo == ISO_RES_AUTO_DEALLOC; + if (skip) goto out; bandwidth = r->params.bandwidth; - fw_iso_resource_manage(client->device->card, generation, + fw_iso_resource_manage(client->device->card, current_generation, r->params.channels, &channel, &bandwidth, todo == ISO_RES_AUTO_ALLOC || todo == ISO_RES_AUTO_REALLOC); |
