Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1803295ybz; Thu, 30 Apr 2020 05:54:02 -0700 (PDT) X-Google-Smtp-Source: APiQypIRutDEp6hIXJBKuWWeJItQdl3g+zwK6QJZc9l80NVg+ReGr4FULzJYEGLVns29z2JCrjTX X-Received: by 2002:a50:ee86:: with SMTP id f6mr2610181edr.123.1588251242630; Thu, 30 Apr 2020 05:54:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588251242; cv=none; d=google.com; s=arc-20160816; b=a/DZQaf+kpcqtlNMkZU+ysSx6sDgWDVFWU0wH1r0+ohns4o4k5gwVgrOtamCDKQk3Y gZMgK8HjjuwaZpXMi85ih0NlWa020lDDOjAeYuV/JzAMF9mAByS9wd6I3g4SCZkLDTnS ohT7Z4skWKhjUL/lZv2odvecOWU3PWvyOr1qyWXRKXE7E4LfIaOlGxqSY9PAgrZ2mQaK udMo9kms8w+Eg/YIKnyEULxb5v/0FrCR0F7OlMCVU+r/nK01K4CRQ5X/y/8FFkcHmF6B QHmE6vac6Uz7lZni1MaTC7wTSD6a/rmdd0Gj2XHzEI2Gjw+SZ4aJjsEmcA3H5S5IPNrg EdTQ== 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=qBOpLYhVKzBZcfMSpd0UfJdlSBsgp/BBww8ay7w8x8o=; b=UKGrqdFtGb8oAPuhHa6n5q28/W5QfDjgESfX6izF7JzVcvVnZTbmZFx8ZAx44CttJW 2SuL4hKk0SGFm0fQeD6wraYrIWUcUEnAIU1biBG497Gkp254CtNSMMY+FGXHMmi5Yskx PXLC3a65lRhWuYYW8NMIvmaEcti1yQVLtIEah2onVRimLurQnMYIZeC4DiED/vz7L9fT Cnp9isCvwOc1/uGIRlQ5/GEazYCzYjr2PwULA5TcFey8ex2VksPij80w4DsCsepUt/wu WQ+I80KXuNgYxcqGlBzBV8mV23RrxJH/iMAuYyu883uDRRgvF+paxsa/IdI70OsaiAvM D3SQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r25si5583111edb.189.2020.04.30.05.53.38; Thu, 30 Apr 2020 05:54:02 -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; 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=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726760AbgD3MwM (ORCPT + 99 others); Thu, 30 Apr 2020 08:52:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45468 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726127AbgD3MwM (ORCPT ); Thu, 30 Apr 2020 08:52:12 -0400 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B821BC035494 for ; Thu, 30 Apr 2020 05:52:11 -0700 (PDT) Received: from localhost (unknown [IPv6:2a01:e0a:2c:6930:5cf4:84a1:2763:fe0d]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: bbrezillon) by bhuna.collabora.co.uk (Postfix) with ESMTPSA id 631232A274B; Thu, 30 Apr 2020 13:52:08 +0100 (BST) Date: Thu, 30 Apr 2020 14:52:05 +0200 From: Boris Brezillon To: Ricardo Ribalda Delgado Cc: Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , linux-mtd@lists.infradead.org, LKML , Tudor Ambarus Subject: Re: [PATCH v2] mtd: Fix mtd not the same name not registered if nvmem Message-ID: <20200430145205.06e16bd4@collabora.com> In-Reply-To: References: <20200401100240.445447-1-ribalda@kernel.org> <20200402065953.9974-1-ribalda@kernel.org> <20200427162222.1c2b2c85@xps13> <20200427163711.07614619@collabora.com> <20200427164922.5829717f@xps13> <20200427211024.174f5830@collabora.com> Organization: Collabora X-Mailer: Claws Mail 3.17.5 (GTK+ 2.24.32; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 30 Apr 2020 14:26:51 +0200 Ricardo Ribalda Delgado wrote: > Hi > > On Mon, Apr 27, 2020 at 9:10 PM Boris Brezillon > wrote: > > > > On Mon, 27 Apr 2020 16:49:22 +0200 > > Miquel Raynal wrote: > > > > > Hi Boris, > > > > > > Boris Brezillon wrote on Mon, 27 Apr > > > 2020 16:37:11 +0200: > > > > > > > On Mon, 27 Apr 2020 16:22:22 +0200 > > > > Miquel Raynal wrote: > > > > > > > > > Hi Ricardo, > > > > > > > > > > Ricardo Ribalda Delgado wrote on Tue, 14 Apr 2020 > > > > > 15:47:23 +0200: > > > > > > > > > > > Ping? > > > > > > > > > > > > On Thu, Apr 2, 2020 at 8:59 AM Ricardo Ribalda Delgado > > > > > > wrote: > > > > > > > > > > > > > > When the nvmem framework is enabled, a nvmem device is created per mtd > > > > > > > device/partition. > > > > > > > > > > > > > > It is not uncommon that a device can have multiple mtd devices with > > > > > > > partitions that have the same name. Eg, when there DT overlay is allowed > > > > > > > and the same device with mtd is attached twice. > > > > > > > > > > > > > > Under that circumstances, the mtd fails to register due to a name > > > > > > > duplication on the nvmem framework. > > > > > > > > > > > > > > With this patch we add a _1, _2, _X to the subsequent names if there is > > > > > > > a collition, and throw a warning, instead of not starting the mtd > > > > > > > device. > > > > > > > > > > > > > > [ 8.948991] sysfs: cannot create duplicate filename '/bus/nvmem/devices/Production Data' > > > > > > > [ 8.948992] CPU: 7 PID: 246 Comm: systemd-udevd Not tainted 5.5.0-qtec-standard #13 > > > > > > > [ 8.948993] Hardware name: AMD Dibbler/Dibbler, BIOS 05.22.04.0019 10/26/2019 > > > > > > > [ 8.948994] Call Trace: > > > > > > > [ 8.948996] dump_stack+0x50/0x70 > > > > > > > [ 8.948998] sysfs_warn_dup.cold+0x17/0x2d > > > > > > > [ 8.949000] sysfs_do_create_link_sd.isra.0+0xc2/0xd0 > > > > > > > [ 8.949002] bus_add_device+0x74/0x140 > > > > > > > [ 8.949004] device_add+0x34b/0x850 > > > > > > > [ 8.949006] nvmem_register.part.0+0x1bf/0x640 > > > > > > > ... > > > > > > > [ 8.948926] mtd mtd8: Failed to register NVMEM device > > > > > > > > > > > > > > Signed-off-by: Ricardo Ribalda Delgado > > > > > > > > > > Thanks for proposing this change. Indeed we are aware of the problem > > > > > and the best solution that we could come up with was to create an > > > > > additional "unique_name" field to the mtd_info structure. This new > > > > > field would have the form: > > > > > > > > > > [] > > > > > > > > > > The separator might be '~' (but I am completely open on that), and that > > > > > would give for instance: > > > > > > > > > > my-controller~my-device~my-part~mysub-part > > > > > > > > I'd prefer something slightly more standard for the separator, like '/', > > > > which is what we usually use when we want to represent a path in a tree. > > > > I do agree on the general approach though. > > > > > > I am not sure / is a valid separator here we would use this > > > name to create a sysfs entry. Would it work? > > > > Hm, you're probably right, I didn't check how the name was used by > > nvmem. I also see that partition names can contain spaces, which is > > not that great. So, if we want to use mtd->unique_name we should > > probably sanitize it before passing it to nvmem. All this makes me > > reconsider your initial proposal: use 'mtdX' as the nvmem name. It's > > unique and it's simple enough to not require this extra sanitization > > pass, on the other hand, guessing the nvmem partition based on such an > > opaque name is not simple, not to mention that the mtd device name can > > change depending on the probe order. > > > > I also wonder if creating nvmem devs unconditionally for all mtd > > devices is a good idea. Sounds like we should only do that if there's an > > explicit request to have one partition exposed as an nvmem. > > > > Note that, no matter what we decide about nvmem, I think having unique > > names at the MTD level is a good thing. > > I have no preference one way or another. > > The issue is that our current master leads to mtds not working fine > and making the system unusable. Whatever we decide it must be fast and > the patch backported. > > My original patch follows the same logic as led does where there is a > duplicated name. I can send a separate patch that uses mtdX and then > you decide what to pick. Or we can go with a third way, but it needs > to be soon ;). Please send a patch using dev_name(&mtd->dev), and let's hope it doesn't break someone else use case.