Skip to content

Commit

Permalink
Merge tag 'ata-6.11-rc1' of git://git.kernel.org/pub/scm/linux/kernel…
Browse files Browse the repository at this point in the history
…/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
  • Loading branch information
torvalds committed Jul 17, 2024
2 parents 01f851a + 6739fad commit e2f710f
Show file tree
Hide file tree
Showing 14 changed files with 230 additions and 225 deletions.
21 changes: 0 additions & 21 deletions Documentation/devicetree/bindings/ata/ahci-fsl-qoriq.txt

This file was deleted.

64 changes: 64 additions & 0 deletions Documentation/devicetree/bindings/ata/fsl,ahci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/ata/fsl,ahci.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: Freescale QorIQ AHCI SATA Controller

maintainers:
- Frank Li <[email protected]>

properties:
compatible:
oneOf:
- description: SATA controller for ls1012a
items:
- const: fsl,ls1012a-ahci
- const: fsl,ls1043a-ahci
- enum:
- fsl,ls1021a-ahci
- fsl,ls1028a-ahci
- fsl,ls1043a-ahci
- fsl,ls1046a-ahci
- fsl,ls1088a-ahci
- fsl,ls2080a-ahci
- fsl,lx2160a-ahci

reg:
minItems: 1
maxItems: 2

reg-names:
items:
- const: ahci
- const: sata-ecc
minItems: 1

clocks:
maxItems: 1

interrupts:
maxItems: 1

dma-coherent: true

required:
- compatible
- reg
- clocks
- interrupts

additionalProperties: false

examples:
- |
#include <dt-bindings/interrupt-controller/arm-gic.h>
sata@3200000 {
compatible = "fsl,ls1021a-ahci";
reg = <0x3200000 0x10000>;
interrupts = <GIC_SPI 101 IRQ_TYPE_LEVEL_HIGH>;
clocks = <&platform_clk 1>;
dma-coherent;
};
2 changes: 1 addition & 1 deletion drivers/ata/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ config SATA_AHCI
config SATA_MOBILE_LPM_POLICY
int "Default SATA Link Power Management policy"
range 0 4
default 0
default 3
depends on SATA_AHCI
help
Select the Default SATA Link Power Management (LPM) policy to use
Expand Down
4 changes: 3 additions & 1 deletion drivers/ata/ahci.c
Original file line number Diff line number Diff line change
Expand Up @@ -1732,8 +1732,10 @@ static void ahci_update_initial_lpm_policy(struct ata_port *ap)
* Management Interaction in AHCI 1.3.1. Therefore, do not enable
* LPM if the port advertises itself as an external port.
*/
if (ap->pflags & ATA_PFLAG_EXTERNAL)
if (ap->pflags & ATA_PFLAG_EXTERNAL) {
ata_port_dbg(ap, "external port, not enabling LPM\n");
return;
}

/* If no LPM states are supported by the HBA, do not bother with LPM */
if ((ap->host->flags & ATA_HOST_NO_PART) &&
Expand Down
12 changes: 2 additions & 10 deletions drivers/ata/libahci.c
Original file line number Diff line number Diff line change
Expand Up @@ -2075,13 +2075,6 @@ static void ahci_qc_fill_rtf(struct ata_queued_cmd *qc)
struct ahci_port_priv *pp = qc->ap->private_data;
u8 *rx_fis = pp->rx_fis;

/*
* rtf may already be filled (e.g. for successful NCQ commands).
* If that is the case, we have nothing to do.
*/
if (qc->flags & ATA_QCFLAG_RTF_FILLED)
return;

if (pp->fbs_enabled)
rx_fis += qc->dev->link->pmp * AHCI_RX_FIS_SZ;

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

Expand All @@ -2118,12 +2110,10 @@ static void ahci_qc_fill_rtf(struct ata_queued_cmd *qc)
*/
qc->result_tf.status = fis[2];
qc->result_tf.error = fis[3];
qc->flags |= ATA_QCFLAG_RTF_FILLED;
return;
}

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

static void ahci_qc_ncq_fill_rtf(struct ata_port *ap, u64 done_mask)
Expand Down Expand Up @@ -2158,6 +2148,7 @@ static void ahci_qc_ncq_fill_rtf(struct ata_port *ap, u64 done_mask)
if (qc && ata_is_ncq(qc->tf.protocol)) {
qc->result_tf.status = status;
qc->result_tf.error = error;
qc->result_tf.flags = qc->tf.flags;
qc->flags |= ATA_QCFLAG_RTF_FILLED;
}
done_mask &= ~(1ULL << tag);
Expand All @@ -2182,6 +2173,7 @@ static void ahci_qc_ncq_fill_rtf(struct ata_port *ap, u64 done_mask)
fis += RX_FIS_SDB;
qc->result_tf.status = fis[2];
qc->result_tf.error = fis[3];
qc->result_tf.flags = qc->tf.flags;
qc->flags |= ATA_QCFLAG_RTF_FILLED;
}
done_mask &= ~(1ULL << tag);
Expand Down
49 changes: 23 additions & 26 deletions drivers/ata/libata-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ static unsigned int ata_dev_set_xfermode(struct ata_device *dev);
static void ata_dev_xfermask(struct ata_device *dev);
static unsigned long ata_dev_blacklisted(const struct ata_device *dev);

atomic_t ata_print_id = ATOMIC_INIT(0);
static DEFINE_IDA(ata_ida);

#ifdef CONFIG_ATA_FORCE
struct ata_force_param {
Expand Down Expand Up @@ -4800,8 +4800,16 @@ static void fill_result_tf(struct ata_queued_cmd *qc)
{
struct ata_port *ap = qc->ap;

/*
* rtf may already be filled (e.g. for successful NCQ commands).
* If that is the case, we have nothing to do.
*/
if (qc->flags & ATA_QCFLAG_RTF_FILLED)
return;

qc->result_tf.flags = qc->tf.flags;
ap->ops->qc_fill_rtf(qc);
qc->flags |= ATA_QCFLAG_RTF_FILLED;
}

static void ata_verify_xfer(struct ata_queued_cmd *qc)
Expand Down Expand Up @@ -5455,15 +5463,20 @@ int sata_link_init_spd(struct ata_link *link)
struct ata_port *ata_port_alloc(struct ata_host *host)
{
struct ata_port *ap;
int id;

ap = kzalloc(sizeof(*ap), GFP_KERNEL);
if (!ap)
return NULL;

ap->pflags |= ATA_PFLAG_INITIALIZING | ATA_PFLAG_FROZEN;
ap->lock = &host->lock;
ap->print_id = -1;
ap->local_port_no = -1;
id = ida_alloc_min(&ata_ida, 1, GFP_KERNEL);
if (id < 0) {
kfree(ap);
return NULL;
}
ap->print_id = id;
ap->host = host;
ap->dev = host->dev;

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

return ap;
}
EXPORT_SYMBOL_GPL(ata_port_alloc);

void ata_port_free(struct ata_port *ap)
{
Expand All @@ -5497,6 +5511,7 @@ void ata_port_free(struct ata_port *ap)
kfree(ap->pmp_link);
kfree(ap->slave_link);
kfree(ap->ncq_sense_buf);
ida_free(&ata_ida, ap->print_id);
kfree(ap);
}
EXPORT_SYMBOL_GPL(ata_port_free);
Expand Down Expand Up @@ -5547,32 +5562,27 @@ EXPORT_SYMBOL_GPL(ata_host_put);
/**
* ata_host_alloc - allocate and init basic ATA host resources
* @dev: generic device this host is associated with
* @max_ports: maximum number of ATA ports associated with this host
* @n_ports: the number of ATA ports associated with this host
*
* Allocate and initialize basic ATA host resources. LLD calls
* this function to allocate a host, initializes it fully and
* attaches it using ata_host_register().
*
* @max_ports ports are allocated and host->n_ports is
* initialized to @max_ports. The caller is allowed to decrease
* host->n_ports before calling ata_host_register(). The unused
* ports will be automatically freed on registration.
*
* RETURNS:
* Allocate ATA host on success, NULL on failure.
*
* LOCKING:
* Inherited from calling layer (may sleep).
*/
struct ata_host *ata_host_alloc(struct device *dev, int max_ports)
struct ata_host *ata_host_alloc(struct device *dev, int n_ports)
{
struct ata_host *host;
size_t sz;
int i;
void *dr;

/* alloc a container for our list of ATA ports (buses) */
sz = sizeof(struct ata_host) + (max_ports + 1) * sizeof(void *);
sz = sizeof(struct ata_host) + n_ports * sizeof(void *);
host = kzalloc(sz, GFP_KERNEL);
if (!host)
return NULL;
Expand All @@ -5592,11 +5602,11 @@ struct ata_host *ata_host_alloc(struct device *dev, int max_ports)
spin_lock_init(&host->lock);
mutex_init(&host->eh_mutex);
host->dev = dev;
host->n_ports = max_ports;
host->n_ports = n_ports;
kref_init(&host->kref);

/* allocate ports bound to this host */
for (i = 0; i < max_ports; i++) {
for (i = 0; i < n_ports; i++) {
struct ata_port *ap;

ap = ata_port_alloc(host);
Expand Down Expand Up @@ -5905,19 +5915,6 @@ int ata_host_register(struct ata_host *host, const struct scsi_host_template *sh
return -EINVAL;
}

/* Blow away unused ports. This happens when LLD can't
* determine the exact number of ports to allocate at
* allocation time.
*/
for (i = host->n_ports; host->ports[i]; i++)
ata_port_free(host->ports[i]);

/* give ports names and add SCSI hosts */
for (i = 0; i < host->n_ports; i++) {
host->ports[i]->print_id = atomic_inc_return(&ata_print_id);
host->ports[i]->local_port_no = i + 1;
}

/* Create associated sysfs transport objects */
for (i = 0; i < host->n_ports; i++) {
rc = ata_tport_add(host->dev,host->ports[i]);
Expand Down
49 changes: 0 additions & 49 deletions drivers/ata/libata-sata.c
Original file line number Diff line number Diff line change
Expand Up @@ -1204,55 +1204,6 @@ int ata_scsi_change_queue_depth(struct scsi_device *sdev, int queue_depth)
}
EXPORT_SYMBOL_GPL(ata_scsi_change_queue_depth);

/**
* ata_sas_port_alloc - Allocate port for a SAS attached SATA device
* @host: ATA host container for all SAS ports
* @port_info: Information from low-level host driver
* @shost: SCSI host that the scsi device is attached to
*
* LOCKING:
* PCI/etc. bus probe sem.
*
* RETURNS:
* ata_port pointer on success / NULL on failure.
*/

struct ata_port *ata_sas_port_alloc(struct ata_host *host,
struct ata_port_info *port_info,
struct Scsi_Host *shost)
{
struct ata_port *ap;

ap = ata_port_alloc(host);
if (!ap)
return NULL;

ap->port_no = 0;
ap->lock = &host->lock;
ap->pio_mask = port_info->pio_mask;
ap->mwdma_mask = port_info->mwdma_mask;
ap->udma_mask = port_info->udma_mask;
ap->flags |= port_info->flags;
ap->ops = port_info->port_ops;
ap->cbl = ATA_CBL_SATA;
ap->print_id = atomic_inc_return(&ata_print_id);

return ap;
}
EXPORT_SYMBOL_GPL(ata_sas_port_alloc);

int ata_sas_tport_add(struct device *parent, struct ata_port *ap)
{
return ata_tport_add(parent, ap);
}
EXPORT_SYMBOL_GPL(ata_sas_tport_add);

void ata_sas_tport_delete(struct ata_port *ap)
{
ata_tport_delete(ap);
}
EXPORT_SYMBOL_GPL(ata_sas_tport_delete);

/**
* ata_sas_device_configure - Default device_configure routine for libata
* devices
Expand Down
Loading

0 comments on commit e2f710f

Please sign in to comment.