Skip to content

Commit 2209399

Browse files
committed
Merge tag 'ata-6.15-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/libata/linux
Pull ata updates from Niklas Cassel: - Add 'external' to the libata.force module parameter, in order to allow a user to workaround broken firmware (me) - Use the str_up_down() helper in the sata_via driver (Salah Triki) - Convert the Freescale PowerQUICC SATA device tree binding to YAML (J. Neuschäfer) - Do not use ATAPI DMA for a device that only supports PIO (me) - Add Marvell 88SE9215 PCI device ID to the ahci driver. Since the controller has quirks, it cannot rely on the generic AHCI PCI class code entry (Daniel Kral) - Improve the return value of atapi_check_dma() (Huacai Chen) - Fix the NCQ Non-Data log not supported print to actually reference the correct log (me) - Make Marvel 88SE9215 prefer DMA for ATAPI devices (Huacai Chen) - Simplify the AHCI IRQ vector allocations by performing the IRQ vector allocations in the same function, regardless of IRQ type (Tomas Henzl) * tag 'ata-6.15-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/libata/linux: ata: ahci: simplify init function ahci: Marvell 88SE9215 controllers prefer DMA for ATAPI ata: libata: Fix NCQ Non-Data log not supported print ata: libata: Improve return value of atapi_check_dma() ahci: add PCI ID for Marvell 88SE9215 SATA Controller ata: libata-eh: Do not use ATAPI DMA for a device limited to PIO mode dt-bindings: ata: Convert fsl,pq-sata to YAML ata: sata_via: Use str_up_down() helper in vt6420_prereset() ata: libata-core: Add 'external' to the libata.force kernel parameter
2 parents 9b960d8 + 565d065 commit 2209399

File tree

9 files changed

+141
-44
lines changed

9 files changed

+141
-44
lines changed

Documentation/admin-guide/kernel-parameters.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3117,6 +3117,8 @@
31173117
* max_sec_lba48: Set or clear transfer size limit to
31183118
65535 sectors.
31193119

3120+
* external: Mark port as external (hotplug-capable).
3121+
31203122
* [no]lpm: Enable or disable link power management.
31213123

31223124
* [no]setxfer: Indicate if transfer speed mode setting
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
2+
%YAML 1.2
3+
---
4+
$id: http://devicetree.org/schemas/ata/fsl,pq-sata.yaml#
5+
$schema: http://devicetree.org/meta-schemas/core.yaml#
6+
7+
title: Freescale 8xxx/3.0 Gb/s SATA nodes
8+
9+
maintainers:
10+
- J. Neuschäfer <[email protected]>
11+
12+
description:
13+
SATA nodes are defined to describe on-chip Serial ATA controllers.
14+
Each SATA controller should have its own node.
15+
16+
properties:
17+
compatible:
18+
oneOf:
19+
- items:
20+
- enum:
21+
- fsl,mpc8377-sata
22+
- fsl,mpc8536-sata
23+
- fsl,mpc8315-sata
24+
- fsl,mpc8379-sata
25+
- const: fsl,pq-sata
26+
- const: fsl,pq-sata-v2
27+
28+
reg:
29+
maxItems: 1
30+
31+
interrupts:
32+
maxItems: 1
33+
34+
cell-index:
35+
$ref: /schemas/types.yaml#/definitions/uint32
36+
enum: [1, 2, 3, 4]
37+
description: |
38+
1 for controller @ 0x18000
39+
2 for controller @ 0x19000
40+
3 for controller @ 0x1a000
41+
4 for controller @ 0x1b000
42+
43+
required:
44+
- compatible
45+
- interrupts
46+
- cell-index
47+
48+
additionalProperties: false
49+
50+
examples:
51+
- |
52+
#include <dt-bindings/interrupt-controller/irq.h>
53+
sata@18000 {
54+
compatible = "fsl,mpc8379-sata", "fsl,pq-sata";
55+
reg = <0x18000 0x1000>;
56+
cell-index = <1>;
57+
interrupts = <44 IRQ_TYPE_LEVEL_LOW>;
58+
};
59+
60+
...

Documentation/devicetree/bindings/ata/fsl-sata.txt

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

drivers/ata/ahci.c

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ enum board_ids {
6363
board_ahci_pcs_quirk_no_devslp,
6464
board_ahci_pcs_quirk_no_sntf,
6565
board_ahci_yes_fbs,
66+
board_ahci_yes_fbs_atapi_dma,
6667

6768
/* board IDs for specific chipsets in alphabetical order */
6869
board_ahci_al,
@@ -188,6 +189,14 @@ static const struct ata_port_info ahci_port_info[] = {
188189
.udma_mask = ATA_UDMA6,
189190
.port_ops = &ahci_ops,
190191
},
192+
[board_ahci_yes_fbs_atapi_dma] = {
193+
AHCI_HFLAGS (AHCI_HFLAG_YES_FBS |
194+
AHCI_HFLAG_ATAPI_DMA_QUIRK),
195+
.flags = AHCI_FLAG_COMMON,
196+
.pio_mask = ATA_PIO4,
197+
.udma_mask = ATA_UDMA6,
198+
.port_ops = &ahci_ops,
199+
},
191200
/* by chipsets */
192201
[board_ahci_al] = {
193202
AHCI_HFLAGS (AHCI_HFLAG_NO_PMP | AHCI_HFLAG_NO_MSI),
@@ -589,6 +598,8 @@ static const struct pci_device_id ahci_pci_tbl[] = {
589598
.driver_data = board_ahci_yes_fbs },
590599
{ PCI_DEVICE(PCI_VENDOR_ID_MARVELL_EXT, 0x91a3),
591600
.driver_data = board_ahci_yes_fbs },
601+
{ PCI_DEVICE(PCI_VENDOR_ID_MARVELL_EXT, 0x9215),
602+
.driver_data = board_ahci_yes_fbs_atapi_dma },
592603
{ PCI_DEVICE(PCI_VENDOR_ID_MARVELL_EXT, 0x9230),
593604
.driver_data = board_ahci_yes_fbs },
594605
{ PCI_DEVICE(PCI_VENDOR_ID_MARVELL_EXT, 0x9235),
@@ -1665,13 +1676,15 @@ static int ahci_get_irq_vector(struct ata_host *host, int port)
16651676
return pci_irq_vector(to_pci_dev(host->dev), port);
16661677
}
16671678

1668-
static int ahci_init_msi(struct pci_dev *pdev, unsigned int n_ports,
1679+
static void ahci_init_irq(struct pci_dev *pdev, unsigned int n_ports,
16691680
struct ahci_host_priv *hpriv)
16701681
{
16711682
int nvec;
16721683

1673-
if (hpriv->flags & AHCI_HFLAG_NO_MSI)
1674-
return -ENODEV;
1684+
if (hpriv->flags & AHCI_HFLAG_NO_MSI) {
1685+
pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_INTX);
1686+
return;
1687+
}
16751688

16761689
/*
16771690
* If number of MSIs is less than number of ports then Sharing Last
@@ -1685,7 +1698,7 @@ static int ahci_init_msi(struct pci_dev *pdev, unsigned int n_ports,
16851698
if (!(readl(hpriv->mmio + HOST_CTL) & HOST_MRSM)) {
16861699
hpriv->get_irq_vector = ahci_get_irq_vector;
16871700
hpriv->flags |= AHCI_HFLAG_MULTI_MSI;
1688-
return nvec;
1701+
return;
16891702
}
16901703

16911704
/*
@@ -1700,12 +1713,13 @@ static int ahci_init_msi(struct pci_dev *pdev, unsigned int n_ports,
17001713

17011714
/*
17021715
* If the host is not capable of supporting per-port vectors, fall
1703-
* back to single MSI before finally attempting single MSI-X.
1716+
* back to single MSI before finally attempting single MSI-X or
1717+
* a legacy INTx.
17041718
*/
17051719
nvec = pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_MSI);
17061720
if (nvec == 1)
1707-
return nvec;
1708-
return pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_MSIX);
1721+
return;
1722+
pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_MSIX | PCI_IRQ_INTX);
17091723
}
17101724

17111725
static void ahci_mark_external_port(struct ata_port *ap)
@@ -1985,10 +1999,8 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
19851999
}
19862000
host->private_data = hpriv;
19872001

1988-
if (ahci_init_msi(pdev, n_ports, hpriv) < 0) {
1989-
/* legacy intx interrupts */
1990-
pcim_intx(pdev, 1);
1991-
}
2002+
ahci_init_irq(pdev, n_ports, hpriv);
2003+
19922004
hpriv->irq = pci_irq_vector(pdev, 0);
19932005

19942006
if (!(hpriv->cap & HOST_CAP_SSS) || ahci_ignore_sss)

drivers/ata/ahci.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ enum {
246246
AHCI_HFLAG_NO_SXS = BIT(26), /* SXS not supported */
247247
AHCI_HFLAG_43BIT_ONLY = BIT(27), /* 43bit DMA addr limit */
248248
AHCI_HFLAG_INTEL_PCS_QUIRK = BIT(28), /* apply Intel PCS quirk */
249+
AHCI_HFLAG_ATAPI_DMA_QUIRK = BIT(29), /* force ATAPI to use DMA */
249250

250251
/* ap->flags bits */
251252

drivers/ata/libahci.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1322,6 +1322,10 @@ static void ahci_dev_config(struct ata_device *dev)
13221322
{
13231323
struct ahci_host_priv *hpriv = dev->link->ap->host->private_data;
13241324

1325+
if ((dev->class == ATA_DEV_ATAPI) &&
1326+
(hpriv->flags & AHCI_HFLAG_ATAPI_DMA_QUIRK))
1327+
dev->quirks |= ATA_QUIRK_ATAPI_MOD16_DMA;
1328+
13251329
if (hpriv->flags & AHCI_HFLAG_SECT255) {
13261330
dev->max_sectors = 255;
13271331
ata_dev_info(dev,

drivers/ata/libata-core.c

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ struct ata_force_param {
8888
unsigned int xfer_mask;
8989
unsigned int quirk_on;
9090
unsigned int quirk_off;
91+
unsigned int pflags_on;
9192
u16 lflags_on;
9293
u16 lflags_off;
9394
};
@@ -331,6 +332,35 @@ void ata_force_cbl(struct ata_port *ap)
331332
}
332333
}
333334

335+
/**
336+
* ata_force_pflags - force port flags according to libata.force
337+
* @ap: ATA port of interest
338+
*
339+
* Force port flags according to libata.force and whine about it.
340+
*
341+
* LOCKING:
342+
* EH context.
343+
*/
344+
static void ata_force_pflags(struct ata_port *ap)
345+
{
346+
int i;
347+
348+
for (i = ata_force_tbl_size - 1; i >= 0; i--) {
349+
const struct ata_force_ent *fe = &ata_force_tbl[i];
350+
351+
if (fe->port != -1 && fe->port != ap->print_id)
352+
continue;
353+
354+
/* let pflags stack */
355+
if (fe->param.pflags_on) {
356+
ap->pflags |= fe->param.pflags_on;
357+
ata_port_notice(ap,
358+
"FORCE: port flag 0x%x forced -> 0x%x\n",
359+
fe->param.pflags_on, ap->pflags);
360+
}
361+
}
362+
}
363+
334364
/**
335365
* ata_force_link_limits - force link limits according to libata.force
336366
* @link: ATA link of interest
@@ -486,6 +516,7 @@ static void ata_force_quirks(struct ata_device *dev)
486516
}
487517
}
488518
#else
519+
static inline void ata_force_pflags(struct ata_port *ap) { }
489520
static inline void ata_force_link_limits(struct ata_link *link) { }
490521
static inline void ata_force_xfermask(struct ata_device *dev) { }
491522
static inline void ata_force_quirks(struct ata_device *dev) { }
@@ -2243,7 +2274,7 @@ static void ata_dev_config_ncq_non_data(struct ata_device *dev)
22432274

22442275
if (!ata_log_supported(dev, ATA_LOG_NCQ_NON_DATA)) {
22452276
ata_dev_warn(dev,
2246-
"NCQ Send/Recv Log not supported\n");
2277+
"NCQ Non-Data Log not supported\n");
22472278
return;
22482279
}
22492280
err_mask = ata_read_log_page(dev, ATA_LOG_NCQ_NON_DATA,
@@ -4552,7 +4583,7 @@ int atapi_check_dma(struct ata_queued_cmd *qc)
45524583
*/
45534584
if (!(qc->dev->quirks & ATA_QUIRK_ATAPI_MOD16_DMA) &&
45544585
unlikely(qc->nbytes & 15))
4555-
return 1;
4586+
return -EOPNOTSUPP;
45564587

45574588
if (ap->ops->check_atapi_dma)
45584589
return ap->ops->check_atapi_dma(qc);
@@ -5460,6 +5491,8 @@ struct ata_port *ata_port_alloc(struct ata_host *host)
54605491
#endif
54615492
ata_sff_port_init(ap);
54625493

5494+
ata_force_pflags(ap);
5495+
54635496
return ap;
54645497
}
54655498
EXPORT_SYMBOL_GPL(ata_port_alloc);
@@ -6272,6 +6305,9 @@ EXPORT_SYMBOL_GPL(ata_platform_remove_one);
62726305
{ "no" #name, .lflags_on = (flags) }, \
62736306
{ #name, .lflags_off = (flags) }
62746307

6308+
#define force_pflag_on(name, flags) \
6309+
{ #name, .pflags_on = (flags) }
6310+
62756311
#define force_quirk_on(name, flag) \
62766312
{ #name, .quirk_on = (flag) }
62776313

@@ -6331,6 +6367,8 @@ static const struct ata_force_param force_tbl[] __initconst = {
63316367
force_lflag_on(rstonce, ATA_LFLAG_RST_ONCE),
63326368
force_lflag_onoff(dbdelay, ATA_LFLAG_NO_DEBOUNCE_DELAY),
63336369

6370+
force_pflag_on(external, ATA_PFLAG_EXTERNAL),
6371+
63346372
force_quirk_onoff(ncq, ATA_QUIRK_NONCQ),
63356373
force_quirk_onoff(ncqtrim, ATA_QUIRK_NO_NCQ_TRIM),
63366374
force_quirk_onoff(ncqati, ATA_QUIRK_NO_NCQ_ON_ATI),

drivers/ata/libata-eh.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1542,8 +1542,15 @@ unsigned int atapi_eh_request_sense(struct ata_device *dev,
15421542
tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE;
15431543
tf.command = ATA_CMD_PACKET;
15441544

1545-
/* is it pointless to prefer PIO for "safety reasons"? */
1546-
if (ap->flags & ATA_FLAG_PIO_DMA) {
1545+
/*
1546+
* Do not use DMA if the connected device only supports PIO, even if the
1547+
* port prefers PIO commands via DMA.
1548+
*
1549+
* Ideally, we should call atapi_check_dma() to check if it is safe for
1550+
* the LLD to use DMA for REQUEST_SENSE, but we don't have a qc.
1551+
* Since we can't check the command, perhaps we should only use pio?
1552+
*/
1553+
if ((ap->flags & ATA_FLAG_PIO_DMA) && !(dev->flags & ATA_DFLAG_PIO)) {
15471554
tf.protocol = ATAPI_PROT_DMA;
15481555
tf.feature |= ATAPI_PKT_DMA;
15491556
} else {

drivers/ata/sata_via.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include <scsi/scsi_cmnd.h>
2626
#include <scsi/scsi_host.h>
2727
#include <linux/libata.h>
28+
#include <linux/string_choices.h>
2829

2930
#define DRV_NAME "sata_via"
3031
#define DRV_VERSION "2.6"
@@ -359,7 +360,7 @@ static int vt6420_prereset(struct ata_link *link, unsigned long deadline)
359360

360361
ata_port_info(ap,
361362
"SATA link %s 1.5 Gbps (SStatus %X SControl %X)\n",
362-
online ? "up" : "down", sstatus, scontrol);
363+
str_up_down(online), sstatus, scontrol);
363364

364365
/* SStatus is read one more time */
365366
svia_scr_read(link, SCR_STATUS, &sstatus);

0 commit comments

Comments
 (0)