firewire: support S100B...S400B and link slower than PHY
authorStefan Richter <stefanr@s5r6.in-berlin.de>
Sun, 10 Jun 2007 19:31:36 +0000 (21:31 +0200)
committerStefan Richter <stefanr@s5r6.in-berlin.de>
Mon, 9 Jul 2007 22:07:43 +0000 (00:07 +0200)
Use a speed probe to determine the speed over 1394b buses and of nodes
which report a link speed less than their PHY speed.

Log the effective maximum speed of newly created nodes in dmesg.

Also, read the config ROM (except bus info block) at the maximum speed
rather than S100.  This isn't a real optimization though because we
still only use quadlet read requests for the entire ROM.

The patch also adds support for S1600 and S3200, although such hardware
does not exist yet.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Signed-off-by: Kristian Høgsberg <krh@redhat.com>
drivers/firewire/fw-cdev.c
drivers/firewire/fw-device.c
drivers/firewire/fw-device.h
drivers/firewire/fw-sbp2.c
drivers/firewire/fw-topology.h

index dbb76427d52947d64e14f6c11855dac5be698650..75388641a7d34619f1a1ec1c11aa856e5d13fe6f 100644 (file)
@@ -397,7 +397,7 @@ static int ioctl_send_request(struct client *client, void *buffer)
                        request->tcode & 0x1f,
                        device->node->node_id,
                        request->generation,
-                       device->node->max_speed,
+                       device->max_speed,
                        request->offset,
                        response->response.data, request->length,
                        complete_transaction, response);
index c1ce465d97103b3855393cd79bdfd778d531d41b..2b6586341635b9ed57dafc5f6ebb977924177010 100644 (file)
@@ -401,8 +401,7 @@ static int read_rom(struct fw_device *device, int index, u32 * data)
 
        offset = 0xfffff0000400ULL + index * 4;
        fw_send_request(device->card, &t, TCODE_READ_QUADLET_REQUEST,
-                       device->node_id,
-                       device->generation, SCODE_100,
+                       device->node_id, device->generation, device->max_speed,
                        offset, NULL, 4, complete_transaction, &callback_data);
 
        wait_for_completion(&callback_data.done);
@@ -418,6 +417,8 @@ static int read_bus_info_block(struct fw_device *device)
        u32 stack[16], sp, key;
        int i, end, length;
 
+       device->max_speed = SCODE_100;
+
        /* First read the bus info block. */
        for (i = 0; i < 5; i++) {
                if (read_rom(device, i, &rom[i]) != RCODE_COMPLETE)
@@ -434,6 +435,33 @@ static int read_bus_info_block(struct fw_device *device)
                        return -1;
        }
 
+       device->max_speed = device->node->max_speed;
+
+       /*
+        * Determine the speed of
+        *   - devices with link speed less than PHY speed,
+        *   - devices with 1394b PHY (unless only connected to 1394a PHYs),
+        *   - all devices if there are 1394b repeaters.
+        * Note, we cannot use the bus info block's link_spd as starting point
+        * because some buggy firmwares set it lower than necessary and because
+        * 1394-1995 nodes do not have the field.
+        */
+       if ((rom[2] & 0x7) < device->max_speed ||
+           device->max_speed == SCODE_BETA ||
+           device->card->beta_repeaters_present) {
+               u32 dummy;
+
+               /* for S1600 and S3200 */
+               if (device->max_speed == SCODE_BETA)
+                       device->max_speed = device->card->link_speed;
+
+               while (device->max_speed > SCODE_100) {
+                       if (read_rom(device, 0, &dummy) == RCODE_COMPLETE)
+                               break;
+                       device->max_speed--;
+               }
+       }
+
        /*
         * Now parse the config rom.  The config rom is a recursive
         * directory structure so we parse it using a stack of
@@ -680,8 +708,10 @@ static void fw_device_init(struct work_struct *work)
                    FW_DEVICE_RUNNING) == FW_DEVICE_SHUTDOWN)
                fw_device_shutdown(&device->work.work);
        else
-               fw_notify("created new fw device %s (%d config rom retries)\n",
-                         device->device.bus_id, device->config_rom_retries);
+               fw_notify("created new fw device %s "
+                         "(%d config rom retries, S%d00)\n",
+                         device->device.bus_id, device->config_rom_retries,
+                         1 << device->max_speed);
 
        /*
         * Reschedule the IRM work if we just finished reading the
index af1723eae4ba6d7868d521fd340de08fdd993a9b..d13e6a69707ffe6265a32fbd92efbfb0b31497d1 100644 (file)
@@ -40,6 +40,7 @@ struct fw_device {
        struct fw_node *node;
        int node_id;
        int generation;
+       unsigned max_speed;
        struct fw_card *card;
        struct device device;
        struct list_head link;
index 16e942f72e48156cce7f603db8d5010df6fe13de..851c2da060d24175a7e059160029ce61a5dae56f 100644 (file)
@@ -346,8 +346,7 @@ sbp2_send_orb(struct sbp2_orb *orb, struct fw_unit *unit,
        spin_unlock_irqrestore(&device->card->lock, flags);
 
        fw_send_request(device->card, &orb->t, TCODE_WRITE_BLOCK_REQUEST,
-                       node_id, generation,
-                       device->node->max_speed, offset,
+                       node_id, generation, device->max_speed, offset,
                        &orb->pointer, sizeof(orb->pointer),
                        complete_transaction, orb);
 }
@@ -1018,8 +1017,8 @@ static int sbp2_scsi_queuecommand(struct scsi_cmnd *cmd, scsi_done_fn_t done)
         * if we set this to max_speed + 7, we get the right value.
         */
        orb->request.misc =
-               COMMAND_ORB_MAX_PAYLOAD(device->node->max_speed + 7) |
-               COMMAND_ORB_SPEED(device->node->max_speed) |
+               COMMAND_ORB_MAX_PAYLOAD(device->max_speed + 7) |
+               COMMAND_ORB_SPEED(device->max_speed) |
                COMMAND_ORB_NOTIFY;
 
        if (cmd->sc_data_direction == DMA_FROM_DEVICE)
index aced9f7db35805f25d8220a6cc44f53a29ba0ce1..da61ec09183e230b857652e4a61a125b78aa3dd4 100644 (file)
@@ -29,19 +29,18 @@ enum {
 
 struct fw_port {
        struct fw_node *node;
-       unsigned speed : 3; /* S100, S200, ... S3200 */
 };
 
 struct fw_node {
        u16 node_id;
        u8 color;
        u8 port_count;
-       unsigned link_on : 1;
-       unsigned initiated_reset : 1;
-       unsigned b_path : 1;
-       u8 phy_speed : 3; /* As in the self ID packet. */
-       u8 max_speed : 5; /* Minimum of all phy-speeds and port speeds on
-                          * the path from the local node to this node. */
+       u8 link_on : 1;
+       u8 initiated_reset : 1;
+       u8 b_path : 1;
+       u8 phy_speed : 2; /* As in the self ID packet. */
+       u8 max_speed : 2; /* Minimum of all phy-speeds on the path from the
+                          * local node to this node. */
        u8 max_depth : 4; /* Maximum depth to any leaf node */
        u8 max_hops : 4;  /* Max hops in this sub tree */
        atomic_t ref_count;