summaryrefslogtreecommitdiffstats
path: root/drivers/ata
AgeCommit message (Collapse)AuthorFilesLines
2022-06-22powerpc/mpc5xxx: Switch mpc5xxx_get_bus_frequency() to use fwnodeAndy Shevchenko1-1/+1
Switch mpc5xxx_get_bus_frequency() to use fwnode in order to help cleaning up other parts of the kernel from OF specific code. No functional change intended. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Acked-by: Chris Packham <chris.packham@alliedtelesis.co.nz> # for i2c-mpc Acked-by: Wolfram Sang <wsa@kernel.org> # for the I2C part Acked-by: Mark Brown <broonie@kernel.org> Acked-by: Marc Kleine-Budde <mkl@pengutronix.de> # for mscan/mpc5xxx_can Acked-by: Damien Le Moal <damien.lemoal@opensource.wdc.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://lore.kernel.org/r/20220507100147.5802-2-andriy.shevchenko@linux.intel.com
2022-06-20ata: pata_macio: Fix compilation warningDamien Le Moal1-1/+1
Change the debug print format for the PIO, MWDMA and UDMA masks from long to int to match the new type used for these fields in struct ata_port_info. Fixes: f0a6d77b351c ("ata: make transfer mode masks *unsigned int*") Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
2022-06-20ata: libata-eh: fix sloppy result type of ata_internal_cmd_timeout()Sergey Shtylyov2-12/+12
ata_internal_cmd_timeout() returns *unsigned long* timeout in ms, however ata_exec_internal_sg() passes that timeout to msecs_to_jiffies() that takes just *unsigned int*. Change ata_internal_cmd_timeout()'s result type to *unsigned int* as well, also updating the *struct* ata_eh_cmd_timeout_ent and the command timeout tables -- all timeouts fit into *unsigned int* but we have to change ULONG_MAX to UINT_MAX... Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru> Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
2022-06-20ata: libata-core: fix sloppy parameter type in ata_exec_internal[_sg]()Sergey Shtylyov2-4/+4
Make the 'timeout' parameter to ata_exec_internal_sg() *unsigned int* as msecs_to_jiffies() that it calls takes just *unsigned int* for the time in milliseconds. Then follow the suit with ata_exec_internal(), its only caller; also fix up ata_dev_set_feature(), the only ata_exec_internal()'s caller that explicitly passes *unsigned long* variable for timeout... Found by Linux Verification Center (linuxtesting.org) with the SVACE static analysis tool. Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru> Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
2022-06-20ata: libata-eh: fix sloppy result type of ata_eh_nr_in_flight()Sergey Shtylyov1-4/+4
ata_eh_nr_in_flight() counts the # of the active tagged commands and thus cannot return a negative value but the result type is nevertheless int. Switching it to unsigned int (along with the local variables receiving the function's result) helps avoiding the sign extension instructions when comparing with or assigning to unsigned long ata_port::fastdrain_cnt and thus results in a more compact 64-bit code. Found by Linux Verification Center (linuxtesting.org) with the SVACE static analysis tool. [Damien] Fixed commit message. Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru> Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
2022-06-17ata: libata-core: make ata_exec_internal_sg() *static*Sergey Shtylyov2-8/+4
ata_exec_internal_sg() is only called by ata_exec_internal() further in the same file, so we can make it *static* and remove its prototype from drivers/ata/libata.h... Suggested-by: Damien Le Moal <damien.lemoal@opensource.wdc.com> Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru> Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
2022-06-17ata: make transfer mode masks *unsigned int*Sergey Shtylyov12-43/+43
The packed transfer mode masks and also the {pio|mwdma|udma}_mask fields of *struct*s ata_device and ata_port_info are declared as *unsigned long* (which is a 64-bit type on 64-bit architectures) but actually the packed masks occupy only 20 bits (7 PIO modes, 5 MWDMA modes, and 8 UDMA modes) and the PIO/MWDMA/UDMA masks easily fit into just 8 bits each, so we can safely use (always 32-bit) *unsigned int* variables instead. This saves 745 bytes of object code in libata-core.o alone, not to mention LLDDs... Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru> Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
2022-06-14ata: libata-core: get rid of *else* branches in ata_id_n_sectors()Sergey Shtylyov1-11/+9
Using *else* after *return* doesn't make much sense -- getting rid of such *else* branches reduces the indentation levels and thus reduces # of LoC... Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru> Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
2022-06-13ata: libata-core: fix sloppy typing in ata_id_n_sectors()Sergey Shtylyov1-4/+6
The code multiplying the # of cylinders/heads/sectors in ata_id_n_sectors() to get a disk capacity implicitly uses the *int* type for that calculation and casting the result to 'u64' before returning ensues a sign extension. Explicitly casting the 'u16' typed multipliers to 'u32' results in avoiding a sign extension instruction and so in a more compact code... Found by Linux Verification Center (linuxtesting.org) with the SVACE static analysis tool. Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru> Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
2022-06-13ata: pata_hpt3x2n: pass base DPLL frequency to hpt3x2n_pci_clock()Sergey Shtylyov1-8/+11
Currently, the base DPLL frequency is hardcoded in hpt3x2n_pci_clock(). Align with the updated 'pata_hpt37x' driver, where this frequency is a parameter to hpt37x_pci_clock(). While at it, also do the following to align with the 'pata_hpt37x' driver: - fix the 'freq' local variable's type; - remove the 'iobase' local variable; - extend the comment to the inl() call; - move the 'total' local variable's declaration. Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru> Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
2022-06-13ata: pata_hpt37x: merge hpt374_read_freq() to hpt37x_pci_clock()Sergey Shtylyov1-24/+10
With hpt374_read_freq() implemented as a separate function, there's some code duplication going on, not to mention that this function is named incorrectly: it returns the f_CNT register value saved by BIOS, not the PCI clock frequency. Folding hpt374_read_freq() into hpt37x_pci_clock() saves 20 bytes of object code with x86_64 gcc 10.3.1... Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru> Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
2022-06-13ata: pata_hpt37x: factor out hpt37x_pci_clock()Sergey Shtylyov1-43/+51
Factor out the PCI clock frequency detection code into hpt37x_pci_clock(), so that this driver becomes more like 'pata_hpt3x2n'. Note that I decided to change the way HPT374 is identified to using the PCI device ID... Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru> Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
2022-06-13ata: pata_hpt37x: move claculating PCI clock from hpt37x_clock_slot()Sergey Shtylyov1-17/+28
hpt37x_init_one() incorrectly calls an averaged f_CNT register value 'freq' and hpt37x_clock_slot() takes that value as the 'freq' parameter -- rename the former variable to 'fcnt' and move the actual code calculating the PCI clock from hpt37x_clock_slot() to hpt37x_init_one(), along with adding the frequency clamping code, in preparation for the factoring out the PCI clock detection, so that this driver would become more like the 'pata_hpt3x2n' driver... Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru> Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
2022-06-13ata: libata: Fix syntax errors in commentsXiang wangx1-1/+1
Delete the redundant word 'in'. Signed-off-by: Xiang wangx <wangxiang@cdjrlc.com> Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
2022-06-09ata: libata-transport: fix {dma|pio|xfer}_mode sysfs filesSergey Shtylyov1-1/+1
The {dma|pio}_mode sysfs files are incorrectly documented as having a list of the supported DMA/PIO transfer modes, while the corresponding fields of the *struct* ata_device hold the transfer mode IDs, not masks. To match these docs, the {dma|pio}_mode (and even xfer_mode!) sysfs files are handled by the ata_bitfield_name_match() macro which leads to reading such kind of nonsense from them: $ cat /sys/class/ata_device/dev3.0/pio_mode XFER_UDMA_7, XFER_UDMA_6, XFER_UDMA_5, XFER_UDMA_4, XFER_MW_DMA_4, XFER_PIO_6, XFER_PIO_5, XFER_PIO_4, XFER_PIO_3, XFER_PIO_2, XFER_PIO_1, XFER_PIO_0 Using the correct ata_bitfield_name_search() macro fixes that: $ cat /sys/class/ata_device/dev3.0/pio_mode XFER_PIO_4 While fixing the file documentation, somewhat reword the {dma|pio}_mode file doc and add a note about being mostly useful for PATA devices to the xfer_mode file doc... Fixes: d9027470b886 ("[libata] Add ATA transport class") Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru> Cc: stable@vger.kernel.org Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
2022-06-08libata: fix translation of concurrent positioning rangesTyler Erickson1-1/+1
Fixing the page length in the SCSI translation for the concurrent positioning ranges VPD page. It was writing starting in offset 3 rather than offset 2 where the MSB is supposed to start for the VPD page length. Cc: stable@vger.kernel.org Fixes: fe22e1c2f705 ("libata: support concurrent positioning ranges log") Signed-off-by: Tyler Erickson <tyler.erickson@seagate.com> Reviewed-by: Muhammad Ahmad <muhammad.ahmad@seagate.com> Tested-by: Michael English <michael.english@seagate.com> Reviewed-by: Hannes Reinecke <hare@suse.de> Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
2022-06-08libata: fix reading concurrent positioning ranges logTyler Erickson1-8/+13
The concurrent positioning ranges log is not a fixed size and may depend on how many ranges are supported by the device. This patch uses the size reported in the GPL directory to determine the number of pages supported by the device before attempting to read this log page. This resolves this error from the dmesg output: ata6.00: Read log 0x47 page 0x00 failed, Emask 0x1 Cc: stable@vger.kernel.org Fixes: fe22e1c2f705 ("libata: support concurrent positioning ranges log") Signed-off-by: Tyler Erickson <tyler.erickson@seagate.com> Reviewed-by: Muhammad Ahmad <muhammad.ahmad@seagate.com> Tested-by: Michael English <michael.english@seagate.com> Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
2022-06-06ata: pata_octeon_cf: Fix refcount leak in octeon_cf_probeMiaoqian Lin1-0/+3
of_find_device_by_node() takes reference, we should use put_device() to release it when not need anymore. Add missing put_device() to avoid refcount leak. Fixes: 43f01da0f279 ("MIPS/OCTEON/ata: Convert pata_octeon_cf.c to use device tree.") Signed-off-by: Miaoqian Lin <linmq006@gmail.com> Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru> Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
2022-06-06ata: libata-core: fix NULL pointer deref in ata_host_alloc_pinfo()Sergey Shtylyov1-2/+2
In an unlikely (and probably wrong?) case that the 'ppi' parameter of ata_host_alloc_pinfo() points to an array starting with a NULL pointer, there's going to be a kernel oops as the 'pi' local variable won't get reassigned from the initial value of NULL. Initialize 'pi' instead to '&ata_dummy_port_info' to fix the possible kernel oops for good... Found by Linux Verification Center (linuxtesting.org) with the SVACE static analysis tool. Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru> Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
2022-06-02Merge tag 'arm-multiplatform-5.19-2' of ↵Linus Torvalds1-2/+1
git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc Pull more ARM multiplatform updates from Arnd Bergmann: "The second part of the multiplatform changes now converts the Intel/Marvell PXA platform along with the rest. The patches went through several rebases before the merge window as bugs were found, so they remained separate. This has to touch a lot of drivers, in particular the touchscreen, pcmcia, sound and clk bits, to detach the driver files from the platform and board specific header files" * tag 'arm-multiplatform-5.19-2' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc: (48 commits) ARM: pxa/mmp: remove traces of plat-pxa ARM: pxa: convert to multiplatform ARM: pxa/sa1100: move I/O space to PCI_IOBASE ARM: pxa: remove support for MTD_XIP ARM: pxa: move mach/*.h to mach-pxa/ ARM: PXA: fix multi-cpu build of xsc3 ARM: pxa: move plat-pxa to drivers/soc/ ARM: mmp: rename pxa_register_device ARM: mmp: remove tavorevb board support ARM: pxa: remove unused mach/bitfield.h ARM: pxa: move clk register definitions to driver ARM: pxa: move smemc register access from clk to platform cpufreq: pxa3: move clk register access to clk driver ARM: pxa: remove get_clk_frequency_khz() ARM: pxa: pcmcia: move smemc configuration back to arch ASoC: pxa: i2s: use normal MMIO accessors ASoC: pxa: ac97: use normal MMIO accessors ASoC: pxa: use pdev resource for FIFO regs Input: wm97xx - get rid of irq_enable method in wm97xx_mach_ops Input: wm97xx - switch to using threaded IRQ ...
2022-05-23Merge tag 'ata-5.19-rc1' of ↵Linus Torvalds11-248/+228
git://git.kernel.org/pub/scm/linux/kernel/git/dlemoal/libata Pull ata updates from Damien Le Moal: "For this cycle, the libata.force kernel parameter changes stand out. Beside that, some small cleanups in various drivers. In more detail: - Changes to the pata_mpc52xx driver in preparation for powerpc's asm/prom.h cleanup, from Christophe. - Improved ATA command allocation, from John. - Various small cleanups to the pata_via, pata_sil680, pata_ftide010, sata_gemini, ahci_brcm drivers and to libata-core, from Sergey, Diego, Ruyi, Mighao and Jiabing. - Add support for the RZ/G2H SoC to the rcar-sata driver, from Lad. - AHCI RAID ID cleanup, from Dan. - Improvement to the libata.force kernel parameter to allow most horkage flags to be manually forced for debugging drive issues in the field without needing recompiling a kernel, from me" * tag 'ata-5.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/dlemoal/libata: ata: pata_ftide010: Remove unneeded ERROR check before clk_disable_unprepare doc: admin-guide: Update libata kernel parameters ata: libata-core: Allow forcing most horkage flags ata: libata-core: Improve link flags forced settings ata: libata-core: Refactor force_tbl definition ata: libata-core: cleanup ata_device_blacklist ata: simplify the return expression of brcm_ahci_remove ata: Make use of the helper function devm_platform_ioremap_resource() ata: libata-core: replace "its" with "it is" ahci: Add a generic 'controller2' RAID id dt-bindings: ata: renesas,rcar-sata: Add r8a774e1 support ata: pata_via: fix sloppy typing in via_do_set_mode() ata: pata_sil680: fix result type of sil680_sel{dev|reg}() ata: libata-core: fix parameter type in ata_xfer_mode2shift() libata: Improve ATA queued command allocation ata: pata_mpc52xx: Prepare cleanup of powerpc's asm/prom.h
2022-05-16ata: pata_ftide010: Remove unneeded ERROR check before clk_disable_unprepareWan Jiabing1-4/+3
ERROR check is already in clk_disable() and clk_unprepare() by using IS_ERR_OR_NULL. Remove unneeded ERROR check for ftide->pclk here. Signed-off-by: Wan Jiabing <wanjiabing@vivo.com> Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
2022-05-09ata: libata-core: Allow forcing most horkage flagsDamien Le Moal1-2/+20
To facilitate debugging of drive issues in the field without kernel changes (e.g. temporary test patches), add an entry for most horkage flags in the force_tbl array to allow controlling these horkage settings with the libata.force kernel boot parameter. Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com> Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru> Reviewed-by: Hannes Reinecke <hare@suse.de>
2022-05-09ata: libata-core: Improve link flags forced settingsDamien Le Moal1-10/+22
Similarly to the horkage flags, introduce the force_lflag_onoff() macro to define struct ata_force_param entries of the force_tbl array that allow turning on or off a link flag using the libata.force boot parameter. To be consistent with naming, the macro force_lflag() is renamed to force_lflag_on(). Using force_lflag_onoff(), define a new force_tbl entry for the ATA_LFLAG_NO_DEBOUNCE_DELAY link flag, thus allowing testing if an adapter requires a link debounce delay or not. Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com> Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru> Reviewed-by: Hannes Reinecke <hare@suse.de>
2022-05-09ata: libata-core: Refactor force_tbl definitionDamien Le Moal1-58/+81
Introduce the macro definitions force_cbl(), force_spd_limit(), force_xfer(), force_lflag(), force_horkage_on() and force_horkage_onoff() to define with a more compact syntax the struct ata_force_param entries in the force_tbl array defined in the function ata_parse_force_one(). To reduce the indentation of the array declaration, force_tbl definition is also moved out of the ata_parse_force_one() function. The entries are also reordered to group them by type of the quirck that is applied. Finally, fix a comment in ata_parse_force_param() incorrectly referencing force_tbl instead of ata_force_tbl. Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com> Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru> Reviewed-by: Hannes Reinecke <hare@suse.de>
2022-05-09ata: libata-core: cleanup ata_device_blacklistDamien Le Moal1-49/+49
Remove the unneeded comma after the last field of the array entries. Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com> Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru> Reviewed-by: Hannes Reinecke <hare@suse.de>
2022-05-09ata: simplify the return expression of brcm_ahci_removeMinghao Chi1-6/+1
Simplify the return expression. Reported-by: Zeal Robot <zealci@zte.com.cn> Signed-off-by: Minghao Chi <chi.minghao@zte.com.cn> Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
2022-04-22ata: pata_marvell: Check the 'bmdma_addr' beforing readingZheyu Ma1-0/+2
Before detecting the cable type on the dma bar, the driver should check whether the 'bmdma_addr' is zero, which means the adapter does not support DMA, otherwise we will get the following error: [ 5.146634] Bad IO access at port 0x1 (return inb(port)) [ 5.147206] WARNING: CPU: 2 PID: 303 at lib/iomap.c:44 ioread8+0x4a/0x60 [ 5.150856] RIP: 0010:ioread8+0x4a/0x60 [ 5.160238] Call Trace: [ 5.160470] <TASK> [ 5.160674] marvell_cable_detect+0x6e/0xc0 [pata_marvell] [ 5.161728] ata_eh_recover+0x3520/0x6cc0 [ 5.168075] ata_do_eh+0x49/0x3c0 Signed-off-by: Zheyu Ma <zheyuma97@gmail.com> Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
2022-04-22ata: Make use of the helper function devm_platform_ioremap_resource()Lv Ruyi1-6/+1
Use the devm_platform_ioremap_resource() helper instead of calling platform_get_resource() and devm_ioremap_resource() separately.Make the code simpler without functional changes. Reported-by: Zeal Robot <zealci@zte.com.cn> Signed-off-by: Lv Ruyi <lv.ruyi@zte.com.cn> Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
2022-04-22ata: libata-core: replace "its" with "it is"Diego Viola1-2/+2
and "isn't" with "is not". The former fixes the typo while the latter just uses the same formal language. Signed-off-by: Diego Viola <diego.viola@gmail.com> Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
2022-04-22ahci: Add a generic 'controller2' RAID idDan Williams1-2/+3
Intel server platforms that support 'RAID', i.e. have platform firmware support for software-RAID metadata + features that the kernel also understands, maintain the same device-ids for RAID from generation to generation. This is in contrast to client platforms that have tended to roll new device-ids every platform generation. However, even though server platform keep the ids there are still unique device-ids per controller instance. To date there have only been 2 controllers on these platforms, but platforms code named Emmitsburg add a third controller. Add the device-id for this third controller and collect it with the other generic server RAID ids. As mentioned here [1], the pain of continuing add new and different device-ids for RAID mode to this file [2] has been heard. Ideally this device-id would not matter and the class code would remain PCI_CLASS_STORAGE_SATA_AHCI regardless of the RAID mode, but other operating systems depend on the class code *not* being AHCI when the device is in RAID mode. That said, going forward there is little reason for new server RAID ids to be added as they can simply reuse one of the existing ids even for a new controller. Server software RAID features continue to be supported on Linux. Client software RAID features continue to be not supported and the recommendation there remains to set the device to AHCI mode in platform firmware. Link: https://lore.kernel.org/all/8e61fb0104422e8d70701e2ddc7b1ca53f009797.camel@intel.com [1] Link: https://lore.kernel.org/all/20201119165022.GA3582@infradead.org/ [2] Cc: Damien Le Moal <damien.lemoal@opensource.wdc.com> Cc: Christoph Hellwig <hch@lst.de> Cc: Mika Westerberg <mika.westerberg@linux.intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
2022-04-20ARM: pxa: use pdev resource for palmld mmioArnd Bergmann1-2/+1
The palmld header is almost unused in drivers, the only remaining thing now is the PATA device address, which should really be passed as a resource. Cc: linux-ide@vger.kernel.org Acked-by: Robert Jarzmik <robert.jarzmik@free.fr> Acked-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> Acked-by: Damien Le Moal <damien.lemoal@opensource.wdc.com> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
2022-04-13ata: pata_via: fix sloppy typing in via_do_set_mode()Sergey Shtylyov1-3/+3
The local variables 'T' and 'UT' are needlessly declared as *unsigned* *long* -- the corresponding parameters of ata_timing_compute() are both declared as *int*. While fixing up those declarations, also make the 'via_clock' and 'T' variables *const* as they are never re-assigned after initialization -- the object code should remain the same as gcc previously used copy propagation anyway... Found by Linux Verification Center (linuxtesting.org) with the SVACE static analysis tool. Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru> Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
2022-04-13ata: pata_sil680: fix result type of sil680_sel{dev|reg}()Sergey Shtylyov1-17/+13
sil680_sel{dev|reg}() return a PCI config space address but needlessly use the *unsigned long* type for that, whereas the PCI config space accessors take *int* for the address parameter. Switch these functions to returning *int*, updating the local variables at their call sites. Get rid of the 'base' local variables in these functions, while at it... Found by Linux Verification Center (linuxtesting.org) with the SVACE static analysis tool. Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru> Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
2022-04-12ata: libata-core: fix parameter type in ata_xfer_mode2shift()Sergey Shtylyov1-1/+1
The data transfer mode that corresponds to the 'xfer_mode' parameter for ata_xfer_mode2shift() is a 8-bit *unsigned* value. Using *unsigned long* to declare the parameter leads to a problematic implicit *int* to *unsigned long* cast and was most probably a result of a copy/paste mistake -- use the 'u8' type instead, as in ata_xfer_mode2mask()... Found by Linux Verification Center (linuxtesting.org) with the SVACE static analysis tool. Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru> Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
2022-04-11libata: Improve ATA queued command allocationJohn Garry4-96/+36
Improve ATA queued command allocation as follows: - For attaining a qc tag for a SAS host we need to allocate a bit in ata_port.sas_tag_allocated bitmap. However we already have a unique tag per device in range [0, ATA_MAX_QUEUE -1] in the scsi cmnd budget token, so just use that instead. - It is a bit pointless to have ata_qc_new_init() in libata-core.c since it pokes scsi internals, so inline it in ata_scsi_qc_new() (in libata-scsi.c). Also update Doc accordingly. - Use standard SCSI helpers set_host_byte() and set_status_byte() in ata_scsi_qc_new(). Christoph Hellwig originally contributed the change to inline ata_qc_new_init(). Signed-off-by: John Garry <john.garry@huawei.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
2022-04-11ata: pata_mpc52xx: Prepare cleanup of powerpc's asm/prom.hChristophe Leroy1-1/+2
powerpc's asm/prom.h brings some headers that it doesn't need itself. In order to clean it up, first add missing headers in users of asm/prom.h Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu> Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru> Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
2022-04-06ata: ahci: Rename CONFIG_SATA_LPM_POLICY configuration item backMario Limonciello3-4/+6
CONFIG_SATA_LPM_MOBILE_POLICY was renamed to CONFIG_SATA_LPM_POLICY in commit 4dd4d3deb502 ("ata: ahci: Rename CONFIG_SATA_LPM_MOBILE_POLICY configuration item"). This can potentially cause problems as users would invisibly lose configuration policy defaults when they built the new kernel. To avoid such problems, switch back to the old name (even if it's wrong). Suggested-by: Christoph Hellwig <hch@infradead.org> Suggested-by: Damien Le Moal <damien.lemoal@opensource.wdc.com> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com> Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
2022-04-04ata: libata-core: Disable READ LOG DMA EXT for Samsung 840 EVOsChristian Lamparter1-0/+3
Samsung' 840 EVO with the latest firmware (EXT0DB6Q) locks up with the a message: "READ LOG DMA EXT failed, trying PIO" during boot. Initially this was discovered because it caused a crash with the sata_dwc_460ex controller on a WD MyBook Live DUO. The reporter "Tice Rex" which has the unique opportunity that he has two Samsung 840 EVO SSD! One with the older firmware "EXT0BB0Q" which booted fine and didn't expose "READ LOG DMA EXT". But the newer/latest firmware "EXT0DB6Q" caused the headaches. BugLink: https://github.com/openwrt/openwrt/issues/9505 Signed-off-by: Christian Lamparter <chunkeey@gmail.com> Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
2022-04-04ata: sata_dwc_460ex: Fix crash due to OOB writeChristian Lamparter1-1/+5
the driver uses libata's "tag" values from in various arrays. Since the mentioned patch bumped the ATA_TAG_INTERNAL to 32, the value of the SATA_DWC_QCMD_MAX needs to account for that. Otherwise ATA_TAG_INTERNAL usage cause similar crashes like this as reported by Tice Rex on the OpenWrt Forum and reproduced (with symbols) here: | BUG: Kernel NULL pointer dereference at 0x00000000 | Faulting instruction address: 0xc03ed4b8 | Oops: Kernel access of bad area, sig: 11 [#1] | BE PAGE_SIZE=4K PowerPC 44x Platform | CPU: 0 PID: 362 Comm: scsi_eh_1 Not tainted 5.4.163 #0 | NIP: c03ed4b8 LR: c03d27e8 CTR: c03ed36c | REGS: cfa59950 TRAP: 0300 Not tainted (5.4.163) | MSR: 00021000 <CE,ME> CR: 42000222 XER: 00000000 | DEAR: 00000000 ESR: 00000000 | GPR00: c03d27e8 cfa59a08 cfa55fe0 00000000 0fa46bc0 [...] | [..] | NIP [c03ed4b8] sata_dwc_qc_issue+0x14c/0x254 | LR [c03d27e8] ata_qc_issue+0x1c8/0x2dc | Call Trace: | [cfa59a08] [c003f4e0] __cancel_work_timer+0x124/0x194 (unreliable) | [cfa59a78] [c03d27e8] ata_qc_issue+0x1c8/0x2dc | [cfa59a98] [c03d2b3c] ata_exec_internal_sg+0x240/0x524 | [cfa59b08] [c03d2e98] ata_exec_internal+0x78/0xe0 | [cfa59b58] [c03d30fc] ata_read_log_page.part.38+0x1dc/0x204 | [cfa59bc8] [c03d324c] ata_identify_page_supported+0x68/0x130 | [...] This is because sata_dwc_dma_xfer_complete() NULLs the dma_pending's next neighbour "chan" (a *dma_chan struct) in this '32' case right here (line ~735): > hsdevp->dma_pending[tag] = SATA_DWC_DMA_PENDING_NONE; Then the next time, a dma gets issued; dma_dwc_xfer_setup() passes the NULL'd hsdevp->chan to the dmaengine_slave_config() which then causes the crash. With this patch, SATA_DWC_QCMD_MAX is now set to ATA_MAX_QUEUE + 1. This avoids the OOB. But please note, there was a worthwhile discussion on what ATA_TAG_INTERNAL and ATA_MAX_QUEUE is. And why there should not be a "fake" 33 command-long queue size. Ideally, the dw driver should account for the ATA_TAG_INTERNAL. In Damien Le Moal's words: "... having looked at the driver, it is a bigger change than just faking a 33rd "tag" that is in fact not a command tag at all." Fixes: 28361c403683c ("libata: add extra internal command") Cc: stable@kernel.org # 4.18+ BugLink: https://github.com/openwrt/openwrt/issues/9505 Signed-off-by: Christian Lamparter <chunkeey@gmail.com> Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
2022-04-04ata: libata-sff: Fix compilation warning in ata_sff_lost_interrupt()Damien Le Moal1-1/+1
When returning false, ata_sff_altstatus() does not return any status value, resulting in a compilation warning in ata_sff_lost_interrupt() ("uninitialized symbol 'status'"). Fix this by initializing the local variable "status" to 0. Fixes: 03c0e84f9c1e ("ata: libata-sff: refactor ata_sff_altstatus()") Cc: stable@vger.kernel.org Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
2022-03-28Merge tag 'char-misc-5.18-rc1' of ↵Linus Torvalds3-4/+2
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc Pull char/misc and other driver updates from Greg KH: "Here is the big set of char/misc and other small driver subsystem updates for 5.18-rc1. Included in here are merges from driver subsystems which contain: - iio driver updates and new drivers - fsi driver updates - fpga driver updates - habanalabs driver updates and support for new hardware - soundwire driver updates and new drivers - phy driver updates and new drivers - coresight driver updates - icc driver updates Individual changes include: - mei driver updates - interconnect driver updates - new PECI driver subsystem added - vmci driver updates - lots of tiny misc/char driver updates All of these have been in linux-next for a while with no reported problems" * tag 'char-misc-5.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc: (556 commits) firmware: google: Properly state IOMEM dependency kgdbts: fix return value of __setup handler firmware: sysfb: fix platform-device leak in error path firmware: stratix10-svc: add missing callback parameter on RSU arm64: dts: qcom: add non-secure domain property to fastrpc nodes misc: fastrpc: Add dma handle implementation misc: fastrpc: Add fdlist implementation misc: fastrpc: Add helper function to get list and page misc: fastrpc: Add support to secure memory map dt-bindings: misc: add fastrpc domain vmid property misc: fastrpc: check before loading process to the DSP misc: fastrpc: add secure domain support dt-bindings: misc: add property to support non-secure DSP misc: fastrpc: Add support to get DSP capabilities misc: fastrpc: add support for FASTRPC_IOCTL_MEM_MAP/UNMAP misc: fastrpc: separate fastrpc device from channel context dt-bindings: nvmem: brcm,nvram: add basic NVMEM cells dt-bindings: nvmem: make "reg" property optional nvmem: brcm_nvram: parse NVRAM content into NVMEM cells nvmem: dt-bindings: Fix the error of dt-bindings check ...
2022-03-24Merge tag 'scsi-misc' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsiLinus Torvalds1-1/+3
Pull SCSI updates from James Bottomley: "This series consists of the usual driver updates (qla2xxx, pm8001, libsas, smartpqi, scsi_debug, lpfc, iscsi, mpi3mr) plus minor updates and bug fixes. The high blast radius core update is the removal of write same, which affects block and several non-SCSI devices. The other big change, which is more local, is the removal of the SCSI pointer" * tag 'scsi-misc' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi: (281 commits) scsi: scsi_ioctl: Drop needless assignment in sg_io() scsi: bsg: Drop needless assignment in scsi_bsg_sg_io_fn() scsi: lpfc: Copyright updates for 14.2.0.0 patches scsi: lpfc: Update lpfc version to 14.2.0.0 scsi: lpfc: SLI path split: Refactor BSG paths scsi: lpfc: SLI path split: Refactor Abort paths scsi: lpfc: SLI path split: Refactor SCSI paths scsi: lpfc: SLI path split: Refactor CT paths scsi: lpfc: SLI path split: Refactor misc ELS paths scsi: lpfc: SLI path split: Refactor VMID paths scsi: lpfc: SLI path split: Refactor FDISC paths scsi: lpfc: SLI path split: Refactor LS_RJT paths scsi: lpfc: SLI path split: Refactor LS_ACC paths scsi: lpfc: SLI path split: Refactor the RSCN/SCR/RDF/EDC/FARPR paths scsi: lpfc: SLI path split: Refactor PLOGI/PRLI/ADISC/LOGO paths scsi: lpfc: SLI path split: Refactor base ELS paths and the FLOGI path scsi: lpfc: SLI path split: Introduce lpfc_prep_wqe scsi: lpfc: SLI path split: Refactor fast and slow paths to native SLI4 scsi: lpfc: SLI path split: Refactor lpfc_iocbq scsi: lpfc: Use kcalloc() ...
2022-03-23Merge tag 'ata-5.18-rc1' of ↵Linus Torvalds56-531/+447
git://git.kernel.org/pub/scm/linux/kernel/git/dlemoal/libata Pull ata updates from Damien Le Moal: "For this cycle, no big change but many small fixes and code cleanup to libata, the ahci driver and various pata drivers. In more details: - Code simplification in pata_platform using platform_get_mem_or_io(), from Lad. - Fix read-only arrays declarations as const in pata_atiixp and pata_pdc202xx_old, from Colin. - Various cleanups and code simplification in libata-scsi, from me. - Remove dead code in libata-acpi, from Sergey. - Skip device scan deboune delay for Marvell 88SE9235 adapters (ahci) to speedup boot, from Paul. - Simplify functions declaration and use for functions always returning 0 in libata-core, from Sergey. - Non-fatal error fixes and in the pata_hpt366 and pata_hpt3x2n drivers, from Sergey. - Various code cleanup in the pata_artop, pata_hpt37x, pata_hpt366, pata_hpt3x2n, pata_samsung_cf and sata_rcar drivers, from Sergey. - Some libata-sff and libata-scsi code cleanup (e.g. change functions to return "bool"), from Sergey. - Renae ahci_board_mobile to board_ahci_low_power to be more descriptive of the feature as that is also used on PC and server AHCI adapters, from Mario. - Cleanup of OF match tables, from Geert. - Simplify the pata_pxa driver initialization using platform_get_irq(), from Minghao" * tag 'ata-5.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/dlemoal/libata: (38 commits) ata: pata_pxa: Use platform_get_irq() to get the interrupt ata: Drop commas after OF match table sentinels ata: ahci: Rename CONFIG_SATA_LPM_MOBILE_POLICY configuration item ata: ahci: Rename `AHCI_HFLAG_IS_MOBILE` ata: ahci: Rename board_ahci_mobile ata: pata_hpt37x: merge transfer mode setting methods ata: libata-sff: use *switch* statement in ata_sff_dev_classify() ata: add/use ata_taskfile::{error|status} fields ata: Kconfig: fix sata gemini compile test condition ata: libata-scsi: use *switch* statements to check SCSI command codes ata: libata-sff: refactor ata_sff_altstatus() ata: libata-sff: refactor ata_sff_set_devctl() ata: libata-sff: make ata_resources_present() return 'bool' ata: pata_hpt3x2n: disable fast interrupts in prereset() method ata: pata_hpt37x: disable fast interrupts in prereset() method ata: pata_hpt366: disable fast interrupts in prereset() method ata: pata_mpc52xx: use GFP_KERNEL ata: sata_rcar: drop unused #define's ata: pata_hpt366: check channel enable bits ata: sata_rcar: make sata_rcar_ata_devchk() return 'bool' ...
2022-03-10Merge tag 'phy-for-5.18' of ↵Greg Kroah-Hartman3-4/+2
git://git.kernel.org/pub/scm/linux/kernel/git/phy/linux-phy into char-misc-next Vinod writes: phy-for-5.18 - New support: - Mediatek tphy support for MT8186 - Qualcomm usb phy support for sc8180x and sc8280xp - Qualcomm ufs phy support for sc8180x and sc8280xp - Qualcomm usb phy support for MSM8953 - Cadence D-Phy Rx support - Sun4i support for USB phy - Rockchip naneng combo phy support for RK3568 - Qualcomm eDP PHY for sc7280 - Updates: - wake on support for Synopsis XHCI controllers - Yamilify Qualcomm USB HS phy binding - Charger detection support for TI tusb1210 * tag 'phy-for-5.18' of git://git.kernel.org/pub/scm/linux/kernel/git/phy/linux-phy: (53 commits) phy: qcom-qmp: add sc8280xp UFS PHY dt-bindings: phy: qcom,qmp: add sc8180x and sc8280xp ufs compatibles phy: qcom-snps: Add sc8280xp support dt-bindings: phy: qcom,usb-snps-femto-v2: Add sc8180x and sc8280xp dt-bindings: Revert "dt-bindings: soc: grf: add naneng combo phy register compatible" phy: dt-bindings: Add Cadence D-PHY Rx bindings phy: dt-bindings: cdns,dphy: add power-domains property phy: dt-bindings: Convert Cadence DPHY binding to YAML phy: cadence: Add Cadence D-PHY Rx driver dt-bindings: phy: renesas,usb2-phy: Document RZ/V2L phy bindings Revert "PCI: aardvark: Fix initialization with old Marvell's Arm Trusted Firmware" Revert "usb: host: xhci: mvebu: make USB 3.0 PHY optional for Armada 3720" Revert "ata: ahci: mvebu: Make SATA PHY optional for Armada 3720" phy: marvell: phy-mvebu-a3700-comphy: Add native kernel implementation phy: marvell: phy-mvebu-a3700-comphy: Remove port from driver configuration phy: phy-brcm-usb: fixup BCM4908 support dt-bindings: phy: mediatek,tphy: Add compatible for MT8192 phy: ti: tusb1210: Add charger detection phy: ti: tusb1210: Add a delay between power-on and restoring the phy-parameters phy: ti: tusb1210: Drop tusb->vendor_specific2 != 0 check from tusb1210_power_on() ...
2022-03-10ata: pata_pxa: Use platform_get_irq() to get the interruptMinghao Chi1-5/+5
platform_get_resource(pdev, IORESOURCE_IRQ, ..) relies on static allocation of IRQ resources in DT core code, this causes an issue when using hierarchical interrupt domains using "interrupts" property in the node as this bypasses the hierarchical setup and messes up the irq chaining. In preparation for removal of static setup of IRQ resource from DT core code use platform_get_irq(). Reported-by: Zeal Robot <zealci@zte.com.cn> Signed-off-by: Minghao Chi <chi.minghao@zte.com.cn> Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru> Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
2022-03-07ata: Drop commas after OF match table sentinelsGeert Uytterhoeven24-51/+33
It does not make sense to have a comma after a sentinel, as any new elements must be added before the sentinel. Add comments to clarify the purpose of the empty elements. Rewrap entries to a single line to have a consistent style. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru> Acked-by: Florian Fainelli <f.fainelli@gmail.com> [ahci_brcm] Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
2022-03-01scsi: core: Remove the cmd field from struct scsi_requestChristoph Hellwig1-1/+3
Now that each scsi_request is backed by a scsi_cmnd, there is no need to indirect the CDB storage. Change all submitters of SCSI passthrough requests to store the CDB information directly in the scsi_cmnd, and while doing so allocate the full 32 bytes that cover all Linux supported SCSI hosts instead of requiring dynamic allocation for > 16 byte CDBs. On 64-bit systems this does not change the size of the scsi_cmnd at all, while on 32-bit systems it slightly increases it for now, but that increase will be made up by the removal of the remaining scsi_request fields. Link: https://lore.kernel.org/r/20220224175552.988286-4-hch@lst.de Reviewed-by: Bart Van Assche <bvanassche@acm.org> Reviewed-by: John Garry <john.garry@huawei.com> Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2022-03-01ata: ahci: Rename CONFIG_SATA_LPM_MOBILE_POLICY configuration itemMario Limonciello3-5/+5
`CONFIG_SATA_LPM_MOBILE_POLICY` reflects a configuration to apply only to mobile chipsets. As some desktop boards may want to use this policy by default as well, rename the configuration item to `SATA_LPM_POLICY`. Reviewed-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Paul Menzel <pmenzel@molgen.mpg.de> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com> Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
2022-03-01ata: ahci: Rename `AHCI_HFLAG_IS_MOBILE`Mario Limonciello2-4/+4
`AHCI_HFLAG_IS_MOBILE` designates that a chipset should be using the default link power management policy from a kernel configuration item. As desktop chipsets may also be interested in this default policy configuration, rename the flag to `AHCI_HFLAG_USE_LPM_POLICY` to more accurately reflect that a chipset doesn't have to be mobile to adopt it. Reviewed-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Paul Menzel <pmenzel@molgen.mpg.de> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com> Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>