Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Revert "firewire: core: use mutex to coordinate concurrent calls to flush completions"

This reverts commit d9605d67562505e27dcc0f71af418118d3db91e5, since this
commit is on the following reverted changes.

Link: https://lore.kernel.org/r/20240912133038.238786-2-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>

+25 -24
+2 -9
drivers/firewire/core-iso.c
··· 157 157 ctx->callback.sc = callback; 158 158 ctx->callback_data = callback_data; 159 159 INIT_WORK(&ctx->work, flush_completions_work); 160 - mutex_init(&ctx->flushing_completions_mutex); 161 160 162 161 trace_isoc_outbound_allocate(ctx, channel, speed); 163 162 trace_isoc_inbound_single_allocate(ctx, channel, header_size); ··· 173 174 trace_isoc_inbound_multiple_destroy(ctx); 174 175 175 176 ctx->card->driver->free_iso_context(ctx); 176 - 177 - mutex_destroy(&ctx->flushing_completions_mutex); 178 177 } 179 178 EXPORT_SYMBOL(fw_iso_context_destroy); 180 179 ··· 226 229 * to process the context asynchronously, fw_iso_context_schedule_flush_completions() is available 227 230 * instead. 228 231 * 229 - * Context: Process context due to mutex_trylock(). 232 + * Context: Process context. 230 233 */ 231 234 int fw_iso_context_flush_completions(struct fw_iso_context *ctx) 232 235 { ··· 234 237 trace_isoc_inbound_single_flush_completions(ctx); 235 238 trace_isoc_inbound_multiple_flush_completions(ctx); 236 239 237 - scoped_cond_guard(mutex_try, /* nothing to do */, &ctx->flushing_completions_mutex) { 238 - return ctx->card->driver->flush_iso_completions(ctx); 239 - } 240 - 241 - return 0; 240 + return ctx->card->driver->flush_iso_completions(ctx); 242 241 } 243 242 EXPORT_SYMBOL(fw_iso_context_flush_completions); 244 243
+23 -14
drivers/firewire/ohci.c
··· 166 166 struct context context; 167 167 void *header; 168 168 size_t header_length; 169 + unsigned long flushing_completions; 169 170 u32 mc_buffer_bus; 170 171 u16 mc_completed; 171 172 u16 last_timestamp; ··· 3579 3578 static int ohci_flush_iso_completions(struct fw_iso_context *base) 3580 3579 { 3581 3580 struct iso_context *ctx = container_of(base, struct iso_context, base); 3581 + int ret = 0; 3582 3582 3583 - // Note that tasklet softIRQ is not used to process isochronous context anymore. 3584 - context_tasklet((unsigned long)&ctx->context); 3583 + if (!test_and_set_bit_lock(0, &ctx->flushing_completions)) { 3584 + // Note that tasklet softIRQ is not used to process isochronous context anymore. 3585 + context_tasklet((unsigned long)&ctx->context); 3585 3586 3586 - switch (base->type) { 3587 - case FW_ISO_CONTEXT_TRANSMIT: 3588 - case FW_ISO_CONTEXT_RECEIVE: 3589 - if (ctx->header_length != 0) 3590 - flush_iso_completions(ctx, FW_ISO_CONTEXT_COMPLETIONS_CAUSE_FLUSH); 3591 - return 0; 3592 - case FW_ISO_CONTEXT_RECEIVE_MULTICHANNEL: 3593 - if (ctx->mc_completed != 0) 3594 - flush_ir_buffer_fill(ctx); 3595 - return 0; 3596 - default: 3597 - return -ENOSYS; 3587 + switch (base->type) { 3588 + case FW_ISO_CONTEXT_TRANSMIT: 3589 + case FW_ISO_CONTEXT_RECEIVE: 3590 + if (ctx->header_length != 0) 3591 + flush_iso_completions(ctx, FW_ISO_CONTEXT_COMPLETIONS_CAUSE_FLUSH); 3592 + break; 3593 + case FW_ISO_CONTEXT_RECEIVE_MULTICHANNEL: 3594 + if (ctx->mc_completed != 0) 3595 + flush_ir_buffer_fill(ctx); 3596 + break; 3597 + default: 3598 + ret = -ENOSYS; 3599 + } 3600 + 3601 + clear_bit_unlock(0, &ctx->flushing_completions); 3602 + smp_mb__after_atomic(); 3598 3603 } 3604 + 3605 + return ret; 3599 3606 } 3600 3607 3601 3608 static const struct fw_card_driver ohci_driver = {
-1
include/linux/firewire.h
··· 512 512 struct fw_iso_context { 513 513 struct fw_card *card; 514 514 struct work_struct work; 515 - struct mutex flushing_completions_mutex; 516 515 int type; 517 516 int channel; 518 517 int speed;