firewire: core: option to log bus reset initiation
authorAdam Goldman <adamg@pobox.com>
Sun, 24 Mar 2024 22:37:25 +0000 (07:37 +0900)
committerTakashi Sakamoto <o-takashi@sakamocchi.jp>
Mon, 6 May 2024 02:06:03 +0000 (11:06 +0900)
Add a debug parameter to firewire-core, analogous to the one in
firewire-ohci. When this is set to 1, log when we schedule, delay, or
initiate a bus reset. Since FireWire bus resets can originate from any
node on the bus, specific logging of the resets we initiate provides
additional insight.

Signed-off-by: Adam Goldman <adamg@pobox.com>
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
drivers/firewire/core-card.c
drivers/firewire/core-transaction.c
drivers/firewire/core.h

index 401a77e3b5fa8ed9e9b834c4a55cde98d2b2a8db..dac1b0fc7a42872d1d20414af7f894b00fc605f1 100644 (file)
@@ -221,11 +221,19 @@ static int reset_bus(struct fw_card *card, bool short_reset)
        int reg = short_reset ? 5 : 1;
        int bit = short_reset ? PHY_BUS_SHORT_RESET : PHY_BUS_RESET;
 
+       if (unlikely(fw_core_param_debug & FW_CORE_PARAM_DEBUG_BUSRESETS))
+               fw_notice(card, "initiating %s bus reset\n",
+                         short_reset ? "short" : "long");
+
        return card->driver->update_phy_reg(card, reg, 0, bit);
 }
 
 void fw_schedule_bus_reset(struct fw_card *card, bool delayed, bool short_reset)
 {
+       if (unlikely(fw_core_param_debug & FW_CORE_PARAM_DEBUG_BUSRESETS))
+               fw_notice(card, "scheduling %s bus reset\n",
+                         short_reset ? "short" : "long");
+
        /* We don't try hard to sort out requests of long vs. short resets. */
        card->br_short = short_reset;
 
@@ -244,6 +252,8 @@ static void br_work(struct work_struct *work)
        /* Delay for 2s after last reset per IEEE 1394 clause 8.2.1. */
        if (card->reset_jiffies != 0 &&
            time_before64(get_jiffies_64(), card->reset_jiffies + 2 * HZ)) {
+               if (unlikely(fw_core_param_debug & FW_CORE_PARAM_DEBUG_BUSRESETS))
+                       fw_notice(card, "delaying bus reset\n");
                if (!queue_delayed_work(fw_workqueue, &card->br_work, 2 * HZ))
                        fw_card_put(card);
                return;
index 130b95aca629022d183461a0ec215c14366678c4..c427b7861eaf0e0224ae610b34e99a4d6507f421 100644 (file)
@@ -1385,5 +1385,12 @@ static void __exit fw_core_cleanup(void)
        idr_destroy(&fw_device_idr);
 }
 
+int fw_core_param_debug;
+module_param_named(debug, fw_core_param_debug, int, 0644);
+MODULE_PARM_DESC(debug, "Verbose logging (default = 0"
+       ", bus resets = "       __stringify(FW_CORE_PARAM_DEBUG_BUSRESETS)
+       ")");
+
+
 module_init(fw_core_init);
 module_exit(fw_core_cleanup);
index 95c10f3d2282f59c814b27c3440de2b69b34484d..ff96e5456b5de7c30929259a4ef850b0cf66075f 100644 (file)
@@ -238,6 +238,10 @@ static inline bool is_next_generation(int new_generation, int old_generation)
 /* OHCI-1394's default upper bound for physical DMA: 4 GB */
 #define FW_MAX_PHYSICAL_RANGE          (1ULL << 32)
 
+#define FW_CORE_PARAM_DEBUG_BUSRESETS  1
+
+extern int fw_core_param_debug;
+
 void fw_core_handle_request(struct fw_card *card, struct fw_packet *request);
 void fw_core_handle_response(struct fw_card *card, struct fw_packet *packet);
 int fw_get_response_length(struct fw_request *request);