linux-2.6-microblaze.git
3 years agoRevert "mtd: rawnand: bbt: Skip bad blocks when searching for the BBT in NAND"
Fabio Estevam [Mon, 19 Apr 2021 14:03:50 +0000 (11:03 -0300)]
Revert "mtd: rawnand: bbt: Skip bad blocks when searching for the BBT in NAND"

This reverts commit bd9c9fe2ad04546940f4a9979d679e62cae6aa51.

Since commit bd9c9fe2ad04 ("mtd: rawnand: bbt: Skip bad blocks when
searching for  the BBT in NAND") the bad block table cannot be found
on a imx27-phytec-phycard-s-rdk board:

Bad block table not found for chip 0
Bad block table not found for chip 0

Revert it for now, until a better solution can be found.

Signed-off-by: Fabio Estevam <festevam@gmail.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210419140350.809853-1-festevam@gmail.com
3 years agomtd: core: Constify buf in mtd_write_user_prot_reg()
Tudor Ambarus [Sat, 3 Apr 2021 06:09:31 +0000 (09:09 +0300)]
mtd: core: Constify buf in mtd_write_user_prot_reg()

The write buffer comes from user and should be const.
Constify write buffer in mtd core and across all _write_user_prot_reg()
users. cfi_cmdset_{0001, 0002} and onenand_base will pay the cost of an
explicit cast to discard the const qualifier since the beginning, since
they are using an otp_op_t function prototype that is used for both reads
and writes. mtd_dataflash and SPI NOR will benefit of the const buffer
because they are using different paths for writes and reads.

Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210403060931.7119-1-tudor.ambarus@microchip.com
3 years agoMerge tag 'nand/for-5.13' of git://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux...
Richard Weinberger [Thu, 15 Apr 2021 19:14:51 +0000 (21:14 +0200)]
Merge tag 'nand/for-5.13' of git://git./linux/kernel/git/mtd/linux into mtd/next

MTD core:
* Handle possible -EPROBE_DEFER from parse_mtd_partitions()

NAND core:
* Fix error handling in nand_prog_page_op() (x2)
* Add a helper to retrieve the number of ECC bytes per step
* Add a helper to retrieve the number of ECC steps
* Let ECC engines advertize the exact number of steps
* ECC Hamming:
  - Populate the public nsteps field
  - Use the public nsteps field
* ECC BCH:
  - Populate the public nsteps field
  - Use the public nsteps field

Raw NAND core:
* Add support for secure regions in NAND memory
* Try not to use the ECC private structures
* Remove duplicate include in rawnand.h
* BBT:
  - Skip bad blocks when searching for the BBT in NAND

Raw NAND controller drivers:
* Qcom:
  - Convert bindings to YAML
  - Use dma_mapping_error() for error check
  - Add missing nand_cleanup() in error path
  - Return actual error code instead of -ENODEV
  - Update last code word register
  - Add helper to configure location register
  - Rename parameter name in macro
  - Add helper to check last code word
  - Convert nandc to chip in Read/Write helper
  - Update register macro name for 0x2c offset
* GPMI:
  - Fix a double free in gpmi_nand_init
* Rockchip:
  - Use flexible-array member instead of zero-length array
* Atmel:
  - Update ecc_stats.corrected counter
* MXC:
  - Remove unneeded of_match_ptr()
* R852:
  - replace spin_lock_irqsave by spin_lock in hard IRQ
* Brcmnand:
  - Move to polling in pio mode on oops write
  - Read/write oob during EDU transfer
  - Fix OOB R/W with Hamming ECC
* FSMC:
  - Fix error code in fsmc_nand_probe()
* OMAP:
  - Use ECC information from the generic structures

SPI-NAND core:
* Add missing MODULE_DEVICE_TABLE()

SPI-NAND drivers:
* gigadevice: Support GD5F1GQ5UExxG

3 years agoMerge tag 'spi-nor/for-5.13' of git://git.kernel.org/pub/scm/linux/kernel/git/mtd...
Richard Weinberger [Thu, 15 Apr 2021 19:13:51 +0000 (21:13 +0200)]
Merge tag 'spi-nor/for-5.13' of git://git./linux/kernel/git/mtd/linux into mtd/next

SPI NOR core changes:
- Add OTP support
- Fix module unload while an op in progress
- Add various cleanup patches

SPI NOR controller drivers changes:
- intel-spi: Move platform data header to x86 subfolder

3 years agoMerge tag 'cfi/for-5.13' of git://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux...
Richard Weinberger [Thu, 15 Apr 2021 19:12:54 +0000 (21:12 +0200)]
Merge tag 'cfi/for-5.13' of git://git./linux/kernel/git/mtd/linux into mtd/next

CFI changes

Just a couple of fixes for v5.13-rc1
* Disable broken buffered writes for CFI chips within ID 0x2201
* Address a Coverity report for unused value

3 years agoRevert "mtd: spi-nor: macronix: Add support for mx25l51245g"
Tudor Ambarus [Fri, 2 Apr 2021 08:20:30 +0000 (11:20 +0300)]
Revert "mtd: spi-nor: macronix: Add support for mx25l51245g"

This reverts commit 04b8edad262eec0d153005973dfbdd83423c0dcb.

mx25l51245g and mx66l51235l have the same flash ID. The flash
detection returns the first entry in the flash_info array that
matches the flash ID that was read, thus for the 0xc2201a ID,
mx25l51245g was always hit, introducing a regression for
mx66l51235l.

If one wants to differentiate the flash names, a better fix would be
to differentiate between the two at run-time, depending on SFDP,
and choose the correct name from a list of flash names, depending on
the SFDP differentiator.

Fixes: 04b8edad262e ("mtd: spi-nor: macronix: Add support for mx25l51245g")
Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
Acked-by: Pratyush Yadav <p.yadav@ti.com>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20210402082031.19055-2-tudor.ambarus@microchip.com
3 years agomtd: spi-nor: core: Fix an issue of releasing resources during read/write
Xiang Chen [Thu, 1 Apr 2021 07:34:46 +0000 (15:34 +0800)]
mtd: spi-nor: core: Fix an issue of releasing resources during read/write

If rmmod the driver during read or write, the driver will release the
resources which are used during read or write, so it is possible to
refer to NULL pointer.

Use the testcase "mtd_debug read /dev/mtd0 0xc00000 0x400000 dest_file &
sleep 0.5;rmmod spi_hisi_sfc_v3xx.ko", the issue can be reproduced in
hisi_sfc_v3xx driver.

To avoid the issue, fill the interface _get_device and _put_device of
mtd_info to grab the reference to the spi controller driver module, so
the request of rmmod the driver is rejected before read/write is finished.

Fixes: b199489d37b2 ("mtd: spi-nor: add the framework for SPI NOR")
Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
Signed-off-by: Yicong Yang <yangyicong@hisilicon.com>
Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
Tested-by: Michael Walle <michael@walle.cc>
Tested-by: Tudor Ambarus <tudor.ambarus@microchip.com>
Reviewed-by: Michael Walle <michael@walle.cc>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/1617262486-4223-1-git-send-email-yangyicong@hisilicon.com
3 years agomtd: cfi_cmdset_0002: remove redundant assignment to variable timeo
Colin Ian King [Thu, 25 Mar 2021 17:45:14 +0000 (17:45 +0000)]
mtd: cfi_cmdset_0002: remove redundant assignment to variable timeo

The variable timeo is being initialized with a value that is never read
and it is being updated later with a new value.  The initialization is
redundant and can be removed.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Vignesh Raghavendra <vigneshr@ti.com>
Link: https://lore.kernel.org/r/20210325174514.486272-1-colin.king@canonical.com
Addresses-Coverity: ("Unused value")

3 years agomtd: cfi_cmdset_0002: Disable buffered writes for AMD chip 0x2201
Mauri Sandberg [Tue, 9 Mar 2021 17:48:59 +0000 (19:48 +0200)]
mtd: cfi_cmdset_0002: Disable buffered writes for AMD chip 0x2201

Buffer writes do not work with AMD chip 0x2201. The chip in question
is a AMD/Spansion/Cypress Semiconductor S29GL256N and datasheet [1]
talks about writing buffers being possible. While waiting for a neater
solution resort to writing word-sized chunks only.

Without the patch kernel logs will be flooded with entries like below:

jffs2_scan_eraseblock(): End of filesystem marker found at 0x0
jffs2_build_filesystem(): unlocking the mtd device...
done.
jffs2_build_filesystem(): erasing all blocks after the end marker...
MTD do_write_buffer_wait(): software timeout, address:0x01ec000a.
jffs2: Write clean marker to block at 0x01920000 failed: -5
MTD do_write_buffer_wait(): software timeout, address:0x01e2000a.
jffs2: Write clean marker to block at 0x01880000 failed: -5
MTD do_write_buffer_wait(): software timeout, address:0x01e0000a.
jffs2: Write clean marker to block at 0x01860000 failed: -5
MTD do_write_buffer_wait(): software timeout, address:0x01dc000a.
jffs2: Write clean marker to block at 0x01820000 failed: -5
MTD do_write_buffer_wait(): software timeout, address:0x01da000a.
jffs2: Write clean marker to block at 0x01800000 failed: -5
...

Tested on a Buffalo wzr-hp-g300nh running kernel 5.10.16.

[1] https://www.cypress.com/file/219941/download
or  https://datasheetspdf.com/pdf-file/565708/SPANSION/S29GL256N/1

Signed-off-by: Mauri Sandberg <sandberg@mailfence.com>
Signed-off-by: Vignesh Raghavendra <vigneshr@ti.com>
Link: https://lore.kernel.org/r/20210309174859.362060-1-sandberg@mailfence.com
3 years agomtd: rawnand: qcom: Use dma_mapping_error() for error check
Manivannan Sadhasivam [Mon, 5 Apr 2021 05:09:12 +0000 (10:39 +0530)]
mtd: rawnand: qcom: Use dma_mapping_error() for error check

dma_mapping_error() should be used for checking the error value of
dma_map_resource() API.

Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210405050912.115591-1-manivannan.sadhasivam@linaro.org
3 years agomtd: rawnand: gpmi: Fix a double free in gpmi_nand_init
Lv Yunlong [Sat, 3 Apr 2021 06:09:05 +0000 (23:09 -0700)]
mtd: rawnand: gpmi: Fix a double free in gpmi_nand_init

If the callee gpmi_alloc_dma_buffer() failed to alloc memory for
this->raw_buffer, gpmi_free_dma_buffer() will be called to free
this->auxiliary_virt. But this->auxiliary_virt is still a non-NULL
and valid ptr.

Then gpmi_alloc_dma_buffer() returns err and gpmi_free_dma_buffer()
is called again to free this->auxiliary_virt in err_out. This causes
a double free.

As gpmi_free_dma_buffer() has already called in gpmi_alloc_dma_buffer's
error path, so it should return err directly instead of releasing the dma
buffer again.

Fixes: 4d02423e9afe6 ("mtd: nand: gpmi: Fix gpmi_nand_init() error path")
Signed-off-by: Lv Yunlong <lyl2019@mail.ustc.edu.cn>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210403060905.5251-1-lyl2019@mail.ustc.edu.cn
3 years agomtd: rawnand: qcom: Add missing nand_cleanup() in error path
Manivannan Sadhasivam [Fri, 2 Apr 2021 15:01:28 +0000 (20:31 +0530)]
mtd: rawnand: qcom: Add missing nand_cleanup() in error path

Add missing nand_cleanup() in the alloc_bam_transaction() error path
to cleanup the resources properly.

Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210402150128.29128-5-manivannan.sadhasivam@linaro.org
3 years agomtd: rawnand: Add support for secure regions in NAND memory
Manivannan Sadhasivam [Fri, 2 Apr 2021 15:01:27 +0000 (20:31 +0530)]
mtd: rawnand: Add support for secure regions in NAND memory

On a typical end product, a vendor may choose to secure some regions in
the NAND memory which are supposed to stay intact between FW upgrades.
The access to those regions will be blocked by a secure element like
Trustzone. So the normal world software like Linux kernel should not
touch these regions (including reading).

The regions are declared using a NAND chip DT property,
"secure-regions". So let's make use of this property in the raw NAND
core and skip access to the secure regions present in a system.

Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210402150128.29128-4-manivannan.sadhasivam@linaro.org
3 years agodt-bindings: mtd: Add a property to declare secure regions in NAND chips
Manivannan Sadhasivam [Fri, 2 Apr 2021 15:01:26 +0000 (20:31 +0530)]
dt-bindings: mtd: Add a property to declare secure regions in NAND chips

On a typical end product, a vendor may choose to secure some regions in
the NAND memory which are supposed to stay intact between FW upgrades.
The access to those regions will be blocked by a secure element like
Trustzone. So the normal world software like Linux kernel should not
touch these regions (including reading).

So let's add a property for declaring such secure regions so that the
drivers can skip touching them.

Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210402150128.29128-3-manivannan.sadhasivam@linaro.org
3 years agodt-bindings: mtd: Convert Qcom NANDc binding to YAML
Manivannan Sadhasivam [Fri, 2 Apr 2021 15:01:25 +0000 (20:31 +0530)]
dt-bindings: mtd: Convert Qcom NANDc binding to YAML

Convert Qcom NANDc devicetree binding to YAML.

Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210402150128.29128-2-manivannan.sadhasivam@linaro.org
3 years agomtd: spi-nor: winbond: add OTP support to w25q32fw/jw
Michael Walle [Sun, 21 Mar 2021 23:51:40 +0000 (00:51 +0100)]
mtd: spi-nor: winbond: add OTP support to w25q32fw/jw

With all the helper functions in place, add OTP support for the Winbond
W25Q32JW and W25Q32FW.

Both were tested on a LS1028A SoC with a NXP FSPI controller.

Signed-off-by: Michael Walle <michael@walle.cc>
Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
Link: https://lore.kernel.org/r/20210321235140.8308-4-michael@walle.cc
3 years agomtd: spi-nor: implement OTP support for Winbond and similar flashes
Michael Walle [Sun, 21 Mar 2021 23:51:39 +0000 (00:51 +0100)]
mtd: spi-nor: implement OTP support for Winbond and similar flashes

Use the new OTP ops to implement OTP access on Winbond flashes. Most
Winbond flashes provides up to four different OTP regions ("Security
Registers").

Winbond devices use a special opcode to read and write to the OTP
regions, just like the RDSFDP opcode. In fact, it seems that the
(undocumented) first OTP area of the newer flashes is the actual SFDP
table.

On a side note, Winbond devices also allow erasing the OTP regions as
long as the area isn't locked down.

Signed-off-by: Michael Walle <michael@walle.cc>
Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
Link: https://lore.kernel.org/r/20210321235140.8308-3-michael@walle.cc
3 years agomtd: spi-nor: add OTP support
Michael Walle [Sun, 21 Mar 2021 23:51:38 +0000 (00:51 +0100)]
mtd: spi-nor: add OTP support

SPI flashes sometimes have a special OTP area, which can (and is) used to
store immutable properties like board serial number or vendor assigned
network hardware addresses.

The MTD subsystem already supports accessing such areas and some (non
SPI NOR) flashes already implement support for it. It differentiates
between user and factory areas. User areas can be written by the user and
factory ones are pre-programmed and locked down by the vendor, usually
containing an "electrical serial number". This patch will only add support
for the user areas.

Lay the foundation and implement the MTD callbacks for the SPI NOR and add
necessary parameters to the flash_info structure. If a flash supports OTP
it can be added by the convenience macro OTP_INFO(). Sometimes there are
individual regions, which might have individual offsets. Therefore, it is
possible to specify the starting address of the first regions as well as
the distance between two regions (e.g. Winbond devices uses this method).

Additionally, the regions might be locked down. Once locked, no further
write access is possible.

For SPI NOR flashes the OTP area is accessed like the normal memory, e.g.
by offset addressing; except that you either have to use special read/write
commands (Winbond) or you have to enter (and exit) a specific OTP mode
(Macronix, Micron).

Thus we introduce four operations to which the MTD callbacks will be
mapped: .read(), .write(), .lock() and .is_locked(). The read and the write
ops will be given an address offset to operate on while the locking ops use
regions because locking always affects a whole region. It is up to the
flash driver to implement these ops.

Signed-off-by: Michael Walle <michael@walle.cc>
[ta: use div64_u64(), IS_ALIGNED, params->otp.org. unsigned int region,
drop comment, add rlen local variable in spi_nor_mtd_otp_lock()]
Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
Link: https://lore.kernel.org/r/20210321235140.8308-2-michael@walle.cc
3 years agomtd: spi-nor: swp: Improve code around spi_nor_check_lock_status_sr()
Tudor Ambarus [Mon, 22 Mar 2021 07:51:31 +0000 (09:51 +0200)]
mtd: spi-nor: swp: Improve code around spi_nor_check_lock_status_sr()

- bool return value for spi_nor_check_lock_status_sr(), gets rid of
  the return 1,
- introduce temporary variables for better readability.

Suggested-by: Joe Perches <joe@perches.com>
Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
Reviewed-by: Pratyush Yadav <p.yadav@ti.com>
Reviewed-by: Michael Walle <michael@walle.cc>
Link: https://lore.kernel.org/r/20210322075131.45093-3-tudor.ambarus@microchip.com
3 years agomtd: spi-nor: Move Software Write Protection logic out of the core
Tudor Ambarus [Mon, 22 Mar 2021 07:51:30 +0000 (09:51 +0200)]
mtd: spi-nor: Move Software Write Protection logic out of the core

It makes the core file a bit smaller and provides better separation
between the Software Write Protection features and the core logic.
All the next generic software write protection features (e.g. Individual
Block Protection) will reside in swp.c.

Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
Reviewed-by: Michael Walle <michael@walle.cc>
Acked-by: Pratyush Yadav <p.yadav@ti.com>
Link: https://lore.kernel.org/r/20210322075131.45093-2-tudor.ambarus@microchip.com
3 years agomtd: rawnand: bbt: Skip bad blocks when searching for the BBT in NAND
Stefan Riedmueller [Thu, 25 Mar 2021 10:23:37 +0000 (11:23 +0100)]
mtd: rawnand: bbt: Skip bad blocks when searching for the BBT in NAND

The blocks containing the bad block table can become bad as well. So
make sure to skip any blocks that are marked bad when searching for the
bad block table.

Otherwise in very rare cases where two BBT blocks wear out it might
happen that an obsolete BBT is used instead of a newer available
version.

Signed-off-by: Stefan Riedmueller <s.riedmueller@phytec.de>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210325102337.481172-1-s.riedmueller@phytec.de
3 years agoinclude: linux: mtd: Remove duplicate include of nand.h
Wan Jiabing [Tue, 23 Mar 2021 03:17:37 +0000 (11:17 +0800)]
include: linux: mtd: Remove duplicate include of nand.h

linux/mtd/nand.h has been included at line 17.
So we remove the duplicate one at line 21.

Signed-off-by: Wan Jiabing <wanjiabing@vivo.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210323031737.259365-1-wanjiabing@vivo.com
3 years agomtd: parsers: ofpart: support Linksys Northstar partitions
Rafał Miłecki [Fri, 12 Mar 2021 13:49:19 +0000 (14:49 +0100)]
mtd: parsers: ofpart: support Linksys Northstar partitions

This allows extending ofpart parser with support for Linksys Northstar
devices. That support uses recently added quirks mechanism.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210312134919.7767-2-zajec5@gmail.com
3 years agodt-bindings: mtd: add binding for Linksys Northstar partitions
Rafał Miłecki [Fri, 12 Mar 2021 13:49:18 +0000 (14:49 +0100)]
dt-bindings: mtd: add binding for Linksys Northstar partitions

Linksys on Broadcom Northstar devices uses fixed flash layout with
multiple firmware partitions.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210312134919.7767-1-zajec5@gmail.com
3 years agodt-bindings: mtd: Document use of nvmem-cells compatible
Ansuel Smith [Fri, 12 Mar 2021 06:28:21 +0000 (07:28 +0100)]
dt-bindings: mtd: Document use of nvmem-cells compatible

Document nvmem-cells compatible used to treat mtd partitions as a
nvmem provider.

Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210312062830.20548-3-ansuelsmth@gmail.com
3 years agodt-bindings: nvmem: drop $nodename restriction
Ansuel Smith [Fri, 12 Mar 2021 06:28:20 +0000 (07:28 +0100)]
dt-bindings: nvmem: drop $nodename restriction

Drop $nodename restriction as now mtd partition can also be used as
nvmem provider.

Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210312062830.20548-2-ansuelsmth@gmail.com
3 years agomtd: core: add nvmem-cells compatible to parse mtd as nvmem cells
Ansuel Smith [Fri, 12 Mar 2021 06:28:19 +0000 (07:28 +0100)]
mtd: core: add nvmem-cells compatible to parse mtd as nvmem cells

Partitions that contains the nvmem-cells compatible will register
their direct subonodes as nvmem cells and the node will be treated as a
nvmem provider.

Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
Tested-by: Rafał Miłecki <rafal@milecki.pl>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210312062830.20548-1-ansuelsmth@gmail.com
3 years agomtd: add OTP (one-time-programmable) erase ioctl
Michael Walle [Wed, 3 Mar 2021 20:18:19 +0000 (21:18 +0100)]
mtd: add OTP (one-time-programmable) erase ioctl

This may sound like a contradiction but some SPI-NOR flashes really
support erasing their OTP region until it is finally locked. Having the
possibility to erase an OTP region might come in handy during
development.

The ioctl argument follows the OTPLOCK style.

Signed-off-by: Michael Walle <michael@walle.cc>
Acked-by: Vignesh Raghavendra <vigneshr@ti.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210303201819.2752-1-michael@walle.cc
3 years agomtd: require write permissions for locking and badblock ioctls
Michael Walle [Wed, 3 Mar 2021 15:57:35 +0000 (16:57 +0100)]
mtd: require write permissions for locking and badblock ioctls

MEMLOCK, MEMUNLOCK and OTPLOCK modify protection bits. Thus require
write permission. Depending on the hardware MEMLOCK might even be
write-once, e.g. for SPI-NOR flashes with their WP# tied to GND. OTPLOCK
is always write-once.

MEMSETBADBLOCK modifies the bad block table.

Fixes: f7e6b19bc764 ("mtd: properly check all write ioctls for permissions")
Signed-off-by: Michael Walle <michael@walle.cc>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Acked-by: Rafał Miłecki <rafal@milecki.pl>
Acked-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210303155735.25887-1-michael@walle.cc
3 years agomtd: spinand: core: add missing MODULE_DEVICE_TABLE()
Alexander Lobakin [Tue, 23 Mar 2021 17:37:19 +0000 (17:37 +0000)]
mtd: spinand: core: add missing MODULE_DEVICE_TABLE()

The module misses MODULE_DEVICE_TABLE() for both SPI and OF ID tables
and thus never autoloads on ID matches.
Add the missing declarations.
Present since day-0 of spinand framework introduction.

Fixes: 7529df465248 ("mtd: nand: Add core infrastructure to support SPI NANDs")
Cc: stable@vger.kernel.org # 4.19+
Signed-off-by: Alexander Lobakin <alobakin@pm.me>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210323173714.317884-1-alobakin@pm.me
3 years agomtd: rawnand: rockchip: Use flexible-array member instead of zero-length array
Zou Wei [Tue, 23 Mar 2021 13:11:37 +0000 (13:11 +0000)]
mtd: rawnand: rockchip: Use flexible-array member instead of zero-length array

Suppresses the following coccinelle warning:

drivers/mtd/nand/raw/rockchip-nand-controller.c:162:4-8: WARNING use flexible-array member instead

Signed-off-by: Zou Wei <zou_wei@huawei.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210323131137.45552-1-zou_wei@huawei.com
3 years agomtd: rawnand: atmel: Update ecc_stats.corrected counter
Kai Stuhlemmer (ebee Engineering) [Mon, 22 Mar 2021 15:07:14 +0000 (17:07 +0200)]
mtd: rawnand: atmel: Update ecc_stats.corrected counter

Update MTD ECC statistics with the number of corrected bits.

Fixes: f88fc122cc34 ("mtd: nand: Cleanup/rework the atmel_nand driver")
Cc: stable@vger.kernel.org
Signed-off-by: Kai Stuhlemmer (ebee Engineering) <kai.stuhlemmer@ebee.de>
Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210322150714.101585-1-tudor.ambarus@microchip.com
3 years agomtd: rawnand: mxc: Remove unneeded of_match_ptr()
Fabio Estevam [Tue, 16 Mar 2021 00:00:42 +0000 (21:00 -0300)]
mtd: rawnand: mxc: Remove unneeded of_match_ptr()

i.MX is a DT-only platform, so of_match_ptr() can be safely
removed.

Remove the unneeded of_match_ptr().

Signed-off-by: Fabio Estevam <festevam@gmail.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210316000042.200392-1-festevam@gmail.com
3 years agomtd: rawnand: r852: replace spin_lock_irqsave by spin_lock in hard IRQ
Tian Tao [Mon, 15 Mar 2021 01:08:15 +0000 (09:08 +0800)]
mtd: rawnand: r852: replace spin_lock_irqsave by spin_lock in hard IRQ

The code has been in a irq-disabled context since it is hard IRQ. There
is no necessity to do it again.

Signed-off-by: Tian Tao <tiantao6@hisilicon.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/1615770495-31939-1-git-send-email-tiantao6@hisilicon.com
3 years agomtd: rawnand: remove duplicate include in rawnand.h
Zhang Yunkai [Sat, 13 Mar 2021 10:57:02 +0000 (02:57 -0800)]
mtd: rawnand: remove duplicate include in rawnand.h

'linux/mtd/nand.h' included in 'rawnand.h' is duplicated.
It is also included in the 17th line.

Signed-off-by: Zhang Yunkai <zhang.yunkai@zte.com.cn>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210313105702.365878-1-zhang.yunkai@zte.com.cn
3 years agomtd: rawnand: brcmnand: move to polling in pio mode on oops write
Kamal Dasu [Thu, 11 Mar 2021 17:09:09 +0000 (12:09 -0500)]
mtd: rawnand: brcmnand: move to polling in pio mode on oops write

This change makes sure that Broadcom NAND driver moves to interrupt
polling on the first brcmnand_write() call.

Signed-off-by: Kamal Dasu <kdasu.kdev@gmail.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210311170909.9031-2-kdasu.kdev@gmail.com
3 years agomtd: rawnand: brcmnand: read/write oob during EDU transfer
Kamal Dasu [Thu, 11 Mar 2021 17:09:08 +0000 (12:09 -0500)]
mtd: rawnand: brcmnand: read/write oob during EDU transfer

Added support to read/write oob during EDU transfers.

Signed-off-by: Kamal Dasu <kdasu.kdev@gmail.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210311170909.9031-1-kdasu.kdev@gmail.com
3 years agomtd: spi-nor: core: Update comment about the default flash parameters
Tudor Ambarus [Mon, 15 Mar 2021 05:56:34 +0000 (07:56 +0200)]
mtd: spi-nor: core: Update comment about the default flash parameters

s/legacy/default. spi_nor_info_init_params initializes some default
flash parameters and settings that can be overwritten when parsing
SFDP, or by fixup hooks. There's nothing legacy about them, they are
just some default settings, if not otherwise discovered or specified.

Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
Reviewed-by: Pratyush Yadav <p.yadav@ti.com>
Link: https://lore.kernel.org/r/20210315055634.17332-1-tudor.ambarus@microchip.com
3 years agomtd: spi-nor: Get rid of duplicated argument in spi_nor_parse_sfdp()
Tudor Ambarus [Sat, 6 Mar 2021 09:50:00 +0000 (11:50 +0200)]
mtd: spi-nor: Get rid of duplicated argument in spi_nor_parse_sfdp()

spi_nor_parse_sfdp(nor, nor->params);
passes for the second argument a member within the first argument.
Drop the second argument and obtain it directly from the first,
and do it across all the children functions. This is a follow up for
'commit 69a8eed58cc0 ("mtd: spi-nor: Don't copy self-pointing struct around")'

Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
Reviewed-by: Pratyush Yadav <p.yadav@ti.com>
Link: https://lore.kernel.org/r/20210306095002.22983-4-tudor.ambarus@microchip.com
3 years agomtd: spi-nor: core: Add vdbg msg for spi_nor_erase_multi_sectors()
Tudor Ambarus [Sat, 6 Mar 2021 09:49:59 +0000 (11:49 +0200)]
mtd: spi-nor: core: Add vdbg msg for spi_nor_erase_multi_sectors()

Useful when debugging non-uniform erase.

Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
Reviewed-by: Pratyush Yadav <p.yadav@ti.com>
Link: https://lore.kernel.org/r/20210306095002.22983-3-tudor.ambarus@microchip.com
3 years agomtd: spi-nor: core: Advance erase after the erase cmd has been completed
Tudor Ambarus [Sat, 6 Mar 2021 09:49:58 +0000 (11:49 +0200)]
mtd: spi-nor: core: Advance erase after the erase cmd has been completed

addr and len were gratuitously updated even when spi_nor_wait_till_ready()
failed. Wait for the erase cmd to complete and then advance the erase.

Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
Reviewed-by: Pratyush Yadav <p.yadav@ti.com>
Link: https://lore.kernel.org/r/20210306095002.22983-2-tudor.ambarus@microchip.com
3 years agomtd: rawnand: stm32_fmc2: Fix fall-through warnings for Clang
Gustavo A. R. Silva [Fri, 5 Mar 2021 08:29:53 +0000 (02:29 -0600)]
mtd: rawnand: stm32_fmc2: Fix fall-through warnings for Clang

In preparation to enable -Wimplicit-fallthrough for Clang, fix a couple
of warnings by explicitly adding a couple of break statements instead
of letting the code fall through to the next case.

Link: https://github.com/KSPP/linux/issues/115
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210305082953.GA137771@embeddedor
3 years agomtd: rawnand: fsmc: Fix fall-through warnings for Clang
Gustavo A. R. Silva [Fri, 5 Mar 2021 08:25:59 +0000 (02:25 -0600)]
mtd: rawnand: fsmc: Fix fall-through warnings for Clang

In preparation to enable -Wimplicit-fallthrough for Clang, fix a warning
by explicitly adding a break statement instead of letting the code fall
through to the next case.

Link: https://github.com/KSPP/linux/issues/115
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210305082559.GA137646@embeddedor
3 years agomtd: onenand: Fix fall-through warnings for Clang
Gustavo A. R. Silva [Fri, 5 Mar 2021 08:23:56 +0000 (02:23 -0600)]
mtd: onenand: Fix fall-through warnings for Clang

In preparation to enable -Wimplicit-fallthrough for Clang, fix a warning
by explicitly adding a break statement instead of letting the code fall
through to the next case.

Link: https://github.com/KSPP/linux/issues/115
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210305082356.GA137489@embeddedor
3 years agomtd: mtdchar: Fix fall-through warnings for Clang
Gustavo A. R. Silva [Fri, 5 Mar 2021 08:22:24 +0000 (02:22 -0600)]
mtd: mtdchar: Fix fall-through warnings for Clang

In preparation to enable -Wimplicit-fallthrough for Clang, fix a warning
by explicitly adding a break statement instead of letting the code fall
through to the next case.

Link: https://github.com/KSPP/linux/issues/115
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210305082224.GA137360@embeddedor
3 years agomtd: cfi: Fix fall-through warnings for Clang
Gustavo A. R. Silva [Fri, 5 Mar 2021 08:19:33 +0000 (02:19 -0600)]
mtd: cfi: Fix fall-through warnings for Clang

In preparation to enable -Wimplicit-fallthrough for Clang, fix multiple
warnings by explicitly adding multiple break statements and a return
instead of letting the code fall through to the next case.

Link: https://github.com/KSPP/linux/issues/115
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Acked-by: Vignesh Raghavendra <vigneshr@ti.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210305081933.GA137147@embeddedor
3 years agomtd: maps: fix error return code of physmap_flash_remove()
Jia-Ju Bai [Mon, 8 Mar 2021 03:44:46 +0000 (19:44 -0800)]
mtd: maps: fix error return code of physmap_flash_remove()

When platform_get_drvdata() returns NULL to info, no error return code
of physmap_flash_remove() is assigned.
To fix this bug, err is assigned with -EINVAL in this case

Fixes: 73566edf9b91 ("[MTD] Convert physmap to platform driver")
Reported-by: TOTE Robot <oslab@tsinghua.edu.cn>
Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210308034446.3052-1-baijiaju1990@gmail.com
3 years agomtd: parsers: ofpart: make symbol 'bcm4908_partitions_quirks' static
Wei Yongjun [Thu, 4 Mar 2021 06:46:00 +0000 (06:46 +0000)]
mtd: parsers: ofpart: make symbol 'bcm4908_partitions_quirks' static

The sparse tool complains as follows:

drivers/mtd/parsers/ofpart_core.c:25:32: warning:
 symbol 'bcm4908_partitions_quirks' was not declared. Should it be static?

This symbol is not used outside of ofpart_core.c, so this
commit marks it static.

Fixes: 457da931b608 ("mtd: parsers: ofpart: support BCM4908 fixed partitions")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210304064600.3279138-1-weiyongjun1@huawei.com
3 years agomtd: parsers: qcom: incompatible with spi-nor 4k sectors
Baruch Siach [Wed, 3 Mar 2021 16:48:16 +0000 (18:48 +0200)]
mtd: parsers: qcom: incompatible with spi-nor 4k sectors

Partition size and offset value are in block size units, which is the
same as 'erasesize'. But when 4K sectors are enabled erasesize is set to
4K. Bail out in that case.

Fixes: 803eb124e1a64 ("mtd: parsers: Add Qcom SMEM parser")
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Baruch Siach <baruch@tkos.co.il>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/0a2611f885b894274436ded3ca78bc0440fca74a.1614790096.git.baruch@tkos.co.il
3 years agomtd: parsers: qcom: Fix error condition
Miquel Raynal [Wed, 3 Mar 2021 08:46:34 +0000 (09:46 +0100)]
mtd: parsers: qcom: Fix error condition

qcom_smem_get() does not return NULL, and even if it did, the NULL
condition is usually not an error but a success condition and should
not trigger an error trace.

Let's replace IS_ERR_OR_NULL() by IS_ERR().

This fixes the following smatch warning:
drivers/mtd/parsers/qcomsmempart.c:109 parse_qcomsmem_part() warn: passing zero to 'PTR_ERR'

Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Fixes: 803eb124e1a6 ("mtd: parsers: Add Qcom SMEM parser")
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210303084634.12796-1-miquel.raynal@bootlin.com
3 years agomtd: parsers: ofpart: limit parsing of deprecated DT syntax
Rafał Miłecki [Tue, 2 Mar 2021 19:00:12 +0000 (20:00 +0100)]
mtd: parsers: ofpart: limit parsing of deprecated DT syntax

For backward compatibility ofpart still supports the old syntax like:
spi-flash@0 {
compatible = "jedec,spi-nor";
reg = <0x0>;

partition@0 {
label = "bootloader";
reg = <0x0 0x100000>;
};
};
(without "partitions" subnode).

There is no reason however to support nested partitions without a clear
"compatible" string like:
partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;

partition@0 {
label = "bootloader";
reg = <0x0 0x100000>;

partition@0 {
label = "config";
reg = <0x80000 0x80000>;
};
};
};
(we never officially supported or documented that).

Make sure ofpart doesn't attempt to parse above.

Cc: Ansuel Smith <ansuelsmth@gmail.com>
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210302190012.1255-1-zajec5@gmail.com
3 years agomtd: parsers: ofpart: support BCM4908 fixed partitions
Rafał Miłecki [Mon, 1 Mar 2021 10:58:23 +0000 (11:58 +0100)]
mtd: parsers: ofpart: support BCM4908 fixed partitions

Some devices use fixed partitioning with some partitions requiring some
extra logic. E.g. BCM4908 may have multiple firmware partitions but
detecting currently used one requires checking bootloader parameters.

To support such cases without duplicating a lot of code (without copying
most of the ofpart.c code) support for post-parsing callback was added.

BCM4908 support in ofpart can be enabled using config option and results
in compiling & executing a specific callback. It simply reads offset of
currently used firmware partition from the DT. Bootloader specifies it
using the "brcm_blparms" property.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210301105823.31032-1-zajec5@gmail.com
3 years agomtd: mtdcore: constify name param in mtd_bdi_init
Tomas Winkler [Thu, 25 Feb 2021 14:33:29 +0000 (16:33 +0200)]
mtd: mtdcore: constify name param in mtd_bdi_init

The bdi name is not modified by the function, it should be const.

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210225143329.430012-1-tomas.winkler@intel.com
3 years agomtd: parsers: extend Qcom SMEM parser to SPI flash
Baruch Siach [Tue, 23 Feb 2021 11:47:04 +0000 (13:47 +0200)]
mtd: parsers: extend Qcom SMEM parser to SPI flash

The Qcom MIBIB partition might be stored on SPI flash devices, and the
parser works in this case just as well:

[    1.404229] spi_qup 78b5000.spi: IN:block:16, fifo:64, OUT:block:16, fifo:64
[    1.408078] spi-nor spi0.0: found mx25u6435f, expected n25q128a11
[    1.415016] spi-nor spi0.0: mx25u6435f (8192 Kbytes)
[    1.420756] 12 qcomsmem partitions found on MTD device spi0.0
[    1.425739] Creating 12 MTD partitions on "spi0.0":
[    1.431381] 0x000000000000-0x00000000c000 : "0:sbl1"
[    1.437058] 0x00000000c000-0x00000000d000 : "0:mibib"
[    1.442143] 0x00000000d000-0x000000027000 : "0:qsee"
[    1.447057] 0x000000027000-0x000000028000 : "0:devcfg"
[    1.452088] 0x000000028000-0x00000002a000 : "0:rpm"
[    1.457065] 0x00000002a000-0x00000002b000 : "0:cdt"
[    1.461832] 0x00000002b000-0x00000002c000 : "0:appsblenv"
[    1.466736] 0x00000002c000-0x000000036000 : "0:appsbl"
[    1.472248] 0x000000036000-0x00000003a000 : "0:art"
[    1.477297] 0x00000003a000-0x00000003e000 : "config"
[    1.482047] 0x00000003e000-0x00000004e000 : "data"
[    1.487257] 0x00000004e000-0x000000200000 : "0:hlos"

Remove dependency on MTD_NAND_QCOM. Update the Kconfig prompt and help
text accordingly.

Cc: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Baruch Siach <baruch@tkos.co.il>
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/7f558e888a41c5b1fd4ca0427b3976531c51a876.1614080824.git.baruch@tkos.co.il
3 years agomtd: char: Get rid of Big MTD Lock
Alexander Sverdlin [Wed, 17 Feb 2021 21:18:45 +0000 (22:18 +0100)]
mtd: char: Get rid of Big MTD Lock

Get rid of central chrdev MTD lock, which prevents simultaneous operations
on completely independent physical MTD chips. Replace it with newly
introduced per-master mutex.

Signed-off-by: Alexander Sverdlin <alexander.sverdlin@nokia.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210217211845.43364-2-alexander.sverdlin@nokia.com
3 years agomtd: char: Drop mtd_mutex usage from mtdchar_open()
Alexander Sverdlin [Wed, 17 Feb 2021 21:18:44 +0000 (22:18 +0100)]
mtd: char: Drop mtd_mutex usage from mtdchar_open()

It looks unnecessary in the function, remove it from the function
having in mind to remove it completely.

Signed-off-by: Alexander Sverdlin <alexander.sverdlin@nokia.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210217211845.43364-1-alexander.sverdlin@nokia.com
3 years agomtd: don't lock when recursively deleting partitions
David Bauer [Wed, 17 Feb 2021 19:53:20 +0000 (20:53 +0100)]
mtd: don't lock when recursively deleting partitions

When recursively deleting partitions, don't acquire the masters
partition lock twice. Otherwise the process ends up in a deadlocked
state.

Fixes: 46b5889cc2c5 ("mtd: implement proper partition handling")
Signed-off-by: David Bauer <mail@david-bauer.net>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210217195320.893253-1-mail@david-bauer.net
3 years agomtd: rfd_ftl: Use module_mtd_blktrans to register driver
Dejin Zheng [Sat, 13 Feb 2021 16:46:00 +0000 (00:46 +0800)]
mtd: rfd_ftl: Use module_mtd_blktrans to register driver

Removing some boilerplate by using module_mtd_blktrans instead of calling
register and unregister in the otherwise empty init/exit functions.

Signed-off-by: Dejin Zheng <zhengdejin5@gmail.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210213164600.409061-9-zhengdejin5@gmail.com
3 years agomtd: nftlcore: Use module_mtd_blktrans to register driver
Dejin Zheng [Sat, 13 Feb 2021 16:45:59 +0000 (00:45 +0800)]
mtd: nftlcore: Use module_mtd_blktrans to register driver

Removing some boilerplate by using module_mtd_blktrans instead of calling
register and unregister in the otherwise empty init/exit functions.

Signed-off-by: Dejin Zheng <zhengdejin5@gmail.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210213164600.409061-8-zhengdejin5@gmail.com
3 years agomtd: mtdswap: Use module_mtd_blktrans to register driver
Dejin Zheng [Sat, 13 Feb 2021 16:45:58 +0000 (00:45 +0800)]
mtd: mtdswap: Use module_mtd_blktrans to register driver

Removing some boilerplate by using module_mtd_blktrans instead of calling
register and unregister in the otherwise empty init/exit functions.

Signed-off-by: Dejin Zheng <zhengdejin5@gmail.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210213164600.409061-7-zhengdejin5@gmail.com
3 years agomtd: mtdblock_ro: Use module_mtd_blktrans to register driver
Dejin Zheng [Sat, 13 Feb 2021 16:45:57 +0000 (00:45 +0800)]
mtd: mtdblock_ro: Use module_mtd_blktrans to register driver

Removing some boilerplate by using module_mtd_blktrans instead of calling
register and unregister in the otherwise empty init/exit functions.

Signed-off-by: Dejin Zheng <zhengdejin5@gmail.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210213164600.409061-6-zhengdejin5@gmail.com
3 years agomtd: mtdblock: Use module_mtd_blktrans to register driver
Dejin Zheng [Sat, 13 Feb 2021 16:45:56 +0000 (00:45 +0800)]
mtd: mtdblock: Use module_mtd_blktrans to register driver

Removing some boilerplate by using module_mtd_blktrans instead of calling
register and unregister in the otherwise empty init/exit functions.

Signed-off-by: Dejin Zheng <zhengdejin5@gmail.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210213164600.409061-5-zhengdejin5@gmail.com
3 years agomtd: inftlcore: Use module_mtd_blktrans to register driver
Dejin Zheng [Sat, 13 Feb 2021 16:45:55 +0000 (00:45 +0800)]
mtd: inftlcore: Use module_mtd_blktrans to register driver

Removing some boilerplate by using module_mtd_blktrans instead of calling
register and unregister in the otherwise empty init/exit functions.

Signed-off-by: Dejin Zheng <zhengdejin5@gmail.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210213164600.409061-4-zhengdejin5@gmail.com
3 years agomtd: ftl: Use module_mtd_blktrans to register driver
Dejin Zheng [Sat, 13 Feb 2021 16:45:54 +0000 (00:45 +0800)]
mtd: ftl: Use module_mtd_blktrans to register driver

Removing some boilerplate by using module_mtd_blktrans instead of calling
register and unregister in the otherwise empty init/exit functions.

Signed-off-by: Dejin Zheng <zhengdejin5@gmail.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210213164600.409061-3-zhengdejin5@gmail.com
3 years agomtd: Add helper macro for register_mtd_blktrans boilerplate
Dejin Zheng [Sat, 13 Feb 2021 16:45:53 +0000 (00:45 +0800)]
mtd: Add helper macro for register_mtd_blktrans boilerplate

This patch introduces the module_mtd_blktrans macro which is a convenience
macro for mtd blktrans modules similar to module_platform_driver.
It is intended to be used by drivers which init/exit section does nothing
but register/unregister the mtd blktrans driver. By using this macro it is
possible to eliminate a few lines of boilerplate code per mtd blktrans
driver.

Signed-off-by: Dejin Zheng <zhengdejin5@gmail.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210213164600.409061-2-zhengdejin5@gmail.com
3 years agomtd: physmap: physmap-bt1-rom: Fix unintentional stack access
Gustavo A. R. Silva [Fri, 12 Feb 2021 10:40:22 +0000 (04:40 -0600)]
mtd: physmap: physmap-bt1-rom: Fix unintentional stack access

Cast &data to (char *) in order to avoid unintentionally accessing
the stack.

Notice that data is of type u32, so any increment to &data
will be in the order of 4-byte chunks, and this piece of code
is actually intended to be a byte offset.

Fixes: b3e79e7682e0 ("mtd: physmap: Add Baikal-T1 physically mapped ROM support")
Addresses-Coverity-ID: 1497765 ("Out-of-bounds access")
Cc: stable@vger.kernel.org
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Acked-by: Serge Semin <fancer.lancer@gmail.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210212104022.GA242669@embeddedor
3 years agomtd: rawnand: qcom: Return actual error code instead of -ENODEV
Manivannan Sadhasivam [Tue, 2 Mar 2021 13:27:57 +0000 (18:57 +0530)]
mtd: rawnand: qcom: Return actual error code instead of -ENODEV

In qcom_probe_nand_devices() function, the error code returned by
qcom_nand_host_init_and_register() is converted to -ENODEV in the case
of failure. This poses issue if -EPROBE_DEFER is returned when the
dependency is not available for a component like parser.

So let's restructure the error handling logic a bit and return the
actual error code in case of qcom_nand_host_init_and_register() failure.

Fixes: c76b78d8ec05 ("mtd: nand: Qualcomm NAND controller driver")
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
3 years agomtd: Handle possible -EPROBE_DEFER from parse_mtd_partitions()
Manivannan Sadhasivam [Tue, 2 Mar 2021 13:27:56 +0000 (18:57 +0530)]
mtd: Handle possible -EPROBE_DEFER from parse_mtd_partitions()

There are chances that the parse_mtd_partitions() function will return
-EPROBE_DEFER in mtd_device_parse_register(). This might happen when
the dependency is not available for the parser. For instance, on SDX55
the MTD_QCOMSMEM_PARTS parser depends on the QCOM_SMEM driver to parse
the partitions defined in the shared memory region. With the current
flow, the error returned from parse_mtd_partitions() will be discarded
in favor of trying to add the fallback partition.

This will prevent the driver to end up in probe deferred pool and the
partitions won't be parsed even after the QCOM_SMEM driver is available.

Fix this issue by bailing out of mtd_device_parse_register() when
-EPROBE_DEFER error is returned from parse_mtd_partitions() function and
propagate the error code to the driver core for probing later.

Fixes: 5ac67ce36cfe ("mtd: move code adding (registering) partitions to the parse_mtd_partitions()")
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
3 years agomtd: rawnand: brcmnand: fix OOB R/W with Hamming ECC
Álvaro Fernández Rojas [Wed, 24 Feb 2021 08:02:10 +0000 (09:02 +0100)]
mtd: rawnand: brcmnand: fix OOB R/W with Hamming ECC

Hamming ECC doesn't cover the OOB data, so reading or writing OOB shall
always be done without ECC enabled.
This is a problem when adding JFFS2 cleanmarkers to erased blocks. If JFFS2
clenmarkers are added to the OOB with ECC enabled, OOB bytes will be changed
from ff ff ff to 00 00 00, reporting incorrect ECC errors.

Fixes: 27c5b17cd1b1 ("mtd: nand: add NAND driver "library" for Broadcom STB NAND controller")
Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
Acked-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210224080210.23686-1-noltari@gmail.com
3 years agomtd: rawnand: qcom: update last code word register
Md Sadre Alam [Tue, 23 Feb 2021 19:39:01 +0000 (01:09 +0530)]
mtd: rawnand: qcom: update last code word register

From QPIC v2 onwards a new register got added to read last
code word.Add support for this READ_LOCATION_LAST_CW_n
register.

In the case of QPIC v2, codewords 0, 1 and 2 will be accessed
through READ_LOCATION_n, while codeword 3 will be accessed
through READ_LOCATION_LAST_CW_n.

Signed-off-by: Md Sadre Alam <mdalam@codeaurora.org>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/1614109141-7531-5-git-send-email-mdalam@codeaurora.org
3 years agomtd: rawnand: qcom: Add helper to configure location register
Md Sadre Alam [Tue, 23 Feb 2021 19:39:00 +0000 (01:09 +0530)]
mtd: rawnand: qcom: Add helper to configure location register

Create a nandc_set_read_loc() helper to abstract the
configuration of the location register.

QPIC v2 onwards features a separate location register
for the last codeword, so introducing this extra helper
which will simplify the addition of QPIC v2 support.

Signed-off-by: Md Sadre Alam <mdalam@codeaurora.org>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/1614109141-7531-4-git-send-email-mdalam@codeaurora.org
3 years agomtd: rawnand: qcom: Rename parameter name in macro
Md Sadre Alam [Tue, 23 Feb 2021 19:38:59 +0000 (01:08 +0530)]
mtd: rawnand: qcom: Rename parameter name in macro

Rename the parameters of the nandc_set_read_loc() macro
to avoid the confusion between is_last_read_loc which
is last location in a read code word and last_cw which
is last code word of a page data.

Signed-off-by: Md Sadre Alam <mdalam@codeaurora.org>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/1614109141-7531-3-git-send-email-mdalam@codeaurora.org
3 years agomtd: rawnand: qcom: Add helper to check last code word
Md Sadre Alam [Tue, 23 Feb 2021 19:38:58 +0000 (01:08 +0530)]
mtd: rawnand: qcom: Add helper to check last code word

Add the qcom_nandc_is_last_cw() helper which checks if
the input cw index is the last one or not.

Signed-off-by: Md Sadre Alam <mdalam@codeaurora.org>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/1614109141-7531-2-git-send-email-mdalam@codeaurora.org
3 years agomtd: rawnand: qcom: Convert nandc to chip in Read/Write helper
Md Sadre Alam [Tue, 23 Feb 2021 19:38:57 +0000 (01:08 +0530)]
mtd: rawnand: qcom: Convert nandc to chip in Read/Write helper

This change will convert nandc to chip in Read/Write helper, this
change is needed because if we wnated to access number of steps
in Read/Write helper then we need to get the chip->ecc.steps,
currentlly its not possible.After this change we can directly
acces chip->ecc.steps in Read/Write helper.

Signed-off-by: Md Sadre Alam <mdalam@codeaurora.org>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/1614109141-7531-1-git-send-email-mdalam@codeaurora.org
3 years agomtd: rawnand: fsmc: Fix error code in fsmc_nand_probe()
Dan Carpenter [Mon, 15 Feb 2021 15:58:49 +0000 (18:58 +0300)]
mtd: rawnand: fsmc: Fix error code in fsmc_nand_probe()

If dma_request_channel() fails then the probe fails and it should
return a negative error code, but currently it returns success.

fixes: 4774fb0a48aa ("mtd: nand/fsmc: Add DMA support")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/YCqaOZ83OvPOzLwh@mwanda
3 years agomtd: spinand: gigadevice: Support GD5F1GQ5UExxG
Reto Schneider [Thu, 11 Feb 2021 11:36:19 +0000 (12:36 +0100)]
mtd: spinand: gigadevice: Support GD5F1GQ5UExxG

The relevant changes to the already existing GD5F1GQ4UExxG support has
been determined by consulting the GigaDevice product change notice
AN-0392-10, version 1.0 from November 30, 2020.

As the overlaps are huge, variable names have been generalized
accordingly.

Apart from the lowered ECC strength (4 instead of 8 bits per 512 bytes),
the new device ID, and the extra quad IO dummy byte, no changes had to
be taken into account.

New hardware features are not supported, namely:
 - Power on reset
 - Unique ID
 - Double transfer rate (DTR)
 - Parameter page
 - Random data quad IO

The inverted semantic of the "driver strength" register bits, defaulting
to 100% instead of 50% for the Q5 devices, got ignored as the driver has
never touched them anyway.

The no longer supported "read from cache during block erase"
functionality is not reflected as the current SPI NAND core does not
support it anyway.

Implementation has been tested on MediaTek MT7688 based GARDENA smart
Gateways using both, GigaDevice GD5F1GQ5UEYIG and GD5F1GQ4UBYIG.

Signed-off-by: Reto Schneider <reto.schneider@husqvarnagroup.com>
Reviewed-by: Frieder Schrempf <frieder.schrempf@kontron.de>
Reviewed-by: Stefan Roese <sr@denx.de>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210211113619.3502-1-code@reto-schneider.ch
3 years agomtd: nand: fix error handling in nand_prog_page_op() #2
Sascha Hauer [Fri, 5 Feb 2021 14:27:25 +0000 (15:27 +0100)]
mtd: nand: fix error handling in nand_prog_page_op() #2

On success nand_exec_prog_page_op() returns the NAND status byte, but on
failure it returns a negative error code. nand_prog_page_op() interprets
the return value as NAND status byte without error checking.  This means
a failure in nand_exec_prog_page_op() can go through unnoticed.

The straight forward fix would be to add the missing error checking. To
clean the code a bit we can move the nand status check to
nand_prog_page_op().  This way we can get rid of the overloaded return
value from nand_exec_prog_page_op() and return a plain error code which
is less error prone.

nand_exec_prog_page_op() is only called from one other place and in this
call the 'prog' parameter is false in which case the nand status check
is skipped, so it's correct to not add the NAND status check there.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210205142725.13225-2-s.hauer@pengutronix.de
3 years agomtd: nand: fix error handling in nand_prog_page_op() #1
Sascha Hauer [Fri, 5 Feb 2021 14:27:24 +0000 (15:27 +0100)]
mtd: nand: fix error handling in nand_prog_page_op() #1

On success chip->legacy.waitfunc() returns the NAND status byte, but on
failure it returns a negative error code. This was never tested for and
instead the return value was interpreted as NAND status without error
checking. Add the missing error check.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210205142725.13225-1-s.hauer@pengutronix.de
3 years agomtd: rawnand: qcom: Update register macro name for 0x2c offset
Md Sadre Alam [Sat, 30 Jan 2021 20:07:16 +0000 (01:37 +0530)]
mtd: rawnand: qcom: Update register macro name for 0x2c offset

This change will remove unused register name macro NAND_DEV1_ECC_CFG.
Since this register was only available in QPIC version 1.4.20 ipq40xx
and it was not used. In QPIC version 1.5 on wards this register got
removed.In QPIC version 2.0 0x2c offset is updated with register
NAND_AUTO_STATUS_EN So adding this register macro NAND_AUTO_STATUS_EN
with offset 0x2c.

Signed-off-by: Md Sadre Alam <mdalam@codeaurora.org>
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/1612037236-7954-1-git-send-email-mdalam@codeaurora.org
3 years agomtd: nand: ecc-hamming: Use the public nsteps field
Miquel Raynal [Wed, 27 Jan 2021 20:30:20 +0000 (21:30 +0100)]
mtd: nand: ecc-hamming: Use the public nsteps field

The software Hamming ECC engine stores the nsteps variable in its own
private structure while it is also exported as a public ECC field.

Let's get rid of the redundant private one and let's use the
nand_ecc_context structure when possible.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Tested-by: Adam Ford <aford173@gmail.com> #logicpd Torpedo
Link: https://lore.kernel.org/linux-mtd/20210127203020.9574-10-miquel.raynal@bootlin.com
3 years agomtd: nand: ecc-bch: Use the public nsteps field
Miquel Raynal [Wed, 27 Jan 2021 20:30:19 +0000 (21:30 +0100)]
mtd: nand: ecc-bch: Use the public nsteps field

The software BCH ECC engine stores the nsteps variable in its own
private structure while it is also exported as a public ECC field.

Let's get rid of the redundant private one and let's use the
nand_ecc_context structure when possible.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Tested-by: Adam Ford <aford173@gmail.com> #logicpd Torpedo
Link: https://lore.kernel.org/linux-mtd/20210127203020.9574-9-miquel.raynal@bootlin.com
3 years agomtd: rawnand: omap: Use ECC information from the generic structures
Miquel Raynal [Wed, 27 Jan 2021 20:30:18 +0000 (21:30 +0100)]
mtd: rawnand: omap: Use ECC information from the generic structures

As part of a previous fix, we imported the BCH internal structure in
order to get information about the BCH engine configuration.

It is best not to access private structure so instead, a small rework
has been done to export more information from the ECC engines. Now,
let's use these.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Tested-by: Adam Ford <aford173@gmail.com> #logicpd Torpedo
Link: https://lore.kernel.org/linux-mtd/20210127203020.9574-8-miquel.raynal@bootlin.com
3 years agomtd: rawnand: Try not to use the ECC private structures
Miquel Raynal [Wed, 27 Jan 2021 20:30:17 +0000 (21:30 +0100)]
mtd: rawnand: Try not to use the ECC private structures

Most of the time, there is no need to use the software ECC Hamming and
BCH algorithms private context to know their configuration. All the
data has been stored by their ->init_ctx() hook in the generic NAND
ECC engine structure, so use this one when possible.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Tested-by: Adam Ford <aford173@gmail.com> #logicpd Torpedo
Link: https://lore.kernel.org/linux-mtd/20210127203020.9574-7-miquel.raynal@bootlin.com
3 years agomtd: nand: Add a helper to retrieve the number of ECC bytes per step
Miquel Raynal [Wed, 27 Jan 2021 20:30:16 +0000 (21:30 +0100)]
mtd: nand: Add a helper to retrieve the number of ECC bytes per step

This operation is very common and deserves a helper. It of course only
works after the ECC engine initialization.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Tested-by: Adam Ford <aford173@gmail.com> #logicpd Torpedo
Link: https://lore.kernel.org/linux-mtd/20210127203020.9574-6-miquel.raynal@bootlin.com
3 years agomtd: nand: Add a helper to retrieve the number of ECC steps
Miquel Raynal [Wed, 27 Jan 2021 20:30:15 +0000 (21:30 +0100)]
mtd: nand: Add a helper to retrieve the number of ECC steps

This operation is very common and deserves a helper. It of course only
works after the ECC engine initialization.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Tested-by: Adam Ford <aford173@gmail.com> #logicpd Torpedo
Link: https://lore.kernel.org/linux-mtd/20210127203020.9574-5-miquel.raynal@bootlin.com
3 years agomtd: nand: ecc-hamming: Populate the public nsteps field
Miquel Raynal [Wed, 27 Jan 2021 20:30:14 +0000 (21:30 +0100)]
mtd: nand: ecc-hamming: Populate the public nsteps field

Advertize the actual number of steps that will actually be used by the
driver by populating the public field.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Tested-by: Adam Ford <aford173@gmail.com> #logicpd Torpedo
Link: https://lore.kernel.org/linux-mtd/20210127203020.9574-4-miquel.raynal@bootlin.com
3 years agomtd: nand: ecc-bch: Populate the public nsteps field
Miquel Raynal [Wed, 27 Jan 2021 20:30:13 +0000 (21:30 +0100)]
mtd: nand: ecc-bch: Populate the public nsteps field

Advertize the actual number of steps that will actually be used by the
driver by populating the public field.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Tested-by: Adam Ford <aford173@gmail.com> #logicpd Torpedo
Link: https://lore.kernel.org/linux-mtd/20210127203020.9574-3-miquel.raynal@bootlin.com
3 years agomtd: nand: Let ECC engines advertize the exact number of steps
Miquel Raynal [Wed, 27 Jan 2021 20:30:12 +0000 (21:30 +0100)]
mtd: nand: Let ECC engines advertize the exact number of steps

This is an information that might be useful for specific uses, so
export it, which might avoid having to guess the number of steps when
necessary.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Tested-by: Adam Ford <aford173@gmail.com> #logicpd Torpedo
Link: https://lore.kernel.org/linux-mtd/20210127203020.9574-2-miquel.raynal@bootlin.com
3 years agoMAINTAINERS: Add Michael and Pratyush as designated reviewers for SPI NOR
Tudor Ambarus [Mon, 8 Mar 2021 09:23:33 +0000 (11:23 +0200)]
MAINTAINERS: Add Michael and Pratyush as designated reviewers for SPI NOR

It's already been the case for some time that Michael and Pratyush
are reviewing SPI NOR patches. Update MAINTAINERS to reflect reality.

Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
Acked-by: Michael Walle <michael@walle.cc>
Acked-by: Pratyush Yadav <p.yadav@ti.com>
Acked-by: Vignesh Raghavendra <vigneshr@ti.com>
Link: https://lore.kernel.org/r/20210308092333.80521-2-tudor.ambarus@microchip.com
3 years agomtd: spi-nor: intel-spi: Move platform data header to x86 subfolder
Andy Shevchenko [Thu, 4 Mar 2021 14:08:20 +0000 (16:08 +0200)]
mtd: spi-nor: intel-spi: Move platform data header to x86 subfolder

In order to group x86 related platform data move intel-spi.h to x86 folder.

While at it, remove duplicate inclusion in C file.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
[ta: s/x85/x86]
Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
Reviewed-by: Vignesh Raghavendra <vigneshr@ti.com>
Link: https://lore.kernel.org/r/20210304140820.56692-1-andriy.shevchenko@linux.intel.com
3 years agomtd: spi-nor: use is_power_of_2()
Michael Walle [Fri, 5 Mar 2021 23:45:52 +0000 (00:45 +0100)]
mtd: spi-nor: use is_power_of_2()

There is already a function to check if an integer is a power of 2. Use
it.

Signed-off-by: Michael Walle <michael@walle.cc>
Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
Link: https://lore.kernel.org/r/20210305234552.19204-1-michael@walle.cc
3 years agomtd: spi-nor: winbond: Add support for w25q512jvq
Shuhao Mai [Mon, 8 Feb 2021 07:53:03 +0000 (15:53 +0800)]
mtd: spi-nor: winbond: Add support for w25q512jvq

Add support for w25q512jvq. This is of the same series chip with
w25q256jv, which is already supported, but with size doubled and
different JEDEC ID.

Tested on Intel whitley platform with dd from/to the flash for
read/write respectly, and flash_erase for erasing the flash.

Signed-off-by: Shuhao Mai <shuhao.mai.1990@gmail.com>
[ta: put flash_info flags in order, first SPI_NOR_DUAL_READ, then
SPI_NOR_QUAD_READ]
Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
Link: https://lore.kernel.org/r/20210208075303.4200-1-shuhao.mai.1990@gmail.com
3 years agoLinux 5.12-rc2
Linus Torvalds [Sat, 6 Mar 2021 01:33:41 +0000 (17:33 -0800)]
Linux 5.12-rc2

3 years agoMerge tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma
Linus Torvalds [Sat, 6 Mar 2021 01:27:59 +0000 (17:27 -0800)]
Merge tag 'for-linus' of git://git./linux/kernel/git/rdma/rdma

Pull rdma fixes from Jason Gunthorpe:
 "Nothing special here, though Bob's regression fixes for rxe would have
  made it before the rc cycle had there not been such strong winter
  weather!

   - Fix corner cases in the rxe reference counting cleanup that are
     causing regressions in blktests for SRP

   - Two kdoc fixes so W=1 is clean

   - Missing error return in error unwind for mlx5

   - Wrong lock type nesting in IB CM"

* tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma:
  RDMA/rxe: Fix errant WARN_ONCE in rxe_completer()
  RDMA/rxe: Fix extra deref in rxe_rcv_mcast_pkt()
  RDMA/rxe: Fix missed IB reference counting in loopback
  RDMA/uverbs: Fix kernel-doc warning of _uverbs_alloc
  RDMA/mlx5: Set correct kernel-doc identifier
  IB/mlx5: Add missing error code
  RDMA/rxe: Fix missing kconfig dependency on CRYPTO
  RDMA/cm: Fix IRQ restore in ib_send_cm_sidr_rep

3 years agoMerge tag 'gcc-plugins-v5.12-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git...
Linus Torvalds [Sat, 6 Mar 2021 01:23:03 +0000 (17:23 -0800)]
Merge tag 'gcc-plugins-v5.12-rc2' of git://git./linux/kernel/git/kees/linux

Pull gcc-plugins fixes from Kees Cook:
 "Tiny gcc-plugin fixes for v5.12-rc2. These issues are small but have
  been reported a couple times now by static analyzers, so best to get
  them fixed to reduce the noise. :)

   - Fix coding style issues (Jason Yan)"

* tag 'gcc-plugins-v5.12-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux:
  gcc-plugins: latent_entropy: remove unneeded semicolon
  gcc-plugins: structleak: remove unneeded variable 'ret'

3 years agoMerge tag 'pstore-v5.12-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/kees...
Linus Torvalds [Sat, 6 Mar 2021 01:21:25 +0000 (17:21 -0800)]
Merge tag 'pstore-v5.12-rc2' of git://git./linux/kernel/git/kees/linux

Pull pstore fixes from Kees Cook:

 - Rate-limit ECC warnings (Dmitry Osipenko)

 - Fix error path check for NULL (Tetsuo Handa)

* tag 'pstore-v5.12-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux:
  pstore/ram: Rate-limit "uncorrectable error in header" message
  pstore: Fix warning in pstore_kill_sb()

3 years agoMerge tag 'for-5.12/dm-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/device...
Linus Torvalds [Fri, 5 Mar 2021 21:25:23 +0000 (13:25 -0800)]
Merge tag 'for-5.12/dm-fixes' of git://git./linux/kernel/git/device-mapper/linux-dm

Pull device mapper fixes from Mike Snitzer:
 "Fix DM verity target's optional Forward Error Correction (FEC) for
  Reed-Solomon roots that are unaligned to block size"

* tag 'for-5.12/dm-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm:
  dm verity: fix FEC for RS roots unaligned to block size
  dm bufio: subtract the number of initial sectors in dm_bufio_get_device_size

3 years agoMerge tag 'block-5.12-2021-03-05' of git://git.kernel.dk/linux-block
Linus Torvalds [Fri, 5 Mar 2021 20:59:37 +0000 (12:59 -0800)]
Merge tag 'block-5.12-2021-03-05' of git://git.kernel.dk/linux-block

Pull block fixes from Jens Axboe:

 - NVMe fixes:
      - more device quirks (Julian Einwag, Zoltán Böszörményi, Pascal
        Terjan)
      - fix a hwmon error return (Daniel Wagner)
      - fix the keep alive timeout initialization (Martin George)
      - ensure the model_number can't be changed on a used subsystem
        (Max Gurtovoy)

 - rsxx missing -EFAULT on copy_to_user() failure (Dan)

 - rsxx remove unused linux.h include (Tian)

 - kill unused RQF_SORTED (Jean)

 - updated outdated BFQ comments (Joseph)

 - revert work-around commit for bd_size_lock, since we removed the
   offending user in this merge window (Damien)

* tag 'block-5.12-2021-03-05' of git://git.kernel.dk/linux-block:
  nvmet: model_number must be immutable once set
  nvme-fabrics: fix kato initialization
  nvme-hwmon: Return error code when registration fails
  nvme-pci: add quirks for Lexar 256GB SSD
  nvme-pci: mark Kingston SKC2000 as not supporting the deepest power state
  nvme-pci: mark Seagate Nytro XM1440 as QUIRK_NO_NS_DESC_LIST.
  rsxx: Return -EFAULT if copy_to_user() fails
  block/bfq: update comments and default value in docs for fifo_expire
  rsxx: remove unused including <linux/version.h>
  block: Drop leftover references to RQF_SORTED
  block: revert "block: fix bd_size_lock use"

3 years agoMerge tag 'io_uring-5.12-2021-03-05' of git://git.kernel.dk/linux-block
Linus Torvalds [Fri, 5 Mar 2021 20:44:43 +0000 (12:44 -0800)]
Merge tag 'io_uring-5.12-2021-03-05' of git://git.kernel.dk/linux-block

Pull io_uring fixes from Jens Axboe:
 "A bit of a mix between fallout from the worker change, cleanups and
  reductions now possible from that change, and fixes in general. In
  detail:

   - Fully serialize manager and worker creation, fixing races due to
     that.

   - Clean up some naming that had gone stale.

   - SQPOLL fixes.

   - Fix race condition around task_work rework that went into this
     merge window.

   - Implement unshare. Used for when the original task does unshare(2)
     or setuid/seteuid and friends, drops the original workers and forks
     new ones.

   - Drop the only remaining piece of state shuffling we had left, which
     was cred. Move it into issue instead, and we can drop all of that
     code too.

   - Kill f_op->flush() usage. That was such a nasty hack that we had
     out of necessity, we no longer need it.

   - Following from ->flush() removal, we can also drop various bits of
     ctx state related to SQPOLL and cancelations.

   - Fix an issue with IOPOLL retry, which originally was fallout from a
     filemap change (removing iov_iter_revert()), but uncovered an issue
     with iovec re-import too late.

   - Fix an issue with system suspend.

   - Use xchg() for fallback work, instead of cmpxchg().

   - Properly destroy io-wq on exec.

   - Add create_io_thread() core helper, and use that in io-wq and
     io_uring. This allows us to remove various silly completion events
     related to thread setup.

   - A few error handling fixes.

  This should be the grunt of fixes necessary for the new workers, next
  week should be quieter. We've got a pending series from Pavel on
  cancelations, and how tasks and rings are indexed. Outside of that,
  should just be minor fixes. Even with these fixes, we're still killing
  a net ~80 lines"

* tag 'io_uring-5.12-2021-03-05' of git://git.kernel.dk/linux-block: (41 commits)
  io_uring: don't restrict issue_flags for io_openat
  io_uring: make SQPOLL thread parking saner
  io-wq: kill hashed waitqueue before manager exits
  io_uring: clear IOCB_WAITQ for non -EIOCBQUEUED return
  io_uring: don't keep looping for more events if we can't flush overflow
  io_uring: move to using create_io_thread()
  kernel: provide create_io_thread() helper
  io_uring: reliably cancel linked timeouts
  io_uring: cancel-match based on flags
  io-wq: ensure all pending work is canceled on exit
  io_uring: ensure that threads freeze on suspend
  io_uring: remove extra in_idle wake up
  io_uring: inline __io_queue_async_work()
  io_uring: inline io_req_clean_work()
  io_uring: choose right tctx->io_wq for try cancel
  io_uring: fix -EAGAIN retry with IOPOLL
  io-wq: fix error path leak of buffered write hash map
  io_uring: remove sqo_task
  io_uring: kill sqo_dead and sqo submission halting
  io_uring: ignore double poll add on the same waitqueue head
  ...

3 years agoMerge tag 'pm-5.12-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
Linus Torvalds [Fri, 5 Mar 2021 20:36:33 +0000 (12:36 -0800)]
Merge tag 'pm-5.12-rc2' of git://git./linux/kernel/git/rafael/linux-pm

Pull power management fixes from Rafael Wysocki:
 "These fix the usage of device links in the runtime PM core code and
  update the DTPM (Dynamic Thermal Power Management) feature added
  recently.

  Specifics:

   - Make the runtime PM core code avoid attempting to suspend supplier
     devices before updating the PM-runtime status of a consumer to
     'suspended' (Rafael Wysocki).

   - Fix DTPM (Dynamic Thermal Power Management) root node
     initialization and label that feature as EXPERIMENTAL in Kconfig
     (Daniel Lezcano)"

* tag 'pm-5.12-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm:
  powercap/drivers/dtpm: Add the experimental label to the option description
  powercap/drivers/dtpm: Fix root node initialization
  PM: runtime: Update device status before letting suppliers suspend