tree 98ac8725b5afaeb8f8c53307b9902eecf74305b7
parent 8f6901534a91a5c5a0aff3f1cddbd261a6c39949
author Michael S. Tsirkin <[EMAIL PROTECTED]> Tue Apr 12 08:26:55 2005
committer Linus Torvalds <[EMAIL PROTECTED]> Tue Apr 12 08:26:55 2005
[PATCH] IB/mthca: add mthca_table_find() function
Add mthca_table_find() function, which returns the lowmem address of an entry
in a mem-free HCA's context tables. This will be used by the FMR
implementation.
Signed-off-by: Michael S. Tsirkin <[EMAIL PROTECTED]>
Signed-off-by: Roland Dreier <[EMAIL PROTECTED]>
Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
Signed-off-by: Linus Torvalds <[EMAIL PROTECTED]>
mthca_memfree.c | 34 ++++++++++++++++++++++++++++++++++
mthca_memfree.h | 1 +
2 files changed, 35 insertions(+)
Index: drivers/infiniband/hw/mthca/mthca_memfree.c
===================================================================
---
83d6c51589eb595e9928bf0224228df2605a7853/drivers/infiniband/hw/mthca/mthca_memfree.c
(mode:100644 sha1:e650a32c941bbbd5746239f1c3499c58782726db)
+++
98ac8725b5afaeb8f8c53307b9902eecf74305b7/drivers/infiniband/hw/mthca/mthca_memfree.c
(mode:100644 sha1:f832c379e6daf67c15fca3421c5c5ae4f62e1319)
@@ -192,6 +192,40 @@
up(&table->mutex);
}
+void *mthca_table_find(struct mthca_icm_table *table, int obj)
+{
+ int idx, offset, i;
+ struct mthca_icm_chunk *chunk;
+ struct mthca_icm *icm;
+ struct page *page = NULL;
+
+ if (!table->lowmem)
+ return NULL;
+
+ down(&table->mutex);
+
+ idx = (obj & (table->num_obj - 1)) * table->obj_size;
+ icm = table->icm[idx / MTHCA_TABLE_CHUNK_SIZE];
+ offset = idx % MTHCA_TABLE_CHUNK_SIZE;
+
+ if (!icm)
+ goto out;
+
+ list_for_each_entry(chunk, &icm->chunk_list, list) {
+ for (i = 0; i < chunk->npages; ++i) {
+ if (chunk->mem[i].length >= offset) {
+ page = chunk->mem[i].page;
+ break;
+ }
+ offset -= chunk->mem[i].length;
+ }
+ }
+
+out:
+ up(&table->mutex);
+ return page ? lowmem_page_address(page) + offset : NULL;
+}
+
int mthca_table_get_range(struct mthca_dev *dev, struct mthca_icm_table *table,
int start, int end)
{
Index: drivers/infiniband/hw/mthca/mthca_memfree.h
===================================================================
---
83d6c51589eb595e9928bf0224228df2605a7853/drivers/infiniband/hw/mthca/mthca_memfree.h
(mode:100644 sha1:6dfc0ba9e4d539ac3abc1371e15060bf739e19f6)
+++
98ac8725b5afaeb8f8c53307b9902eecf74305b7/drivers/infiniband/hw/mthca/mthca_memfree.h
(mode:100644 sha1:df2cff295126f28bbf47983d3d64cb6788fa40d3)
@@ -85,6 +85,7 @@
void mthca_free_icm_table(struct mthca_dev *dev, struct mthca_icm_table
*table);
int mthca_table_get(struct mthca_dev *dev, struct mthca_icm_table *table, int
obj);
void mthca_table_put(struct mthca_dev *dev, struct mthca_icm_table *table, int
obj);
+void *mthca_table_find(struct mthca_icm_table *table, int obj);
int mthca_table_get_range(struct mthca_dev *dev, struct mthca_icm_table *table,
int start, int end);
void mthca_table_put_range(struct mthca_dev *dev, struct mthca_icm_table
*table,
-
To unsubscribe from this list: send the line "unsubscribe bk-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at http://vger.kernel.org/majordomo-info.html