Skip to content

Commit 5a69195

Browse files
committed
Merge tag 'ata-7.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/libata/linux
Pull ata updates from Niklas Cassel: - Misc code cleanups related to tag checking and tag command completion (Damien) - Remove Baikal bt1-ahci DT binding since the upstreaming for this SoC is not going to be finalized (Andy) - Only call the libata port error handler from the SCSI error handler if there were command timeouts or if EH was scheduled for the port (Damien) - Refactor ata_scsiop_maint_in() to more clearly show that there is only one service action implemented for the MAINTENANCE IN command (me) - Clean up the handling of sysfs attributes exposed by libata (Heiner) - Let libahci_platform use a flexible array member for platform PHYs to avoid multiple allocations (Rosen) - Do not retry reset if the device has been removed/hot-unplugged (Igor) - Add missing newlines to error prints in pata_arasan_cf driver (Haoyu) - Use the correct SCSI host byte when completing deferred ATA PASS-THROUGH commands, to avoid the SCSI mid-layer from failing the commands instead of requeuing (Igor) * tag 'ata-7.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/libata/linux: ata: libata-scsi: fix requeue of deferred ATA PASS-THROUGH commands ata: pata_arasan_cf: fix missing newline in dev_err() messages ata: libata-transport: remove static variable ata_scsi_transport_template ata: libata-transport: split struct ata_internal ata: libata-transport: use static struct ata_transport_internal to simplify match functions ata: libata-transport: inline ata_attach|release_transport ata: libata-transport: instantiate struct ata_internal statically ata: libata-eh: Do not retry reset if the device is gone ata: libahci_platform: use flex array for platform PHYs ata: libata-transport: remove redundant dynamic sysfs attributes ata: libata-scsi: refactor ata_scsiop_maint_in() ata: libata-eh: avoid unnecessary calls to ata_scsi_port_error_handler() ata: ahci-dwc: Remove not-going-to-be-supported code for Baikal SoC ata: libata-scsi: rename and improve ata_qc_done() ata: libata-scsi: make ata_scsi_simulate() static ata: libata-scsi: simplify ata_scsi_requeue_deferred_qc() ata: libata-sata: simplify ata_sas_queuecmd() ata: libata-core: improve tag checks in ata_qc_issue()
2 parents 40286d6 + 8ebf408 commit 5a69195

13 files changed

Lines changed: 258 additions & 477 deletions

File tree

Documentation/devicetree/bindings/ata/baikal,bt1-ahci.yaml

Lines changed: 0 additions & 115 deletions
This file was deleted.

drivers/ata/Kconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,6 @@ config AHCI_DM816
194194
config AHCI_DWC
195195
tristate "Synopsys DWC AHCI SATA support"
196196
select SATA_HOST
197-
select MFD_SYSCON if (MIPS_BAIKAL_T1 || COMPILE_TEST)
198197
help
199198
This option enables support for the Synopsys DWC AHCI SATA
200199
controller implementation.

drivers/ata/ahci.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,6 @@ struct ahci_host_priv {
357357
* If platform uses PHYs. There is a 1:1 relation between the port number and
358358
* the PHY position in this array.
359359
*/
360-
struct phy **phys;
361360
unsigned nports; /* Number of ports */
362361
void *plat_data; /* Other platform data */
363362
unsigned int irq; /* interrupt line */
@@ -379,6 +378,8 @@ struct ahci_host_priv {
379378
/* only required for per-port MSI(-X) support */
380379
int (*get_irq_vector)(struct ata_host *host,
381380
int port);
381+
382+
struct phy *phys[] __counted_by(nports);
382383
};
383384

384385
/*

drivers/ata/ahci_dwc.c

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,10 @@
1313
#include <linux/kernel.h>
1414
#include <linux/libata.h>
1515
#include <linux/log2.h>
16-
#include <linux/mfd/syscon.h>
1716
#include <linux/module.h>
1817
#include <linux/of.h>
1918
#include <linux/platform_device.h>
2019
#include <linux/pm.h>
21-
#include <linux/regmap.h>
2220

2321
#include "ahci.h"
2422

@@ -92,20 +90,6 @@
9290
#define AHCI_DWC_PORT_PHYCR 0x74
9391
#define AHCI_DWC_PORT_PHYSR 0x78
9492

95-
/* Baikal-T1 AHCI SATA specific registers */
96-
#define AHCI_BT1_HOST_PHYCR AHCI_DWC_HOST_GPCR
97-
#define AHCI_BT1_HOST_MPLM_MASK GENMASK(29, 23)
98-
#define AHCI_BT1_HOST_LOSDT_MASK GENMASK(22, 20)
99-
#define AHCI_BT1_HOST_CRR BIT(19)
100-
#define AHCI_BT1_HOST_CRW BIT(18)
101-
#define AHCI_BT1_HOST_CRCD BIT(17)
102-
#define AHCI_BT1_HOST_CRCA BIT(16)
103-
#define AHCI_BT1_HOST_CRDI_MASK GENMASK(15, 0)
104-
105-
#define AHCI_BT1_HOST_PHYSR AHCI_DWC_HOST_GPSR
106-
#define AHCI_BT1_HOST_CRA BIT(16)
107-
#define AHCI_BT1_HOST_CRDO_MASK GENMASK(15, 0)
108-
10993
struct ahci_dwc_plat_data {
11094
unsigned int pflags;
11195
unsigned int hflags;
@@ -122,39 +106,6 @@ struct ahci_dwc_host_priv {
122106
u32 dmacr[AHCI_MAX_PORTS];
123107
};
124108

125-
static int ahci_bt1_init(struct ahci_host_priv *hpriv)
126-
{
127-
struct ahci_dwc_host_priv *dpriv = hpriv->plat_data;
128-
int ret;
129-
130-
/* APB, application and reference clocks are required */
131-
if (!ahci_platform_find_clk(hpriv, "pclk") ||
132-
!ahci_platform_find_clk(hpriv, "aclk") ||
133-
!ahci_platform_find_clk(hpriv, "ref")) {
134-
dev_err(&dpriv->pdev->dev, "No system clocks specified\n");
135-
return -EINVAL;
136-
}
137-
138-
/*
139-
* Fully reset the SATA AXI and ref clocks domain to ensure the state
140-
* machine is working from scratch especially if the reference clocks
141-
* source has been changed.
142-
*/
143-
ret = ahci_platform_assert_rsts(hpriv);
144-
if (ret) {
145-
dev_err(&dpriv->pdev->dev, "Couldn't assert the resets\n");
146-
return ret;
147-
}
148-
149-
ret = ahci_platform_deassert_rsts(hpriv);
150-
if (ret) {
151-
dev_err(&dpriv->pdev->dev, "Couldn't de-assert the resets\n");
152-
return ret;
153-
}
154-
155-
return 0;
156-
}
157-
158109
static struct ahci_host_priv *ahci_dwc_get_resources(struct platform_device *pdev)
159110
{
160111
struct ahci_dwc_host_priv *dpriv;
@@ -457,15 +408,9 @@ static struct ahci_dwc_plat_data ahci_dwc_plat = {
457408
.pflags = AHCI_PLATFORM_GET_RESETS,
458409
};
459410

460-
static struct ahci_dwc_plat_data ahci_bt1_plat = {
461-
.pflags = AHCI_PLATFORM_GET_RESETS | AHCI_PLATFORM_RST_TRIGGER,
462-
.init = ahci_bt1_init,
463-
};
464-
465411
static const struct of_device_id ahci_dwc_of_match[] = {
466412
{ .compatible = "snps,dwc-ahci", &ahci_dwc_plat },
467413
{ .compatible = "snps,spear-ahci", &ahci_dwc_plat },
468-
{ .compatible = "baikal,bt1-ahci", &ahci_bt1_plat },
469414
{},
470415
};
471416
MODULE_DEVICE_TABLE(of, ahci_dwc_of_match);

drivers/ata/libahci_platform.c

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -482,15 +482,29 @@ struct ahci_host_priv *ahci_platform_get_resources(struct platform_device *pdev,
482482
struct ahci_host_priv *hpriv;
483483
u32 mask_port_map = 0;
484484
u32 max_port;
485+
int nports;
485486

486487
if (!devres_open_group(dev, NULL, GFP_KERNEL))
487488
return ERR_PTR(-ENOMEM);
488489

489-
hpriv = devres_alloc(ahci_platform_put_resources, sizeof(*hpriv),
490+
/* find maximum port id for allocating structures */
491+
max_port = ahci_platform_find_max_port_id(dev);
492+
/*
493+
* Set nports according to maximum port id. Clamp at
494+
* AHCI_MAX_PORTS, warning message for invalid port id
495+
* is generated later.
496+
* When DT has no sub-nodes max_port is 0, nports is 1,
497+
* in order to be able to use the
498+
* ahci_platform_[en|dis]able_[phys|regulators] functions.
499+
*/
500+
nports = min(AHCI_MAX_PORTS, max_port + 1);
501+
hpriv = devres_alloc(ahci_platform_put_resources, struct_size(hpriv, phys, nports),
490502
GFP_KERNEL);
491503
if (!hpriv)
492504
goto err_out;
493505

506+
hpriv->nports = nports;
507+
494508
devres_add(dev, hpriv);
495509

496510
/*
@@ -573,23 +587,6 @@ struct ahci_host_priv *ahci_platform_get_resources(struct platform_device *pdev,
573587
goto err_out;
574588
}
575589

576-
/* find maximum port id for allocating structures */
577-
max_port = ahci_platform_find_max_port_id(dev);
578-
/*
579-
* Set nports according to maximum port id. Clamp at
580-
* AHCI_MAX_PORTS, warning message for invalid port id
581-
* is generated later.
582-
* When DT has no sub-nodes max_port is 0, nports is 1,
583-
* in order to be able to use the
584-
* ahci_platform_[en|dis]able_[phys|regulators] functions.
585-
*/
586-
hpriv->nports = min(AHCI_MAX_PORTS, max_port + 1);
587-
588-
hpriv->phys = devm_kcalloc(dev, hpriv->nports, sizeof(*hpriv->phys), GFP_KERNEL);
589-
if (!hpriv->phys) {
590-
rc = -ENOMEM;
591-
goto err_out;
592-
}
593590
/*
594591
* We cannot use devm_ here, since ahci_platform_put_resources() uses
595592
* target_pwrs after devm_ have freed memory

drivers/ata/libata-core.c

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5151,8 +5151,13 @@ void ata_qc_issue(struct ata_queued_cmd *qc)
51515151
struct ata_link *link = qc->dev->link;
51525152
u8 prot = qc->tf.protocol;
51535153

5154-
/* Make sure only one non-NCQ command is outstanding. */
5155-
WARN_ON_ONCE(ata_tag_valid(link->active_tag));
5154+
/*
5155+
* Make sure we have a valid tag and that only one non-NCQ command is
5156+
* outstanding.
5157+
*/
5158+
if (WARN_ON_ONCE(!ata_tag_valid(qc->tag)) ||
5159+
WARN_ON_ONCE(ata_tag_valid(link->active_tag)))
5160+
goto sys_err;
51565161

51575162
if (ata_is_ncq(prot)) {
51585163
WARN_ON_ONCE(link->sactive & (1 << qc->hw_tag));
@@ -6773,23 +6778,14 @@ static int __init ata_init(void)
67736778
}
67746779

67756780
libata_transport_init();
6776-
ata_scsi_transport_template = ata_attach_transport();
6777-
if (!ata_scsi_transport_template) {
6778-
ata_sff_exit();
6779-
rc = -ENOMEM;
6780-
goto err_out;
6781-
}
67826781

67836782
printk(KERN_DEBUG "libata version " DRV_VERSION " loaded.\n");
6784-
return 0;
67856783

6786-
err_out:
6787-
return rc;
6784+
return 0;
67886785
}
67896786

67906787
static void __exit ata_exit(void)
67916788
{
6792-
ata_release_transport(ata_scsi_transport_template);
67936789
libata_transport_exit();
67946790
ata_sff_exit();
67956791
ata_free_force_param();

drivers/ata/libata-eh.c

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -560,21 +560,27 @@ void ata_scsi_error(struct Scsi_Host *host)
560560
{
561561
struct ata_port *ap = ata_shost_to_port(host);
562562
unsigned long flags;
563+
int nr_timedout;
563564
LIST_HEAD(eh_work_q);
564565

565566
spin_lock_irqsave(host->host_lock, flags);
566567
list_splice_init(&host->eh_cmd_q, &eh_work_q);
567568
spin_unlock_irqrestore(host->host_lock, flags);
568569

569-
ata_scsi_cmd_error_handler(host, ap, &eh_work_q);
570-
571-
/* If we timed raced normal completion and there is nothing to
572-
recover nr_timedout == 0 why exactly are we doing error recovery ? */
573-
ata_scsi_port_error_handler(host, ap);
570+
/*
571+
* First check what errors we got with ata_scsi_cmd_error_handler().
572+
* If we had no command timeouts and EH is not scheduled for this port,
573+
* meaning that we do not have any failed command, then there is no
574+
* need to go through the full port error handling. We only need to
575+
* flush the completed commands we have.
576+
*/
577+
nr_timedout = ata_scsi_cmd_error_handler(host, ap, &eh_work_q);
578+
if (nr_timedout || ata_port_eh_scheduled(ap))
579+
ata_scsi_port_error_handler(host, ap);
580+
else
581+
scsi_eh_flush_done_q(&ap->eh_done_q);
574582

575-
/* finish or retry handled scmd's and clean up */
576583
WARN_ON(!list_empty(&eh_work_q));
577-
578584
}
579585

580586
/**
@@ -586,9 +592,11 @@ void ata_scsi_error(struct Scsi_Host *host)
586592
* process the given list of commands and return those finished to the
587593
* ap->eh_done_q. This function is the first part of the libata error
588594
* handler which processes a given list of failed commands.
595+
*
596+
* Return the number of commands that timed out.
589597
*/
590-
void ata_scsi_cmd_error_handler(struct Scsi_Host *host, struct ata_port *ap,
591-
struct list_head *eh_work_q)
598+
int ata_scsi_cmd_error_handler(struct Scsi_Host *host, struct ata_port *ap,
599+
struct list_head *eh_work_q)
592600
{
593601
int i;
594602
unsigned long flags;
@@ -695,6 +703,8 @@ void ata_scsi_cmd_error_handler(struct Scsi_Host *host, struct ata_port *ap,
695703
ap->eh_tries = ATA_EH_MAX_TRIES;
696704

697705
spin_unlock_irqrestore(ap->lock, flags);
706+
707+
return nr_timedout;
698708
}
699709
EXPORT_SYMBOL(ata_scsi_cmd_error_handler);
700710

@@ -3171,7 +3181,7 @@ int ata_eh_reset(struct ata_link *link, int classify,
31713181
sata_scr_read(link, SCR_STATUS, &sstatus))
31723182
rc = -ERESTART;
31733183

3174-
if (try >= max_tries) {
3184+
if (try >= max_tries || rc == -ENODEV) {
31753185
/*
31763186
* Thaw host port even if reset failed, so that the port
31773187
* can be retried on the next phy event. This risks

0 commit comments

Comments
 (0)