Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1929795pxa; Mon, 3 Aug 2020 02:58:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxefh/PbfweS0zXmQnThItge6nTCEdU1HKZlY0f2EYonBksIl4oX0X+oyFU9Z56iyj70woZ X-Received: by 2002:a05:6402:7d5:: with SMTP id u21mr14658292edy.235.1596448708838; Mon, 03 Aug 2020 02:58:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596448708; cv=none; d=google.com; s=arc-20160816; b=tI70Aaiyhq/KUxSWiOym3fZioWfuYm3h/dYvvoLZoLHI1gHDY+HMdrqv8Ll7wA4FFZ jNExyHjpvLTWkiPqpwRY7IyS6QFtzyucUJZXJBX9UiXRnAInj45M1hNpjcTdJsBSP7w0 raKVJbKAtZ1SIXngjmh0H1+zgKeplTfa+VQEVMfzS9MHeixs/FlONIxkjRUQfmSOitkx /gFGVBO9yQ9paHNaHCPbS7yrGoqssscl9kiKBa20dL0XH8WV39GEViTPDrzEmsFYwcnK akqjAF+5rN9PGZe2+oonrKbMtx4atTY1EarAa1LSXhzo5snFBTLzy7x7uiKzXLhHIj04 hhVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:organization:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:ironport-sdr:ironport-sdr; bh=GxLB2nwMnOQ7VqtON+nyB290TDnllVSyNdbSSMwDvf0=; b=iqXhR7nzp9MEqYCa9Vo2k4k0+eC8vRum6uhp46cHXq/kEENovgKLoQ7iwFZGU2E0jg kKbDu5UljcI3juQhlLlrcI2K4M966MqyQVQzoeTfyfIa8oCTHXvpK4fnZ4F0V6oTwQTa R2AlEZa8Y2LfWiSL9AMnVGtC15V4XsOwMnWVfFeZetq8ed2rtYDvCr6aGaLEzxR6+PvU DkwiXYi0o35peB0E+K6zT1BJBO79q4tS1mmH9KB1c4AwOR2N4BZekFlTnrT5SDBlYZ3/ 6emhTjvTeuyBYLsIz4t0VVSzbof3OR2X3JxJ2qLqWOvW+8f8YSG6f4xZ/njlxZ6jjt/3 5YEQ== 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=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c89si10447690edf.596.2020.08.03.02.58.06; Mon, 03 Aug 2020 02:58:28 -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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726058AbgHCJ50 (ORCPT + 99 others); Mon, 3 Aug 2020 05:57:26 -0400 Received: from mga07.intel.com ([134.134.136.100]:43518 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725965AbgHCJ5Z (ORCPT ); Mon, 3 Aug 2020 05:57:25 -0400 IronPort-SDR: 0O2O0Ju5EEMwF4I0hSmpcTNJNMu1CQh9pDJ0b0TeQR9mo/hPTUm5p0DXe3qy/MCeXyhYlnq3rf xf8wGg5T2F3w== X-IronPort-AV: E=McAfee;i="6000,8403,9701"; a="216495737" X-IronPort-AV: E=Sophos;i="5.75,429,1589266800"; d="scan'208";a="216495737" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Aug 2020 02:57:24 -0700 IronPort-SDR: MsiKdyIvj4fmPlYeIFCmVI5xosoHyyG+1kksLDAieWifeoY53aYQt2EGOqbylbRPy1hkBTV432 Fom/VXLNwQXA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,429,1589266800"; d="scan'208";a="396002736" Received: from lahna.fi.intel.com (HELO lahna) ([10.237.72.163]) by fmsmga001.fm.intel.com with SMTP; 03 Aug 2020 02:57:21 -0700 Received: by lahna (sSMTP sendmail emulation); Mon, 03 Aug 2020 12:57:20 +0300 Date: Mon, 3 Aug 2020 12:57:20 +0300 From: Mika Westerberg To: Daniel Gutson Cc: Tudor Ambarus , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Boris Brezillon , linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, Alex Bazhaniuk , Richard Hughes , Arnd Bergmann , Greg Kroah-Hartman Subject: Re: [PATCH] Module argument to control whether intel-spi-pci attempts to turn the SPI flash chip writeable Message-ID: <20200803095720.GC1375436@lahna.fi.intel.com> References: <20200724212853.11601-1-daniel.gutson@eclypsium.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200724212853.11601-1-daniel.gutson@eclypsium.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Sorry for the delay, I was on vacation. On Fri, Jul 24, 2020 at 06:28:53PM -0300, Daniel Gutson wrote: > Currently, intel-spi has a module argument that controls whether the driver > attempts to turn the SPI flash chip writeable. The default value > is FALSE (don't try to make it writeable). > However, this flag applies only for a number of devices, coming from the > platform driver, whereas the devices detected through the PCI driver > (intel-spi-pci) are not subject to this check since the configuration > takes place in intel-spi-pci which doesn't have an argument. > > That's why I propose this patch to add such argument to intel-spi-pci, > so the user can control whether the driver tries to make the chip > writeable or not, being the default FALSE as is the argument of > intel-spi. > > Signed-off-by: Daniel Gutson > --- > drivers/mtd/spi-nor/controllers/intel-spi-pci.c | 16 +++++++++++----- > 1 file changed, 11 insertions(+), 5 deletions(-) > > diff --git a/drivers/mtd/spi-nor/controllers/intel-spi-pci.c b/drivers/mtd/spi-nor/controllers/intel-spi-pci.c > index 81329f680bec..77e57450f166 100644 > --- a/drivers/mtd/spi-nor/controllers/intel-spi-pci.c > +++ b/drivers/mtd/spi-nor/controllers/intel-spi-pci.c > @@ -24,6 +24,10 @@ static const struct intel_spi_boardinfo cnl_info = { > .type = INTEL_SPI_CNL, > }; > > +static bool writeable; > +module_param(writeable, bool, 0); > +MODULE_PARM_DESC(writeable, "Enable write access to SPI flash chip (default=0)"); I think instead of this we should simply make it so that the driver never tries to make the chip writable. > + > static int intel_spi_pci_probe(struct pci_dev *pdev, > const struct pci_device_id *id) > { > @@ -41,12 +45,14 @@ static int intel_spi_pci_probe(struct pci_dev *pdev, > if (!info) > return -ENOMEM; > > - /* Try to make the chip read/write */ > - pci_read_config_dword(pdev, BCR, &bcr); > - if (!(bcr & BCR_WPD)) { > - bcr |= BCR_WPD; > - pci_write_config_dword(pdev, BCR, bcr); > + if (writeable) { > + /* Try to make the chip read/write */ > pci_read_config_dword(pdev, BCR, &bcr); > + if (!(bcr & BCR_WPD)) { > + bcr |= BCR_WPD; > + pci_write_config_dword(pdev, BCR, bcr); > + pci_read_config_dword(pdev, BCR, &bcr); > + } > } > info->writeable = !!(bcr & BCR_WPD); So here we just read the BCR register and then set info->writeable based on its value. Then it is up to the BIOS to enable this if it allows writing the flash chip from the OS side.