[ofa-general] [PATCH 1 of 2] mthca: mthca_QUERY_ADAPTER reads fields which are reserved in memfree

Jack Morgenstein jackm at dev.mellanox.co.il
Sun Jan 27 08:13:20 PST 2008


mthca: For memfree devices, obtain revision ID from MAD_IFC, not QUERY_ADAPTER

For memfree devices, the firmware QUERY_ADAPTER command does not return
vendor_id, device_id, and revision_id; do not return these fields in the
QUERY_ADAPTER function for memfree devices.

In addition, for memfree devices, initialize the rev_id field of the
mthca device via init_node_data (MAD IFC query), as is done in the
query_device verb implementation.

Signed-off-by: Jack Morgenstein <jackm at dev.mellanox.co.il>

---

Roland,
I left the non-memfree implementation as it was before.  Its possible that
the memfree implementation is good for non-memfree as well, in which case
the "if (mthca_is_memfree)" conditions can be eliminated (i.e., just
use the memfree implementation unconditionally).

Jack

Index: ofed_kernel/drivers/infiniband/hw/mthca/mthca_cmd.c
===================================================================
--- ofed_kernel.orig/drivers/infiniband/hw/mthca/mthca_cmd.c	2008-01-27 15:56:24.000000000 +0200
+++ ofed_kernel/drivers/infiniband/hw/mthca/mthca_cmd.c	2008-01-27 16:28:42.134053000 +0200
@@ -1254,10 +1254,14 @@ int mthca_QUERY_ADAPTER(struct mthca_dev
 
 	if (err)
 		goto out;
-
-	MTHCA_GET(adapter->vendor_id, outbox,   QUERY_ADAPTER_VENDOR_ID_OFFSET);
-	MTHCA_GET(adapter->device_id, outbox,   QUERY_ADAPTER_DEVICE_ID_OFFSET);
-	MTHCA_GET(adapter->revision_id, outbox, QUERY_ADAPTER_REVISION_ID_OFFSET);
+	if (!mthca_is_memfree(dev)) {
+		MTHCA_GET(adapter->vendor_id, outbox,
+			  QUERY_ADAPTER_VENDOR_ID_OFFSET);
+		MTHCA_GET(adapter->device_id, outbox,
+			  QUERY_ADAPTER_DEVICE_ID_OFFSET);
+		MTHCA_GET(adapter->revision_id, outbox,
+			  QUERY_ADAPTER_REVISION_ID_OFFSET);
+	}
 	MTHCA_GET(adapter->inta_pin, outbox,    QUERY_ADAPTER_INTA_PIN_OFFSET);
 
 	get_board_id(outbox + QUERY_ADAPTER_VSD_OFFSET / 4,
Index: ofed_kernel/drivers/infiniband/hw/mthca/mthca_main.c
===================================================================
--- ofed_kernel.orig/drivers/infiniband/hw/mthca/mthca_main.c	2008-01-27 15:56:24.000000000 +0200
+++ ofed_kernel/drivers/infiniband/hw/mthca/mthca_main.c	2008-01-27 16:30:20.490528000 +0200
@@ -744,7 +744,8 @@ static int mthca_init_hca(struct mthca_d
 	}
 
 	mdev->eq_table.inta_pin = adapter.inta_pin;
-	mdev->rev_id            = adapter.revision_id;
+	if (!mthca_is_memfree(mdev))
+		mdev->rev_id = adapter.revision_id;
 	memcpy(mdev->board_id, adapter.board_id, sizeof mdev->board_id);
 
 	return 0;
Index: ofed_kernel/drivers/infiniband/hw/mthca/mthca_provider.c
===================================================================
--- ofed_kernel.orig/drivers/infiniband/hw/mthca/mthca_provider.c	2007-08-08 11:51:43.000000000 +0300
+++ ofed_kernel/drivers/infiniband/hw/mthca/mthca_provider.c	2008-01-27 16:37:12.097729000 +0200
@@ -1270,6 +1270,8 @@ static int mthca_init_node_data(struct m
 		goto out;
 	}
 
+	if (mthca_is_memfree(dev))
+		dev->rev_id = be32_to_cpup((__be32 *) (out_mad->data + 32));
 	memcpy(&dev->ib_dev.node_guid, out_mad->data + 12, 8);
 
 out:



More information about the general mailing list