mirror of
git://git.yoctoproject.org/linux-yocto.git
synced 2025-07-06 05:45:29 +02:00
firewire: ohci: use guard macro to maintain image of configuration ROM
The 1394 OHCI driver uses spinlock for the process to update local configuration ROM. This commit uses guard macro to maintain the spinlock. Link: https://lore.kernel.org/r/20240805085408.251763-17-o-takashi@sakamocchi.jp Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
This commit is contained in:
parent
b10e56fd0e
commit
86baade948
|
@ -2139,8 +2139,7 @@ static void bus_reset_work(struct work_struct *work)
|
||||||
at_context_flush(&ohci->at_request_ctx);
|
at_context_flush(&ohci->at_request_ctx);
|
||||||
at_context_flush(&ohci->at_response_ctx);
|
at_context_flush(&ohci->at_response_ctx);
|
||||||
|
|
||||||
spin_lock_irq(&ohci->lock);
|
scoped_guard(spinlock_irq, &ohci->lock) {
|
||||||
|
|
||||||
ohci->generation = generation;
|
ohci->generation = generation;
|
||||||
reg_write(ohci, OHCI1394_IntEventClear, OHCI1394_busReset);
|
reg_write(ohci, OHCI1394_IntEventClear, OHCI1394_busReset);
|
||||||
reg_write(ohci, OHCI1394_IntMaskSet, OHCI1394_busReset);
|
reg_write(ohci, OHCI1394_IntMaskSet, OHCI1394_busReset);
|
||||||
|
@ -2148,15 +2147,11 @@ static void bus_reset_work(struct work_struct *work)
|
||||||
if (ohci->quirks & QUIRK_RESET_PACKET)
|
if (ohci->quirks & QUIRK_RESET_PACKET)
|
||||||
ohci->request_generation = generation;
|
ohci->request_generation = generation;
|
||||||
|
|
||||||
/*
|
// This next bit is unrelated to the AT context stuff but we have to do it under the
|
||||||
* This next bit is unrelated to the AT context stuff but we
|
// spinlock also. If a new config rom was set up before this reset, the old one is
|
||||||
* have to do it under the spinlock also. If a new config rom
|
// now no longer in use and we can free it. Update the config rom pointers to point
|
||||||
* was set up before this reset, the old one is now no longer
|
// to the current config rom and clear the next_config_rom pointer so a new update
|
||||||
* in use and we can free it. Update the config rom pointers
|
// can take place.
|
||||||
* to point to the current config rom and clear the
|
|
||||||
* next_config_rom pointer so a new update can take place.
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (ohci->next_config_rom != NULL) {
|
if (ohci->next_config_rom != NULL) {
|
||||||
if (ohci->next_config_rom != ohci->config_rom) {
|
if (ohci->next_config_rom != ohci->config_rom) {
|
||||||
free_rom = ohci->config_rom;
|
free_rom = ohci->config_rom;
|
||||||
|
@ -2166,25 +2161,19 @@ static void bus_reset_work(struct work_struct *work)
|
||||||
ohci->config_rom_bus = ohci->next_config_rom_bus;
|
ohci->config_rom_bus = ohci->next_config_rom_bus;
|
||||||
ohci->next_config_rom = NULL;
|
ohci->next_config_rom = NULL;
|
||||||
|
|
||||||
/*
|
// Restore config_rom image and manually update config_rom registers.
|
||||||
* Restore config_rom image and manually update
|
// Writing the header quadlet will indicate that the config rom is ready,
|
||||||
* config_rom registers. Writing the header quadlet
|
// so we do that last.
|
||||||
* will indicate that the config rom is ready, so we
|
reg_write(ohci, OHCI1394_BusOptions, be32_to_cpu(ohci->config_rom[2]));
|
||||||
* do that last.
|
|
||||||
*/
|
|
||||||
reg_write(ohci, OHCI1394_BusOptions,
|
|
||||||
be32_to_cpu(ohci->config_rom[2]));
|
|
||||||
ohci->config_rom[0] = ohci->next_header;
|
ohci->config_rom[0] = ohci->next_header;
|
||||||
reg_write(ohci, OHCI1394_ConfigROMhdr,
|
reg_write(ohci, OHCI1394_ConfigROMhdr, be32_to_cpu(ohci->next_header));
|
||||||
be32_to_cpu(ohci->next_header));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (param_remote_dma) {
|
if (param_remote_dma) {
|
||||||
reg_write(ohci, OHCI1394_PhyReqFilterHiSet, ~0);
|
reg_write(ohci, OHCI1394_PhyReqFilterHiSet, ~0);
|
||||||
reg_write(ohci, OHCI1394_PhyReqFilterLoSet, ~0);
|
reg_write(ohci, OHCI1394_PhyReqFilterLoSet, ~0);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
spin_unlock_irq(&ohci->lock);
|
|
||||||
|
|
||||||
if (free_rom)
|
if (free_rom)
|
||||||
dmam_free_coherent(ohci->card.device, CONFIG_ROM_SIZE, free_rom, free_rom_bus);
|
dmam_free_coherent(ohci->card.device, CONFIG_ROM_SIZE, free_rom, free_rom_bus);
|
||||||
|
@ -2626,19 +2615,13 @@ static int ohci_set_config_rom(struct fw_card *card,
|
||||||
if (next_config_rom == NULL)
|
if (next_config_rom == NULL)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
spin_lock_irq(&ohci->lock);
|
scoped_guard(spinlock_irq, &ohci->lock) {
|
||||||
|
// If there is not an already pending config_rom update, push our new allocation
|
||||||
/*
|
// into the ohci->next_config_rom and then mark the local variable as null so that
|
||||||
* If there is not an already pending config_rom update,
|
// we won't deallocate the new buffer.
|
||||||
* push our new allocation into the ohci->next_config_rom
|
//
|
||||||
* and then mark the local variable as null so that we
|
// OTOH, if there is a pending config_rom update, just use that buffer with the new
|
||||||
* won't deallocate the new buffer.
|
// config_rom data, and let this routine free the unused DMA allocation.
|
||||||
*
|
|
||||||
* OTOH, if there is a pending config_rom update, just
|
|
||||||
* use that buffer with the new config_rom data, and
|
|
||||||
* let this routine free the unused DMA allocation.
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (ohci->next_config_rom == NULL) {
|
if (ohci->next_config_rom == NULL) {
|
||||||
ohci->next_config_rom = next_config_rom;
|
ohci->next_config_rom = next_config_rom;
|
||||||
ohci->next_config_rom_bus = next_config_rom_bus;
|
ohci->next_config_rom_bus = next_config_rom_bus;
|
||||||
|
@ -2651,8 +2634,7 @@ static int ohci_set_config_rom(struct fw_card *card,
|
||||||
ohci->next_config_rom[0] = 0;
|
ohci->next_config_rom[0] = 0;
|
||||||
|
|
||||||
reg_write(ohci, OHCI1394_ConfigROMmap, ohci->next_config_rom_bus);
|
reg_write(ohci, OHCI1394_ConfigROMmap, ohci->next_config_rom_bus);
|
||||||
|
}
|
||||||
spin_unlock_irq(&ohci->lock);
|
|
||||||
|
|
||||||
/* If we didn't use the DMA allocation, delete it. */
|
/* If we didn't use the DMA allocation, delete it. */
|
||||||
if (next_config_rom != NULL) {
|
if (next_config_rom != NULL) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user