Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1349430rwl; Wed, 29 Mar 2023 16:48:47 -0700 (PDT) X-Google-Smtp-Source: AKy350bDq1aanbGC+u8XYsoaA4a1JoJp1paoycRuDyWJlPCdRkHI8hsQKS/42qcK0fU7VmUtlHA9 X-Received: by 2002:a17:906:cb87:b0:931:8ad4:a586 with SMTP id mf7-20020a170906cb8700b009318ad4a586mr21758813ejb.30.1680133726855; Wed, 29 Mar 2023 16:48:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680133726; cv=none; d=google.com; s=arc-20160816; b=k7pH/eGbMMPAh6IGTpEO5XGCktKEmGZYuHlhtOYKS4MxJ2Jfc6NCtjWfXthYNUlT5G nHDkCLqvKpSfihoRMdqb4RkrEpWw/2QNMJLe4M3C5ET6x4qZyw9OCg3Ld/BuD6WULt1a M/X3SwBIlnWl55V3STOfFwIWSi8DFnYcvWzKUEpYwCODVop5yQIMZNgPx/SB6dPaCpNc ViU7c4iLkM+eExqXc7uk5V+5t3eBRHJvGeVvoztFxpOssD0nzOTXdzKGrEgZo/nBt7nG srl8a22c/hCzBI3sIEjMZYMTAh+87DrBxMxjPZlgsV8VcYTfWqTFzHzX5T8HnAh9h+A/ p+WQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=7ETYu9f3O7bRoQnr7/k7PLVrkbB1GMeAB1+nXGIoc5o=; b=dSDGMpcYM9l2juo00kclnGwSEQGS5Y3uCX64l7ieLMct2XjaPuUeakifFyYvKRAyDd 4sR1Qjj6s6aQby7YxClQgK+eWWDr4nYRWxNBbNlABp1sedLQgyZmQx0tGfoLkI1Byxdd F/FOvIgCsYMD4PgshaSJPk008BR8umdXRbiXeUKIgGq6HMSYsXDWyMKfvdoxeerBh7vp us2SK2sCyrNMmvJ+b0tbJghzHqY+B/LV7UL2tHC+p0FL6IT479xXwollqr7hHQOugQ5j QRqYspLDM6AfTlJNP68sOzeDTMqe3dFcL80VQq9ksLlKXfNBmHof2VPyskG8n8nEg24c kGEQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gt35-20020a1709072da300b0093cf8c96446si21136007ejc.686.2023.03.29.16.48.20; Wed, 29 Mar 2023 16:48:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230292AbjC2XsI (ORCPT + 99 others); Wed, 29 Mar 2023 19:48:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229462AbjC2XsH (ORCPT ); Wed, 29 Mar 2023 19:48:07 -0400 Received: from mail-pj1-f46.google.com (mail-pj1-f46.google.com [209.85.216.46]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 98C423C1E; Wed, 29 Mar 2023 16:48:06 -0700 (PDT) Received: by mail-pj1-f46.google.com with SMTP id lr16-20020a17090b4b9000b0023f187954acso17889294pjb.2; Wed, 29 Mar 2023 16:48:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680133686; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=7ETYu9f3O7bRoQnr7/k7PLVrkbB1GMeAB1+nXGIoc5o=; b=iRI/dFowb/m0oJsln98s1Zh6mfmPsRdbtf1nvZSX9l9fJ/73lqbptBUFzlVZ+uFtDn jqgpnRMrIFQM/EaOQXAZY/tyXRFVYt88CNWhowJdTB0X5i1xgDFjMFF/V6E2Et5IeISm Ey4uKhA5ZXiCx45Fe3kPiKENijwhGZ9OJRy9P6aTMmZXXClIXStaMqFBKTIk0O34b8b+ xlHlEuwJQSju/XABmtJfV//oFmbMHZ5+z+mfKx8497Ew++9ktbvFqhLb1FQhpoqeR/Ap 90e4ioE1yepgP+GyygZCBWv5NGk11FysjmKzsvLLjP5zP5jBCZFIClxTQF9DfzVJeTpB fAYA== X-Gm-Message-State: AAQBX9fLUuyLPox2rYpXrVCVOMIjK8wPVGVAL47+/uvnhRiYx/OELbw1 xEjFSNZW6+vfq+E0quwxoCQb3XidEu5wnw== X-Received: by 2002:a17:90b:4c12:b0:23f:7dfb:7dc1 with SMTP id na18-20020a17090b4c1200b0023f7dfb7dc1mr22878981pjb.33.1680133685493; Wed, 29 Mar 2023 16:48:05 -0700 (PDT) Received: from snowbird ([199.73.127.3]) by smtp.gmail.com with ESMTPSA id q59-20020a17090a1b4100b00233acae2ce6sm1931922pjq.23.2023.03.29.16.48.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Mar 2023 16:48:05 -0700 (PDT) Date: Wed, 29 Mar 2023 16:48:01 -0700 From: Dennis Zhou To: Ulf Hansson Cc: linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] mmc: inline the first mmc_scan() on mmc_start_host() Message-ID: References: <20230329202148.71107-1-dennis@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230329202148.71107-1-dennis@kernel.org> X-Spam-Status: No, score=0.5 required=5.0 tests=FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When using dm-verity with a data partition on an emmc device, dm-verity races with the discovery of attached emmc devices. This is because mmc's probing code sets up the host data structure then a work item is scheduled to do discovery afterwards. To prevent this race on init, let's inline the first call to detection, __mm_scan(), and let subsequent detect calls be handled via the workqueue. Signed-off-by: Dennis Zhou --- Sigh.. fix missing static declaration. drivers/mmc/core/core.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 368f10405e13..fda7ee57dee3 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -2185,10 +2185,8 @@ int mmc_card_alternative_gpt_sector(struct mmc_card *card, sector_t *gpt_sector) } EXPORT_SYMBOL(mmc_card_alternative_gpt_sector); -void mmc_rescan(struct work_struct *work) +static void __mmc_rescan(struct mmc_host *host) { - struct mmc_host *host = - container_of(work, struct mmc_host, detect.work); int i; if (host->rescan_disable) @@ -2249,6 +2247,14 @@ void mmc_rescan(struct work_struct *work) mmc_schedule_delayed_work(&host->detect, HZ); } +void mmc_rescan(struct work_struct *work) +{ + struct mmc_host *host = + container_of(work, struct mmc_host, detect.work); + + __mmc_rescan(host); +} + void mmc_start_host(struct mmc_host *host) { host->f_init = max(min(freqs[0], host->f_max), host->f_min); @@ -2261,7 +2267,8 @@ void mmc_start_host(struct mmc_host *host) } mmc_gpiod_request_cd_irq(host); - _mmc_detect_change(host, 0, false); + host->detect_change = 1; + __mmc_rescan(host); } void __mmc_stop_host(struct mmc_host *host) -- 2.40.0