Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp3777348ybv; Tue, 25 Feb 2020 07:09:00 -0800 (PST) X-Google-Smtp-Source: APXvYqy/LCo4W8Azmdap7+MXWYzJjvQSbR0X4GuPrlSApmpLDzAlDmO9/b3N8kwGKYPS3dfukYch X-Received: by 2002:a9d:4c06:: with SMTP id l6mr46591706otf.161.1582643340022; Tue, 25 Feb 2020 07:09:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582643340; cv=none; d=google.com; s=arc-20160816; b=rqfrZDoTWqhBFEYGS5k5AJXLumOdb2TmiwLSHz+Bkl9BRVFwfQqxtcg5OMX8mnkqW1 8wYXPl6L2+tbt9ht+SR7xU662Wd0gzNluQWLPmPQojd6LXb7cO6WojaQBdcp/quXRFma BJeKusBXagItXw3EjJQeuB+y3gldgGBQ08Y6dfaazZy32p14kVaCu391X+FUSoF8ijf2 7fmCEFIYyavffqhEeB3IbKVl8WWjqE9KOUtIkIjCc0vl3KOCQzJmlSYSFQpsHqqPGGbj cvPTmBGQqAiW8iIm+DdxOsAtnVi3PEm/IZD+BzjewilFgn0qBDl3HSgrYaRZXWUijFbl wAeg== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=VAjOwG3wByBMn+LNEOxqdTA7mvnfEFLl2FcpxcCoSHY=; b=SYF4FcIN6mNOTk5W3HseyzolzDoYlKSy/gFzbP2vbgFp6PjbLPRJ2c+Ll9NAzwAp88 vBbY7KaQTh7Ox0vveHzNT2OoxiawqohzmL1fcMYttKrqeZMFRDjXwrT6HGZivMD7ASrF /bKLZnMoOdjqJ0wNgiqtmXLYwhoCgj7KmC77ZbtPdW847BryRawNBZx6m6T4TCDdLLzO OQY+b8yAE8DuPtZLb7dJ0DFe5QXiJCy49P/1Q+qp7uw4e0R/uvBixJjg3fLYa4LOqzNH DTFdmGrzVs32NvAv0q2Y7Cwm61lRZzU4ljNC6uuaShftK5+PcB0ZBi83HnKwCcIjJjTe wTlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BD+8OaHi; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g17si8398573otk.252.2020.02.25.07.08.41; Tue, 25 Feb 2020 07:09:00 -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; dkim=pass header.i=@linaro.org header.s=google header.b=BD+8OaHi; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730923AbgBYO7w (ORCPT + 99 others); Tue, 25 Feb 2020 09:59:52 -0500 Received: from mail-wr1-f66.google.com ([209.85.221.66]:33099 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730754AbgBYO7w (ORCPT ); Tue, 25 Feb 2020 09:59:52 -0500 Received: by mail-wr1-f66.google.com with SMTP id u6so15136391wrt.0 for ; Tue, 25 Feb 2020 06:59:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=VAjOwG3wByBMn+LNEOxqdTA7mvnfEFLl2FcpxcCoSHY=; b=BD+8OaHiDfSbH7mVkARg8BcbO6G1kpEnyE0SAe8AOMg0N1S4RUYy7IXx4Qd2yfoLvP P6mxlyK3EkbxhO2pn1wEc9tlQR3cORggeQs+dWlJ9XcG35sX61+FZpkvqQbu+YZbcsMc VZ5qDRe+dzkSOfRm6PTWaGhF1lh3/Tz0tVr8znpFmII4uoh4iaBl/aCSP/r3sbPo7TcT 7NMCc0qOSKz8WzRtRbnwD2dQ1935AdUB1JOzDpibqbtFq8BaekxDmJi93R59b4u8CP0/ eT3XRv7fM85vO1Zg59FyAmGLGPNJ0U0dIPFjn6PdOhjaJmEiCD1yj6DPR7M+3q8/+CaG ocyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=VAjOwG3wByBMn+LNEOxqdTA7mvnfEFLl2FcpxcCoSHY=; b=V87Kn7uHe7xxTQr9+D+KHQEWtyt2199R1LAipd/TCp77/6E4N6rSIT+HPwhkN7lSRl SnF8c//ZrWTPhtfCGoZCTV9+fAl77XDpwMvT7p3yy7Vx5PlVBrzLrKvWq3oVN0Bmnknn lC7SlklvWWvra3LGpOq0HpcSEiGdQxj+tzieWoDDkrbVWAUmGb4rrpsPom7RrA/wVCmb WPBKuV5i6YFvOp8eKMahvE44zpSuRM445EAO5GCkMA8Kqm9cQ41Uzk7ZmHzufBirPV+e 4Vcr7HlNrzwLl1pegIXg+77TGenNS5AVdB3sNW/2wouRpO8cKAFyt46n3tHS0lOiECDl GW6A== X-Gm-Message-State: APjAAAXZ8EBElfqJf0YEZomwnsWw7wFtcWAmLqB5k4MPMHEUQweN83JC VRtY90DvmX7cYU38AVtjm2Fs+VxRfG0= X-Received: by 2002:a05:6000:188:: with SMTP id p8mr72417075wrx.336.1582642787608; Tue, 25 Feb 2020 06:59:47 -0800 (PST) Received: from [192.168.86.34] (cpc89974-aztw32-2-0-cust43.18-1.cable.virginm.net. [86.30.250.44]) by smtp.googlemail.com with ESMTPSA id b7sm16062991wrs.97.2020.02.25.06.59.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 25 Feb 2020 06:59:46 -0800 (PST) Subject: Re: [PATCH v1 0/3] nvmem: Add support for write-only instances, and clean-up To: Nicholas Johnson , "linux-kernel@vger.kernel.org" Cc: Mika Westerberg References: From: Srinivas Kandagatla Message-ID: Date: Tue, 25 Feb 2020 14:59:46 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 24/02/2020 17:41, Nicholas Johnson wrote: > [Based on Linux v5.6-rc3, does not apply successfully to Linux v5.6-rc2] > > Hello all, > > I offer the first patch in this series to support write-only instances > of nvmem. The use-case is the Thunderbolt driver, for which Mika > Westerberg needs write-only nvmem. Refer to 03cd45d2e219 ("thunderbolt: > Prevent crash if non-active NVMem file is read"). > Had a look at the crash trace from the mentioned patch. Why can not we add a check for reg_read in bin_attr_nvmem_read() before dereferencing it? The reason I ask this is because removing read_only is not that simple as you think. Firstly because a there is no way to derive this flag by just looking at read/write callbacks. Providers are much more generic drivers ex: at24 which can have read/write interfaces implemented, however read only flag is enforced at board/platform level config either via device tree property bindings or a write protection gpio. Removing this is also going to break the device tree bindings. only alternative I can see ATM is the mentioned check. --srini > The second patch in this series reverts the workaround 03cd45d2e219 > ("thunderbolt: Prevent crash if non-active NVMem file is read") which > Mika applied in the mean time to prevent a kernel-mode NULL dereference. > If Mika wants to do this himself or there is some reason not to apply > this, that is fine, but in my mind, it is a logical progression to apply > one after the other in the same series. > > The third patch in this series removes the .read_only field, because we > do not have a .write_only field. It only makes sense to have both or > neither. Having either of them makes it hard to be consistent - what > happens if a driver were to set both .read_only and .write_only? And > there is the question of deciding if the nvmem is read-only because of > the .read_only, or based on if the .reg_read is not NULL. What if they > disagree? This patch does touch a lot of files, and I will understand if > you do not wish to apply it. It is optional and does not need to be > applied with the first two. > > Thank you in advance for reviewing these. > > Kind regards, > > Nicholas Johnson (3): > nvmem: Add support for write-only instances > Revert "thunderbolt: Prevent crash if non-active NVMem file is read" > nvmem: Remove .read_only field from nvmem_config > > drivers/misc/eeprom/at24.c | 4 +- > drivers/misc/eeprom/at25.c | 4 +- > drivers/misc/eeprom/eeprom_93xx46.c | 4 +- > drivers/mtd/mtdcore.c | 1 - > drivers/nvmem/bcm-ocotp.c | 1 - > drivers/nvmem/core.c | 5 +- > drivers/nvmem/imx-iim.c | 1 - > drivers/nvmem/imx-ocotp-scu.c | 1 - > drivers/nvmem/imx-ocotp.c | 1 - > drivers/nvmem/lpc18xx_otp.c | 1 - > drivers/nvmem/meson-mx-efuse.c | 1 - > drivers/nvmem/nvmem-sysfs.c | 77 ++++++++++++++++++++++++++--- > drivers/nvmem/nvmem.h | 1 - > drivers/nvmem/rockchip-efuse.c | 1 - > drivers/nvmem/rockchip-otp.c | 1 - > drivers/nvmem/sc27xx-efuse.c | 1 - > drivers/nvmem/sprd-efuse.c | 1 - > drivers/nvmem/stm32-romem.c | 1 - > drivers/nvmem/sunxi_sid.c | 1 - > drivers/nvmem/uniphier-efuse.c | 1 - > drivers/nvmem/zynqmp_nvmem.c | 1 - > drivers/soc/tegra/fuse/fuse-tegra.c | 1 - > drivers/thunderbolt/switch.c | 8 --- > drivers/w1/slaves/w1_ds250x.c | 1 - > include/linux/nvmem-provider.h | 2 - > 25 files changed, 77 insertions(+), 45 deletions(-) >