Commit Graph

9231 Commits

Author SHA1 Message Date
Manivannan Sadhasivam
dcd1e618b6 mtd: rawnand: qcom: Do not override the error no of submit_descs()
Just use the error no returned by submit_descs() instead of overriding it
with -EIO.

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/20230805174146.57006-10-manivannan.sadhasivam@linaro.org
2023-08-18 16:34:33 +02:00
Manivannan Sadhasivam
c56de1e5b9 mtd: rawnand: qcom: Simplify the call to nand_prog_page_end_op()
Now that the dma desc cleanup is moved inside submit_descs(), let's
simplify the call to nand_prog_page_end_op() inside qcom_nandc_write_page()
and qcom_nandc_write_page_raw() to match other functions.

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/20230805174146.57006-9-manivannan.sadhasivam@linaro.org
2023-08-18 16:34:31 +02:00
Manivannan Sadhasivam
bb7a103d45 mtd: rawnand: qcom: Unmap sg_list and free desc within submic_descs()
There are two types of dma descriptors being used in this driver allocated
by, prepare_bam_async_desc() and prep_adm_dma_desc() helper functions.
These functions map and prepare the descriptors to be used for dma
transfers.

And all the descriptors are submitted inside the submit_descs() function.
Once the transfer completion happens, those descriptors should be unmapped
and freed as a part of cleanup.

Currently, free_descs() function is doing the said cleanup of descriptors.
But the callers of submit_descs() are required to call free_descs() in both
the success and error cases.

Since there are no other transactions need to be done after submit_descs(),
let's just move the contents of free_descs() inside submit_descs() itself.

This makes sure that the cleanup is handled within the submit_descs()
thereby offloading the cleanup part from callers.

While at it, let's also rename the return variable from "r" to "ret".

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/20230805174146.57006-8-manivannan.sadhasivam@linaro.org
2023-08-18 16:34:30 +02:00
Manivannan Sadhasivam
cf82436dd8 mtd: rawnand: qcom: Wrap qcom_nand_exec_op() to 80 columns
Both the function arguments and the definition could be wrapped to 80
columns to save line space.

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/20230805174146.57006-7-manivannan.sadhasivam@linaro.org
2023-08-18 16:34:28 +02:00
Manivannan Sadhasivam
ab15aabac0 mtd: rawnand: qcom: Use EOPNOTSUPP instead of ENOTSUPP
Checkpatch complains over the usage of ENOTSUPP for new patches as below:

WARNING: ENOTSUPP is not a SUSV4 error code, prefer EOPNOTSUPP

So let's fix the error code which is already present in qcom_check_op().

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/20230805174146.57006-6-manivannan.sadhasivam@linaro.org
2023-08-18 16:34:27 +02:00
Manivannan Sadhasivam
b4bb480031 mtd: rawnand: qcom: Fix the opcode check in qcom_check_op()
qcom_check_op() function checks for the invalid opcode for the instruction
types. Currently, it just returns -ENOTSUPP for all opcodes of
NAND_OP_CMD_INSTR type due to the use of "||" operator instead of "&&".
Fix it!

This also fixes the following smatch warning:

drivers/mtd/nand/raw/qcom_nandc.c:3036 qcom_check_op() warn: was && intended here instead of ||?

Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/r/202308032022.SnXkKyFs-lkp@intel.com/
Fixes: 89550beb09 ("mtd: rawnand: qcom: Implement exec_op()")
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/20230805174146.57006-5-manivannan.sadhasivam@linaro.org
2023-08-18 16:34:26 +02:00
Manivannan Sadhasivam
dd3c8f4ab2 mtd: rawnand: qcom: Handle unsupported opcode in qcom_op_cmd_mapping()
Handle the scenario where the caller has passed an unsupported opcode to
qcom_op_cmd_mapping(). In that case, log the error and return the
-EOPNOTSUPP errono. Also, let's propagate this error code all the way up.

This also fixes the following smatch warning:

drivers/mtd/nand/raw/qcom_nandc.c:2941 qcom_op_cmd_mapping() error: uninitialized symbol 'ret'.

Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/r/202308032022.SnXkKyFs-lkp@intel.com/
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/20230805174146.57006-4-manivannan.sadhasivam@linaro.org
2023-08-18 16:34:24 +02:00
Manivannan Sadhasivam
d68b7e5f49 mtd: rawnand: qcom: Rename variables in qcom_op_cmd_mapping()
qcom_op_cmd_mapping() function accepts opcode and returns the corresponding
command register. So let's rename the local variables and parameters to
reflect the same.

Reported-by: Miquel Raynal <miquel.raynal@bootlin.com>
Closes: https://lore.kernel.org/all/20230804190750.3367a044@xps-13/
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/20230805174146.57006-3-manivannan.sadhasivam@linaro.org
2023-08-18 16:34:23 +02:00
Manivannan Sadhasivam
847178fe4c mtd: rawnand: qcom: Remove superfluous initialization of "ret"
In all the cases, "ret" variable is assigned a value before returning it.
So there is no need to explicitly initialize it with 0.

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/20230805174146.57006-2-manivannan.sadhasivam@linaro.org
2023-08-18 16:34:22 +02:00
Zhu Wang
3549fecd10 mtd: rawnand: vf610_nfc: Do not check 0 for platform_get_irq()
Since platform_get_irq() never returned zero, so it need not to check
whether it returned zero, and we use the return error code of
platform_get_irq() to replace the current return error code, for that
platform_get_irq() may return -EINVAL or -ENXIO.

Signed-off-by: Zhu Wang <wangzhu9@huawei.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20230803085056.30888-1-wangzhu9@huawei.com
2023-08-04 09:02:51 +02:00
Li Zetao
31cbe3a7e2 mtd: rawnand: brcmnand: Use devm_platform_ioremap_resource_byname()
Convert platform_get_resource_byname() + devm_ioremap_resource() to a
single call to devm_platform_ioremap_resource_byname(), as this is
exactly what this function does.

Signed-off-by: Li Zetao <lizetao1@huawei.com>
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20230802013500.1030853-1-lizetao1@huawei.com
2023-08-04 09:02:49 +02:00
Arseniy Krasnov
4622daf4b5 mtd: rawnand: meson: fix build error
Fixes the following build error:

drivers/mtd/nand/raw/meson_nand.c:244:59: error: initializer element is not a compile-time constant
static const struct nand_ecc_step_info axg_stepinfo[] = { axg_stepinfo_1024, axg_stepinfo_512 };
                                                          ^~~~~~~~~~~~~~~~~

Fixes: 0e1db39336 ("mtd: rawnand: meson: support for 512B ECC step size")
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202307281007.MMuVjmJ9-lkp@intel.com/
Signed-off-by: Arseniy Krasnov <AVKrasnov@sberdevices.ru>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20230728093810.2985324-1-AVKrasnov@sberdevices.ru
2023-07-28 14:32:31 +02:00
Miquel Raynal
e253242931 mtd: rawnand: qcom: Fix address parsing within ->exec_op()
The naddrs variable is initialized but not used. Fixing this could have
been a matter of dropping the variable, but the right way to do it looks
a bit more complex: we can avoid useless writes to the q_op structure by
using it. In practice we could even have possible out-of-bound bugs with
the existing implementation. Let's fix all that by just performing the
right number of assignments in the addr{1,2}_reg fields.

Fixes: 89550beb09 ("mtd: rawnand: qcom: Implement exec_op()")
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202307131959.PdPSC86K-lkp@intel.com/
Closes: https://lore.kernel.org/oe-kbuild-all/202307131730.NOYbcjBr-lkp@intel.com/
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Acked-by: Manivannan Sadhasivam <mani@kernel.org>
Reviewed-by: Tudor Ambarus <tudor.ambarus@linaro.org>
Link: https://lore.kernel.org/linux-mtd/20230716144612.32132-9-miquel.raynal@bootlin.com
2023-07-28 14:32:29 +02:00
Miquel Raynal
e260efea80 mtd: rawnand: qcom: Early structure initialization
Instead of allocating a structure on the stack with random data and then
expect the callee to perform the initialization (which is, in general,
error prone), prefer zeroing the structure explicitly at allocation and
provide the already zeroed area, so no explicit memset operation is
needed. It is probably safer to do so, so we limit the timeframe when
dirty data could actually be accessed by mistake.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Acked-by: Manivannan Sadhasivam <mani@kernel.org>
Reviewed-by: Tudor Ambarus <tudor.ambarus@linaro.org>
Link: https://lore.kernel.org/linux-mtd/20230716144612.32132-8-miquel.raynal@bootlin.com
2023-07-28 14:32:28 +02:00
Miquel Raynal
548b7509d9 mtd: rawnand: qcom: Fix a typo
Fix the following checkpatch warning:
	CHECK: 'tranasction' may be misspelled - perhaps 'transaction'?

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Acked-by: Manivannan Sadhasivam <mani@kernel.org>
Reviewed-by: Tudor Ambarus <tudor.ambarus@linaro.org>
Link: https://lore.kernel.org/linux-mtd/20230716144612.32132-7-miquel.raynal@bootlin.com
2023-07-28 14:32:26 +02:00
Miquel Raynal
fd29ba6707 mtd: rawnand: qcom: Fix wrong indentation
The main "for" loop in qcom_read_status_exec() does guard the following
to if's which are badly indented. Fix the indentation.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Acked-by: Manivannan Sadhasivam <mani@kernel.org>
Reviewed-by: Tudor Ambarus <tudor.ambarus@linaro.org>
Link: https://lore.kernel.org/linux-mtd/20230716144612.32132-6-miquel.raynal@bootlin.com
2023-07-28 14:32:24 +02:00
Miquel Raynal
3b645b384b mtd: rawnand: qcom: Fix the spacing
Fix following checkpatch warning:
	"CHECK: Please don't use multiple blank lines"
	"CHECK: Please use a blank line after
		function/struct/union/enum declarations"

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Acked-by: Manivannan Sadhasivam <mani@kernel.org>
Reviewed-by: Tudor Ambarus <tudor.ambarus@linaro.org>
Link: https://lore.kernel.org/linux-mtd/20230716144612.32132-5-miquel.raynal@bootlin.com
2023-07-28 14:32:22 +02:00
Miquel Raynal
062d8acb19 mtd: rawnand: qcom: Fix alignment with open parenthesis
Fix the following checkpatch warning:
    	"CHECK: Alignment should match open parenthesis"

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Acked-by: Manivannan Sadhasivam <mani@kernel.org>
Reviewed-by: Tudor Ambarus <tudor.ambarus@linaro.org>
Link: https://lore.kernel.org/linux-mtd/20230716144612.32132-4-miquel.raynal@bootlin.com
2023-07-28 14:32:21 +02:00
Miquel Raynal
428771b61a mtd: rawnand: qcom: Use u8 instead of uint8_t
Fix the following checkpatch warning:
    "CHECK: Prefer kernel type 'u8' over 'uint8_t'"

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Acked-by: Manivannan Sadhasivam <mani@kernel.org>
Reviewed-by: Tudor Ambarus <tudor.ambarus@linaro.org>
Link: https://lore.kernel.org/linux-mtd/20230716144612.32132-3-miquel.raynal@bootlin.com
2023-07-28 14:32:19 +02:00
Miquel Raynal
a6de66607a mtd: rawnand: qcom: Use the BIT() macro
Fix the following checkpatch warning:
    "CHECK: Prefer using the BIT macro"

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Acked-by: Manivannan Sadhasivam <mani@kernel.org>
Reviewed-by: Tudor Ambarus <tudor.ambarus@linaro.org>
Link: https://lore.kernel.org/linux-mtd/20230716144612.32132-2-miquel.raynal@bootlin.com
2023-07-28 14:32:17 +02:00
Rafał Miłecki
6680d8b679 mtd: rawnand: brcmnand: propagate init error -EPROBE_DEFER up
MTD subsystem may return -EPROBE_DEFER if something isn't ready yet.
It's important to pass that error up so device will get probed later.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Acked-by: Florian Fainelli <florian.fainelli@broadcom.com>
Acked-by: William Zhang <william.zhang@broadcom.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20230719084324.14799-1-zajec5@gmail.com
2023-07-27 17:02:01 +02:00
Arseniy Krasnov
0e1db39336 mtd: rawnand: meson: support for 512B ECC step size
Meson NAND supports both 512B and 1024B ECC step size.

Signed-off-by: Arseniy Krasnov <AVKrasnov@sberdevices.ru>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20230717053402.1203724-3-AVKrasnov@sberdevices.ru
2023-07-27 17:01:59 +02:00
Chris Packham
72b9a3fc4b mtd: rawnand: marvell: add support for AC5 SoC
Add support for the AC5/AC5X SoC from Marvell. The NFC on this SoC only
supports SDR modes up to 3.

Marvell's SDK includes some predefined values for the ndtr registers.
These haven't been incorporated as the existing code seems to get good
values based on measurements taken with an oscilloscope.

Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20230703035044.2063303-4-chris.packham@alliedtelesis.co.nz
2023-07-15 18:05:38 +02:00
Md Sadre Alam
2e7f735b38 mtd: rawnand: qcom: Remove legacy interface
Remove legacy interface implementation

Co-developed-by: Sricharan Ramabadhran <quic_srichara@quicinc.com>
Signed-off-by: Sricharan Ramabadhran <quic_srichara@quicinc.com>
Signed-off-by: Md Sadre Alam <quic_mdalam@quicinc.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20230710054440.23297-2-quic_mdalam@quicinc.com
2023-07-15 18:05:38 +02:00
Md Sadre Alam
89550beb09 mtd: rawnand: qcom: Implement exec_op()
Implement exec_op() so we can later get rid of the legacy
interface implementation.

Co-developed-by: Sricharan Ramabadhran <quic_srichara@quicinc.com>
Signed-off-by: Sricharan Ramabadhran <quic_srichara@quicinc.com>
Signed-off-by: Md Sadre Alam <quic_mdalam@quicinc.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20230710054440.23297-1-quic_mdalam@quicinc.com
2023-07-15 18:05:38 +02:00
Yangtao Li
b798f7729c mtd: nand: omap: Use devm_platform_get_and_ioremap_resource()
Convert platform_get_resource(), devm_ioremap_resource() to a single
call to devm_platform_get_and_ioremap_resource(), as this is exactly
what this function does.

Signed-off-by: Yangtao Li <frank.li@vivo.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20230713104422.29222-1-frank.li@vivo.com
2023-07-15 18:05:32 +02:00
Yangtao Li
717a53833d mtd: nand: samsung: Convert to devm_platform_ioremap_resource() and devm_platform_get_and_ioremap_resource()
Use devm_platform_ioremap_resource() and
devm_platform_get_and_ioremap_resource() to simplify code.

Signed-off-by: Yangtao Li <frank.li@vivo.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20230707040622.78174-11-frank.li@vivo.com
2023-07-12 14:07:57 +02:00
Yangtao Li
09ea085f64 mtd: rawnand: atmel: Use devm_platform_get_and_ioremap_resource()
Convert platform_get_resource(), devm_ioremap_resource() to a single
call to devm_platform_get_and_ioremap_resource(), as this is exactly
what this function does.

Signed-off-by: Yangtao Li <frank.li@vivo.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20230707040622.78174-10-frank.li@vivo.com
2023-07-12 14:07:55 +02:00
Yangtao Li
892ad2638a mtd: rawnand: fsl_upm: Use devm_platform_get_and_ioremap_resource()
Convert platform_get_resource(), devm_ioremap_resource() to a single
call to devm_platform_get_and_ioremap_resource(), as this is exactly
what this function does.

Signed-off-by: Yangtao Li <frank.li@vivo.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20230707040622.78174-8-frank.li@vivo.com
2023-07-12 14:07:54 +02:00
Yangtao Li
9cd9dda8f0 mtd: rawnand: lpc32xx_mlc: Use devm_platform_get_and_ioremap_resource()
Convert platform_get_resource(), devm_ioremap_resource() to a single
call to devm_platform_get_and_ioremap_resource(), as this is exactly
what this function does.

Signed-off-by: Yangtao Li <frank.li@vivo.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20230707040622.78174-7-frank.li@vivo.com
2023-07-12 14:07:52 +02:00
Yangtao Li
68e10224a5 mtd: rawnand: stm32_fmc2: Use devm_platform_get_and_ioremap_resource()
Convert platform_get_resource(), devm_ioremap_resource() to a single
call to devm_platform_get_and_ioremap_resource(), as this is exactly
what this function does.

Signed-off-by: Yangtao Li <frank.li@vivo.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20230707040622.78174-6-frank.li@vivo.com
2023-07-12 14:07:50 +02:00
Yangtao Li
189175e0c3 mtd: rawnand: omap2: Use devm_platform_get_and_ioremap_resource()
Convert platform_get_resource(), devm_ioremap_resource() to a single
call to devm_platform_get_and_ioremap_resource(), as this is exactly
what this function does.

Signed-off-by: Yangtao Li <frank.li@vivo.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20230707040622.78174-5-frank.li@vivo.com
2023-07-12 14:07:49 +02:00
Yangtao Li
4eef841d29 mtd: rawnand: sh_flctl: Use devm_platform_get_and_ioremap_resource()
Convert platform_get_resource(), devm_ioremap_resource() to a single
call to devm_platform_get_and_ioremap_resource(), as this is exactly
what this function does.

Signed-off-by: Yangtao Li <frank.li@vivo.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20230707040622.78174-4-frank.li@vivo.com
2023-07-12 14:07:47 +02:00
Yangtao Li
c96b3e0905 mtd: rawnand: mxc: Convert to devm_platform_ioremap_resource()
Use devm_platform_ioremap_resource() to simplify code.

Signed-off-by: Yangtao Li <frank.li@vivo.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20230707040622.78174-3-frank.li@vivo.com
2023-07-12 14:07:45 +02:00
Yangtao Li
1c66c7523f mtd: rawnand: lpc32xx_slc: Use devm_platform_get_and_ioremap_resource()
Convert platform_get_resource(), devm_ioremap_resource() to a single
call to devm_platform_get_and_ioremap_resource(), as this is exactly
what this function does.

Signed-off-by: Yangtao Li <frank.li@vivo.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20230707040622.78174-2-frank.li@vivo.com
2023-07-12 14:07:44 +02:00
Yangtao Li
81a16e154c mtd: rawnand: sunxi: Use devm_platform_get_and_ioremap_resource()
Convert platform_get_resource(), devm_ioremap_resource() to a single
call to devm_platform_get_and_ioremap_resource(), as this is exactly
what this function does.

Signed-off-by: Yangtao Li <frank.li@vivo.com>
Acked-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20230707040622.78174-1-frank.li@vivo.com
2023-07-12 14:07:42 +02:00
William Zhang
60177390fa mtd: rawnand: brcmnand: Fix mtd oobsize
brcmnand controller can only access the flash spare area up to certain
bytes based on the ECC level. It can be less than the actual flash spare
area size. For example, for many NAND chip supporting ECC BCH-8, it has
226 bytes spare area. But controller can only uses 218 bytes. So brcmand
driver overrides the mtd oobsize with the controller's accessible spare
area size. When the nand base driver utilizes the nand_device object, it
resets the oobsize back to the actual flash spare aprea size from
nand_memory_organization structure and controller may not able to access
all the oob area as mtd advises.

This change fixes the issue by overriding the oobsize in the
nand_memory_organization structure to the controller's accessible spare
area size.

Fixes: a7ab085d7c ("mtd: rawnand: Initialize the nand_device object")
Signed-off-by: William Zhang <william.zhang@broadcom.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20230706182909.79151-6-william.zhang@broadcom.com
2023-07-12 13:45:15 +02:00
William Zhang
5d53244186 mtd: rawnand: brcmnand: Fix potential out-of-bounds access in oob write
When the oob buffer length is not in multiple of words, the oob write
function does out-of-bounds read on the oob source buffer at the last
iteration. Fix that by always checking length limit on the oob buffer
read and fill with 0xff when reaching the end of the buffer to the oob
registers.

Fixes: 27c5b17cd1 ("mtd: nand: add NAND driver "library" for Broadcom STB NAND controller")
Signed-off-by: William Zhang <william.zhang@broadcom.com>
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Cc: stable@vger.kernel.org
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20230706182909.79151-5-william.zhang@broadcom.com
2023-07-12 13:45:12 +02:00
William Zhang
e66dd31719 mtd: rawnand: brcmnand: Fix crash during the panic_write
When executing a NAND command within the panic write path, wait for any
pending command instead of calling BUG_ON to avoid crashing while
already crashing.

Fixes: 27c5b17cd1 ("mtd: nand: add NAND driver "library" for Broadcom STB NAND controller")
Signed-off-by: William Zhang <william.zhang@broadcom.com>
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Reviewed-by: Kursad Oney <kursad.oney@broadcom.com>
Reviewed-by: Kamal Dasu <kamal.dasu@broadcom.com>
Cc: stable@vger.kernel.org
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20230706182909.79151-4-william.zhang@broadcom.com
2023-07-12 13:45:10 +02:00
William Zhang
9cc0a598b9 mtd: rawnand: brcmnand: Fix potential false time out warning
If system is busy during the command status polling function, the driver
may not get the chance to poll the status register till the end of time
out and return the premature status.  Do a final check after time out
happens to ensure reading the correct status.

Fixes: 9d2ee0a60b ("mtd: nand: brcmnand: Check flash #WP pin status before nand erase/program")
Signed-off-by: William Zhang <william.zhang@broadcom.com>
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Cc: stable@vger.kernel.org
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20230706182909.79151-3-william.zhang@broadcom.com
2023-07-12 13:45:08 +02:00
William Zhang
2ec2839a90 mtd: rawnand: brcmnand: Fix ECC level field setting for v7.2 controller
v7.2 controller has different ECC level field size and shift in the acc
control register than its predecessor and successor controller. It needs
to be set specifically.

Fixes: decba6d478 ("mtd: brcmnand: Add v7.2 controller support")
Signed-off-by: William Zhang <william.zhang@broadcom.com>
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Cc: stable@vger.kernel.org
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20230706182909.79151-2-william.zhang@broadcom.com
2023-07-12 13:45:07 +02:00
Arseniy Krasnov
cda24ab773 mtd: rawnand: meson: use NAND core API to check status
NAND core API already has functions to send NAND_CMD_STATUS and leave
status checking mode by sending NAND_CMD_READ0, so use both of them
instead of direct access to the controller registers.

Signed-off-by: Arseniy Krasnov <AVKrasnov@sberdevices.ru>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20230705104403.696680-3-AVKrasnov@sberdevices.ru
2023-07-12 13:42:54 +02:00
Arseniy Krasnov
079c8d9da2 mtd: rawnand: export 'nand_exit_status_op()'
Export this function to work in pair with 'nand_status_op()' which is
already exported.

Signed-off-by: Arseniy Krasnov <AVKrasnov@sberdevices.ru>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20230705104403.696680-2-AVKrasnov@sberdevices.ru
2023-07-12 13:42:52 +02:00
Neil Armstrong
ecdaf0ee79 nand: oxnas_nand: remove obsolete raw nand driver
Due to lack of maintenance and stall of development for a few years now,
and since no new features will ever be added upstream, remove support
for OX810 and OX820 nand.

Acked-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Daniel Golle <daniel@makrotopia.org>
Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
Acked-by: Miquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20230630-topic-oxnas-upstream-remove-v2-5-fb6ab3dea87c@linaro.org
2023-07-12 13:42:49 +02:00
Sridharan S N
dabd64be75 mtd: spinand: toshiba: add support for T{C,H}58NYG{0,2}S3HBAI4 and TH58NYG3S0HBAI6
Add support for:
   TC58NYG0S3HBAI4 - 1Gb SLC NAND flash
   TH58NYG2S3HBAI4 - 4Gb SLC NAND flash
   TH58NYG3S0HBAI6 - 8Gb SLC NAND flash

All of these has 8b/512b on-die ECC capability

Signed-off-by: Sridharan S N <quic_sridsn@quicinc.com>
Signed-off-by: Md Sadre Alam <quic_mdalam@quicinc.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20230623045757.30055-4-quic_sridsn@quicinc.com
2023-07-12 13:35:05 +02:00
Sridharan S N
aa08bf187f mtd: spinand: esmt: add support for F50D2G41KA
This adds support for ESMT F50D2G41KA. This is 2Gb SLC NAND flash
with 8b/512b on-die ECC capability.

Signed-off-by: Sridharan S N <quic_sridsn@quicinc.com>
Signed-off-by: Md Sadre Alam <quic_mdalam@quicinc.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20230623045757.30055-3-quic_sridsn@quicinc.com
2023-07-12 13:34:54 +02:00
Sridharan S N
746b0f2675 mtd: spinand: gigadevice: add support for GD5F1GQ{4,5}RExxH
Add support for:
	GD5F1GQ5RExxH
	GD5F1GQ4RExxH

Both are 1Gb SLC NAND flash with 4b/512b on-die ECC capability and has
2K + 64B PageSize.

Signed-off-by: Sridharan S N <quic_sridsn@quicinc.com>
Signed-off-by: Md Sadre Alam <quic_mdalam@quicinc.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20230623045757.30055-2-quic_sridsn@quicinc.com
2023-07-12 13:34:27 +02:00
Linus Torvalds
1364b4068a Core MTD changes:
* otp:
   - Put factory OTP/NVRAM into the entropy pool
   - Clean up on error in mtd_otp_nvmem_add()
 
 MTD devices changes:
 * sm_ftl: Fix typos in comments
 * Use SPDX license headers
 * pismo: Switch back to use i2c_driver's .probe()
 * mtdpart: Drop useless LIST_HEAD
 * st_spi_fsm: Use the devm_clk_get_enabled() helper function
 
 DT binding changes:
 * partitions:
   - Include TP-Link SafeLoader in allowed list
   - Add missing type for "linux,rootfs"
 * Extend the nand node names filter
 * Create a file for raw NAND chip properties
 * Mark nand-ecc-placement deprecated
 * Describe nand-ecc-mode
 * Prevent NAND chip unevaluated properties in all NAND bindings with a NAND chip
   reference.
 * Qcom: Fix a property position
 * Marvell: Convert to YAML DT schema
 
 Raw NAND chip drivers changes:
 * Macronix: OTP access for MX30LFxG18AC
 * Add basic Sandisk manufacturer ops
 * Add support for Sandisk SDTNQGAMA
 
 Raw NAND controller driver changes:
 * Meson:
   - Replace integer consts with proper defines
   - Allow waiting w/o wired ready/busy pin
   - Check buffer length validity
   - Fix unaligned DMA buffers handling
   - dt-bindings: Fix 'nand-rb' property
 * Arasan: Revert "mtd: rawnand: arasan: Prevent an unsupported configuration"
   as this limitation is no longer true thanks to the recent efforts in improving
   the clocks support in this driver
 
 SPI-NAND changes:
 * Gigadevice: add support for GD5F2GQ5xExxH
 * Macronix: Add support for serial NAND flashes
 -----BEGIN PGP SIGNATURE-----
 
 iQEzBAABCgAdFiEE9HuaYnbmDhq/XIDIJWrqGEe9VoQFAmSV0L8ACgkQJWrqGEe9
 VoS4wggApYa1Qy7FRqofMEkrTxUQgLYFi4QzeCZLwdavtzUANcqck5WpOFzZE+ws
 A7cdvp0gxcbl2Y0lKKIiEU+UdJpXjr6aZpCRVK05n/8OZTFvUd7dYttK0swsh+QD
 OAN/Y8ESbDjOHhV8jT8y8ItRY2wAeNyLTAvOjI5I+i8iEJ8AK3N5Or6tFWZ5CUn8
 HX2R1hpwBfZeVfkg+uMRxnrqhG/IpzmrXRGuRYGvMBuqO1gxU1/3GuZLUIxIsVH2
 8XfhY1fdMLaHsZ20yR2ZxVKgo/53tPVxNucsdv9OwiwEZWVhxVoX8wP4t4kH3fTL
 IIgB+TVGm5KBgtQUUEwFk6mji+Yxpw==
 =dbsj
 -----END PGP SIGNATURE-----

Merge tag 'mtd/for-6.5' of git://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux

Pull mtd updates from
 "Core MTD changes:
   - otp:
      - Put factory OTP/NVRAM into the entropy pool
      - Clean up on error in mtd_otp_nvmem_add()

  MTD devices changes:
   - sm_ftl: Fix typos in comments
   - Use SPDX license headers
   - pismo: Switch back to use i2c_driver's .probe()
   - mtdpart: Drop useless LIST_HEAD
   - st_spi_fsm: Use the devm_clk_get_enabled() helper function

  DT binding changes:
   - partitions:
      - Include TP-Link SafeLoader in allowed list
      - Add missing type for "linux,rootfs"
   - Extend the nand node names filter
   - Create a file for raw NAND chip properties
   - Mark nand-ecc-placement deprecated
   - Describe nand-ecc-mode
   - Prevent NAND chip unevaluated properties in all NAND bindings with
     a NAND chip reference.
   - Qcom: Fix a property position
   - Marvell: Convert to YAML DT schema

  Raw NAND chip drivers changes:
   - Macronix: OTP access for MX30LFxG18AC
   - Add basic Sandisk manufacturer ops
   - Add support for Sandisk SDTNQGAMA

  Raw NAND controller driver changes:
   - Meson:
      - Replace integer consts with proper defines
      - Allow waiting w/o wired ready/busy pin
      - Check buffer length validity
      - Fix unaligned DMA buffers handling
      - dt-bindings: Fix 'nand-rb' property
   - Arasan: Revert "mtd: rawnand: arasan: Prevent an unsupported
     configuration" as this limitation is no longer true thanks to the
     recent efforts in improving the clocks support in this driver

  SPI-NAND changes:
   - Gigadevice: add support for GD5F2GQ5xExxH
   - Macronix: Add support for serial NAND flashes"

* tag 'mtd/for-6.5' of git://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux: (38 commits)
  dt-bindings: mtd: marvell-nand: Convert to YAML DT scheme
  dt-bindings: mtd: ti,am654: Prevent unevaluated properties
  dt-bindings: mtd: mediatek: Prevent NAND chip unevaluated properties
  dt-bindings: mtd: mediatek: Reference raw-nand-chip.yaml
  dt-bindings: mtd: stm32: Prevent NAND chip unevaluated properties
  dt-bindings: mtd: rockchip: Prevent NAND chip unevaluated properties
  dt-bindings: mtd: intel: Prevent NAND chip unevaluated properties
  dt-bindings: mtd: denali: Prevent NAND chip unevaluated properties
  dt-bindings: mtd: brcmnand: Prevent NAND chip unevaluated properties
  dt-bindings: mtd: meson: Prevent NAND chip unevaluated properties
  dt-bindings: mtd: sunxi: Prevent NAND chip unevaluated properties
  dt-bindings: mtd: ingenic: Prevent NAND chip unevaluated properties
  dt-bindings: mtd: qcom: Prevent NAND chip unevaluated properties
  dt-bindings: mtd: qcom: Fix a property position
  dt-bindings: mtd: Describe nand-ecc-mode
  dt-bindings: mtd: Mark nand-ecc-placement deprecated
  dt-bindings: mtd: Create a file for raw NAND chip properties
  dt-bindings: mtd: Accept nand related node names
  mtd: sm_ftl: Fix typos in comments
  mtd: otp: clean up on error in mtd_otp_nvmem_add()
  ...
2023-06-28 14:02:03 -07:00
Linus Torvalds
a0433f8cae for-6.5/block-2023-06-23
-----BEGIN PGP SIGNATURE-----
 
 iQJEBAABCAAuFiEEwPw5LcreJtl1+l5K99NY+ylx4KYFAmSV8dwQHGF4Ym9lQGtl
 cm5lbC5kawAKCRD301j7KXHgpilGD/9Yys1oxIXJpRf00fzrylAlBthRxMjFQVWw
 zAut106hAQiBHvU8IkmGA3MvEFVHxtzwYhHI7IR8K3aZBIqscweCqmVI9JyogJw9
 U9Twnzel47VmuKdM94FeoN+hbj1fP8EWTjzmy67/zEEfFCdmHvNlMi3lSrGYIpFy
 39LxTB99Y4UarM5PtWbes37GYYljzMSWKuo4AfBkvq1eQa+sZ0Vq2xAABKq3UM7f
 apqhgHtkJooRePDP0eQp+kAyyVMgW2jIK+oIdJDxNF3CKTu2w40RzaYz6fp+jVSU
 H4R/xS59GW4/xql+VBJDh/qJg9K62DPPYjlW8BmSR8+IjvfFpsyH3/MacE50CD3P
 20fs/Mnj49H79fDrQEHJI53cOOb2EmUitbwLbvOcColNTPpt8loBtdQxjF2RMU8R
 Nyort9DJPFclYCxky1LYg1CNEC2Ln4Zy/jD47wPvqRmOQphOoVlV/hPnOEqvjaZC
 49Vn70W2DeE9cXvYI7ha+XIg6/oj+Gs3iusEbV08Ci7EAtXgI+ZUUsQ97K8UNiUh
 h2lqSJtuI7lBpYP9sf+BeCch5UCC+xGYyTdoM5f58lehWBBPtbs0g7S9RyRyOYxe
 n+yxEUo3dAGzJ/xsKAjinbZfeWIpr0b1TkAh4w3Cq/BKzRr9Bp8lBAxYuancbQ+Y
 1ADPteUOTA==
 =zP4Y
 -----END PGP SIGNATURE-----

Merge tag 'for-6.5/block-2023-06-23' of git://git.kernel.dk/linux

Pull block updates from Jens Axboe:

 - NVMe pull request via Keith:
      - Various cleanups all around (Irvin, Chaitanya, Christophe)
      - Better struct packing (Christophe JAILLET)
      - Reduce controller error logs for optional commands (Keith)
      - Support for >=64KiB block sizes (Daniel Gomez)
      - Fabrics fixes and code organization (Max, Chaitanya, Daniel
        Wagner)

 - bcache updates via Coly:
      - Fix a race at init time (Mingzhe Zou)
      - Misc fixes and cleanups (Andrea, Thomas, Zheng, Ye)

 - use page pinning in the block layer for dio (David)

 - convert old block dio code to page pinning (David, Christoph)

 - cleanups for pktcdvd (Andy)

 - cleanups for rnbd (Guoqing)

 - use the unchecked __bio_add_page() for the initial single page
   additions (Johannes)

 - fix overflows in the Amiga partition handling code (Michael)

 - improve mq-deadline zoned device support (Bart)

 - keep passthrough requests out of the IO schedulers (Christoph, Ming)

 - improve support for flush requests, making them less special to deal
   with (Christoph)

 - add bdev holder ops and shutdown methods (Christoph)

 - fix the name_to_dev_t() situation and use cases (Christoph)

 - decouple the block open flags from fmode_t (Christoph)

 - ublk updates and cleanups, including adding user copy support (Ming)

 - BFQ sanity checking (Bart)

 - convert brd from radix to xarray (Pankaj)

 - constify various structures (Thomas, Ivan)

 - more fine grained persistent reservation ioctl capability checks
   (Jingbo)

 - misc fixes and cleanups (Arnd, Azeem, Demi, Ed, Hengqi, Hou, Jan,
   Jordy, Li, Min, Yu, Zhong, Waiman)

* tag 'for-6.5/block-2023-06-23' of git://git.kernel.dk/linux: (266 commits)
  scsi/sg: don't grab scsi host module reference
  ext4: Fix warning in blkdev_put()
  block: don't return -EINVAL for not found names in devt_from_devname
  cdrom: Fix spectre-v1 gadget
  block: Improve kernel-doc headers
  blk-mq: don't insert passthrough request into sw queue
  bsg: make bsg_class a static const structure
  ublk: make ublk_chr_class a static const structure
  aoe: make aoe_class a static const structure
  block/rnbd: make all 'class' structures const
  block: fix the exclusive open mask in disk_scan_partitions
  block: add overflow checks for Amiga partition support
  block: change all __u32 annotations to __be32 in affs_hardblocks.h
  block: fix signed int overflow in Amiga partition support
  block: add capacity validation in bdev_add_partition()
  block: fine-granular CAP_SYS_ADMIN for Persistent Reservation
  block: disallow Persistent Reservation on partitions
  reiserfs: fix blkdev_put() warning from release_journal_dev()
  block: fix wrong mode for blkdev_get_by_dev() from disk_scan_partitions()
  block: document the holder argument to blkdev_get_by_path
  ...
2023-06-26 12:47:20 -07:00
Miquel Raynal
cf431a5998 Merge branch 'nand/next' into mtd/next 2023-06-23 19:02:09 +02:00