From 5df1ee459452e29d39cf717cd0719146427709d9 Mon Sep 17 00:00:00 2001 From: Tony Dinh Date: Sun, 5 Sep 2021 14:48:25 -0700 Subject: arm: mvebu : sata_mv should probe all ports While a board could have multiple SATA ports, some of the ports might not have a disk attached to them. So while probing for disks, sata_mv_probe() should continue probing all ports, and skip one with no disk attached. Tests with: - Seagate Goflex Net (Marvell Kirkwood 88F6281) out-of-tree u-boot. - Zyxel NSA325 (Marvell Kirkwood 88F6282 out-of-tree u-boot. Observation: If a board has 2 or more SATA ports, and there is only one disk attached to one of the ports, sata_mv_probe() does not return a successful probe status. And if only one disk is attached to the 2nd port (i.e. port 1), it is not probed at all. Patch Description: Let sata_mv_probe() continues probing all ports, even if there is error in probing a given port, and then return a successful status if there is at least one port was probed successfully. Signed-off-by: Tony Dinh Reviewed-by: Stefan Roese --- drivers/ata/sata_mv.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'drivers/ata') diff --git a/drivers/ata/sata_mv.c b/drivers/ata/sata_mv.c index dadb2c7c2e..003222d47b 100644 --- a/drivers/ata/sata_mv.c +++ b/drivers/ata/sata_mv.c @@ -1068,6 +1068,7 @@ static int sata_mv_probe(struct udevice *dev) int nr_ports; int ret; int i; + int status = -ENODEV; /* If the probe fails to detected any SATA port */ /* Get number of ports of this SATA controller */ nr_ports = min(fdtdec_get_int(blob, node, "nr-ports", -1), @@ -1078,7 +1079,7 @@ static int sata_mv_probe(struct udevice *dev) IF_TYPE_SATA, -1, 512, 0, &blk); if (ret) { debug("Can't create device\n"); - return ret; + continue; } priv = dev_get_plat(blk); @@ -1088,18 +1089,23 @@ static int sata_mv_probe(struct udevice *dev) ret = sata_mv_init_sata(blk, i); if (ret) { debug("%s: Failed to init bus\n", __func__); - return ret; + continue; } /* Scan SATA port */ ret = sata_mv_scan_sata(blk, i); if (ret) { debug("%s: Failed to scan bus\n", __func__); - return ret; + continue; } + + /* If we got here, the current SATA port was probed + * successfully, so set the probe status to successful. + */ + status = 0; } - return 0; + return status; } static int sata_mv_scan(struct udevice *dev) -- cgit v1.2.3 From d6d504d7ba8dc61dc0015ddd682bfce1dafa7dfc Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 1 Aug 2021 18:54:25 -0600 Subject: pci: acpi: Drop DM_PCI check from ahci We don't need these checks anymore since when PCI is enabled, driver model is always used. Drop them. Signed-off-by: Simon Glass --- drivers/ata/ahci.c | 55 ------------------------------------------------------ include/ahci.h | 4 ---- 2 files changed, 59 deletions(-) (limited to 'drivers/ata') diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c index d4047c04f5..2062197afc 100644 --- a/drivers/ata/ahci.c +++ b/drivers/ata/ahci.c @@ -170,13 +170,8 @@ int ahci_reset(void __iomem *base) static int ahci_host_init(struct ahci_uc_priv *uc_priv) { #if !defined(CONFIG_SCSI_AHCI_PLAT) && !defined(CONFIG_DM_SCSI) -# ifdef CONFIG_DM_PCI struct udevice *dev = uc_priv->dev; struct pci_child_plat *pplat = dev_get_parent_plat(dev); -# else - pci_dev_t pdev = uc_priv->dev; - unsigned short vendor; -# endif u16 tmp16; #endif void __iomem *mmio = uc_priv->mmio_base; @@ -200,23 +195,12 @@ static int ahci_host_init(struct ahci_uc_priv *uc_priv) writel_with_flush(0xf, mmio + HOST_PORTS_IMPL); #if !defined(CONFIG_SCSI_AHCI_PLAT) && !defined(CONFIG_DM_SCSI) -# ifdef CONFIG_DM_PCI if (pplat->vendor == PCI_VENDOR_ID_INTEL) { u16 tmp16; dm_pci_read_config16(dev, 0x92, &tmp16); dm_pci_write_config16(dev, 0x92, tmp16 | 0xf); } -# else - pci_read_config_word(pdev, PCI_VENDOR_ID, &vendor); - - if (vendor == PCI_VENDOR_ID_INTEL) { - u16 tmp16; - pci_read_config_word(pdev, 0x92, &tmp16); - tmp16 |= 0xf; - pci_write_config_word(pdev, 0x92, tmp16); - } -# endif #endif uc_priv->cap = readl(mmio + HOST_CAP); uc_priv->port_map = readl(mmio + HOST_PORTS_IMPL); @@ -331,15 +315,9 @@ static int ahci_host_init(struct ahci_uc_priv *uc_priv) debug("HOST_CTL 0x%x\n", tmp); #if !defined(CONFIG_DM_SCSI) #ifndef CONFIG_SCSI_AHCI_PLAT -# ifdef CONFIG_DM_PCI dm_pci_read_config16(dev, PCI_COMMAND, &tmp16); tmp |= PCI_COMMAND_MASTER; dm_pci_write_config16(dev, PCI_COMMAND, tmp16); -# else - pci_read_config_word(pdev, PCI_COMMAND, &tmp16); - tmp |= PCI_COMMAND_MASTER; - pci_write_config_word(pdev, PCI_COMMAND, tmp16); -# endif #endif #endif return 0; @@ -349,11 +327,7 @@ static int ahci_host_init(struct ahci_uc_priv *uc_priv) static void ahci_print_info(struct ahci_uc_priv *uc_priv) { #if !defined(CONFIG_SCSI_AHCI_PLAT) && !defined(CONFIG_DM_SCSI) -# if defined(CONFIG_DM_PCI) struct udevice *dev = uc_priv->dev; -# else - pci_dev_t pdev = uc_priv->dev; -# endif u16 cc; #endif void __iomem *mmio = uc_priv->mmio_base; @@ -379,11 +353,7 @@ static void ahci_print_info(struct ahci_uc_priv *uc_priv) #if defined(CONFIG_SCSI_AHCI_PLAT) || defined(CONFIG_DM_SCSI) scc_s = "SATA"; #else -# ifdef CONFIG_DM_PCI dm_pci_read_config16(dev, 0x0a, &cc); -# else - pci_read_config_word(pdev, 0x0a, &cc); -# endif if (cc == 0x0101) scc_s = "IDE"; else if (cc == 0x0106) @@ -428,11 +398,7 @@ static void ahci_print_info(struct ahci_uc_priv *uc_priv) } #if defined(CONFIG_DM_SCSI) || !defined(CONFIG_SCSI_AHCI_PLAT) -# if defined(CONFIG_DM_PCI) || defined(CONFIG_DM_SCSI) static int ahci_init_one(struct ahci_uc_priv *uc_priv, struct udevice *dev) -# else -static int ahci_init_one(struct ahci_uc_priv *uc_priv, pci_dev_t dev) -# endif { #if !defined(CONFIG_DM_SCSI) u16 vendor; @@ -450,7 +416,6 @@ static int ahci_init_one(struct ahci_uc_priv *uc_priv, pci_dev_t dev) uc_priv->udma_mask = 0x7f; /*Fixme,assume to support UDMA6 */ #if !defined(CONFIG_DM_SCSI) -#ifdef CONFIG_DM_PCI uc_priv->mmio_base = dm_pci_map_bar(dev, PCI_BASE_ADDRESS_5, PCI_REGION_MEM); @@ -461,18 +426,6 @@ static int ahci_init_one(struct ahci_uc_priv *uc_priv, pci_dev_t dev) dm_pci_read_config16(dev, PCI_VENDOR_ID, &vendor); if (vendor == 0x197b) dm_pci_write_config8(dev, 0x41, 0xa1); -#else - uc_priv->mmio_base = pci_map_bar(dev, PCI_BASE_ADDRESS_5, - PCI_REGION_MEM); - - /* Take from kernel: - * JMicron-specific fixup: - * make sure we're in AHCI mode - */ - pci_read_config_word(dev, PCI_VENDOR_ID, &vendor); - if (vendor == 0x197b) - pci_write_config_byte(dev, 0x41, 0xa1); -#endif #else struct scsi_plat *plat = dev_get_uclass_plat(dev); uc_priv->mmio_base = (void *)plat->base; @@ -1006,7 +959,6 @@ void scsi_low_level_init(int busdevfunc) return; } uc_priv = probe_ent; -# if defined(CONFIG_DM_PCI) struct udevice *dev; int ret; @@ -1014,9 +966,6 @@ void scsi_low_level_init(int busdevfunc) if (ret) return; ahci_init_one(uc_priv, dev); -# else - ahci_init_one(uc_priv, busdevfunc); -# endif #else uc_priv = probe_ent; #endif @@ -1026,7 +975,6 @@ void scsi_low_level_init(int busdevfunc) #endif #ifndef CONFIG_SCSI_AHCI_PLAT -# if defined(CONFIG_DM_PCI) || defined(CONFIG_DM_SCSI) int ahci_init_one_dm(struct udevice *dev) { struct ahci_uc_priv *uc_priv = dev_get_uclass_priv(dev); @@ -1034,7 +982,6 @@ int ahci_init_one_dm(struct udevice *dev) return ahci_init_one(uc_priv, dev); } #endif -#endif int ahci_start_ports_dm(struct udevice *dev) { @@ -1196,7 +1143,6 @@ int ahci_probe_scsi(struct udevice *ahci_dev, ulong base) return 0; } -#ifdef CONFIG_DM_PCI int ahci_probe_scsi_pci(struct udevice *ahci_dev) { ulong base; @@ -1221,7 +1167,6 @@ int ahci_probe_scsi_pci(struct udevice *ahci_dev) PCI_REGION_MEM); return ahci_probe_scsi(ahci_dev, base); } -#endif struct scsi_ops scsi_ops = { .exec = ahci_scsi_exec, diff --git a/include/ahci.h b/include/ahci.h index fb96dd8861..d5453042d1 100644 --- a/include/ahci.h +++ b/include/ahci.h @@ -148,16 +148,12 @@ struct ahci_ioports { * where dev is the controller (although at present it sometimes stands alone). */ struct ahci_uc_priv { -#if defined(CONFIG_DM_PCI) || defined(CONFIG_DM_SCSI) /* * TODO(sjg@chromium.org): Drop this once this structure is only used * in a driver-model context (i.e. attached to a device with * dev_get_uclass_priv() */ struct udevice *dev; -#else - pci_dev_t dev; -#endif struct ahci_ioports port[AHCI_MAX_PORTS]; u16 *ataid[AHCI_MAX_PORTS]; u32 n_ports; -- cgit v1.2.3