Commit 6527f022 authored by Sean Rhodes's avatar Sean Rhodes Committed by Wentao Guan
Browse files

drivers/card_reader/rtsx_usb: Restore interrupt based detection

stable inclusion
from stable-v6.6.76
commit 9e490b665ca3b012afc9a1fdab3ab69feee6d667
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/IBW08Q

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=9e490b665ca3b012afc9a1fdab3ab69feee6d667



--------------------------------

commit 235b630eda072d7e7b102ab346d6b8a2c028a772 upstream.

This commit reintroduces interrupt-based card detection previously
used in the rts5139 driver. This functionality was removed in commit
00d8521d ("staging: remove rts5139 driver code").

Reintroducing this mechanism fixes presence detection for certain card
readers, which with the current driver, will taken approximately 20
seconds to enter S3 as `mmc_rescan` has to be frozen.

Fixes: 00d8521d ("staging: remove rts5139 driver code")
Cc: stable@vger.kernel.org
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarSean Rhodes <sean@starlabs.systems>
Link: https://lore.kernel.org/r/20241119085815.11769-1-sean@starlabs.systems


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 9e490b665ca3b012afc9a1fdab3ab69feee6d667)
Signed-off-by: default avatarWentao Guan <guanwentao@uniontech.com>
parent 70eb716f
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -286,6 +286,7 @@ static int rtsx_usb_get_status_with_bulk(struct rtsx_ucr *ucr, u16 *status)
int rtsx_usb_get_card_status(struct rtsx_ucr *ucr, u16 *status)
{
	int ret;
	u8 interrupt_val = 0;
	u16 *buf;

	if (!status)
@@ -308,6 +309,20 @@ int rtsx_usb_get_card_status(struct rtsx_ucr *ucr, u16 *status)
		ret = rtsx_usb_get_status_with_bulk(ucr, status);
	}

	rtsx_usb_read_register(ucr, CARD_INT_PEND, &interrupt_val);
	/* Cross check presence with interrupts */
	if (*status & XD_CD)
		if (!(interrupt_val & XD_INT))
			*status &= ~XD_CD;

	if (*status & SD_CD)
		if (!(interrupt_val & SD_INT))
			*status &= ~SD_CD;

	if (*status & MS_CD)
		if (!(interrupt_val & MS_INT))
			*status &= ~MS_CD;

	/* usb_control_msg may return positive when success */
	if (ret < 0)
		return ret;