From patchwork Wed Mar 29 23:48:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dennis Zhou X-Patchwork-Id: 76858 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp763005vqo; Wed, 29 Mar 2023 16:56:19 -0700 (PDT) X-Google-Smtp-Source: AKy350bLw+bwtdOQb6+qpnql8nR42gX7t1+Z5h9QHKDz0l7Ty+S7hNDm1TYB67XCEIzCDhFW2WEW X-Received: by 2002:a17:906:9149:b0:932:4990:2563 with SMTP id y9-20020a170906914900b0093249902563mr22338715ejw.24.1680134178872; Wed, 29 Mar 2023 16:56:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680134178; cv=none; d=google.com; s=arc-20160816; b=GuApmh2I51i/mejQgJ4gfxy3BGUStxMGMmqssHwWuDRQGnE8jYMfdl50FDtnZM3E2t foBLGaRx0iqTudIjHCQAUojYnfNWbcaEtSlYmGhz07DlfxjSS6yO4Fyn3OUKlM7ev7Ny 4Pj/X7KPheU9GW0F+523SBksKCoHWc4tHY/MdNG8p1Q4MUC/F1GsgOau8+rOUw3PyHsZ oA0/2/AYpq8vryi8/b6JCSJzkh1vVAIDTwW4zEtyhRuHRJsG3jozxkmnNU5cRc/XvCUM ZR5g/H3Rx/BiD5MS7nXcW5wyFrfyS7Bt2u5+sGfPy+r/3EbcLBbTx4KHmjSokotkWTdQ akBA== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q17-20020a170906361100b00932b536587csi33278014ejb.354.2023.03.29.16.55.50; Wed, 29 Mar 2023 16:56:18 -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 S230385AbjC2XsJ (ORCPT + 99 others); Wed, 29 Mar 2023 19:48:09 -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-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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761735951370094636?= X-GMAIL-MSGID: =?utf-8?q?1761748376875965194?= 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 Acked-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)