Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp1143730ybx; Tue, 5 Nov 2019 11:05:29 -0800 (PST) X-Google-Smtp-Source: APXvYqw4IgS80VzCS/XlrfNcmlrmJQVNH8QroCc7nY1sjPD4J0keRCppOo/mDsQV4yEYszhDa+LO X-Received: by 2002:aa7:c048:: with SMTP id k8mr37282747edo.254.1572980729474; Tue, 05 Nov 2019 11:05:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1572980729; cv=none; d=google.com; s=arc-20160816; b=POFhqmdupgEqdxHrobi+OT0jZAYKE3/LZKhrZPYC+qvnRflwsZMq/BTulCYeOYzP4x GxlEL8i2Ax184d5KNQpx0Gm9FuT9HvgPqDXjys26tETOFRjpCRqYJWRpFixdb8Q6aTvt yBu5y2RxDnE2cIXWXPOFWRzMBt5YiWIzS7tDI9+trVBT6B6FyTHJJ61hcq19NbNfspKA sVeZNLLA0uHJIFeH+61+i9oF+50fkJ6i2nbdAb7kn0lrZGCvWi3eBu4eKCDtismH7ryO a1CsGRn9TimkGFhf9N1CW56bVrKFgIdHdNZ2Q90gmmLfcEkQl+VRpZo+KMhLAACmkL6b /Kiw== 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:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=XhVrmp0HFTS/9Y05yyVs1EquzgxI0gubOZBjzVFX/qU=; b=jifcN+SfWqcJTS7XNj5uveMGh9eTiaD8sc++x4ar3FMOPSAWHBT2cj4+cLHO0t1huc dhpIy5nGRAzaZ+nK8jUK7SQhOaYeOSyhbN8kdy3PYggQSBZVF5X1+SeLn0wZ8axPbTse 3Z1b+TabTUSnZW8GRz3i1b4ILDqiNUwXKzyO1LvUWaOD1AIA3i0WLpkheOElQNpCrVa0 7tEHmP2ex5ax2dz3TC38z+4inKt0wcfb6Iy1E7LzJlvqyvgCz8PFKNz0U8xAoxf96lSL hpcikvvnPd1ZifdRoJ+G8l4cm9+SLk3tLjySbc/yRQlSu9elrorHd+vkIyMlBVl/2YsZ an8A== ARC-Authentication-Results: i=1; mx.google.com; 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 i39si9932220eda.88.2019.11.05.11.05.04; Tue, 05 Nov 2019 11:05:29 -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; 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 S2390746AbfKETDu convert rfc822-to-8bit (ORCPT + 99 others); Tue, 5 Nov 2019 14:03:50 -0500 Received: from relay7-d.mail.gandi.net ([217.70.183.200]:48345 "EHLO relay7-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390514AbfKETDu (ORCPT ); Tue, 5 Nov 2019 14:03:50 -0500 X-Originating-IP: 91.224.148.103 Received: from xps13 (unknown [91.224.148.103]) (Authenticated sender: miquel.raynal@bootlin.com) by relay7-d.mail.gandi.net (Postfix) with ESMTPSA id 4E88320004; Tue, 5 Nov 2019 19:03:46 +0000 (UTC) Date: Tue, 5 Nov 2019 20:03:44 +0100 From: Miquel Raynal To: Kamal Dasu Cc: linux-mtd@lists.infradead.org, bcm-kernel-feedback-list@broadcom.com, linux-kernel@vger.kernel.org, David Woodhouse , Brian Norris , Marek Vasut , Richard Weinberger , Vignesh Raghavendra Subject: Re: [PATCH] mtd: set mtd partition panic write flag Message-ID: <20191105200344.1e8c3eab@xps13> In-Reply-To: <20191021193343.41320-1-kdasu.kdev@gmail.com> References: <20191021193343.41320-1-kdasu.kdev@gmail.com> Organization: Bootlin X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Kamal, Richard, something to look into below :) Kamal Dasu wrote on Mon, 21 Oct 2019 15:32:52 -0400: > Check mtd panic write flag and set the mtd partition panic > write flag so that low level drivers can use it to take > required action to ensure oops data gets written to assigned > mtd partition. I feel there is something wrong with the current implementation regarding partitions but I am not sure this is the right fix. Is this something you detected with some kind of static checker or did you actually experience an issue? In the commit log you say "check mtd (I suppose you mean the master) panic write flag and set the mtd partition panic write flag" which makes sense, but in reality my understanding is that you do the opposite: you check mtd->oops_panic_write which is the partitions' structure, and set part->parent->oops_panic_write which is the master's flag. Also, I am not sure if it is worth checking anything, why not just set mtd->oops_panic_write in this function? Same comment for the -already existing- condition in mtd_panic_write. As soon as we are in these functions, we know there is a panic, right? So why checking if the bit is already set before forcing it? > > Fixes: 9f897bfdd8 ("mtd: Add flag to indicate panic_write") > Signed-off-by: Kamal Dasu > --- > drivers/mtd/mtdpart.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c > index 7328c066c5ba..b4f6479abeda 100644 > --- a/drivers/mtd/mtdpart.c > +++ b/drivers/mtd/mtdpart.c > @@ -159,6 +159,10 @@ static int part_panic_write(struct mtd_info *mtd, loff_t to, size_t len, > size_t *retlen, const u_char *buf) > { > struct mtd_part *part = mtd_to_part(mtd); > + > + if (mtd->oops_panic_write) > + part->parent->oops_panic_write = true; > + > return part->parent->_panic_write(part->parent, to + part->offset, len, > retlen, buf); > } Thanks, Miquèl