Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp801521pxb; Wed, 27 Jan 2021 23:51:48 -0800 (PST) X-Google-Smtp-Source: ABdhPJxJb/nBZBh5ayWe5TAWyn/9Wmaiz8fM9/dilhT4uxlc2h1wXYEVjjEtczfMvPaliLHZcAzy X-Received: by 2002:aa7:d40f:: with SMTP id z15mr12517473edq.276.1611820308023; Wed, 27 Jan 2021 23:51:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611820308; cv=none; d=google.com; s=arc-20160816; b=JRjxU+bUH7fxXDG6P5jctF8B7AMB7E3FKXI4paQUGtmK9OU5ugXU54UlgdbgHBsUDI lK/FFnXDaB6TzS4IukuvF95yGxh5mdSaSaLKzx4+gmHUBEUe5HWynJaKcwLvbKYdjbF+ DfRcViCc9DcyI+up+qqlmNtHNLprfcsrip+50s2dv/WpNacYDmFTg6m15VVbZKY4BBHH uF0Gj4TmUqz5iNdVAxddMK2GHC5oKFK+31affFVuQ8DA4KO4LTM9vRnmE14l/k8sDZ0P SXYDDAXOtadHroOZSL8GDT8PB/QNHxdGSl3idnvpqz2HwjDAskMvBvLSRCDHTlLs9veo VHLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:thread-index:thread-topic :content-transfer-encoding:mime-version:subject:references :in-reply-to:message-id:cc:to:from:date; bh=u+wUB3Q+iu0zcPgfmjyfsMCY/gJ0RyLAKMbQ6nOy4lo=; b=aktFaysgV0p034LgsaKPJ4RBd4WnF4oYF4tJZImWvfwyauAp76N0fW4h82HuLr80HF SIQDTGY1e+uqG+LDoZzPoyTWVmABZOYNGd0ViY9sDT6cDjJVs2gDZk0Ry6mAemKXvn8E gfLayCopE/ybkqqAvbl5el1mJu2ATgO3vDs05i6QjyYDZSfoVL/7lqcn9aAQQG58SVPE DQFkY3MKV99h6A7CdWcf2LPri5FHSBWJ2Q+yY+5BpfDMBsxOlgsuNhgEYPzUecFBUsz2 IzCCcivC/X+pDqYZ2VZK53EvnxH3oErV+nY1Y3JtNMYKCZDJD8/QnKA1SMHRCozhhD1m 15qA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a12si2392738edr.294.2021.01.27.23.51.23; Wed, 27 Jan 2021 23:51:48 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232268AbhA1HuO convert rfc822-to-8bit (ORCPT + 99 others); Thu, 28 Jan 2021 02:50:14 -0500 Received: from lithops.sigma-star.at ([195.201.40.130]:59074 "EHLO lithops.sigma-star.at" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232274AbhA1Hr4 (ORCPT ); Thu, 28 Jan 2021 02:47:56 -0500 Received: from localhost (localhost [127.0.0.1]) by lithops.sigma-star.at (Postfix) with ESMTP id D1B596074005; Thu, 28 Jan 2021 08:47:11 +0100 (CET) Received: from lithops.sigma-star.at ([127.0.0.1]) by localhost (lithops.sigma-star.at [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id 2I6E_uKbcIlQ; Thu, 28 Jan 2021 08:47:11 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by lithops.sigma-star.at (Postfix) with ESMTP id 7917B6074007; Thu, 28 Jan 2021 08:47:11 +0100 (CET) Received: from lithops.sigma-star.at ([127.0.0.1]) by localhost (lithops.sigma-star.at [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id gwvr2wLtfqUm; Thu, 28 Jan 2021 08:47:11 +0100 (CET) Received: from lithops.sigma-star.at (lithops.sigma-star.at [195.201.40.130]) by lithops.sigma-star.at (Postfix) with ESMTP id 582B36074005; Thu, 28 Jan 2021 08:47:11 +0100 (CET) Date: Thu, 28 Jan 2021 08:47:11 +0100 (CET) From: Richard Weinberger To: Tomas Winkler Cc: Miquel Raynal , Vignesh Raghavendra , linux-mtd , linux-kernel Message-ID: <1665542284.336646.1611820031174.JavaMail.zimbra@nod.at> In-Reply-To: References: <20210127200319.662842-1-tomas.winkler@intel.com> <9732911.325628.1611780400338.JavaMail.zimbra@nod.at> <1776363776.325713.1611782270873.JavaMail.zimbra@nod.at> Subject: Re: [PATCH] mtd: use refcount to prevent corruption MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT X-Originating-IP: [195.201.40.130] X-Mailer: Zimbra 8.8.12_GA_3807 (ZimbraWebClient - FF78 (Linux)/8.8.12_GA_3809) Thread-Topic: use refcount to prevent corruption Thread-Index: AQHW9OeD00Da249Jw0qJn6+VIZAeUao7z7AAgAAh5BBxoBSOfPxzntFAEGBJdu8= Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Tomas, ----- Ursprüngliche Mail ----- >> >> Can you please explain a little more what devices are involved? >> >> Does it implement _get_device() and _put_device()? >> > No this is not connected to those handlers of the underlying device >> > and those won't help. >> > I have a spi device provided by MFD framework so it can go away anytime. >> >> Can it go away physically or just in software? > Software, but since this is mfd it's basically hotplug. The kernel is crashing > when I simulate hardware failure. >> >> Usually the pattern is that you make sure in the device driver that nobody can >> orphan the MTD while it is in use. >> e.g. drivers/mtd/ubi/gluebi.c does so. In _get_device() it grabs a reference on >> the underlying UBI volume to make sure it cannot go away while the MTD (on >> top of UBI) is in use. > > I can try that if it helps, because we are simulating possible lower level > crash. > In an case I believe that the proper refcouting is much more robust solution, > than the current one. > I'd appreciate if someone can review the actual implementation. This happens right now, I try to understand why exactly the current way is not good in enough. :-) Your approach makes sure that the MTD itself does not go away while it has users but how does this help in the case where the underlying MFD just vanishes? The MTD can be in use and the MFD can go away while e.g. mtd_read() or such takes place. Thanks, //richard