From patchwork Thu Sep 23 11:51:29 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian Hunter X-Patchwork-Id: 201742 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id o8NBpqfb030632 for ; Thu, 23 Sep 2010 11:51:57 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754667Ab0IWLv5 (ORCPT ); Thu, 23 Sep 2010 07:51:57 -0400 Received: from smtp.nokia.com ([192.100.122.233]:46551 "EHLO mgw-mx06.nokia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754652Ab0IWLv5 (ORCPT ); Thu, 23 Sep 2010 07:51:57 -0400 Received: from vaebh106.NOE.Nokia.com (vaebh106.europe.nokia.com [10.160.244.32]) by mgw-mx06.nokia.com (Switch-3.3.3/Switch-3.3.3) with ESMTP id o8NBpfjd015508; Thu, 23 Sep 2010 14:51:52 +0300 Received: from vaebh104.NOE.Nokia.com ([10.160.244.30]) by vaebh106.NOE.Nokia.com with Microsoft SMTPSVC(6.0.3790.4675); Thu, 23 Sep 2010 14:51:49 +0300 Received: from mgw-da01.ext.nokia.com ([147.243.128.24]) by vaebh104.NOE.Nokia.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Thu, 23 Sep 2010 14:51:35 +0300 Received: from ahunter-work.research.nokia.com (esdhcp034137.research.nokia.com [172.21.34.137]) by mgw-da01.ext.nokia.com (Switch-3.3.3/Switch-3.3.3) with ESMTP id o8NBpUFk004114; Thu, 23 Sep 2010 14:51:30 +0300 From: Adrian Hunter To: Chris Ball Cc: linux-mmc Mailing List , Adrian Hunter Date: Thu, 23 Sep 2010 14:51:29 +0300 Message-Id: <20100923115129.18000.59696.sendpatchset@ahunter-work.research.nokia.com> In-Reply-To: <20100923115122.18000.46750.sendpatchset@ahunter-work.research.nokia.com> References: <20100923115122.18000.46750.sendpatchset@ahunter-work.research.nokia.com> Subject: [PATCH 1/2] mmc_test: fix memory allocation segment limits X-OriginalArrivalTime: 23 Sep 2010 11:51:35.0761 (UTC) FILETIME=[AC8DDC10:01CB5B15] X-Nokia-AV: Clean Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Thu, 23 Sep 2010 11:51:58 +0000 (UTC) diff --git a/drivers/mmc/card/mmc_test.c b/drivers/mmc/card/mmc_test.c index 6580af7..5874040 100644 --- a/drivers/mmc/card/mmc_test.c +++ b/drivers/mmc/card/mmc_test.c @@ -318,8 +318,8 @@ static struct mmc_test_mem *mmc_test_alloc_mem(unsigned long min_sz, if (max_page_cnt > limit) max_page_cnt = limit; - if (max_page_cnt < min_page_cnt) - max_page_cnt = min_page_cnt; + if (min_page_cnt > max_page_cnt) + min_page_cnt = max_page_cnt; if (max_seg_page_cnt > max_page_cnt) max_seg_page_cnt = max_page_cnt; @@ -359,13 +359,13 @@ static struct mmc_test_mem *mmc_test_alloc_mem(unsigned long min_sz, mem->cnt += 1; if (max_page_cnt <= (1UL << order)) break; + max_page_cnt -= 1UL << order; + page_cnt += 1UL << order; if (mem->cnt >= max_segs) { if (page_cnt < min_page_cnt) goto out_free; break; } - max_page_cnt -= 1UL << order; - page_cnt += 1UL << order; } return mem; @@ -1470,12 +1470,12 @@ static int mmc_test_area_init(struct mmc_test_card *test, int erase, int fill) t->max_tfr = t->max_segs * t->max_seg_sz; /* - * Try to allocate enough memory for the whole area. Less is OK + * Try to allocate enough memory for a max. sized transfer. Less is OK * because the same memory can be mapped into the scatterlist more than * once. Also, take into account the limits imposed on scatterlist * segments by the host driver. */ - t->mem = mmc_test_alloc_mem(min_sz, t->max_sz, t->max_segs, + t->mem = mmc_test_alloc_mem(min_sz, t->max_tfr, t->max_segs, t->max_seg_sz); if (!t->mem) return -ENOMEM;