diff mbox series

[v2,08/10] mmc: core: Allow mmc erase to carry large addresses

Message ID 20240807060309.2403023-9-avri.altman@wdc.com (mailing list archive)
State New
Headers show
Series Add SDUC Support | expand

Commit Message

Avri Altman Aug. 7, 2024, 6:03 a.m. UTC
Preparing for SDUC, Allow the erase address to be larger beyond a 32 bit
address.

Signed-off-by: Avri Altman <avri.altman@wdc.com>
---
 drivers/mmc/core/block.c |  6 ++++--
 drivers/mmc/core/core.c  | 18 ++++++++++--------
 drivers/mmc/core/core.h  |  2 +-
 3 files changed, 15 insertions(+), 11 deletions(-)

Comments

kernel test robot Aug. 7, 2024, 8:15 p.m. UTC | #1
Hi Avri,

kernel test robot noticed the following build errors:

[auto build test ERROR on linus/master]
[also build test ERROR on v6.11-rc2 next-20240807]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Avri-Altman/mmc-sd-SDUC-Support-Recognition/20240807-140950
base:   linus/master
patch link:    https://lore.kernel.org/r/20240807060309.2403023-9-avri.altman%40wdc.com
patch subject: [PATCH v2 08/10] mmc: core: Allow mmc erase to carry large addresses
config: i386-randconfig-004-20240807 (https://download.01.org/0day-ci/archive/20240808/202408080458.9guIB91o-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240808/202408080458.9guIB91o-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202408080458.9guIB91o-lkp@intel.com/

All errors (new ones prefixed by >>):

   ld: drivers/mmc/core/core.o: in function `mmc_do_erase':
>> drivers/mmc/core/core.c:1651: undefined reference to `__udivdi3'
>> ld: drivers/mmc/core/core.c:1652: undefined reference to `__udivdi3'
   ld: drivers/mmc/core/core.o: in function `mmc_erase':
>> drivers/mmc/core/core.c:1827: undefined reference to `__umoddi3'
   ld: drivers/mmc/core/core.o: in function `mmc_align_erase_size':
   drivers/mmc/core/core.c:1745: undefined reference to `__umoddi3'
   ld: drivers/mmc/core/core.o: in function `mmc_erase':
   drivers/mmc/core/core.c:1803: undefined reference to `__umoddi3'


vim +1651 drivers/mmc/core/core.c

dfe86cba7676d5 Adrian Hunter   2010-08-11  1618  
d3d1cbaa99327c Avri Altman     2024-08-07  1619  static int mmc_do_erase(struct mmc_card *card, sector_t from,
d3d1cbaa99327c Avri Altman     2024-08-07  1620  			sector_t to, unsigned int arg)
dfe86cba7676d5 Adrian Hunter   2010-08-11  1621  {
c7836d1593b87c Masahiro Yamada 2016-12-19  1622  	struct mmc_command cmd = {};
bb4eecf23be259 Baolin Wang     2016-07-25  1623  	unsigned int qty = 0, busy_timeout = 0;
e62f1e0b2384e2 Ulf Hansson     2021-05-04  1624  	bool use_r1b_resp;
dfe86cba7676d5 Adrian Hunter   2010-08-11  1625  	int err;
dfe86cba7676d5 Adrian Hunter   2010-08-11  1626  
8f11d1064e01e1 Adrian Hunter   2015-05-07  1627  	mmc_retune_hold(card->host);
8f11d1064e01e1 Adrian Hunter   2015-05-07  1628  
dfe86cba7676d5 Adrian Hunter   2010-08-11  1629  	/*
dfe86cba7676d5 Adrian Hunter   2010-08-11  1630  	 * qty is used to calculate the erase timeout which depends on how many
dfe86cba7676d5 Adrian Hunter   2010-08-11  1631  	 * erase groups (or allocation units in SD terminology) are affected.
dfe86cba7676d5 Adrian Hunter   2010-08-11  1632  	 * We count erasing part of an erase group as one erase group.
dfe86cba7676d5 Adrian Hunter   2010-08-11  1633  	 * For SD, the allocation units are always a power of 2.  For MMC, the
dfe86cba7676d5 Adrian Hunter   2010-08-11  1634  	 * erase group size is almost certainly also power of 2, but it does not
dfe86cba7676d5 Adrian Hunter   2010-08-11  1635  	 * seem to insist on that in the JEDEC standard, so we fall back to
dfe86cba7676d5 Adrian Hunter   2010-08-11  1636  	 * division in that case.  SD may not specify an allocation unit size,
dfe86cba7676d5 Adrian Hunter   2010-08-11  1637  	 * in which case the timeout is based on the number of write blocks.
dfe86cba7676d5 Adrian Hunter   2010-08-11  1638  	 *
dfe86cba7676d5 Adrian Hunter   2010-08-11  1639  	 * Note that the timeout for secure trim 2 will only be correct if the
dfe86cba7676d5 Adrian Hunter   2010-08-11  1640  	 * number of erase groups specified is the same as the total of all
dfe86cba7676d5 Adrian Hunter   2010-08-11  1641  	 * preceding secure trim 1 commands.  Since the power may have been
dfe86cba7676d5 Adrian Hunter   2010-08-11  1642  	 * lost since the secure trim 1 commands occurred, it is generally
dfe86cba7676d5 Adrian Hunter   2010-08-11  1643  	 * impossible to calculate the secure trim 2 timeout correctly.
dfe86cba7676d5 Adrian Hunter   2010-08-11  1644  	 */
dfe86cba7676d5 Adrian Hunter   2010-08-11  1645  	if (card->erase_shift)
dfe86cba7676d5 Adrian Hunter   2010-08-11  1646  		qty += ((to >> card->erase_shift) -
dfe86cba7676d5 Adrian Hunter   2010-08-11  1647  			(from >> card->erase_shift)) + 1;
dfe86cba7676d5 Adrian Hunter   2010-08-11  1648  	else if (mmc_card_sd(card))
dfe86cba7676d5 Adrian Hunter   2010-08-11  1649  		qty += to - from + 1;
dfe86cba7676d5 Adrian Hunter   2010-08-11  1650  	else
dfe86cba7676d5 Adrian Hunter   2010-08-11 @1651  		qty += ((to / card->erase_size) -
dfe86cba7676d5 Adrian Hunter   2010-08-11 @1652  			(from / card->erase_size)) + 1;
dfe86cba7676d5 Adrian Hunter   2010-08-11  1653  
dfe86cba7676d5 Adrian Hunter   2010-08-11  1654  	if (!mmc_card_blockaddr(card)) {
dfe86cba7676d5 Adrian Hunter   2010-08-11  1655  		from <<= 9;
dfe86cba7676d5 Adrian Hunter   2010-08-11  1656  		to <<= 9;
dfe86cba7676d5 Adrian Hunter   2010-08-11  1657  	}
dfe86cba7676d5 Adrian Hunter   2010-08-11  1658  
dfe86cba7676d5 Adrian Hunter   2010-08-11  1659  	if (mmc_card_sd(card))
dfe86cba7676d5 Adrian Hunter   2010-08-11  1660  		cmd.opcode = SD_ERASE_WR_BLK_START;
dfe86cba7676d5 Adrian Hunter   2010-08-11  1661  	else
dfe86cba7676d5 Adrian Hunter   2010-08-11  1662  		cmd.opcode = MMC_ERASE_GROUP_START;
dfe86cba7676d5 Adrian Hunter   2010-08-11  1663  	cmd.arg = from;
dfe86cba7676d5 Adrian Hunter   2010-08-11  1664  	cmd.flags = MMC_RSP_SPI_R1 | MMC_RSP_R1 | MMC_CMD_AC;
dfe86cba7676d5 Adrian Hunter   2010-08-11  1665  	err = mmc_wait_for_cmd(card->host, &cmd, 0);
dfe86cba7676d5 Adrian Hunter   2010-08-11  1666  	if (err) {
a3c76eb9d4a1e6 Girish K S      2011-10-11  1667  		pr_err("mmc_erase: group start error %d, "
dfe86cba7676d5 Adrian Hunter   2010-08-11  1668  		       "status %#x\n", err, cmd.resp[0]);
67716327eec7e9 Adrian Hunter   2011-08-29  1669  		err = -EIO;
dfe86cba7676d5 Adrian Hunter   2010-08-11  1670  		goto out;
dfe86cba7676d5 Adrian Hunter   2010-08-11  1671  	}
dfe86cba7676d5 Adrian Hunter   2010-08-11  1672  
dfe86cba7676d5 Adrian Hunter   2010-08-11  1673  	memset(&cmd, 0, sizeof(struct mmc_command));
dfe86cba7676d5 Adrian Hunter   2010-08-11  1674  	if (mmc_card_sd(card))
dfe86cba7676d5 Adrian Hunter   2010-08-11  1675  		cmd.opcode = SD_ERASE_WR_BLK_END;
dfe86cba7676d5 Adrian Hunter   2010-08-11  1676  	else
dfe86cba7676d5 Adrian Hunter   2010-08-11  1677  		cmd.opcode = MMC_ERASE_GROUP_END;
dfe86cba7676d5 Adrian Hunter   2010-08-11  1678  	cmd.arg = to;
dfe86cba7676d5 Adrian Hunter   2010-08-11  1679  	cmd.flags = MMC_RSP_SPI_R1 | MMC_RSP_R1 | MMC_CMD_AC;
dfe86cba7676d5 Adrian Hunter   2010-08-11  1680  	err = mmc_wait_for_cmd(card->host, &cmd, 0);
dfe86cba7676d5 Adrian Hunter   2010-08-11  1681  	if (err) {
a3c76eb9d4a1e6 Girish K S      2011-10-11  1682  		pr_err("mmc_erase: group end error %d, status %#x\n",
dfe86cba7676d5 Adrian Hunter   2010-08-11  1683  		       err, cmd.resp[0]);
67716327eec7e9 Adrian Hunter   2011-08-29  1684  		err = -EIO;
dfe86cba7676d5 Adrian Hunter   2010-08-11  1685  		goto out;
dfe86cba7676d5 Adrian Hunter   2010-08-11  1686  	}
dfe86cba7676d5 Adrian Hunter   2010-08-11  1687  
dfe86cba7676d5 Adrian Hunter   2010-08-11  1688  	memset(&cmd, 0, sizeof(struct mmc_command));
dfe86cba7676d5 Adrian Hunter   2010-08-11  1689  	cmd.opcode = MMC_ERASE;
dfe86cba7676d5 Adrian Hunter   2010-08-11  1690  	cmd.arg = arg;
bb4eecf23be259 Baolin Wang     2016-07-25  1691  	busy_timeout = mmc_erase_timeout(card, arg, qty);
e62f1e0b2384e2 Ulf Hansson     2021-05-04  1692  	use_r1b_resp = mmc_prepare_busy_cmd(card->host, &cmd, busy_timeout);
bb4eecf23be259 Baolin Wang     2016-07-25  1693  
dfe86cba7676d5 Adrian Hunter   2010-08-11  1694  	err = mmc_wait_for_cmd(card->host, &cmd, 0);
dfe86cba7676d5 Adrian Hunter   2010-08-11  1695  	if (err) {
a3c76eb9d4a1e6 Girish K S      2011-10-11  1696  		pr_err("mmc_erase: erase error %d, status %#x\n",
dfe86cba7676d5 Adrian Hunter   2010-08-11  1697  		       err, cmd.resp[0]);
dfe86cba7676d5 Adrian Hunter   2010-08-11  1698  		err = -EIO;
dfe86cba7676d5 Adrian Hunter   2010-08-11  1699  		goto out;
dfe86cba7676d5 Adrian Hunter   2010-08-11  1700  	}
dfe86cba7676d5 Adrian Hunter   2010-08-11  1701  
dfe86cba7676d5 Adrian Hunter   2010-08-11  1702  	if (mmc_host_is_spi(card->host))
dfe86cba7676d5 Adrian Hunter   2010-08-11  1703  		goto out;
dfe86cba7676d5 Adrian Hunter   2010-08-11  1704  
bb4eecf23be259 Baolin Wang     2016-07-25  1705  	/*
bb4eecf23be259 Baolin Wang     2016-07-25  1706  	 * In case of when R1B + MMC_CAP_WAIT_WHILE_BUSY is used, the polling
bb4eecf23be259 Baolin Wang     2016-07-25  1707  	 * shall be avoided.
bb4eecf23be259 Baolin Wang     2016-07-25  1708  	 */
bb4eecf23be259 Baolin Wang     2016-07-25  1709  	if ((card->host->caps & MMC_CAP_WAIT_WHILE_BUSY) && use_r1b_resp)
bb4eecf23be259 Baolin Wang     2016-07-25  1710  		goto out;
bb4eecf23be259 Baolin Wang     2016-07-25  1711  
0d84c3e6a5b2cd Ulf Hansson     2020-02-04  1712  	/* Let's poll to find out when the erase operation completes. */
04f967ad28c836 Ulf Hansson     2021-05-04  1713  	err = mmc_poll_for_busy(card, busy_timeout, false, MMC_BUSY_ERASE);
8fee476b219d18 Trey Ramsay     2012-11-16  1714  
dfe86cba7676d5 Adrian Hunter   2010-08-11  1715  out:
8f11d1064e01e1 Adrian Hunter   2015-05-07  1716  	mmc_retune_release(card->host);
dfe86cba7676d5 Adrian Hunter   2010-08-11  1717  	return err;
dfe86cba7676d5 Adrian Hunter   2010-08-11  1718  }
dfe86cba7676d5 Adrian Hunter   2010-08-11  1719  
71085123d27dc5 Baolin Wang     2016-09-07  1720  static unsigned int mmc_align_erase_size(struct mmc_card *card,
d3d1cbaa99327c Avri Altman     2024-08-07  1721  					 sector_t *from,
d3d1cbaa99327c Avri Altman     2024-08-07  1722  					 sector_t *to,
71085123d27dc5 Baolin Wang     2016-09-07  1723  					 unsigned int nr)
71085123d27dc5 Baolin Wang     2016-09-07  1724  {
d3d1cbaa99327c Avri Altman     2024-08-07  1725  	sector_t from_new = *from;
d3d1cbaa99327c Avri Altman     2024-08-07  1726  	unsigned int nr_new = nr, rem;
71085123d27dc5 Baolin Wang     2016-09-07  1727  
6c689886fbe41b Baolin Wang     2016-09-07  1728  	/*
6c689886fbe41b Baolin Wang     2016-09-07  1729  	 * When the 'card->erase_size' is power of 2, we can use round_up/down()
6c689886fbe41b Baolin Wang     2016-09-07  1730  	 * to align the erase size efficiently.
6c689886fbe41b Baolin Wang     2016-09-07  1731  	 */
6c689886fbe41b Baolin Wang     2016-09-07  1732  	if (is_power_of_2(card->erase_size)) {
d3d1cbaa99327c Avri Altman     2024-08-07  1733  		sector_t temp = from_new;
6c689886fbe41b Baolin Wang     2016-09-07  1734  
6c689886fbe41b Baolin Wang     2016-09-07  1735  		from_new = round_up(temp, card->erase_size);
6c689886fbe41b Baolin Wang     2016-09-07  1736  		rem = from_new - temp;
6c689886fbe41b Baolin Wang     2016-09-07  1737  
6c689886fbe41b Baolin Wang     2016-09-07  1738  		if (nr_new > rem)
6c689886fbe41b Baolin Wang     2016-09-07  1739  			nr_new -= rem;
6c689886fbe41b Baolin Wang     2016-09-07  1740  		else
6c689886fbe41b Baolin Wang     2016-09-07  1741  			return 0;
6c689886fbe41b Baolin Wang     2016-09-07  1742  
6c689886fbe41b Baolin Wang     2016-09-07  1743  		nr_new = round_down(nr_new, card->erase_size);
6c689886fbe41b Baolin Wang     2016-09-07  1744  	} else {
71085123d27dc5 Baolin Wang     2016-09-07  1745  		rem = from_new % card->erase_size;
71085123d27dc5 Baolin Wang     2016-09-07  1746  		if (rem) {
71085123d27dc5 Baolin Wang     2016-09-07  1747  			rem = card->erase_size - rem;
71085123d27dc5 Baolin Wang     2016-09-07  1748  			from_new += rem;
71085123d27dc5 Baolin Wang     2016-09-07  1749  			if (nr_new > rem)
71085123d27dc5 Baolin Wang     2016-09-07  1750  				nr_new -= rem;
71085123d27dc5 Baolin Wang     2016-09-07  1751  			else
71085123d27dc5 Baolin Wang     2016-09-07  1752  				return 0;
71085123d27dc5 Baolin Wang     2016-09-07  1753  		}
71085123d27dc5 Baolin Wang     2016-09-07  1754  
71085123d27dc5 Baolin Wang     2016-09-07  1755  		rem = nr_new % card->erase_size;
71085123d27dc5 Baolin Wang     2016-09-07  1756  		if (rem)
71085123d27dc5 Baolin Wang     2016-09-07  1757  			nr_new -= rem;
6c689886fbe41b Baolin Wang     2016-09-07  1758  	}
71085123d27dc5 Baolin Wang     2016-09-07  1759  
71085123d27dc5 Baolin Wang     2016-09-07  1760  	if (nr_new == 0)
71085123d27dc5 Baolin Wang     2016-09-07  1761  		return 0;
71085123d27dc5 Baolin Wang     2016-09-07  1762  
71085123d27dc5 Baolin Wang     2016-09-07  1763  	*to = from_new + nr_new;
71085123d27dc5 Baolin Wang     2016-09-07  1764  	*from = from_new;
71085123d27dc5 Baolin Wang     2016-09-07  1765  
71085123d27dc5 Baolin Wang     2016-09-07  1766  	return nr_new;
71085123d27dc5 Baolin Wang     2016-09-07  1767  }
71085123d27dc5 Baolin Wang     2016-09-07  1768  
dfe86cba7676d5 Adrian Hunter   2010-08-11  1769  /**
dfe86cba7676d5 Adrian Hunter   2010-08-11  1770   * mmc_erase - erase sectors.
dfe86cba7676d5 Adrian Hunter   2010-08-11  1771   * @card: card to erase
dfe86cba7676d5 Adrian Hunter   2010-08-11  1772   * @from: first sector to erase
dfe86cba7676d5 Adrian Hunter   2010-08-11  1773   * @nr: number of sectors to erase
bc47e2f6f9e261 Avri Altman     2019-02-26  1774   * @arg: erase command argument
dfe86cba7676d5 Adrian Hunter   2010-08-11  1775   *
dfe86cba7676d5 Adrian Hunter   2010-08-11  1776   * Caller must claim host before calling this function.
dfe86cba7676d5 Adrian Hunter   2010-08-11  1777   */
d3d1cbaa99327c Avri Altman     2024-08-07  1778  int mmc_erase(struct mmc_card *card, sector_t from, unsigned int nr,
dfe86cba7676d5 Adrian Hunter   2010-08-11  1779  	      unsigned int arg)
dfe86cba7676d5 Adrian Hunter   2010-08-11  1780  {
d3d1cbaa99327c Avri Altman     2024-08-07  1781  	unsigned int rem;
d3d1cbaa99327c Avri Altman     2024-08-07  1782  	sector_t to = from + nr;
642c28ab86f766 David Jander    2015-06-23  1783  	int err;
dfe86cba7676d5 Adrian Hunter   2010-08-11  1784  
94fe2580a2f3bb Ulf Hansson     2020-05-08  1785  	if (!(card->csd.cmdclass & CCC_ERASE))
dfe86cba7676d5 Adrian Hunter   2010-08-11  1786  		return -EOPNOTSUPP;
dfe86cba7676d5 Adrian Hunter   2010-08-11  1787  
dfe86cba7676d5 Adrian Hunter   2010-08-11  1788  	if (!card->erase_size)
dfe86cba7676d5 Adrian Hunter   2010-08-11  1789  		return -EOPNOTSUPP;
dfe86cba7676d5 Adrian Hunter   2010-08-11  1790  
bc47e2f6f9e261 Avri Altman     2019-02-26  1791  	if (mmc_card_sd(card) && arg != SD_ERASE_ARG && arg != SD_DISCARD_ARG)
dfe86cba7676d5 Adrian Hunter   2010-08-11  1792  		return -EOPNOTSUPP;
dfe86cba7676d5 Adrian Hunter   2010-08-11  1793  
bc47e2f6f9e261 Avri Altman     2019-02-26  1794  	if (mmc_card_mmc(card) && (arg & MMC_SECURE_ARGS) &&
dfe86cba7676d5 Adrian Hunter   2010-08-11  1795  	    !(card->ext_csd.sec_feature_support & EXT_CSD_SEC_ER_EN))
dfe86cba7676d5 Adrian Hunter   2010-08-11  1796  		return -EOPNOTSUPP;
dfe86cba7676d5 Adrian Hunter   2010-08-11  1797  
489d144563f239 Christian Löhle 2022-11-17  1798  	if (mmc_card_mmc(card) && is_trim_arg(arg) &&
dfe86cba7676d5 Adrian Hunter   2010-08-11  1799  	    !(card->ext_csd.sec_feature_support & EXT_CSD_SEC_GB_CL_EN))
dfe86cba7676d5 Adrian Hunter   2010-08-11  1800  		return -EOPNOTSUPP;
dfe86cba7676d5 Adrian Hunter   2010-08-11  1801  
dfe86cba7676d5 Adrian Hunter   2010-08-11  1802  	if (arg == MMC_SECURE_ERASE_ARG) {
dfe86cba7676d5 Adrian Hunter   2010-08-11  1803  		if (from % card->erase_size || nr % card->erase_size)
dfe86cba7676d5 Adrian Hunter   2010-08-11  1804  			return -EINVAL;
dfe86cba7676d5 Adrian Hunter   2010-08-11  1805  	}
dfe86cba7676d5 Adrian Hunter   2010-08-11  1806  
71085123d27dc5 Baolin Wang     2016-09-07  1807  	if (arg == MMC_ERASE_ARG)
71085123d27dc5 Baolin Wang     2016-09-07  1808  		nr = mmc_align_erase_size(card, &from, &to, nr);
dfe86cba7676d5 Adrian Hunter   2010-08-11  1809  
dfe86cba7676d5 Adrian Hunter   2010-08-11  1810  	if (nr == 0)
dfe86cba7676d5 Adrian Hunter   2010-08-11  1811  		return 0;
dfe86cba7676d5 Adrian Hunter   2010-08-11  1812  
dfe86cba7676d5 Adrian Hunter   2010-08-11  1813  	if (to <= from)
dfe86cba7676d5 Adrian Hunter   2010-08-11  1814  		return -EINVAL;
dfe86cba7676d5 Adrian Hunter   2010-08-11  1815  
dfe86cba7676d5 Adrian Hunter   2010-08-11  1816  	/* 'from' and 'to' are inclusive */
dfe86cba7676d5 Adrian Hunter   2010-08-11  1817  	to -= 1;
dfe86cba7676d5 Adrian Hunter   2010-08-11  1818  
642c28ab86f766 David Jander    2015-06-23  1819  	/*
642c28ab86f766 David Jander    2015-06-23  1820  	 * Special case where only one erase-group fits in the timeout budget:
642c28ab86f766 David Jander    2015-06-23  1821  	 * If the region crosses an erase-group boundary on this particular
642c28ab86f766 David Jander    2015-06-23  1822  	 * case, we will be trimming more than one erase-group which, does not
642c28ab86f766 David Jander    2015-06-23  1823  	 * fit in the timeout budget of the controller, so we need to split it
642c28ab86f766 David Jander    2015-06-23  1824  	 * and call mmc_do_erase() twice if necessary. This special case is
642c28ab86f766 David Jander    2015-06-23  1825  	 * identified by the card->eg_boundary flag.
642c28ab86f766 David Jander    2015-06-23  1826  	 */
642c28ab86f766 David Jander    2015-06-23 @1827  	rem = card->erase_size - (from % card->erase_size);
489d144563f239 Christian Löhle 2022-11-17  1828  	if ((arg & MMC_TRIM_OR_DISCARD_ARGS) && card->eg_boundary && nr > rem) {
642c28ab86f766 David Jander    2015-06-23  1829  		err = mmc_do_erase(card, from, from + rem - 1, arg);
642c28ab86f766 David Jander    2015-06-23  1830  		from += rem;
642c28ab86f766 David Jander    2015-06-23  1831  		if ((err) || (to <= from))
642c28ab86f766 David Jander    2015-06-23  1832  			return err;
642c28ab86f766 David Jander    2015-06-23  1833  	}
642c28ab86f766 David Jander    2015-06-23  1834  
dfe86cba7676d5 Adrian Hunter   2010-08-11  1835  	return mmc_do_erase(card, from, to, arg);
dfe86cba7676d5 Adrian Hunter   2010-08-11  1836  }
dfe86cba7676d5 Adrian Hunter   2010-08-11  1837  EXPORT_SYMBOL(mmc_erase);
dfe86cba7676d5 Adrian Hunter   2010-08-11  1838
kernel test robot Aug. 7, 2024, 9:07 p.m. UTC | #2
Hi Avri,

kernel test robot noticed the following build errors:

[auto build test ERROR on linus/master]
[also build test ERROR on v6.11-rc2 next-20240807]
[cannot apply to ulf-hansson-mmc-mirror/next]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Avri-Altman/mmc-sd-SDUC-Support-Recognition/20240807-140950
base:   linus/master
patch link:    https://lore.kernel.org/r/20240807060309.2403023-9-avri.altman%40wdc.com
patch subject: [PATCH v2 08/10] mmc: core: Allow mmc erase to carry large addresses
config: i386-randconfig-012-20240807 (https://download.01.org/0day-ci/archive/20240808/202408080428.IWxLHNou-lkp@intel.com/config)
compiler: gcc-11 (Debian 11.3.0-12) 11.3.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240808/202408080428.IWxLHNou-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202408080428.IWxLHNou-lkp@intel.com/

All errors (new ones prefixed by >>):

   ld: drivers/mmc/core/core.o: in function `mmc_do_erase':
   drivers/mmc/core/core.c:1651: undefined reference to `__udivdi3'
   ld: drivers/mmc/core/core.c:1652: undefined reference to `__udivdi3'
   ld: drivers/mmc/core/core.o: in function `mmc_erase':
   drivers/mmc/core/core.c:1803: undefined reference to `__umoddi3'
>> ld: drivers/mmc/core/core.c:1827: undefined reference to `__umoddi3'
   ld: drivers/mmc/core/core.o: in function `mmc_align_erase_size':
   drivers/mmc/core/core.c:1745: undefined reference to `__umoddi3'
diff mbox series

Patch

diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c
index abf1e8a124a5..55b9fc34fdd4 100644
--- a/drivers/mmc/core/block.c
+++ b/drivers/mmc/core/block.c
@@ -1154,7 +1154,8 @@  static void mmc_blk_issue_erase_rq(struct mmc_queue *mq, struct request *req,
 {
 	struct mmc_blk_data *md = mq->blkdata;
 	struct mmc_card *card = md->queue.card;
-	unsigned int from, nr;
+	unsigned int nr;
+	sector_t from;
 	int err = 0;
 	blk_status_t status = BLK_STS_OK;
 
@@ -1209,7 +1210,8 @@  static void mmc_blk_issue_secdiscard_rq(struct mmc_queue *mq,
 {
 	struct mmc_blk_data *md = mq->blkdata;
 	struct mmc_card *card = md->queue.card;
-	unsigned int from, nr, arg;
+	unsigned int nr, arg;
+	sector_t from;
 	int err = 0, type = MMC_BLK_SECDISCARD;
 	blk_status_t status = BLK_STS_OK;
 
diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index 754e628b061b..8ea28a04e438 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -1616,8 +1616,8 @@  static unsigned int mmc_erase_timeout(struct mmc_card *card,
 		return mmc_mmc_erase_timeout(card, arg, qty);
 }
 
-static int mmc_do_erase(struct mmc_card *card, unsigned int from,
-			unsigned int to, unsigned int arg)
+static int mmc_do_erase(struct mmc_card *card, sector_t from,
+			sector_t to, unsigned int arg)
 {
 	struct mmc_command cmd = {};
 	unsigned int qty = 0, busy_timeout = 0;
@@ -1718,18 +1718,19 @@  static int mmc_do_erase(struct mmc_card *card, unsigned int from,
 }
 
 static unsigned int mmc_align_erase_size(struct mmc_card *card,
-					 unsigned int *from,
-					 unsigned int *to,
+					 sector_t *from,
+					 sector_t *to,
 					 unsigned int nr)
 {
-	unsigned int from_new = *from, nr_new = nr, rem;
+	sector_t from_new = *from;
+	unsigned int nr_new = nr, rem;
 
 	/*
 	 * When the 'card->erase_size' is power of 2, we can use round_up/down()
 	 * to align the erase size efficiently.
 	 */
 	if (is_power_of_2(card->erase_size)) {
-		unsigned int temp = from_new;
+		sector_t temp = from_new;
 
 		from_new = round_up(temp, card->erase_size);
 		rem = from_new - temp;
@@ -1774,10 +1775,11 @@  static unsigned int mmc_align_erase_size(struct mmc_card *card,
  *
  * Caller must claim host before calling this function.
  */
-int mmc_erase(struct mmc_card *card, unsigned int from, unsigned int nr,
+int mmc_erase(struct mmc_card *card, sector_t from, unsigned int nr,
 	      unsigned int arg)
 {
-	unsigned int rem, to = from + nr;
+	unsigned int rem;
+	sector_t to = from + nr;
 	int err;
 
 	if (!(card->csd.cmdclass & CCC_ERASE))
diff --git a/drivers/mmc/core/core.h b/drivers/mmc/core/core.h
index 37091a6589ed..faae4b6404ad 100644
--- a/drivers/mmc/core/core.h
+++ b/drivers/mmc/core/core.h
@@ -116,7 +116,7 @@  bool mmc_is_req_done(struct mmc_host *host, struct mmc_request *mrq);
 
 int mmc_start_request(struct mmc_host *host, struct mmc_request *mrq);
 
-int mmc_erase(struct mmc_card *card, unsigned int from, unsigned int nr,
+int mmc_erase(struct mmc_card *card, sector_t from, unsigned int nr,
 		unsigned int arg);
 int mmc_can_erase(struct mmc_card *card);
 int mmc_can_trim(struct mmc_card *card);