summaryrefslogtreecommitdiff
path: root/drivers/firewire/ohci.c
AgeCommit message (Collapse)Author
2024-12-08firewire: ohci: use generic power managementVaibhav Gupta
Drivers using legacy PM have to manage PCI states and device's PM states themselves. They also need to take care of configuration registers. With improved and powerful support of generic PM, PCI Core takes care of above mentioned, device-independent, jobs. This driver makes use of PCI helper functions like pci_save/restore_state(), pci_disable_device() and pci_set_power_state() to do required operations. In generic mode, they are no longer needed. Change function parameter in both .suspend() and .resume() to "struct device*" type. Use to_pci_dev() to get "struct pci_dev*" variable. Compile-tested only. Maintainer has tested the changes on non-PowerPC platform and got no failure of the suspend/resume operations. Signed-off-by: Vaibhav Gupta <vaibhavgupta40@gmail.com> Link: https://lore.kernel.org/r/20200720150715.624520-1-vaibhavgupta40@gmail.com Tested-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Signed-off-by; Takashi Sakamoto <o-takashi@sakamocchi.jp<
2024-10-28firewire: ohci: Replace deprecated PCI functionsPhilipp Stanner
pcim_iomap_regions() and pcim_iomap_table() have been deprecated in commit e354bb84a4c1 ("PCI: Deprecate pcim_iomap_table(), pcim_iomap_regions_request_all()"). Replace these functions with pcim_iomap_region(). Signed-off-by: Philipp Stanner <pstanner@redhat.com> Link: https://lore.kernel.org/r/20241028094440.19115-3-pstanner@redhat.com Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
2024-10-01firewire: Correct some typosShen Lichuan
Fixed some confusing typos that were currently identified with codespell, the details are as follows: drivers/firewire/core-topology.c:59: containted ==> contained drivers/firewire/core.h:83: reenable ==> re-enable drivers/firewire/ohci.c:1387: apppends ==> appends drivers/firewire/ohci.c:2216: superceded ==> superseded drivers/firewire/ohci.c:2617: litte ==> little Signed-off-by: Shen Lichuan <shenlichuan@vivo.com> Link: https://lore.kernel.org/r/20240930023344.7535-1-shenlichuan@vivo.com Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
2024-09-12firewire: core: rename cause flag of tracepoints eventTakashi Sakamoto
The flag of FW_ISO_CONTEXT_COMPLETIONS_CAUSE_IRQ directly causes hardIRQ request by 1394 OHCI hardware when the corresponding isochronous packet is transferred, however it is not so directly associated to hardIRQ processing itself. This commit renames the flag so that it relates to interrupt parameter of internal packet data. Link: https://lore.kernel.org/r/20240912133038.238786-6-o-takashi@sakamocchi.jp Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
2024-09-12firewire: core: add helper function to retire descriptorsTakashi Sakamoto
Both IR/IT contexts use the same code to retire completed descriptors as AT context uses. This commit adds a helper function to reduce the duplicated codes. Link: https://lore.kernel.org/r/20240912133038.238786-4-o-takashi@sakamocchi.jp Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
2024-09-12Revert "firewire: core: move workqueue handler from 1394 OHCI driver to core ↵Takashi Sakamoto
function" This reverts commit 767bfb9ef27ebf760290d9f8bc303828b018c312. It appears that the call of ohci_flush_iso_completions() in the work item scheduled by hardIRQ of 1394 OHCI for any isochronous context changes the timing to queue events in the view of user space application. Link: https://lore.kernel.org/r/20240912133038.238786-3-o-takashi@sakamocchi.jp Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
2024-09-12Revert "firewire: core: use mutex to coordinate concurrent calls to flush ↵Takashi Sakamoto
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>
2024-09-09firewire: core: use mutex to coordinate concurrent calls to flush completionsTakashi Sakamoto
In current implementation, test_and_set_bit_lock() is used to mediate concurrent calls of ohci_flush_iso_completions(). However, the ad-hoc usage of atomic operations is not preferable. This commit uses mutex_trylock() as the similar operations. The core function is responsible for the mediation, instead of 1394 OHCI driver. Link: https://lore.kernel.org/r/20240909140018.65289-3-o-takashi@sakamocchi.jp Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
2024-09-09firewire: core: move workqueue handler from 1394 OHCI driver to core functionTakashi Sakamoto
In current implementation, the work item for isochronous context executes the same procedure of fw_iso_context_flush_completions() internally. There is a space to refactor the implementation. This commit calls fw_iso_context_flush_completions() in the work item. It obsoletes fw_iso_context_init_work(). It also obsoletes a pair of disable_work_sync() and enable_work() since the usage of test_and_set_bit_lock() mediates concurrent call already. Link: https://lore.kernel.org/r/20240909140018.65289-2-o-takashi@sakamocchi.jp Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
2024-09-08firewire: core: expose kernel API to schedule work item to process ↵Takashi Sakamoto
isochronous context In packet-per-buffer mode for isochronous context of 1394 OHCI, software can schedule hardIRQ to the buffer in which the content of isochronous packet is processed. The actual behaviour is different between isochronous receive (IR) and transmit (IT) contexts in respect to isochronous cycle in which the hardIRQ occurs. In IR context, the hardIRQ occurs when the buffer is filled actually by the content of received packet. If there are any isochronous cycles in which the packet transmission is skipped, it is postponed to generate the hardIRQ in respect to the isochronous cycle. In IT context, software can schedule the content of packet every isochronous cycle including skipping, therefore the hardIRQ occurs in the isochronous cycle to which the software scheduled. ALSA firewire stack uses the packet-per-buffer mode for both IR/IT contexts. To process time stamp per packet (or per sample in some cases) steadily for media clock recovery against unexpected transmission skips, it uses an IT context to operate all of isochronous contexts by calls of fw_iso_context_flush_completions() in the bottom-half of hardIRQ for the IT context. Although it looks well to handle all of isochronous contexts in a single bottom-half context, it relatively takes longer time. In the future code integration (not yet), it is possible to apply parallelism method to process these context. In the case, it is useful to allow unit drivers to schedule work items to process these isochronous contexts. As a preparation, this commit exposes fw_iso_context_schedule_flush_completions() as a kernel API available by unit drivers. It is renamed from fw_iso_context_queue_work() since it is a counter part of fw_iso_context_flush_completions(). Link: https://lore.kernel.org/r/20240908040549.75304-2-o-takashi@sakamocchi.jp Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
2024-09-04firewire: ohci: operate IT/IR events in sleepable work process instead of ↵Takashi Sakamoto
tasklet softIRQ This commit queues work item for IT/IR events at hardIRQ handler to operate the corresponding isochronous context. The work item is queued to any of worker-pools. The callback for either the implementation of unit protocol and user space clients is executed in sleepable work process context. The change could results in any errors of concurrent processing as well as sleep at atomic context. These errors are fixed by the following commits. Tested-by: Edmund Raile <edmund.raile@protonmail.com> Link: https://lore.kernel.org/r/20240904125155.461886-4-o-takashi@sakamocchi.jp Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
2024-09-04firewire: core: allocate workqueue to handle isochronous contexts in cardTakashi Sakamoto
This commit adds a workqueue dedicated for isochronous context processing. The workqueue is allocated per instance of fw_card structure to satisfy the following characteristics descending from 1394 OHCI specification: In 1394 OHCI specification, memory pages are reserved to each isochronous context dedicated to DMA transmission. It allows to operate these per-context pages concurrently. Software can schedule hardware interrupt for several isochronous context to the same cycle, thus WQ_UNBOUND is specified. Additionally, it is sleepable to operate the content of pages, thus WQ_BH is not used. The isochronous context delivers the packets with time stamp, thus WQ_HIGHPRI is specified for semi real-time data such as IEC 61883-1/6 protocol implemented by ALSA firewire stack. The isochronous context is not used by the implementation of SCSI over IEEE1394 protocol (sbp2), thus WQ_MEM_RECLAIM is not specified. It is useful for users to adjust cpu affinity of the workqueue depending on their work loads, thus WQ_SYS is specified to expose the attributes to user space. Tested-by: Edmund Raile <edmund.raile@protonmail.com> Link: https://lore.kernel.org/r/20240904125155.461886-2-o-takashi@sakamocchi.jp Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
2024-09-03firewire: ohci: obsolete direct usage of printk_ratelimit()Takashi Sakamoto
A commit 77006a0a8282 ("ratelimit: add comment warning people off printk_ratelimit()") has already deprecated printk_ratelimit(). This commit uses alternative functions to obsolete its usage. Link: https://lore.kernel.org/r/20240903101523.317110-1-o-takashi@sakamocchi.jp Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
2024-09-03firewire: ohci: deprecate debug parameterTakashi Sakamoto
Many tracepoints events have been added to 6.10 and 6.11 kernels. They are available as an alternative of debug parameter in firewire-ohci module. The logging messages enabled by the parameter require some cumbersomes in a point of maintenance; e.g. the code to decode transaction frame. This commit adds deprecation text to conduct users to them.. Link: https://lore.kernel.org/r/20240903101455.317067-1-o-takashi@sakamocchi.jp Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
2024-08-17firewire: ohci: fix error path to detect initiated reset in TI TSB41BA3D phyTakashi Sakamoto
A commit 404957c1e207 ("firewire: ohci: use guard macro to serialize accesses to phy registers") refactored initiated_reset() helper function, while the error path was changed wrongly. This commit fixes the bug. Reported-by: Dan Carpenter <dan.carpenter@linaro.org> Fixes: 80f3401dfeb2 ("firewire: ohci: use guard macro to serialize accesses to phy registers") Link: https://lore.kernel.org/r/20240817091128.180303-1-o-takashi@sakamocchi.jp Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
2024-08-14firewire: core/ohci: minor refactoring for computation of configuration ROM sizeTakashi Sakamoto
The size of space for configuration ROM is defined by IEEE 1212. The start and end offsets are available as some macros in UAPI header. This commit uses these macros to compute the size. Link: https://lore.kernel.org/r/20240814131222.69949-4-o-takashi@sakamocchi.jp Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
2024-08-14firewire: ohci: remove unused wrapper macro for dev_info()Takashi Sakamoto
The ohci_info() macro is a thin wrapper of dev_info(), while it is never used. Link: https://lore.kernel.org/r/20240814131222.69949-3-o-takashi@sakamocchi.jp Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
2024-08-14firewire: ohci: use helper macro for compiler aligned attributeTakashi Sakamoto
The __aligned() macro has been available since v4.19 kernel by a commit 815f0ddb346c ("include/linux/compiler*.h: make compiler-*.h mutually exclusive"). This commit replaces with the macro. Link: https://lore.kernel.org/r/20240814131222.69949-2-o-takashi@sakamocchi.jp Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
2024-08-05firewire: ohci: use guard macro to serialize operations for isochronous contextsTakashi Sakamoto
The 1394 OHCI driver uses spinlock to serialize operations for isochronous contexts. This commit uses guard macro to maintain the spinlock. Link: https://lore.kernel.org/r/20240805085408.251763-18-o-takashi@sakamocchi.jp Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
2024-08-05firewire: ohci: use guard macro to maintain image of configuration ROMTakashi Sakamoto
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>
2024-08-05firewire: ohci: use guard macro to maintain bus timeTakashi Sakamoto
The 1394 OHCI driver maintains bus time to respond to querying request. The concurrent access to the bus time is protected by spinlock. This commit uses guard macro to maintain the spinlock. Link: https://lore.kernel.org/r/20240805085408.251763-16-o-takashi@sakamocchi.jp Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
2024-08-05firewire: ohci: use guard macro to serialize accesses to phy registersTakashi Sakamoto
The 1394 OHCI driver protects concurrent accesses to phy registers by mutex object in fw_ohci structure. This commit uses guard macro to maintain the mutex. Link: https://lore.kernel.org/r/20240805085408.251763-5-o-takashi@sakamocchi.jp Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
2024-08-02firewire: ohci: use static inline functions to serialize data of IT DMATakashi Sakamoto
THis commit replaces current implementation with the helper functions added in the former commit. Link: https://lore.kernel.org/r/20240802003606.109402-5-o-takashi@sakamocchi.jp Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
2024-08-02firewire: ohci: use static inline functions to serialize data of AT DMATakashi Sakamoto
This commit replaces current implementation with the helper functions added in the former commit. Link: https://lore.kernel.org/r/20240802003606.109402-3-o-takashi@sakamocchi.jp Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
2024-07-29firewire: ohci: minor code refactoring to localize text tableTakashi Sakamoto
The string table for tcode is just used by log_ar_at_event(). In the case, it is suitable to move the table inner the function definition. This commit is for the purpose. Additionally, the hard-coded value for tcode is replaced with defined macros as many as possible. Link: https://lore.kernel.org/r/20240729134631.127189-3-o-takashi@sakamocchi.jp Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
2024-07-29firewire: ohci: use TCODE_LINK_INTERNAL consistentlyTakashi Sakamoto
In IEEE 1394 specification, 0x0e in tcode field is reserved for internal purpose depending on link layer. In 1394 OHCI specification, it is used to express phy packet in AT/AR contexts. Current implementation of 1394 OHCI driver has several macros for the code. They can be simply replaced with a macro in core code. This commit obsoletes the macros. Link: https://lore.kernel.org/r/20240729134631.127189-2-o-takashi@sakamocchi.jp Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
2024-07-08Revert "firewire: ohci: use common macro to interpret be32 data in le32 buffer"Takashi Sakamoto
This reverts commit f26a38e61c03fdfacb6b596e1daf665cf4526a60, since it causes the following sparse warnings: sparse warnings: (new ones prefixed by >>) >> drivers/firewire/ohci.c:891:23: sparse: sparse: cast to restricted __be32 >> drivers/firewire/ohci.c:891:23: sparse: sparse: cast from restricted __le32 drivers/firewire/ohci.c:892:23: sparse: sparse: cast to restricted __be32 drivers/firewire/ohci.c:892:23: sparse: sparse: cast from restricted __le32 drivers/firewire/ohci.c:893:23: sparse: sparse: cast to restricted __be32 drivers/firewire/ohci.c:893:23: sparse: sparse: cast from restricted __le32 drivers/firewire/ohci.c:905:31: sparse: sparse: cast to restricted __be32 drivers/firewire/ohci.c:905:31: sparse: sparse: cast from restricted __le32 drivers/firewire/ohci.c:914:31: sparse: sparse: cast to restricted __be32 drivers/firewire/ohci.c:914:31: sparse: sparse: cast from restricted __le32 drivers/firewire/ohci.c:939:18: sparse: sparse: cast to restricted __be32 drivers/firewire/ohci.c:939:18: sparse: sparse: cast from restricted __le32 drivers/firewire/ohci.c:2033:23: sparse: sparse: cast to restricted __be32 drivers/firewire/ohci.c:2033:23: sparse: sparse: cast from restricted __le32 drivers/firewire/ohci.c:2037:27: sparse: sparse: cast to restricted __be32 drivers/firewire/ohci.c:2037:27: sparse: sparse: cast from restricted __le32 drivers/firewire/ohci.c:2038:27: sparse: sparse: cast to restricted __be32 drivers/firewire/ohci.c:2038:27: sparse: sparse: cast from restricted __le32 Reported-by: kernel test robot <lkp@intel.com> Closes: https://lore.kernel.org/oe-kbuild-all/202407050656.03bw1YXA-lkp@intel.com/ Link: https://lore.kernel.org/r/20240707134523.11784-1-o-takashi@sakamocchi.jp Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
2024-07-04firewire: ohci: add tracepoints event for data of Self-ID DMATakashi Sakamoto
In 1394 OHCI, the SelfIDComplete event occurs when the hardware has finished transmitting all of the self ID packets received during the bus initialization process to the host memory by DMA. This commit adds a tracepoints event for this event to trace the timing and packet data of Self-ID DMA. It is the part of following tracepoints events helpful to debug some events at bus reset; e.g. the issue addressed at a commit d0b06dc48fb1 ("firewire: core: use long bus reset on gap count error")[1]: * firewire_ohci:irqs * firewire_ohci:self_id_complete * firewire:bus_reset_handle * firewire:self_id_sequence They would be also helpful in the problem about invocation timing of hardIRQ and process (workqueue) contexts. We can often see this kind of problem with -rt kernel[2]. [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=d0b06dc48fb1 [2] https://lore.kernel.org/linux-rt-users/YAwPoaUZ1gTD5y+k@hmbx/ Link: https://lore.kernel.org/r/20240702222034.1378764-6-o-takashi@sakamocchi.jp Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
2024-07-04firewire: ohci: use inline functions to operate data of self-ID DMATakashi Sakamoto
The code of 1394 OHCI driver includes hard-coded magic number to operate data of Self-ID DMA. This commit replaces them with the inline functions added/tested in the former commit. Link: https://lore.kernel.org/r/20240702222034.1378764-5-o-takashi@sakamocchi.jp Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
2024-07-04firewire: ohci: use static function to handle endian issue on PowerPC platformTakashi Sakamoto
It is preferable to use static function instead of functional macro in some points. It checks type of argument, but would be optimized to embedded code instead of function calls. This commit obsoletes the functional macro with the static function. Additionally this commit refactors quirk detection to ease the later work. Link: https://lore.kernel.org/r/20240702222034.1378764-3-o-takashi@sakamocchi.jp Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
2024-07-04firewire: ohci: use common macro to interpret be32 data in le32 bufferTakashi Sakamoto
The 1394 OHCI driver configures the hardware to transfer the data quadlets of packet via DMA after converting it to little endian, therefore the data is typed as __le32. Nevertheless some actual hardware ignores the configuration. In the case, the data in DMA buffer is aligned to big endian (__be32). For the case in big-endian machine, the driver includes the following interpretation from __le32 to u32 (host-endian = __be32): * (__force __u32)(v) In include/linux/byteorder/generic.h, be32_to_cpu() is available. It is expanded to the following expression in 'include/uapi/linux/byteorder/big_endian.h': * (__force __u32)(__be32)(x) This commit replace the ad-hoc endian interpretation with the above. Link: https://lore.kernel.org/r/20240702222034.1378764-2-o-takashi@sakamocchi.jp Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
2024-06-25firewire: ohci: add tracepoints event for hardIRQ eventTakashi Sakamoto
1394 OHCI hardware triggers PCI interrupts to notify any events to software. Current driver for the hardware is programmed by the typical way to utilize top- and bottom- halves, thus it has a timing gap to handle the notification in softIRQ (tasklet). This commit adds a tracepoint event for the hardIRQ event. The comparison of the tracepoint event to tracepoints events in firewire subsystem is helpful to diagnose the timing gap. Link: https://lore.kernel.org/r/20240625031806.956650-3-o-takashi@sakamocchi.jp Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
2024-06-25firewire: ohci: add support for Linux kernel tracepointsTakashi Sakamoto
The Linux Kernel Tracepoints framework is enough useful to trace the interaction between 1394 OHCI hardware and its driver. This commit adds firewire_ohci subsystem to use the framework. It is defined as the different subsystem from the existing firewire subsystem. The definition file for the existing subsystem is slightly changed so that both subsystems are available in 1394 OHCI driver. Link: https://lore.kernel.org/r/20240625031806.956650-2-o-takashi@sakamocchi.jp Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
2024-06-25firewire: core: add tracepoints events for completions of packets in ↵Takashi Sakamoto
isochronous context It is helpful to trace completion of packets in isochronous context when the core function is requested them by both in-kernel units driver and userspace applications. This commit adds some tracepoints events for the aim. Link: https://lore.kernel.org/r/20240623220859.851685-8-o-takashi@sakamocchi.jp Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
2024-06-25firewire: core: add tracepoints events for flushing completions of ↵Takashi Sakamoto
isochronous context It is helpful to trace the flushing completions of isochronous context when the core function is requested them by both in-kernel unit drivers and userspace applications. This commit adds some tracepoints events for the aim. Link: https://lore.kernel.org/r/20240623220859.851685-6-o-takashi@sakamocchi.jp Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
2024-06-17firewire: ohci: use helper inline functions to serialize/deserialize self ID ↵Takashi Sakamoto
packet This commit replaces the existing implementation with the helper functions for self ID packet. Link: https://lore.kernel.org/r/20240605235155.116468-10-o-takashi@sakamocchi.jp Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
2024-06-17firewire: ohci: use helper functions for self ID sequenceTakashi Sakamoto
This commit replaces the existing implementation with the helper functions for self ID sequence. Link: https://lore.kernel.org/r/20240605235155.116468-7-o-takashi@sakamocchi.jp Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
2024-06-17firewire: ohci: minor code refactoring for self ID loggingTakashi Sakamoto
Current implementation to log self ID sequence has the rest to be refactored; e.g. moving translation-unit level variables to the dependent block. This commit is for the purpose. Link: https://lore.kernel.org/r/20240605235155.116468-5-o-takashi@sakamocchi.jp Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
2024-05-06firewire: ohci: obsolete OHCI_PARAM_DEBUG_BUSRESETS from debug module parameterTakashi Sakamoto
The OHCI_PARAM_DEBUG_BUSRESETS bit of debug module parameter was added at a commit a007bb857e0b ("firewire: fw-ohci: conditionally log busReset interrupts"). At the former commit, the bit becomes less meaningful, just to skip logging. This commit obsoletes it. Link: https://lore.kernel.org/r/20240501073238.72769-3-o-takashi@sakamocchi.jp Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
2024-05-06firewire: ohci: add bus-reset event for initial set of handled irqTakashi Sakamoto
In the former commits, the spurious interrupt events are suppressed as possible, by unset bus-reset event from the set of handled irq. The change was written with the less-intrusive style, thus it firstly works at the second time to handle the event. But it is slightly inconvenient. This commit adds the event for the initial set of irq to handle. As a result, the event can be handled even if it is the first time. The change has a benefit that the OHCI_PARAM_DEBUG_BUSRESETS bit in debug module parameter is always effective. Tested-by: Adam Goldman <adamg@pobox.com> Link: https://lore.kernel.org/r/20240501073238.72769-2-o-takashi@sakamocchi.jp Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
2024-05-06firewire: core: obsolete tcode check macros with inline functionsTakashi Sakamoto
This commit declares the helper functions to check tcode to obsolete the functional macros. Link: https://lore.kernel.org/r/20240428071347.409202-7-o-takashi@sakamocchi.jp Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
2024-05-06firewire: ohci: replace hard-coded values with common macrosTakashi Sakamoto
In the helper function for logging in 1394 ohci driver includes the hard-coded variables for transaction code. They can be replaced with the enumerations in UAPI header. Link: https://lore.kernel.org/r/20240428071347.409202-6-o-takashi@sakamocchi.jp Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
2024-05-06firewire: ohci: replace hard-coded values with inline functions for ↵Takashi Sakamoto
asynchronous packet header This commit replaces the hard-coded values with the common inline functions to serialize and deserialize the header of asynchronous packet. Link: https://lore.kernel.org/r/20240428071347.409202-5-o-takashi@sakamocchi.jp Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
2024-05-06firewire: ohci: replace local macros with common inline functions for ↵Takashi Sakamoto
asynchronous packet header This commit uses the common inline functions to serialize and deserialize header of asynchronous packet. Link: https://lore.kernel.org/r/20240428071347.409202-4-o-takashi@sakamocchi.jp Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
2024-05-06firewire: ohci: use pci_irq_vector() to retrieve allocated interrupt lineTakashi Sakamoto
The pci_irq_vector() is available to retrieve the allocated interrupt line instead of the direct access to the member of device structure. Link: https://lore.kernel.org/r/20240331135037.191479-5-o-takashi@sakamocchi.jp Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
2024-05-06firewire: ohci: obsolete usage of deprecated API for MSITakashi Sakamoto
The usage of the pair of pci_enable_msi() and pci_disable_msi() is deprecated. This commit uses the preferred pair of API for the purpose. The call of pci_alloc_irq_vectors() can have a subeffect to change the return value of pci_dev_msi_enabled(). Link: https://lore.kernel.org/r/20240331135037.191479-4-o-takashi@sakamocchi.jp Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
2024-05-06firewire: ohci: replace request_irq() with request_threaded_irq()Takashi Sakamoto
Nowadays request_irq() is a wrapper of request_threaded_irq(). The IRQ handler of 1394 ohci driver has never been optimized yet, while it is a good preparation for the future work to replace the latter. This commit replaces the former. Link: https://lore.kernel.org/r/20240331135037.191479-3-o-takashi@sakamocchi.jp Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
2024-05-06Revert "firewire: ohci: use devres for requested IRQ"Takashi Sakamoto
This reverts commit 5a95f1ded28691e69f7d6718c5dcbc149613d431. As long as allocating any device interrupt vector for MSI, it is inconvenient to utilize managed device resources for IRQ requesting. Link: https://lore.kernel.org/r/20240331135037.191479-2-o-takashi@sakamocchi.jp Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
2024-04-29firewire: ohci: fulfill timestamp for some local asynchronous transactionTakashi Sakamoto
1394 OHCI driver generates packet data for the response subaction to the request subaction to some local registers. In the case, the driver should assign timestamp to them by itself. This commit fulfills the timestamp for the subaction. Cc: stable@vger.kernel.org Fixes: dcadfd7f7c74 ("firewire: core: use union for callback of transaction completion") Link: https://lore.kernel.org/r/20240429084709.707473-1-o-takashi@sakamocchi.jp Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
2024-04-06firewire: ohci: mask bus reset interrupts between ISR and bottom halfAdam Goldman
In the FireWire OHCI interrupt handler, if a bus reset interrupt has occurred, mask bus reset interrupts until bus_reset_work has serviced and cleared the interrupt. Normally, we always leave bus reset interrupts masked. We infer the bus reset from the self-ID interrupt that happens shortly thereafter. A scenario where we unmask bus reset interrupts was introduced in 2008 in a007bb857e0b26f5d8b73c2ff90782d9c0972620: If OHCI_PARAM_DEBUG_BUSRESETS (8) is set in the debug parameter bitmask, we will unmask bus reset interrupts so we can log them. irq_handler logs the bus reset interrupt. However, we can't clear the bus reset event flag in irq_handler, because we won't service the event until later. irq_handler exits with the event flag still set. If the corresponding interrupt is still unmasked, the first bus reset will usually freeze the system due to irq_handler being called again each time it exits. This freeze can be reproduced by loading firewire_ohci with "modprobe firewire_ohci debug=-1" (to enable all debugging output). Apparently there are also some cases where bus_reset_work will get called soon enough to clear the event, and operation will continue normally. This freeze was first reported a few months after a007bb85 was committed, but until now it was never fixed. The debug level could safely be set to -1 through sysfs after the module was loaded, but this would be ineffectual in logging bus reset interrupts since they were only unmasked during initialization. irq_handler will now leave the event flag set but mask bus reset interrupts, so irq_handler won't be called again and there will be no freeze. If OHCI_PARAM_DEBUG_BUSRESETS is enabled, bus_reset_work will unmask the interrupt after servicing the event, so future interrupts will be caught as desired. As a side effect to this change, OHCI_PARAM_DEBUG_BUSRESETS can now be enabled through sysfs in addition to during initial module loading. However, when enabled through sysfs, logging of bus reset interrupts will be effective only starting with the second bus reset, after bus_reset_work has executed. Signed-off-by: Adam Goldman <adamg@pobox.com> Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>