Commit graph

247 commits

Author SHA1 Message Date
Takashi Sakamoto
95a042a0c8 firewire: ohci: reduce the size of common context structure by extracting members into AT structure
In commit 386a4153a2 ("firewire: ohci: cache the context run bit"), a
running member was added to the context structure to cache the running
state of a given DMA context. Although this member is accessible from IR,
IT, and AT contexts, it is currently used only by the AT context.

Additionally, the context structure includes a work item, which is also
used by the AT context. Both members are unnecessary for IR and IT
contexts.

This commit refactors the code by moving these two members into a new
structure specific to AT context.

Link: https://lore.kernel.org/r/20250710131916.31289-1-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
2025-07-12 21:52:16 +09:00
Takashi Sakamoto
aef6bcc0f2 firewire: ohci: use workqueue to handle events of AT request/response contexts
This commit adds a work item to handle events of 1394 OHCI AT
request/response contexts, and queues the item to the specific
workqueue. The call of struct fw_packet.callbaqck() is done in the
workqueue when receiving acknowledgement to the asynchronous packet
transferred to remote node.

Link: https://lore.kernel.org/r/20250615133253.433057-4-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
2025-06-15 22:40:29 +09:00
Takashi Sakamoto
57e6d9f85f firewire: ohci: use workqueue to handle events of AR request/response contexts
This commit adds a work item to handle events of 1394 OHCI AR
request/response contexts, and queues the item to the specific workqueue.
The call of struct fw_address_handler.address_callback() is done in the
workqueue when receiving any requests from the remove nodes. Additionally,
the call of struct fw_packet.callback() is done in the workqueue too when
receiving acknowledge to the asynchronous packet for the response
subaction of split transaction to the remote nodes.

Link: https://lore.kernel.org/r/20250615133253.433057-3-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
2025-06-15 22:40:29 +09:00
Takashi Sakamoto
8ffef793bb firewire: ohci: use from_work() macro to expand parent structure of work_struct
A commit 60b2ebf485 ("workqueue: Introduce from_work() helper for cleaner
callback declarations") introduces a new macro to retrieve a poiner for the
parent structure of the work item. It is convenient to reduce input text.

This commit uses the macro in PCI driver for 1394 OHCI.

Link: https://lore.kernel.org/r/20250608233808.202355-2-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
2025-06-09 08:45:20 +09:00
Takashi Sakamoto
088eb0f161 firewire: ohci: correct code comments about bus_reset tasklet
The tasklet for bus reset event has been replaced with work item, while
some code comments still address to the tasklet.

This commit corrects them.

Fixes: 2d7a36e233 ("firewire: ohci: Move code from the bus reset tasklet into a workqueue")
Link: https://lore.kernel.org/r/20250608233808.202355-1-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
2025-06-09 08:44:51 +09:00
Vaibhav Gupta
892bb0740b firewire: ohci: use generic power management
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-12-08 10:03:13 +09:00
Philipp Stanner
b7688fcde3 firewire: ohci: Replace deprecated PCI functions
pcim_iomap_regions() and pcim_iomap_table() have been deprecated in
commit e354bb84a4 ("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-28 19:47:09 +09:00
Shen Lichuan
8f04019d71 firewire: Correct some typos
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-10-01 19:02:57 +09:00
Takashi Sakamoto
f1cba5212e firewire: core: rename cause flag of tracepoints event
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-12 22:30:38 +09:00
Takashi Sakamoto
5d567654be firewire: core: add helper function to retire descriptors
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-12 22:30:36 +09:00
Takashi Sakamoto
6ffa9bd6eb Revert "firewire: core: move workqueue handler from 1394 OHCI driver to core 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-12 22:30:35 +09:00
Takashi Sakamoto
c45b9a07b6 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>
2024-09-12 22:30:34 +09:00
Takashi Sakamoto
f877f1d81b firewire: core: use mutex to coordinate concurrent calls to flush completions
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-09 23:00:18 +09:00
Takashi Sakamoto
e97fb38fa1 firewire: core: move workqueue handler from 1394 OHCI driver to core function
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-09 23:00:17 +09:00
Takashi Sakamoto
446216bd8e firewire: core: expose kernel API to schedule work item to process 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-08 13:05:48 +09:00
Takashi Sakamoto
5390813c34 firewire: ohci: operate IT/IR events in sleepable work process instead of 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-04 21:51:52 +09:00
Takashi Sakamoto
c6fb88a527 firewire: core: allocate workqueue to handle isochronous contexts in card
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-04 21:51:50 +09:00
Takashi Sakamoto
7d35a00603 firewire: ohci: obsolete direct usage of printk_ratelimit()
A commit 77006a0a82 ("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-03 19:15:23 +09:00
Takashi Sakamoto
cd70237298 firewire: ohci: deprecate debug parameter
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-09-03 19:14:55 +09:00
Takashi Sakamoto
52f9fcbc7b firewire: ohci: fix error path to detect initiated reset in TI TSB41BA3D phy
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-17 18:11:28 +09:00
Takashi Sakamoto
e8b89bc158 firewire: core/ohci: minor refactoring for computation of configuration ROM size
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-14 22:12:22 +09:00
Takashi Sakamoto
d4dcb33973 firewire: ohci: remove unused wrapper macro for dev_info()
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-14 22:12:21 +09:00
Takashi Sakamoto
56a4832c9f firewire: ohci: use helper macro for compiler aligned attribute
The __aligned() macro has been available since v4.19 kernel by a commit
815f0ddb34 ("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-14 22:12:20 +09:00
Takashi Sakamoto
e4c8b8014f firewire: ohci: use guard macro to serialize operations for isochronous contexts
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-05 17:54:08 +09:00
Takashi Sakamoto
86baade948 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>
2024-08-05 17:54:07 +09:00
Takashi Sakamoto
b10e56fd0e firewire: ohci: use guard macro to maintain bus time
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-05 17:54:06 +09:00
Takashi Sakamoto
6d72fbc816 firewire: ohci: use guard macro to serialize accesses to phy registers
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-05 17:53:55 +09:00
Takashi Sakamoto
8a96e7be8c firewire: ohci: use static inline functions to serialize data of IT DMA
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-02 09:36:06 +09:00
Takashi Sakamoto
db7a8f5519 firewire: ohci: use static inline functions to serialize data of AT DMA
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-08-02 09:36:04 +09:00
Takashi Sakamoto
faa11b99c9 firewire: ohci: minor code refactoring to localize text table
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-29 22:46:30 +09:00
Takashi Sakamoto
568a8cbb3d firewire: ohci: use TCODE_LINK_INTERNAL consistently
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-29 22:46:29 +09:00
Takashi Sakamoto
9f349e8e53 Revert "firewire: ohci: use common macro to interpret be32 data in le32 buffer"
This reverts commit f26a38e61c, 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-08 06:42:39 +09:00
Takashi Sakamoto
526e21a2aa firewire: ohci: add tracepoints event for data of Self-ID DMA
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 d0b06dc48f ("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-04 09:07:14 +09:00
Takashi Sakamoto
4a13617ef3 firewire: ohci: use inline functions to operate data of self-ID DMA
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-04 08:12:48 +09:00
Takashi Sakamoto
c538b06de6 firewire: ohci: use static function to handle endian issue on PowerPC platform
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-04 08:12:48 +09:00
Takashi Sakamoto
f26a38e61c firewire: ohci: use common macro to interpret be32 data in le32 buffer
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-07-04 08:12:48 +09:00
Takashi Sakamoto
0d8914165d firewire: ohci: add tracepoints event for hardIRQ event
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-25 21:49:43 +09:00
Takashi Sakamoto
001c1ff5dc firewire: ohci: add support for Linux kernel tracepoints
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-25 21:49:43 +09:00
Takashi Sakamoto
daf763c2d6 firewire: core: add tracepoints events for completions of packets in 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-25 07:31:39 +09:00
Takashi Sakamoto
8320b63e02 firewire: core: add tracepoints events for flushing completions of 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-25 07:31:38 +09:00
Takashi Sakamoto
f9a228364e firewire: ohci: use helper inline functions to serialize/deserialize self ID 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-17 08:37:03 +09:00
Takashi Sakamoto
a16931ac6d firewire: ohci: use helper functions for self ID sequence
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-17 08:37:03 +09:00
Takashi Sakamoto
e404cacfc5 firewire: ohci: minor code refactoring for self ID logging
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-06-17 08:37:03 +09:00
Takashi Sakamoto
42374303b7 firewire: ohci: obsolete OHCI_PARAM_DEBUG_BUSRESETS from debug module parameter
The OHCI_PARAM_DEBUG_BUSRESETS bit of debug module parameter was added at
a commit a007bb857e ("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-06 11:06:06 +09:00
Takashi Sakamoto
0d12f095b4 firewire: ohci: add bus-reset event for initial set of handled irq
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-06 11:06:06 +09:00
Takashi Sakamoto
c5deb01849 firewire: core: obsolete tcode check macros with inline functions
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-06 11:06:05 +09:00
Takashi Sakamoto
2a0b46a988 firewire: ohci: replace hard-coded values with common macros
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-06 11:06:04 +09:00
Takashi Sakamoto
4af4361418 firewire: ohci: replace hard-coded values with inline functions for 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-06 11:06:04 +09:00
Takashi Sakamoto
1162825c9c firewire: ohci: replace local macros with common inline functions for 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-06 11:06:04 +09:00
Takashi Sakamoto
e41b2c1532 firewire: ohci: use pci_irq_vector() to retrieve allocated interrupt line
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-06 11:06:04 +09:00