Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp4409162pxu; Mon, 12 Oct 2020 19:22:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxiF8h6N/riYUMcZb+va9ppCuMu8xtXg3F6qTLNGh0cULDRu4cIotjTksmmecFNOjfQWapT X-Received: by 2002:a05:6402:2076:: with SMTP id bd22mr17969245edb.197.1602555753138; Mon, 12 Oct 2020 19:22:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602555753; cv=none; d=google.com; s=arc-20160816; b=cHq/BqLLePKweg07HqXfwyXYYC4upv2sVKQBLLvq2bFcU7L1kIk+6rrXS7vVKxqoMY rhU1P9o34vHexf2bukMMKbt8DgDbvW9vs/e1qZBD1US5QIyLJ2mQ0DBEQDV7q058VzJq ndYnylirV7vwkCJv1FY+Reo4eSt7bGl4LAw7FOBJf1Y1YrvIXUD4I5Gu7Z+lyVg7M24e 4yP+LtjkyJ5fPDYCsYObubL12A7eLWkHlpJJknEeVaeLPoE55evkerfd+Q/nIcLQ7IAK 5nNQBz2R2B4Kh8LckzLEaAAtNLGEbTgQArcHYrHv0YAyW44a/G5o/wUE5XSCXzNsIZgT eGqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=QoD1fcadF/unFWkv5sT9HEGbx+O/W7urOO5u3Ibjobw=; b=wfau7tn5OcLSz2Ccj0ufvkDAasiVBHn92hYCvxRcQwDQWpkCXAMlwtkRr22uuqvPeB HPf5/A7Ias7u0ujft76EqbkF+js8NOMcdPzP9aTEkzLDjnhj0XG6myWEEJ219g7ork6E 7N9r/zNYzh9V13GQ7clc5Ys47q1rjob5LvuVeZOorlBahUZYxA9KhZrpn+LaPqdqd31s Li6ewYpXtqfZWslfUZK1mZ0AdHWe5lVEhGLSxMuk9Z91+NP7IypwIzAoLihz/Vcj0ckn PIQ7A9kCTwWmamD63VH2FQV0Gwimgf7QqQjHt2uLlGjVI8hphk4wlHZ0pI/wXLn6gRNb Oj0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=1iIHf4GJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v22si13076493ejj.27.2020.10.12.19.22.10; Mon, 12 Oct 2020 19:22:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=1iIHf4GJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390214AbgJLOCJ (ORCPT + 99 others); Mon, 12 Oct 2020 10:02:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:40116 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731008AbgJLNiB (ORCPT ); Mon, 12 Oct 2020 09:38:01 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5146522280; Mon, 12 Oct 2020 13:37:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1602509879; bh=qjAjUT1EOq/LtcBgKckRAfwZ+DgXureRRbtoz4zHvm8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1iIHf4GJ/vduPKjn4fqCq2UARH0l7+ANQKq4wj9scAk6M5Zstc+3nsK62aeGr9tXg 52ZPuXiaq4wO3CgfqaFL91J/rCCXb3xVT3YyeDXA8/iDCtulrnEuSxQXsVA6cjaMtQ 52kDvZzElguAzuEIYl7ExqrcIjfpPFYbqJhRqyz8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Coly Li , Adrian Hunter , Ulf Hansson , Sasha Levin , Vicente Bergas Subject: [PATCH 4.14 68/70] mmc: core: dont set limits.discard_granularity as 0 Date: Mon, 12 Oct 2020 15:27:24 +0200 Message-Id: <20201012132633.481704808@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201012132630.201442517@linuxfoundation.org> References: <20201012132630.201442517@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Coly Li [ Upstream commit 4243219141b67d7c2fdb2d8073c17c539b9263eb ] In mmc_queue_setup_discard() the mmc driver queue's discard_granularity might be set as 0 (when card->pref_erase > max_discard) while the mmc device still declares to support discard operation. This is buggy and triggered the following kernel warning message, WARNING: CPU: 0 PID: 135 at __blkdev_issue_discard+0x200/0x294 CPU: 0 PID: 135 Comm: f2fs_discard-17 Not tainted 5.9.0-rc6 #1 Hardware name: Google Kevin (DT) pstate: 00000005 (nzcv daif -PAN -UAO BTYPE=--) pc : __blkdev_issue_discard+0x200/0x294 lr : __blkdev_issue_discard+0x54/0x294 sp : ffff800011dd3b10 x29: ffff800011dd3b10 x28: 0000000000000000 x27: ffff800011dd3cc4 x26: ffff800011dd3e18 x25: 000000000004e69b x24: 0000000000000c40 x23: ffff0000f1deaaf0 x22: ffff0000f2849200 x21: 00000000002734d8 x20: 0000000000000008 x19: 0000000000000000 x18: 0000000000000000 x17: 0000000000000000 x16: 0000000000000000 x15: 0000000000000000 x14: 0000000000000394 x13: 0000000000000000 x12: 0000000000000000 x11: 0000000000000000 x10: 00000000000008b0 x9 : ffff800011dd3cb0 x8 : 000000000004e69b x7 : 0000000000000000 x6 : ffff0000f1926400 x5 : ffff0000f1940800 x4 : 0000000000000000 x3 : 0000000000000c40 x2 : 0000000000000008 x1 : 00000000002734d8 x0 : 0000000000000000 Call trace: __blkdev_issue_discard+0x200/0x294 __submit_discard_cmd+0x128/0x374 __issue_discard_cmd_orderly+0x188/0x244 __issue_discard_cmd+0x2e8/0x33c issue_discard_thread+0xe8/0x2f0 kthread+0x11c/0x120 ret_from_fork+0x10/0x1c ---[ end trace e4c8023d33dfe77a ]--- This patch fixes the issue by setting discard_granularity as SECTOR_SIZE instead of 0 when (card->pref_erase > max_discard) is true. Now no more complain from __blkdev_issue_discard() for the improper value of discard granularity. This issue is exposed after commit b35fd7422c2f ("block: check queue's limits.discard_granularity in __blkdev_issue_discard()"), a "Fixes:" tag is also added for the commit to make sure people won't miss this patch after applying the change of __blkdev_issue_discard(). Fixes: e056a1b5b67b ("mmc: queue: let host controllers specify maximum discard timeout") Fixes: b35fd7422c2f ("block: check queue's limits.discard_granularity in __blkdev_issue_discard()"). Reported-and-tested-by: Vicente Bergas Signed-off-by: Coly Li Acked-by: Adrian Hunter Cc: Ulf Hansson Link: https://lore.kernel.org/r/20201002013852.51968-1-colyli@suse.de Signed-off-by: Ulf Hansson Signed-off-by: Sasha Levin --- drivers/mmc/core/queue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mmc/core/queue.c b/drivers/mmc/core/queue.c index f74f9ef460cc9..218472879d9ce 100644 --- a/drivers/mmc/core/queue.c +++ b/drivers/mmc/core/queue.c @@ -143,7 +143,7 @@ static void mmc_queue_setup_discard(struct request_queue *q, q->limits.discard_granularity = card->pref_erase << 9; /* granularity must not be greater than max. discard */ if (card->pref_erase > max_discard) - q->limits.discard_granularity = 0; + q->limits.discard_granularity = SECTOR_SIZE; if (mmc_can_secure_erase_trim(card)) queue_flag_set_unlocked(QUEUE_FLAG_SECERASE, q); } -- 2.25.1