Received: by 2002:ac0:8845:0:0:0:0:0 with SMTP id g63csp325276img; Tue, 26 Feb 2019 00:19:34 -0800 (PST) X-Google-Smtp-Source: AHgI3Ia2r3rM+k+pX1VI6A34Ia5J26B85y3UBkhjNo7pLPxivBAt3qd/61jfQfKxc6735+3WTUE/ X-Received: by 2002:a17:902:8303:: with SMTP id bd3mr25292888plb.10.1551169174447; Tue, 26 Feb 2019 00:19:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551169174; cv=none; d=google.com; s=arc-20160816; b=AwW2UPA1PRM7sn1IRdc4mHoi0xZkEEgT50rt2pjJcsgsC4tHTsxIyZsXbz48ZHur5g Junt+73y4/yjogVleaHa79S0XV3n5f8LSuMb3EycflnzjBNiuqj808iF80tmE+aCWcyv F9NoTxNDzGNfMeE+YSmcjMuneP2Imuff2H7KDpOGzDejjdrJfVO38Ujhc6yvfw+bOc6N C+adHqg+aJHPcVVYsawfEb2ghBmdYPCb+GD0hyQD99k9zAvMV06U9iAtfC0NpU5MJrO/ 7LoInQHCSbwQjgM0RaMZqOrPvKRhxuP2ObAHrUHx76qBoSUfZzg18cfissF1Lqgg4unx GItQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=a8KdkHDpk1QFWE0uev1+fXSqk27OFrjXeyo1VHkMZSo=; b=CnEpAYDuE5OvZYvJL7m7z2/CvUvJiATpOz1g2ErQe/LzZqtKUkMLYDjG1tnPToOtQv Zjqo3c6iPqxWh25+9nV6SGBfTktAnZRTTL82v2KPpBIBrJ7Esc7ZAhwY8dGaKIHl/sR/ nB1qYVN012wOVwV3db+ndGg5PDEHbzkKZSloQbhkOFiqXMChFnrKTHDwI+cAqjU7iX02 b2WMZPeLDrtGfX1LZJoX4/mCeHwkkNlhbSwqbUER1SJKc6ueacSZlNGBWWvl5s4j8JtE TOBD2mBvo7OqzKkTvE4LzKkOiwu2I5F8jEaWWGyf99atyVM3qRDgeW+MTfbVjoH7rX5i tpuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UYPHGh5f; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 7si1771984pft.276.2019.02.26.00.19.19; Tue, 26 Feb 2019 00:19:34 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UYPHGh5f; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726706AbfBZISo (ORCPT + 99 others); Tue, 26 Feb 2019 03:18:44 -0500 Received: from mail-ua1-f66.google.com ([209.85.222.66]:36702 "EHLO mail-ua1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725970AbfBZISn (ORCPT ); Tue, 26 Feb 2019 03:18:43 -0500 Received: by mail-ua1-f66.google.com with SMTP id e15so9889349uam.3 for ; Tue, 26 Feb 2019 00:18:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=a8KdkHDpk1QFWE0uev1+fXSqk27OFrjXeyo1VHkMZSo=; b=UYPHGh5f395QN2qqF2ENzBq/xaeokitmR3TMzat3m2hX63XN5jZhpB9JkRyde33Lb4 2siNquY+QNDKcYTfBQ7PXYlWwmTJ5zW3SY6irOrWaAQIrWKv7oUyl+lRNUfa/BivQo/g 4LnTamH8KmI3FnInFfUcdiu550CN7noUW+DtjINW6xQd8qeKBJOHbVeB1tBJILSL5DZu 1WsOzvDnfut9jKX2CyAkNj1jek3qqVyzw8CobXIJCEFu2EHM53iUnMn2TsQjjV1MqAHS YlaibZsNIGvxzsK3vSNHaK9BbCBOMSaTQPlWml/Kw0GfmxCrI+2SuFqN1+/v4zPMWLWT DhbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=a8KdkHDpk1QFWE0uev1+fXSqk27OFrjXeyo1VHkMZSo=; b=mrnwMPiu/lSrCW7r3FaFwPt3/GPALU+NtpGWhKN4l+lf3SIG6IceYDwWgct/wUODSm dT5VHxBXdl9e+ecM+QWAOB7JJTSDNlu1onIZ5cLPaJGMSLyNNnYMHxRZC+caY4+Z2Z5B 9Bnd1yEIlzScv5T2Y/Pd21gG139TaCilkpvJsGg1+5kHWqsJy55cjJ8fGh/RsSRHOTRd ExtDqLusVCqGYcTvDQz2BFLknerc68GNAteteDPK4TF/31Cu7aT+YSjuD5i4Dtjo6AKL Ji4NyOHUSO7LXRNxQt4GWvpTasa83LBTFLlGsJp7oGuRPE7SeV9q9C1LpvtStlAb7G57 rb2w== X-Gm-Message-State: AHQUAuao50f0UKMSomQDc0oza4eaZv94MrBkAFuxkdUSp6F6bfbqCVQm kS6uMKR3mksuPAtCA0XQsLX2vHCBPv+7jR25CTmiEg== X-Received: by 2002:a67:7685:: with SMTP id r127mr11415652vsc.35.1551169122768; Tue, 26 Feb 2019 00:18:42 -0800 (PST) MIME-Version: 1.0 References: <20190210173109.12602-1-j.neuschaefer@gmx.net> In-Reply-To: <20190210173109.12602-1-j.neuschaefer@gmx.net> From: Ulf Hansson Date: Tue, 26 Feb 2019 09:18:06 +0100 Message-ID: Subject: Re: [PATCH] mmc: spi: Fix card detection during probe To: =?UTF-8?Q?Jonathan_Neusch=C3=A4fer?= Cc: "linux-mmc@vger.kernel.org" , Linus Walleij , Laurent Pinchart , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, 10 Feb 2019 at 18:31, Jonathan Neusch=C3=A4fer wrote: > > When using the mmc_spi driver with a card-detect pin, I noticed that the > card was not detected immediately after probe, but only after it was > unplugged and plugged back in (and the CD IRQ fired). > > The call tree looks something like this: > > mmc_spi_probe > mmc_add_host > mmc_start_host > _mmc_detect_change > mmc_schedule_delayed_work(&host->detect, 0) > mmc_rescan > host->bus_ops->detect(host) > mmc_detect > _mmc_detect_card_removed > host->ops->get_cd(host) > mmc_gpio_get_cd -> -ENOSYS (ctx->cd_gpio not set) > mmc_gpiod_request_cd > ctx->cd_gpio =3D desc > > To fix this issue, call mmc_detect_change after the card-detect GPIO/IRQ > is registered. > > Signed-off-by: Jonathan Neusch=C3=A4fer This works well as fix and for stable! However, we should probably clean up the code in ->probe() to avoid this thing altogether. Anyway, I send a patch for that - on top. Applied for fixes and added a stable tag, thanks! Kind regards Uffe > --- > drivers/mmc/host/mmc_spi.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/mmc/host/mmc_spi.c b/drivers/mmc/host/mmc_spi.c > index 10ba46b728e8..8ade14fb2148 100644 > --- a/drivers/mmc/host/mmc_spi.c > +++ b/drivers/mmc/host/mmc_spi.c > @@ -1450,6 +1450,7 @@ static int mmc_spi_probe(struct spi_device *spi) > mmc->caps &=3D ~MMC_CAP_NEEDS_POLL; > mmc_gpiod_request_cd_irq(mmc); > } > + mmc_detect_change(mmc, 0); > > /* Index 1 is write protect/read only */ > status =3D mmc_gpiod_request_ro(mmc, NULL, 1, false, 0, NULL); > -- > 2.20.1 >