diff options
author | Eli Cohen <eli@mellanox.com> | 2013-09-11 09:35:28 -0400 |
---|---|---|
committer | Roland Dreier <roland@purestorage.com> | 2013-10-10 12:23:57 -0400 |
commit | dabed0e6319a1900c8738676bd197f06b5b5b6cc (patch) | |
tree | 3922f49b017b888e29efc5e35ccbf697ac057623 /drivers/net | |
parent | a0c84c326f720c3e3ebb9c49cbce916c05a57297 (diff) |
mlx5: Keep polling to reclaim pages while any returned
Change mlx5_reclaim_startup_pages() to keep polling while any pages
are returned. If none are returned, keep polling for five more seconds
before exiting with an error message.
Signed-off-by: Eli Cohen <eli@mellanox.com>
Signed-off-by: Roland Dreier <roland@purestorage.com>
Diffstat (limited to 'drivers/net')
-rw-r--r-- | drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c b/drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c index 3a2408d44820..7b12acf210f8 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c | |||
@@ -90,6 +90,10 @@ struct mlx5_manage_pages_outbox { | |||
90 | __be64 pas[0]; | 90 | __be64 pas[0]; |
91 | }; | 91 | }; |
92 | 92 | ||
93 | enum { | ||
94 | MAX_RECLAIM_TIME_MSECS = 5000, | ||
95 | }; | ||
96 | |||
93 | static int insert_page(struct mlx5_core_dev *dev, u64 addr, struct page *page, u16 func_id) | 97 | static int insert_page(struct mlx5_core_dev *dev, u64 addr, struct page *page, u16 func_id) |
94 | { | 98 | { |
95 | struct rb_root *root = &dev->priv.page_root; | 99 | struct rb_root *root = &dev->priv.page_root; |
@@ -279,6 +283,9 @@ static int reclaim_pages(struct mlx5_core_dev *dev, u32 func_id, int npages, | |||
279 | int err; | 283 | int err; |
280 | int i; | 284 | int i; |
281 | 285 | ||
286 | if (nclaimed) | ||
287 | *nclaimed = 0; | ||
288 | |||
282 | memset(&in, 0, sizeof(in)); | 289 | memset(&in, 0, sizeof(in)); |
283 | outlen = sizeof(*out) + npages * sizeof(out->pas[0]); | 290 | outlen = sizeof(*out) + npages * sizeof(out->pas[0]); |
284 | out = mlx5_vzalloc(outlen); | 291 | out = mlx5_vzalloc(outlen); |
@@ -388,20 +395,25 @@ static int optimal_reclaimed_pages(void) | |||
388 | 395 | ||
389 | int mlx5_reclaim_startup_pages(struct mlx5_core_dev *dev) | 396 | int mlx5_reclaim_startup_pages(struct mlx5_core_dev *dev) |
390 | { | 397 | { |
391 | unsigned long end = jiffies + msecs_to_jiffies(5000); | 398 | unsigned long end = jiffies + msecs_to_jiffies(MAX_RECLAIM_TIME_MSECS); |
392 | struct fw_page *fwp; | 399 | struct fw_page *fwp; |
393 | struct rb_node *p; | 400 | struct rb_node *p; |
401 | int nclaimed = 0; | ||
394 | int err; | 402 | int err; |
395 | 403 | ||
396 | do { | 404 | do { |
397 | p = rb_first(&dev->priv.page_root); | 405 | p = rb_first(&dev->priv.page_root); |
398 | if (p) { | 406 | if (p) { |
399 | fwp = rb_entry(p, struct fw_page, rb_node); | 407 | fwp = rb_entry(p, struct fw_page, rb_node); |
400 | err = reclaim_pages(dev, fwp->func_id, optimal_reclaimed_pages(), NULL); | 408 | err = reclaim_pages(dev, fwp->func_id, |
409 | optimal_reclaimed_pages(), | ||
410 | &nclaimed); | ||
401 | if (err) { | 411 | if (err) { |
402 | mlx5_core_warn(dev, "failed reclaiming pages (%d)\n", err); | 412 | mlx5_core_warn(dev, "failed reclaiming pages (%d)\n", err); |
403 | return err; | 413 | return err; |
404 | } | 414 | } |
415 | if (nclaimed) | ||
416 | end = jiffies + msecs_to_jiffies(MAX_RECLAIM_TIME_MSECS); | ||
405 | } | 417 | } |
406 | if (time_after(jiffies, end)) { | 418 | if (time_after(jiffies, end)) { |
407 | mlx5_core_warn(dev, "FW did not return all pages. giving up...\n"); | 419 | mlx5_core_warn(dev, "FW did not return all pages. giving up...\n"); |