Skip to content

Commit e2f710f

Browse files
committed
Merge tag 'ata-6.11-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/libata/linux
Pull ata updates from Niklas Cassel: - ATA PASS-THROUGH sense data cleanups and fixes (Igor Pylypiv) Store the sense data for ATA PASS-THROUGH commands at the correct offset in the sense buffer when using fixed format sense data. Cleanup the logic related to generating sense data for PASS-THROUGH commands. Generating sense data for PASS-THROUGH commands would overwrite any eventual (real) sense data received from the device. Honor the D_SENSE bit when generating sense data for PASS-THROUGH commands. (The D_SENSE bit can be set by the user, and determines if the returned sense data should be in fixed format or descriptor format) - ata port allocation cleanups (me) Assign the ata port print_id at port allocation time, such that the ata_port_* print functions can be used earlier in the init call chain. Change the ata port port print_id to use ida_alloc(), such that print_ids will get reused on rmmod + modprobe, instead of being incremented indefinitely. Remove wrappers that only existed in order to export the internal libata functions which they wrapped, and instead export the libata functions directly. - Update SATA_MOBILE_LPM_POLICY Kconfig default to med_power_with_dipm (Mario Limonciello) Using this default was not always a good idea before, because it would break hot plug support. However, with LPM changes in recent kernels, a port marked as external will not enable LPM (in order to not break hot plug), so it is now safe to change the default value of this Kconfig. All major Linux distros have had SATA_MOBILE_LPM_POLICY set to med_power_with_dipm for quite a long time - Convert ahci-fsl-qoriq device tree binding to yaml format (Frank Li) * tag 'ata-6.11-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/libata/linux: dt-bindings: ata: ahci-fsl-qoriq: add fsl,ls1046a-ahci and fsl,ls1012a-ahci ata: ahci: Add debug print for external port ata,scsi: Remove wrapper ata_sas_port_alloc() ata: libata-core: Reuse available ata_port print_ids ata: libata: Assign print_id at port allocation time ata: libata-core: Remove local_port_no struct member ata: libata-sata: Remove superfluous assignment in ata_sas_port_alloc() ata: libata-core: Remove support for decreasing the number of ports ata: libata: Remove unused function declaration for ata_scsi_detect() ata,scsi: Remove wrappers ata_sas_tport_{add,delete}() ata: libata-scsi: Check ATA_QCFLAG_RTF_FILLED before using result_tf ata: libata-core: Set ATA_QCFLAG_RTF_FILLED in fill_result_tf() ata: libata-scsi: Do not pass ATA device id to ata_to_sense_error() ata: libata-scsi: Remove redundant sense_buffer memsets ata: libata-scsi: Honor the D_SENSE bit for CK_COND=1 and no error ata: libata-scsi: Do not overwrite valid sense data when CK_COND=1 ata: libata-scsi: Fix offsets for the fixed format sense data dt-bindings: ata: ahci-fsl-qoriq: convert to yaml format ata: Kconfig: Update SATA_MOBILE_LPM_POLICY default to med_power_with_dipm
2 parents 01f851a + 6739fad commit e2f710f

File tree

14 files changed

+230
-225
lines changed

14 files changed

+230
-225
lines changed

Documentation/devicetree/bindings/ata/ahci-fsl-qoriq.txt

Lines changed: 0 additions & 21 deletions
This file was deleted.
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
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,ahci.yaml#
5+
$schema: http://devicetree.org/meta-schemas/core.yaml#
6+
7+
title: Freescale QorIQ AHCI SATA Controller
8+
9+
maintainers:
10+
- Frank Li <[email protected]>
11+
12+
properties:
13+
compatible:
14+
oneOf:
15+
- description: SATA controller for ls1012a
16+
items:
17+
- const: fsl,ls1012a-ahci
18+
- const: fsl,ls1043a-ahci
19+
- enum:
20+
- fsl,ls1021a-ahci
21+
- fsl,ls1028a-ahci
22+
- fsl,ls1043a-ahci
23+
- fsl,ls1046a-ahci
24+
- fsl,ls1088a-ahci
25+
- fsl,ls2080a-ahci
26+
- fsl,lx2160a-ahci
27+
28+
reg:
29+
minItems: 1
30+
maxItems: 2
31+
32+
reg-names:
33+
items:
34+
- const: ahci
35+
- const: sata-ecc
36+
minItems: 1
37+
38+
clocks:
39+
maxItems: 1
40+
41+
interrupts:
42+
maxItems: 1
43+
44+
dma-coherent: true
45+
46+
required:
47+
- compatible
48+
- reg
49+
- clocks
50+
- interrupts
51+
52+
additionalProperties: false
53+
54+
examples:
55+
- |
56+
#include <dt-bindings/interrupt-controller/arm-gic.h>
57+
58+
sata@3200000 {
59+
compatible = "fsl,ls1021a-ahci";
60+
reg = <0x3200000 0x10000>;
61+
interrupts = <GIC_SPI 101 IRQ_TYPE_LEVEL_HIGH>;
62+
clocks = <&platform_clk 1>;
63+
dma-coherent;
64+
};

drivers/ata/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ config SATA_AHCI
118118
config SATA_MOBILE_LPM_POLICY
119119
int "Default SATA Link Power Management policy"
120120
range 0 4
121-
default 0
121+
default 3
122122
depends on SATA_AHCI
123123
help
124124
Select the Default SATA Link Power Management (LPM) policy to use

drivers/ata/ahci.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1732,8 +1732,10 @@ static void ahci_update_initial_lpm_policy(struct ata_port *ap)
17321732
* Management Interaction in AHCI 1.3.1. Therefore, do not enable
17331733
* LPM if the port advertises itself as an external port.
17341734
*/
1735-
if (ap->pflags & ATA_PFLAG_EXTERNAL)
1735+
if (ap->pflags & ATA_PFLAG_EXTERNAL) {
1736+
ata_port_dbg(ap, "external port, not enabling LPM\n");
17361737
return;
1738+
}
17371739

17381740
/* If no LPM states are supported by the HBA, do not bother with LPM */
17391741
if ((ap->host->flags & ATA_HOST_NO_PART) &&

drivers/ata/libahci.c

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2075,13 +2075,6 @@ static void ahci_qc_fill_rtf(struct ata_queued_cmd *qc)
20752075
struct ahci_port_priv *pp = qc->ap->private_data;
20762076
u8 *rx_fis = pp->rx_fis;
20772077

2078-
/*
2079-
* rtf may already be filled (e.g. for successful NCQ commands).
2080-
* If that is the case, we have nothing to do.
2081-
*/
2082-
if (qc->flags & ATA_QCFLAG_RTF_FILLED)
2083-
return;
2084-
20852078
if (pp->fbs_enabled)
20862079
rx_fis += qc->dev->link->pmp * AHCI_RX_FIS_SZ;
20872080

@@ -2095,7 +2088,6 @@ static void ahci_qc_fill_rtf(struct ata_queued_cmd *qc)
20952088
!(qc->flags & ATA_QCFLAG_EH)) {
20962089
ata_tf_from_fis(rx_fis + RX_FIS_PIO_SETUP, &qc->result_tf);
20972090
qc->result_tf.status = (rx_fis + RX_FIS_PIO_SETUP)[15];
2098-
qc->flags |= ATA_QCFLAG_RTF_FILLED;
20992091
return;
21002092
}
21012093

@@ -2118,12 +2110,10 @@ static void ahci_qc_fill_rtf(struct ata_queued_cmd *qc)
21182110
*/
21192111
qc->result_tf.status = fis[2];
21202112
qc->result_tf.error = fis[3];
2121-
qc->flags |= ATA_QCFLAG_RTF_FILLED;
21222113
return;
21232114
}
21242115

21252116
ata_tf_from_fis(rx_fis + RX_FIS_D2H_REG, &qc->result_tf);
2126-
qc->flags |= ATA_QCFLAG_RTF_FILLED;
21272117
}
21282118

21292119
static void ahci_qc_ncq_fill_rtf(struct ata_port *ap, u64 done_mask)
@@ -2158,6 +2148,7 @@ static void ahci_qc_ncq_fill_rtf(struct ata_port *ap, u64 done_mask)
21582148
if (qc && ata_is_ncq(qc->tf.protocol)) {
21592149
qc->result_tf.status = status;
21602150
qc->result_tf.error = error;
2151+
qc->result_tf.flags = qc->tf.flags;
21612152
qc->flags |= ATA_QCFLAG_RTF_FILLED;
21622153
}
21632154
done_mask &= ~(1ULL << tag);
@@ -2182,6 +2173,7 @@ static void ahci_qc_ncq_fill_rtf(struct ata_port *ap, u64 done_mask)
21822173
fis += RX_FIS_SDB;
21832174
qc->result_tf.status = fis[2];
21842175
qc->result_tf.error = fis[3];
2176+
qc->result_tf.flags = qc->tf.flags;
21852177
qc->flags |= ATA_QCFLAG_RTF_FILLED;
21862178
}
21872179
done_mask &= ~(1ULL << tag);

drivers/ata/libata-core.c

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ static unsigned int ata_dev_set_xfermode(struct ata_device *dev);
8686
static void ata_dev_xfermask(struct ata_device *dev);
8787
static unsigned long ata_dev_blacklisted(const struct ata_device *dev);
8888

89-
atomic_t ata_print_id = ATOMIC_INIT(0);
89+
static DEFINE_IDA(ata_ida);
9090

9191
#ifdef CONFIG_ATA_FORCE
9292
struct ata_force_param {
@@ -4800,8 +4800,16 @@ static void fill_result_tf(struct ata_queued_cmd *qc)
48004800
{
48014801
struct ata_port *ap = qc->ap;
48024802

4803+
/*
4804+
* rtf may already be filled (e.g. for successful NCQ commands).
4805+
* If that is the case, we have nothing to do.
4806+
*/
4807+
if (qc->flags & ATA_QCFLAG_RTF_FILLED)
4808+
return;
4809+
48034810
qc->result_tf.flags = qc->tf.flags;
48044811
ap->ops->qc_fill_rtf(qc);
4812+
qc->flags |= ATA_QCFLAG_RTF_FILLED;
48054813
}
48064814

48074815
static void ata_verify_xfer(struct ata_queued_cmd *qc)
@@ -5455,15 +5463,20 @@ int sata_link_init_spd(struct ata_link *link)
54555463
struct ata_port *ata_port_alloc(struct ata_host *host)
54565464
{
54575465
struct ata_port *ap;
5466+
int id;
54585467

54595468
ap = kzalloc(sizeof(*ap), GFP_KERNEL);
54605469
if (!ap)
54615470
return NULL;
54625471

54635472
ap->pflags |= ATA_PFLAG_INITIALIZING | ATA_PFLAG_FROZEN;
54645473
ap->lock = &host->lock;
5465-
ap->print_id = -1;
5466-
ap->local_port_no = -1;
5474+
id = ida_alloc_min(&ata_ida, 1, GFP_KERNEL);
5475+
if (id < 0) {
5476+
kfree(ap);
5477+
return NULL;
5478+
}
5479+
ap->print_id = id;
54675480
ap->host = host;
54685481
ap->dev = host->dev;
54695482

@@ -5488,6 +5501,7 @@ struct ata_port *ata_port_alloc(struct ata_host *host)
54885501

54895502
return ap;
54905503
}
5504+
EXPORT_SYMBOL_GPL(ata_port_alloc);
54915505

54925506
void ata_port_free(struct ata_port *ap)
54935507
{
@@ -5497,6 +5511,7 @@ void ata_port_free(struct ata_port *ap)
54975511
kfree(ap->pmp_link);
54985512
kfree(ap->slave_link);
54995513
kfree(ap->ncq_sense_buf);
5514+
ida_free(&ata_ida, ap->print_id);
55005515
kfree(ap);
55015516
}
55025517
EXPORT_SYMBOL_GPL(ata_port_free);
@@ -5547,32 +5562,27 @@ EXPORT_SYMBOL_GPL(ata_host_put);
55475562
/**
55485563
* ata_host_alloc - allocate and init basic ATA host resources
55495564
* @dev: generic device this host is associated with
5550-
* @max_ports: maximum number of ATA ports associated with this host
5565+
* @n_ports: the number of ATA ports associated with this host
55515566
*
55525567
* Allocate and initialize basic ATA host resources. LLD calls
55535568
* this function to allocate a host, initializes it fully and
55545569
* attaches it using ata_host_register().
55555570
*
5556-
* @max_ports ports are allocated and host->n_ports is
5557-
* initialized to @max_ports. The caller is allowed to decrease
5558-
* host->n_ports before calling ata_host_register(). The unused
5559-
* ports will be automatically freed on registration.
5560-
*
55615571
* RETURNS:
55625572
* Allocate ATA host on success, NULL on failure.
55635573
*
55645574
* LOCKING:
55655575
* Inherited from calling layer (may sleep).
55665576
*/
5567-
struct ata_host *ata_host_alloc(struct device *dev, int max_ports)
5577+
struct ata_host *ata_host_alloc(struct device *dev, int n_ports)
55685578
{
55695579
struct ata_host *host;
55705580
size_t sz;
55715581
int i;
55725582
void *dr;
55735583

55745584
/* alloc a container for our list of ATA ports (buses) */
5575-
sz = sizeof(struct ata_host) + (max_ports + 1) * sizeof(void *);
5585+
sz = sizeof(struct ata_host) + n_ports * sizeof(void *);
55765586
host = kzalloc(sz, GFP_KERNEL);
55775587
if (!host)
55785588
return NULL;
@@ -5592,11 +5602,11 @@ struct ata_host *ata_host_alloc(struct device *dev, int max_ports)
55925602
spin_lock_init(&host->lock);
55935603
mutex_init(&host->eh_mutex);
55945604
host->dev = dev;
5595-
host->n_ports = max_ports;
5605+
host->n_ports = n_ports;
55965606
kref_init(&host->kref);
55975607

55985608
/* allocate ports bound to this host */
5599-
for (i = 0; i < max_ports; i++) {
5609+
for (i = 0; i < n_ports; i++) {
56005610
struct ata_port *ap;
56015611

56025612
ap = ata_port_alloc(host);
@@ -5905,19 +5915,6 @@ int ata_host_register(struct ata_host *host, const struct scsi_host_template *sh
59055915
return -EINVAL;
59065916
}
59075917

5908-
/* Blow away unused ports. This happens when LLD can't
5909-
* determine the exact number of ports to allocate at
5910-
* allocation time.
5911-
*/
5912-
for (i = host->n_ports; host->ports[i]; i++)
5913-
ata_port_free(host->ports[i]);
5914-
5915-
/* give ports names and add SCSI hosts */
5916-
for (i = 0; i < host->n_ports; i++) {
5917-
host->ports[i]->print_id = atomic_inc_return(&ata_print_id);
5918-
host->ports[i]->local_port_no = i + 1;
5919-
}
5920-
59215918
/* Create associated sysfs transport objects */
59225919
for (i = 0; i < host->n_ports; i++) {
59235920
rc = ata_tport_add(host->dev,host->ports[i]);

drivers/ata/libata-sata.c

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1204,55 +1204,6 @@ int ata_scsi_change_queue_depth(struct scsi_device *sdev, int queue_depth)
12041204
}
12051205
EXPORT_SYMBOL_GPL(ata_scsi_change_queue_depth);
12061206

1207-
/**
1208-
* ata_sas_port_alloc - Allocate port for a SAS attached SATA device
1209-
* @host: ATA host container for all SAS ports
1210-
* @port_info: Information from low-level host driver
1211-
* @shost: SCSI host that the scsi device is attached to
1212-
*
1213-
* LOCKING:
1214-
* PCI/etc. bus probe sem.
1215-
*
1216-
* RETURNS:
1217-
* ata_port pointer on success / NULL on failure.
1218-
*/
1219-
1220-
struct ata_port *ata_sas_port_alloc(struct ata_host *host,
1221-
struct ata_port_info *port_info,
1222-
struct Scsi_Host *shost)
1223-
{
1224-
struct ata_port *ap;
1225-
1226-
ap = ata_port_alloc(host);
1227-
if (!ap)
1228-
return NULL;
1229-
1230-
ap->port_no = 0;
1231-
ap->lock = &host->lock;
1232-
ap->pio_mask = port_info->pio_mask;
1233-
ap->mwdma_mask = port_info->mwdma_mask;
1234-
ap->udma_mask = port_info->udma_mask;
1235-
ap->flags |= port_info->flags;
1236-
ap->ops = port_info->port_ops;
1237-
ap->cbl = ATA_CBL_SATA;
1238-
ap->print_id = atomic_inc_return(&ata_print_id);
1239-
1240-
return ap;
1241-
}
1242-
EXPORT_SYMBOL_GPL(ata_sas_port_alloc);
1243-
1244-
int ata_sas_tport_add(struct device *parent, struct ata_port *ap)
1245-
{
1246-
return ata_tport_add(parent, ap);
1247-
}
1248-
EXPORT_SYMBOL_GPL(ata_sas_tport_add);
1249-
1250-
void ata_sas_tport_delete(struct ata_port *ap)
1251-
{
1252-
ata_tport_delete(ap);
1253-
}
1254-
EXPORT_SYMBOL_GPL(ata_sas_tport_delete);
1255-
12561207
/**
12571208
* ata_sas_device_configure - Default device_configure routine for libata
12581209
* devices

0 commit comments

Comments
 (0)