From: Roland Dreier <roland@topspin.com>
To: akpm@osdl.org
Cc: linux-kernel@vger.kernel.org, openib-general@openib.org
Subject: [PATCH][14/27] IB/mthca: fix MTT allocation in mem-free mode
Date: Fri, 1 Apr 2005 12:49:53 -0800 [thread overview]
Message-ID: <2005411249.E7CWkenJFFkWDs2q@topspin.com> (raw)
In-Reply-To: <2005411249.0FJpqa4lTtcUTWSU@topspin.com>
Fix bug in MTT allocation in mem-free mode.
I misunderstood the MTT size value returned by the firmware -- it is
really the size of a single MTT entry, since mem-free mode does not
segment the MTT as the original firmware did. This meant that our MTT
addresses ended up being off by a factor of 8. This meant that our
MTT allocations might overlap, and so we could overwrite and corrupt
earlier memory regions when writing new MTT entries.
We fix this by always using our 64-byte MTT segment size. This allows
some simplification of the code as well, since there's no reason to
put the MTT segment size in a variable -- we can always use our enum
value directly.
Signed-off-by: Roland Dreier <roland@topspin.com>
--- linux-export.orig/drivers/infiniband/hw/mthca/mthca_cmd.c 2005-04-01 12:38:20.843436141 -0800
+++ linux-export/drivers/infiniband/hw/mthca/mthca_cmd.c 2005-04-01 12:38:25.574409178 -0800
@@ -990,7 +990,6 @@
MTHCA_GET(field, outbox, QUERY_DEV_LIM_MAX_SG_RQ_OFFSET);
dev_lim->max_sg = min_t(int, field, dev_lim->max_sg);
MTHCA_GET(size, outbox, QUERY_DEV_LIM_MTT_ENTRY_SZ_OFFSET);
- dev_lim->mtt_seg_sz = size;
MTHCA_GET(size, outbox, QUERY_DEV_LIM_MPT_ENTRY_SZ_OFFSET);
dev_lim->mpt_entry_sz = size;
MTHCA_GET(field, outbox, QUERY_DEV_LIM_PBL_SZ_OFFSET);
@@ -1018,7 +1017,6 @@
} else {
MTHCA_GET(field, outbox, QUERY_DEV_LIM_MAX_AV_OFFSET);
dev_lim->hca.tavor.max_avs = 1 << (field & 0x3f);
- dev_lim->mtt_seg_sz = MTHCA_MTT_SEG_SIZE;
dev_lim->mpt_entry_sz = MTHCA_MPT_ENTRY_SIZE;
}
--- linux-export.orig/drivers/infiniband/hw/mthca/mthca_cmd.h 2005-03-31 19:06:42.000000000 -0800
+++ linux-export/drivers/infiniband/hw/mthca/mthca_cmd.h 2005-04-01 12:38:25.578408310 -0800
@@ -162,7 +162,6 @@
int cqc_entry_sz;
int srq_entry_sz;
int uar_scratch_entry_sz;
- int mtt_seg_sz;
int mpt_entry_sz;
union {
struct {
--- linux-export.orig/drivers/infiniband/hw/mthca/mthca_dev.h 2005-03-31 19:06:41.000000000 -0800
+++ linux-export/drivers/infiniband/hw/mthca/mthca_dev.h 2005-04-01 12:38:25.561412000 -0800
@@ -121,7 +121,6 @@
int reserved_eqs;
int num_mpts;
int num_mtt_segs;
- int mtt_seg_size;
int reserved_mtts;
int reserved_mrws;
int reserved_uars;
--- linux-export.orig/drivers/infiniband/hw/mthca/mthca_main.c 2005-04-01 12:38:23.852782896 -0800
+++ linux-export/drivers/infiniband/hw/mthca/mthca_main.c 2005-04-01 12:38:25.566410914 -0800
@@ -390,7 +390,7 @@
}
mdev->mr_table.mtt_table = mthca_alloc_icm_table(mdev, init_hca->mtt_base,
- dev_lim->mtt_seg_sz,
+ MTHCA_MTT_SEG_SIZE,
mdev->limits.num_mtt_segs,
mdev->limits.reserved_mtts, 1);
if (!mdev->mr_table.mtt_table) {
--- linux-export.orig/drivers/infiniband/hw/mthca/mthca_mr.c 2005-04-01 12:38:22.968974746 -0800
+++ linux-export/drivers/infiniband/hw/mthca/mthca_mr.c 2005-04-01 12:38:25.582407442 -0800
@@ -263,7 +263,7 @@
goto err_out_mpt_free;
}
- for (i = dev->limits.mtt_seg_size / 8, mr->order = 0;
+ for (i = MTHCA_MTT_SEG_SIZE / 8, mr->order = 0;
i < list_len;
i <<= 1, ++mr->order)
; /* nothing */
@@ -286,7 +286,7 @@
mtt_entry = MAILBOX_ALIGN(mailbox);
mtt_entry[0] = cpu_to_be64(dev->mr_table.mtt_base +
- mr->first_seg * dev->limits.mtt_seg_size);
+ mr->first_seg * MTHCA_MTT_SEG_SIZE);
mtt_entry[1] = 0;
for (i = 0; i < list_len; ++i)
mtt_entry[i + 2] = cpu_to_be64(buffer_list[i] |
@@ -330,7 +330,7 @@
memset(&mpt_entry->lkey, 0,
sizeof *mpt_entry - offsetof(struct mthca_mpt_entry, lkey));
mpt_entry->mtt_seg = cpu_to_be64(dev->mr_table.mtt_base +
- mr->first_seg * dev->limits.mtt_seg_size);
+ mr->first_seg * MTHCA_MTT_SEG_SIZE);
if (0) {
mthca_dbg(dev, "Dumping MPT entry %08x:\n", mr->ibmr.lkey);
--- linux-export.orig/drivers/infiniband/hw/mthca/mthca_profile.c 2005-04-01 12:38:21.237350633 -0800
+++ linux-export/drivers/infiniband/hw/mthca/mthca_profile.c 2005-04-01 12:38:25.570410046 -0800
@@ -95,7 +95,7 @@
profile[MTHCA_RES_RDB].size = MTHCA_RDB_ENTRY_SIZE;
profile[MTHCA_RES_MCG].size = MTHCA_MGM_ENTRY_SIZE;
profile[MTHCA_RES_MPT].size = dev_lim->mpt_entry_sz;
- profile[MTHCA_RES_MTT].size = dev_lim->mtt_seg_sz;
+ profile[MTHCA_RES_MTT].size = MTHCA_MTT_SEG_SIZE;
profile[MTHCA_RES_UAR].size = dev_lim->uar_scratch_entry_sz;
profile[MTHCA_RES_UDAV].size = MTHCA_AV_SIZE;
profile[MTHCA_RES_UARC].size = request->uarc_size;
@@ -229,10 +229,9 @@
break;
case MTHCA_RES_MTT:
dev->limits.num_mtt_segs = profile[i].num;
- dev->limits.mtt_seg_size = dev_lim->mtt_seg_sz;
dev->mr_table.mtt_base = profile[i].start;
init_hca->mtt_base = profile[i].start;
- init_hca->mtt_seg_sz = ffs(dev_lim->mtt_seg_sz) - 7;
+ init_hca->mtt_seg_sz = ffs(MTHCA_MTT_SEG_SIZE) - 7;
break;
case MTHCA_RES_UAR:
dev->limits.num_uars = profile[i].num;
next prev parent reply other threads:[~2005-04-01 20:57 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-04-01 20:49 [PATCH][1/27] IB/mthca: map MPT/MTT context in mem-free mode Roland Dreier
2005-04-01 20:49 ` [PATCH][2/27] IB/mthca: fill in more device query fields Roland Dreier
2005-04-01 20:49 ` [PATCH][3/27] IB/mthca: fix calculation of RDB shift Roland Dreier
2005-04-01 20:49 ` [PATCH][4/27] IB/mthca: fix posting sends with immediate data Roland Dreier
2005-04-01 20:49 ` [PATCH][5/27] IB/mthca: allow unaligned memory regions Roland Dreier
2005-04-01 20:49 ` [PATCH][6/27] IB/mthca: allocate correct number of doorbell pages Roland Dreier
2005-04-01 20:49 ` [PATCH][7/27] IB/mthca: clean up mthca_dereg_mr() Roland Dreier
2005-04-01 20:49 ` [PATCH][8/27] IB/mthca: fix MR allocation error path Roland Dreier
2005-04-01 20:49 ` [PATCH][9/27] IB/mthca: release mutex on doorbell alloc " Roland Dreier
2005-04-01 20:49 ` [PATCH][10/27] IB/mthca: print assigned IRQ when interrupt test fails Roland Dreier
2005-04-01 20:49 ` [PATCH][11/27] IB/mthca: only free doorbell records in mem-free mode Roland Dreier
2005-04-01 20:49 ` [PATCH][12/27] IB/mthca: fix format of CQ number for CQ events Roland Dreier
2005-04-01 20:49 ` [PATCH][13/27] IB/mthca: implement RDMA/atomic operations for mem-free mode Roland Dreier
2005-04-01 20:49 ` Roland Dreier [this message]
2005-04-01 20:49 ` [PATCH][15/27] IB/mthca: fill in opcode field for send completions Roland Dreier
2005-04-01 20:49 ` [PATCH][16/27] IB/mthca: allow address handle creation in interrupt context Roland Dreier
2005-04-01 20:49 ` [PATCH][17/27] IB/mthca: encapsulate MTT buddy allocator Roland Dreier
2005-04-01 20:49 ` [PATCH][18/27] IB/mthca: add SYNC_TPT firmware command Roland Dreier
2005-04-01 20:49 ` [PATCH][19/27] IB/mthca: add mthca_write64_raw() for writing to MTT table directly Roland Dreier
2005-04-01 20:49 ` [PATCH][20/27] IB/mthca: add mthca_table_find() function Roland Dreier
2005-04-01 20:49 ` [PATCH][21/27] IB/mthca: split MR key munging routines Roland Dreier
2005-04-01 20:49 ` [PATCH][22/27] IB/mthca: add fast memory region implementation Roland Dreier
2005-04-01 20:49 ` [PATCH][23/27] IB/mthca: tweaks to mthca_cmd.c Roland Dreier
2005-04-01 20:49 ` [PATCH][24/27] IB/mthca: encapsulate mem-free check into mthca_is_memfree() Roland Dreier
2005-04-01 20:49 ` [PATCH][25/27] IB/mthca: map context for RDMA responder in mem-free mode Roland Dreier
2005-04-01 20:49 ` [PATCH][26/27] IB/mthca: update receive queue initialization for new HCAs Roland Dreier
2005-04-01 20:49 ` [PATCH][27/27] IB/mthca: add support for new MT25204 HCA Roland Dreier
2005-04-01 22:06 ` [PATCH][26.5/27] Add MT25204 PCI IDs Roland Dreier
2005-04-08 0:10 ` Greg KH
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2005411249.E7CWkenJFFkWDs2q@topspin.com \
--to=roland@topspin.com \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=openib-general@openib.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox