Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp4386564pxb; Tue, 5 Oct 2021 01:52:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyIiCyT6dG2yu0ymZpj/xLklL4IH8JG5z5JCU8ecyykNlpwrwh0UArUI+b7gPIMrNqJkcV2 X-Received: by 2002:aa7:d1c2:: with SMTP id g2mr24086305edp.248.1633423978507; Tue, 05 Oct 2021 01:52:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633423978; cv=none; d=google.com; s=arc-20160816; b=XkQon/zJ6WbTMvHmj8Ub28kkx1TToxUBVC1Dr4nDfmf9hMjybXrnMz4tO6CShp5PnH XyvmF1VMlkZmXx/Bi9pR3PXnKVliq+liZRfT/1QpsL6ueDPp6QPUE9l4LxhZG4p2W4lx rWx2ZIeM7JdLfv6hwL2l2z6g9lJVU8gPaBfvZBIBZ19urRb2d2gkoZZRGMiPMa0Ab6hj o2+otJWVGaXYIZKJMh1G7KFC427QyjDsjvO3ONLmRX+NwOZYiEX5ym6xwbl4UZVzmU0F NQlQGXPict4dqB3WY1bpSAstl5xCVv21e+F4D8hU3rBf6ltRmeAFT4WNJgPxZNAJzJAM Z1EA== 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:dkim-signature; bh=TPdDWrZ024V2l89FzGZge5J8n8C5n/epls0/vYEdkbM=; b=0A10+iXCbVMQuU68hNGy3ws2g4GYWKqdP7EoTiL+mqq5d8QwvH5bt6GLzejRqtfGTq /wcEkWaJtXXWic3+Y41etbXI9+4eiO1i/es0Kx6hqgzbgeaWeN6tbhC6CrVMNf1jV2Gl ReeyWvHQS97+tk8cAreE/YueE4qYeXNwel++AsjvkhuJAIG/X3BUzYvXLOh9AQOWndGk ioQbJjT9uPXXOdgH4vJcANq/+PWqG13GS+ENnIOe3cGv35pTZdLq5LOdsePj6SILQ5eF xNtA4xe1xP0e9kyGslERY1I4TTGIDT0c7dfD57jTiiXKHE4oS6ZXoPB0nIrt0uVGNNsY Elyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@geanix.com header.s=first header.b=ca4ypouv; 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=pass (p=NONE sp=NONE dis=NONE) header.from=geanix.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hp35si36596088ejc.307.2021.10.05.01.52.34; Tue, 05 Oct 2021 01:52:58 -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=@geanix.com header.s=first header.b=ca4ypouv; 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=pass (p=NONE sp=NONE dis=NONE) header.from=geanix.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233400AbhJEIvg (ORCPT + 99 others); Tue, 5 Oct 2021 04:51:36 -0400 Received: from first.geanix.com ([116.203.34.67]:37336 "EHLO first.geanix.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233376AbhJEIvc (ORCPT ); Tue, 5 Oct 2021 04:51:32 -0400 Received: from skn-laptop (_gateway [172.25.0.1]) by first.geanix.com (Postfix) with ESMTPSA id 7570EC24F2; Tue, 5 Oct 2021 08:49:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=geanix.com; s=first; t=1633423779; bh=AUnXTubOTobfFxzBcRJ9H6QzFIiTxSYi3vnBtn38bE4=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=ca4ypouvW1ZLkNzvJktUrFio8Kx3ez/L0TDZ04MxVnDZWsLpZps1HPPgy92L88FD3 DOE+KYItMLf/YMYSsIKOsH6R3nAWf+dKcp60WubGprP6x3zGMiwxUPmqs8f+QYE2QP IOi9tSbHpqTHBm7zeiRbnZsE9VHEwCA0edl5jLc2v9NzXpd+U4f86DBtuVoh2fd1IB 8BaXbDg8F2chpFewkSHSWA2Gk78MQNh8kDaZ9uvZwPbxWScL/EH6DMGHqaoNJYHZSX RDMFRTti1Fp7WVOUcEu6Safg+xRcPCOS66HlhBc4ZIblKCvWSTJm10iyteW4B3kl2g PkOX+oxqbq+Kw== Date: Tue, 5 Oct 2021 10:49:38 +0200 From: Sean Nyekjaer To: Boris Brezillon Cc: Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Boris Brezillon , linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [RFC PATCH] mtd: rawnand: use mutex to protect access while in suspend Message-ID: <20211005084938.jcbw24umhehoiirs@skn-laptop> References: <20211004065608.3190348-1-sean@geanix.com> <20211004104147.579f3b01@collabora.com> <20211004085509.iikxtdvxpt6bri5c@skn-laptop> <20211004115817.18739936@collabora.com> <20211004101246.kagtezizympxupat@skn-laptop> <20211004134700.26327f6f@collabora.com> <20211005070930.epgxb5qzumk4awxq@skn-laptop> <20211005102300.5da6d480@collabora.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20211005102300.5da6d480@collabora.com> X-Spam-Status: No, score=-3.1 required=4.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,URIBL_BLOCKED autolearn=disabled version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on 13e2a5895688 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Oct 05, 2021 at 10:23:00AM +0200, Boris Brezillon wrote: > On Tue, 5 Oct 2021 09:09:30 +0200 > Sean Nyekjaer wrote: [ ... ] > > > > Have you seen the reproducer script? > > How would I know about this script or your previous attempt (mentioned > at the end of this email) given I was not Cc-ed on the previous > discussion, and nothing mentions it in this RFC... > That's why I shared it here ;) Initially I thought this was a bug introduced by exec_op. > > --- > > root@iwg26-v1:/data/root# cat /data/crash.sh > > #!/bin/sh -x > > > > echo enabled > /sys/devices/platform/soc/2100000.bus/21f4000.serial/tty/ttymxc4/power/wakeup > > > > rm /data/test50M > > dd if=/dev/urandom of=/tmp/test50M bs=1M count=50 > > cp /tmp/test50M /data/ & > > sleep 1 > > echo mem > /sys/power/state > > --- > > > > As seen in the log above disk is synced before suspend. > > cp is continuing to copy data to ubifs. > > And then user space processes are frozen. > > At this point the kernel thread would have unwritten data. > > > > We tried to solve this with: > > https://lkml.org/lkml/2021/9/1/280 > > I see. It's still unclear to me when the write happens. Is it in the > suspend path (before the system is actually suspended), or in the > resume path (when the system is being resumed). > > Anyway, let's admit writing to a storage device while it's suspended is > a valid use case and requires the storage layer to put this request on > old. This wait should not, IMHO, be handled at the NAND level, but at > the MTD level (using a waitqueue, and an atomic to make > suspended/resumed transitions safe). And abusing a mutex to implement > that is certainly not a good idea. I did't say this was the right solution ;) I actually asked in the RFC: "Should we introduce a new mutex? Or maybe a spin_lock?" What are you proposing, a waitqueue in mtd_info? That gets checked in mtd_write()/mtd_read()? /Sean