aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mmc/card/mmc_test.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mmc/card/mmc_test.c')
-rw-r--r--drivers/mmc/card/mmc_test.c116
1 files changed, 57 insertions, 59 deletions
diff --git a/drivers/mmc/card/mmc_test.c b/drivers/mmc/card/mmc_test.c
index abc1a63bcc5e..233cdfae92f4 100644
--- a/drivers/mmc/card/mmc_test.c
+++ b/drivers/mmc/card/mmc_test.c
@@ -212,7 +212,7 @@ static int mmc_test_busy(struct mmc_command *cmd)
212static int mmc_test_wait_busy(struct mmc_test_card *test) 212static int mmc_test_wait_busy(struct mmc_test_card *test)
213{ 213{
214 int ret, busy; 214 int ret, busy;
215 struct mmc_command cmd; 215 struct mmc_command cmd = {0};
216 216
217 busy = 0; 217 busy = 0;
218 do { 218 do {
@@ -246,18 +246,13 @@ static int mmc_test_buffer_transfer(struct mmc_test_card *test,
246{ 246{
247 int ret; 247 int ret;
248 248
249 struct mmc_request mrq; 249 struct mmc_request mrq = {0};
250 struct mmc_command cmd; 250 struct mmc_command cmd = {0};
251 struct mmc_command stop; 251 struct mmc_command stop = {0};
252 struct mmc_data data; 252 struct mmc_data data = {0};
253 253
254 struct scatterlist sg; 254 struct scatterlist sg;
255 255
256 memset(&mrq, 0, sizeof(struct mmc_request));
257 memset(&cmd, 0, sizeof(struct mmc_command));
258 memset(&data, 0, sizeof(struct mmc_data));
259 memset(&stop, 0, sizeof(struct mmc_command));
260
261 mrq.cmd = &cmd; 256 mrq.cmd = &cmd;
262 mrq.data = &data; 257 mrq.data = &data;
263 mrq.stop = &stop; 258 mrq.stop = &stop;
@@ -731,15 +726,10 @@ static int mmc_test_simple_transfer(struct mmc_test_card *test,
731 struct scatterlist *sg, unsigned sg_len, unsigned dev_addr, 726 struct scatterlist *sg, unsigned sg_len, unsigned dev_addr,
732 unsigned blocks, unsigned blksz, int write) 727 unsigned blocks, unsigned blksz, int write)
733{ 728{
734 struct mmc_request mrq; 729 struct mmc_request mrq = {0};
735 struct mmc_command cmd; 730 struct mmc_command cmd = {0};
736 struct mmc_command stop; 731 struct mmc_command stop = {0};
737 struct mmc_data data; 732 struct mmc_data data = {0};
738
739 memset(&mrq, 0, sizeof(struct mmc_request));
740 memset(&cmd, 0, sizeof(struct mmc_command));
741 memset(&data, 0, sizeof(struct mmc_data));
742 memset(&stop, 0, sizeof(struct mmc_command));
743 733
744 mrq.cmd = &cmd; 734 mrq.cmd = &cmd;
745 mrq.data = &data; 735 mrq.data = &data;
@@ -761,18 +751,13 @@ static int mmc_test_simple_transfer(struct mmc_test_card *test,
761static int mmc_test_broken_transfer(struct mmc_test_card *test, 751static int mmc_test_broken_transfer(struct mmc_test_card *test,
762 unsigned blocks, unsigned blksz, int write) 752 unsigned blocks, unsigned blksz, int write)
763{ 753{
764 struct mmc_request mrq; 754 struct mmc_request mrq = {0};
765 struct mmc_command cmd; 755 struct mmc_command cmd = {0};
766 struct mmc_command stop; 756 struct mmc_command stop = {0};
767 struct mmc_data data; 757 struct mmc_data data = {0};
768 758
769 struct scatterlist sg; 759 struct scatterlist sg;
770 760
771 memset(&mrq, 0, sizeof(struct mmc_request));
772 memset(&cmd, 0, sizeof(struct mmc_command));
773 memset(&data, 0, sizeof(struct mmc_data));
774 memset(&stop, 0, sizeof(struct mmc_command));
775
776 mrq.cmd = &cmd; 761 mrq.cmd = &cmd;
777 mrq.data = &data; 762 mrq.data = &data;
778 mrq.stop = &stop; 763 mrq.stop = &stop;
@@ -1401,8 +1386,9 @@ static int mmc_test_area_io(struct mmc_test_card *test, unsigned long sz,
1401 */ 1386 */
1402static int mmc_test_area_fill(struct mmc_test_card *test) 1387static int mmc_test_area_fill(struct mmc_test_card *test)
1403{ 1388{
1404 return mmc_test_area_io(test, test->area.max_tfr, test->area.dev_addr, 1389 struct mmc_test_area *t = &test->area;
1405 1, 0, 0); 1390
1391 return mmc_test_area_io(test, t->max_tfr, t->dev_addr, 1, 0, 0);
1406} 1392}
1407 1393
1408/* 1394/*
@@ -1415,7 +1401,7 @@ static int mmc_test_area_erase(struct mmc_test_card *test)
1415 if (!mmc_can_erase(test->card)) 1401 if (!mmc_can_erase(test->card))
1416 return 0; 1402 return 0;
1417 1403
1418 return mmc_erase(test->card, t->dev_addr, test->area.max_sz >> 9, 1404 return mmc_erase(test->card, t->dev_addr, t->max_sz >> 9,
1419 MMC_ERASE_ARG); 1405 MMC_ERASE_ARG);
1420} 1406}
1421 1407
@@ -1542,8 +1528,10 @@ static int mmc_test_area_prepare_fill(struct mmc_test_card *test)
1542static int mmc_test_best_performance(struct mmc_test_card *test, int write, 1528static int mmc_test_best_performance(struct mmc_test_card *test, int write,
1543 int max_scatter) 1529 int max_scatter)
1544{ 1530{
1545 return mmc_test_area_io(test, test->area.max_tfr, test->area.dev_addr, 1531 struct mmc_test_area *t = &test->area;
1546 write, max_scatter, 1); 1532
1533 return mmc_test_area_io(test, t->max_tfr, t->dev_addr, write,
1534 max_scatter, 1);
1547} 1535}
1548 1536
1549/* 1537/*
@@ -1583,18 +1571,19 @@ static int mmc_test_best_write_perf_max_scatter(struct mmc_test_card *test)
1583 */ 1571 */
1584static int mmc_test_profile_read_perf(struct mmc_test_card *test) 1572static int mmc_test_profile_read_perf(struct mmc_test_card *test)
1585{ 1573{
1574 struct mmc_test_area *t = &test->area;
1586 unsigned long sz; 1575 unsigned long sz;
1587 unsigned int dev_addr; 1576 unsigned int dev_addr;
1588 int ret; 1577 int ret;
1589 1578
1590 for (sz = 512; sz < test->area.max_tfr; sz <<= 1) { 1579 for (sz = 512; sz < t->max_tfr; sz <<= 1) {
1591 dev_addr = test->area.dev_addr + (sz >> 9); 1580 dev_addr = t->dev_addr + (sz >> 9);
1592 ret = mmc_test_area_io(test, sz, dev_addr, 0, 0, 1); 1581 ret = mmc_test_area_io(test, sz, dev_addr, 0, 0, 1);
1593 if (ret) 1582 if (ret)
1594 return ret; 1583 return ret;
1595 } 1584 }
1596 sz = test->area.max_tfr; 1585 sz = t->max_tfr;
1597 dev_addr = test->area.dev_addr; 1586 dev_addr = t->dev_addr;
1598 return mmc_test_area_io(test, sz, dev_addr, 0, 0, 1); 1587 return mmc_test_area_io(test, sz, dev_addr, 0, 0, 1);
1599} 1588}
1600 1589
@@ -1603,6 +1592,7 @@ static int mmc_test_profile_read_perf(struct mmc_test_card *test)
1603 */ 1592 */
1604static int mmc_test_profile_write_perf(struct mmc_test_card *test) 1593static int mmc_test_profile_write_perf(struct mmc_test_card *test)
1605{ 1594{
1595 struct mmc_test_area *t = &test->area;
1606 unsigned long sz; 1596 unsigned long sz;
1607 unsigned int dev_addr; 1597 unsigned int dev_addr;
1608 int ret; 1598 int ret;
@@ -1610,8 +1600,8 @@ static int mmc_test_profile_write_perf(struct mmc_test_card *test)
1610 ret = mmc_test_area_erase(test); 1600 ret = mmc_test_area_erase(test);
1611 if (ret) 1601 if (ret)
1612 return ret; 1602 return ret;
1613 for (sz = 512; sz < test->area.max_tfr; sz <<= 1) { 1603 for (sz = 512; sz < t->max_tfr; sz <<= 1) {
1614 dev_addr = test->area.dev_addr + (sz >> 9); 1604 dev_addr = t->dev_addr + (sz >> 9);
1615 ret = mmc_test_area_io(test, sz, dev_addr, 1, 0, 1); 1605 ret = mmc_test_area_io(test, sz, dev_addr, 1, 0, 1);
1616 if (ret) 1606 if (ret)
1617 return ret; 1607 return ret;
@@ -1619,8 +1609,8 @@ static int mmc_test_profile_write_perf(struct mmc_test_card *test)
1619 ret = mmc_test_area_erase(test); 1609 ret = mmc_test_area_erase(test);
1620 if (ret) 1610 if (ret)
1621 return ret; 1611 return ret;
1622 sz = test->area.max_tfr; 1612 sz = t->max_tfr;
1623 dev_addr = test->area.dev_addr; 1613 dev_addr = t->dev_addr;
1624 return mmc_test_area_io(test, sz, dev_addr, 1, 0, 1); 1614 return mmc_test_area_io(test, sz, dev_addr, 1, 0, 1);
1625} 1615}
1626 1616
@@ -1629,6 +1619,7 @@ static int mmc_test_profile_write_perf(struct mmc_test_card *test)
1629 */ 1619 */
1630static int mmc_test_profile_trim_perf(struct mmc_test_card *test) 1620static int mmc_test_profile_trim_perf(struct mmc_test_card *test)
1631{ 1621{
1622 struct mmc_test_area *t = &test->area;
1632 unsigned long sz; 1623 unsigned long sz;
1633 unsigned int dev_addr; 1624 unsigned int dev_addr;
1634 struct timespec ts1, ts2; 1625 struct timespec ts1, ts2;
@@ -1640,8 +1631,8 @@ static int mmc_test_profile_trim_perf(struct mmc_test_card *test)
1640 if (!mmc_can_erase(test->card)) 1631 if (!mmc_can_erase(test->card))
1641 return RESULT_UNSUP_HOST; 1632 return RESULT_UNSUP_HOST;
1642 1633
1643 for (sz = 512; sz < test->area.max_sz; sz <<= 1) { 1634 for (sz = 512; sz < t->max_sz; sz <<= 1) {
1644 dev_addr = test->area.dev_addr + (sz >> 9); 1635 dev_addr = t->dev_addr + (sz >> 9);
1645 getnstimeofday(&ts1); 1636 getnstimeofday(&ts1);
1646 ret = mmc_erase(test->card, dev_addr, sz >> 9, MMC_TRIM_ARG); 1637 ret = mmc_erase(test->card, dev_addr, sz >> 9, MMC_TRIM_ARG);
1647 if (ret) 1638 if (ret)
@@ -1649,7 +1640,7 @@ static int mmc_test_profile_trim_perf(struct mmc_test_card *test)
1649 getnstimeofday(&ts2); 1640 getnstimeofday(&ts2);
1650 mmc_test_print_rate(test, sz, &ts1, &ts2); 1641 mmc_test_print_rate(test, sz, &ts1, &ts2);
1651 } 1642 }
1652 dev_addr = test->area.dev_addr; 1643 dev_addr = t->dev_addr;
1653 getnstimeofday(&ts1); 1644 getnstimeofday(&ts1);
1654 ret = mmc_erase(test->card, dev_addr, sz >> 9, MMC_TRIM_ARG); 1645 ret = mmc_erase(test->card, dev_addr, sz >> 9, MMC_TRIM_ARG);
1655 if (ret) 1646 if (ret)
@@ -1661,12 +1652,13 @@ static int mmc_test_profile_trim_perf(struct mmc_test_card *test)
1661 1652
1662static int mmc_test_seq_read_perf(struct mmc_test_card *test, unsigned long sz) 1653static int mmc_test_seq_read_perf(struct mmc_test_card *test, unsigned long sz)
1663{ 1654{
1655 struct mmc_test_area *t = &test->area;
1664 unsigned int dev_addr, i, cnt; 1656 unsigned int dev_addr, i, cnt;
1665 struct timespec ts1, ts2; 1657 struct timespec ts1, ts2;
1666 int ret; 1658 int ret;
1667 1659
1668 cnt = test->area.max_sz / sz; 1660 cnt = t->max_sz / sz;
1669 dev_addr = test->area.dev_addr; 1661 dev_addr = t->dev_addr;
1670 getnstimeofday(&ts1); 1662 getnstimeofday(&ts1);
1671 for (i = 0; i < cnt; i++) { 1663 for (i = 0; i < cnt; i++) {
1672 ret = mmc_test_area_io(test, sz, dev_addr, 0, 0, 0); 1664 ret = mmc_test_area_io(test, sz, dev_addr, 0, 0, 0);
@@ -1684,20 +1676,22 @@ static int mmc_test_seq_read_perf(struct mmc_test_card *test, unsigned long sz)
1684 */ 1676 */
1685static int mmc_test_profile_seq_read_perf(struct mmc_test_card *test) 1677static int mmc_test_profile_seq_read_perf(struct mmc_test_card *test)
1686{ 1678{
1679 struct mmc_test_area *t = &test->area;
1687 unsigned long sz; 1680 unsigned long sz;
1688 int ret; 1681 int ret;
1689 1682
1690 for (sz = 512; sz < test->area.max_tfr; sz <<= 1) { 1683 for (sz = 512; sz < t->max_tfr; sz <<= 1) {
1691 ret = mmc_test_seq_read_perf(test, sz); 1684 ret = mmc_test_seq_read_perf(test, sz);
1692 if (ret) 1685 if (ret)
1693 return ret; 1686 return ret;
1694 } 1687 }
1695 sz = test->area.max_tfr; 1688 sz = t->max_tfr;
1696 return mmc_test_seq_read_perf(test, sz); 1689 return mmc_test_seq_read_perf(test, sz);
1697} 1690}
1698 1691
1699static int mmc_test_seq_write_perf(struct mmc_test_card *test, unsigned long sz) 1692static int mmc_test_seq_write_perf(struct mmc_test_card *test, unsigned long sz)
1700{ 1693{
1694 struct mmc_test_area *t = &test->area;
1701 unsigned int dev_addr, i, cnt; 1695 unsigned int dev_addr, i, cnt;
1702 struct timespec ts1, ts2; 1696 struct timespec ts1, ts2;
1703 int ret; 1697 int ret;
@@ -1705,8 +1699,8 @@ static int mmc_test_seq_write_perf(struct mmc_test_card *test, unsigned long sz)
1705 ret = mmc_test_area_erase(test); 1699 ret = mmc_test_area_erase(test);
1706 if (ret) 1700 if (ret)
1707 return ret; 1701 return ret;
1708 cnt = test->area.max_sz / sz; 1702 cnt = t->max_sz / sz;
1709 dev_addr = test->area.dev_addr; 1703 dev_addr = t->dev_addr;
1710 getnstimeofday(&ts1); 1704 getnstimeofday(&ts1);
1711 for (i = 0; i < cnt; i++) { 1705 for (i = 0; i < cnt; i++) {
1712 ret = mmc_test_area_io(test, sz, dev_addr, 1, 0, 0); 1706 ret = mmc_test_area_io(test, sz, dev_addr, 1, 0, 0);
@@ -1724,15 +1718,16 @@ static int mmc_test_seq_write_perf(struct mmc_test_card *test, unsigned long sz)
1724 */ 1718 */
1725static int mmc_test_profile_seq_write_perf(struct mmc_test_card *test) 1719static int mmc_test_profile_seq_write_perf(struct mmc_test_card *test)
1726{ 1720{
1721 struct mmc_test_area *t = &test->area;
1727 unsigned long sz; 1722 unsigned long sz;
1728 int ret; 1723 int ret;
1729 1724
1730 for (sz = 512; sz < test->area.max_tfr; sz <<= 1) { 1725 for (sz = 512; sz < t->max_tfr; sz <<= 1) {
1731 ret = mmc_test_seq_write_perf(test, sz); 1726 ret = mmc_test_seq_write_perf(test, sz);
1732 if (ret) 1727 if (ret)
1733 return ret; 1728 return ret;
1734 } 1729 }
1735 sz = test->area.max_tfr; 1730 sz = t->max_tfr;
1736 return mmc_test_seq_write_perf(test, sz); 1731 return mmc_test_seq_write_perf(test, sz);
1737} 1732}
1738 1733
@@ -1741,6 +1736,7 @@ static int mmc_test_profile_seq_write_perf(struct mmc_test_card *test)
1741 */ 1736 */
1742static int mmc_test_profile_seq_trim_perf(struct mmc_test_card *test) 1737static int mmc_test_profile_seq_trim_perf(struct mmc_test_card *test)
1743{ 1738{
1739 struct mmc_test_area *t = &test->area;
1744 unsigned long sz; 1740 unsigned long sz;
1745 unsigned int dev_addr, i, cnt; 1741 unsigned int dev_addr, i, cnt;
1746 struct timespec ts1, ts2; 1742 struct timespec ts1, ts2;
@@ -1752,15 +1748,15 @@ static int mmc_test_profile_seq_trim_perf(struct mmc_test_card *test)
1752 if (!mmc_can_erase(test->card)) 1748 if (!mmc_can_erase(test->card))
1753 return RESULT_UNSUP_HOST; 1749 return RESULT_UNSUP_HOST;
1754 1750
1755 for (sz = 512; sz <= test->area.max_sz; sz <<= 1) { 1751 for (sz = 512; sz <= t->max_sz; sz <<= 1) {
1756 ret = mmc_test_area_erase(test); 1752 ret = mmc_test_area_erase(test);
1757 if (ret) 1753 if (ret)
1758 return ret; 1754 return ret;
1759 ret = mmc_test_area_fill(test); 1755 ret = mmc_test_area_fill(test);
1760 if (ret) 1756 if (ret)
1761 return ret; 1757 return ret;
1762 cnt = test->area.max_sz / sz; 1758 cnt = t->max_sz / sz;
1763 dev_addr = test->area.dev_addr; 1759 dev_addr = t->dev_addr;
1764 getnstimeofday(&ts1); 1760 getnstimeofday(&ts1);
1765 for (i = 0; i < cnt; i++) { 1761 for (i = 0; i < cnt; i++) {
1766 ret = mmc_erase(test->card, dev_addr, sz >> 9, 1762 ret = mmc_erase(test->card, dev_addr, sz >> 9,
@@ -1823,11 +1819,12 @@ static int mmc_test_rnd_perf(struct mmc_test_card *test, int write, int print,
1823 1819
1824static int mmc_test_random_perf(struct mmc_test_card *test, int write) 1820static int mmc_test_random_perf(struct mmc_test_card *test, int write)
1825{ 1821{
1822 struct mmc_test_area *t = &test->area;
1826 unsigned int next; 1823 unsigned int next;
1827 unsigned long sz; 1824 unsigned long sz;
1828 int ret; 1825 int ret;
1829 1826
1830 for (sz = 512; sz < test->area.max_tfr; sz <<= 1) { 1827 for (sz = 512; sz < t->max_tfr; sz <<= 1) {
1831 /* 1828 /*
1832 * When writing, try to get more consistent results by running 1829 * When writing, try to get more consistent results by running
1833 * the test twice with exactly the same I/O but outputting the 1830 * the test twice with exactly the same I/O but outputting the
@@ -1844,7 +1841,7 @@ static int mmc_test_random_perf(struct mmc_test_card *test, int write)
1844 if (ret) 1841 if (ret)
1845 return ret; 1842 return ret;
1846 } 1843 }
1847 sz = test->area.max_tfr; 1844 sz = t->max_tfr;
1848 if (write) { 1845 if (write) {
1849 next = rnd_next; 1846 next = rnd_next;
1850 ret = mmc_test_rnd_perf(test, write, 0, sz); 1847 ret = mmc_test_rnd_perf(test, write, 0, sz);
@@ -1874,17 +1871,18 @@ static int mmc_test_random_write_perf(struct mmc_test_card *test)
1874static int mmc_test_seq_perf(struct mmc_test_card *test, int write, 1871static int mmc_test_seq_perf(struct mmc_test_card *test, int write,
1875 unsigned int tot_sz, int max_scatter) 1872 unsigned int tot_sz, int max_scatter)
1876{ 1873{
1874 struct mmc_test_area *t = &test->area;
1877 unsigned int dev_addr, i, cnt, sz, ssz; 1875 unsigned int dev_addr, i, cnt, sz, ssz;
1878 struct timespec ts1, ts2; 1876 struct timespec ts1, ts2;
1879 int ret; 1877 int ret;
1880 1878
1881 sz = test->area.max_tfr; 1879 sz = t->max_tfr;
1880
1882 /* 1881 /*
1883 * In the case of a maximally scattered transfer, the maximum transfer 1882 * In the case of a maximally scattered transfer, the maximum transfer
1884 * size is further limited by using PAGE_SIZE segments. 1883 * size is further limited by using PAGE_SIZE segments.
1885 */ 1884 */
1886 if (max_scatter) { 1885 if (max_scatter) {
1887 struct mmc_test_area *t = &test->area;
1888 unsigned long max_tfr; 1886 unsigned long max_tfr;
1889 1887
1890 if (t->max_seg_sz >= PAGE_SIZE) 1888 if (t->max_seg_sz >= PAGE_SIZE)