]> Git Repo - linux.git/commitdiff
Merge tag 'ata-6.5-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/dlemoal...
authorLinus Torvalds <[email protected]>
Fri, 30 Jun 2023 18:48:16 +0000 (11:48 -0700)
committerLinus Torvalds <[email protected]>
Fri, 30 Jun 2023 18:48:16 +0000 (11:48 -0700)
Pull ata updates from Damien Le Moal:

 - Add support for the .remove_new callback to the ata_platform code to
   simplify device removal interface (Uwe)

 - Code simplification in ata_dev_revalidate() (Yahu)

 - Fix code indentation and coding style in the pata_parport protocol
   modules to avoid warnings from static code analyzers (me)

 - Clarify ata_eh_qc_retry() behavior with better comments (Niklas)

 - Simplify and improve ata_change_queue_depth() behavior to have a
   consistent behavior between libsas managed devices and libata managed
   devices (e.g. AHCI connected devices) (me)

 - Cleanup libata-scsi and libata-eh code to use the ata_ncq_enabled()
   and ata_ncq_supported() helpers instead of open coding flags tests
   (me)

 - Cleanup ahci_reset_controller() code (me)

 - Change the pata_octeon_cf and sata_svw drivers to use
   of_property_read_reg() to simplify the code (Rob, me)

 - Remove unnecessary include files from ahci_octeon driver (me)

 - Modify the DesignWare ahci dt bindings to add support for the
   Rockchip RK3588 AHCI (Sebastian)

* tag 'ata-6.5-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/dlemoal/libata: (29 commits)
  dt-bindings: phy: rockchip: rk3588 has two reset lines
  dt-bindings: ata: dwc-ahci: add Rockchip RK3588
  dt-bindings: ata: dwc-ahci: add PHY clocks
  ata: ahci_octeon: Remove unnecessary include
  ata: pata_octeon_cf: Add missing header include
  ata: ahci: Cleanup ahci_reset_controller()
  ata: Use of_property_read_reg() to parse "reg"
  ata: libata-scsi: Use ata_ncq_supported in ata_scsi_dev_config()
  ata: libata-eh: Use ata_ncq_enabled() in ata_eh_speed_down()
  ata: libata-sata: Improve ata_change_queue_depth()
  ata: libata-sata: Simplify ata_change_queue_depth()
  ata: libata-eh: Clarify ata_eh_qc_retry() behavior at call site
  ata: pata_parport: Fix on26 module code indentation and style
  ata: pata_parport: Fix on20 module code indentation and style
  ata: pata_parport: Fix ktti module code indentation and style
  ata: pata_parport: Fix kbic module code indentation and style
  ata: pata_parport: Fix friq module code indentation and style
  ata: pata_parport: Fix fit3 module code indentation and style
  ata: pata_parport: Fix fit2 module code indentation and style
  ata: pata_parport: Fix epia module code indentation and style
  ...

1  2 
drivers/ata/libata-core.c
drivers/ata/libata-eh.c
drivers/ata/libata-scsi.c
include/linux/libata.h

index b4f246f0cac7f05a6942d41526af51d6f65eb766,8796ef51641cbec2abff0ed922d5b0e20f124624..0e4c2da508217e57c5cc17bb1f334d26b67caf09
@@@ -3802,11 -3802,7 +3802,7 @@@ int ata_dev_revalidate(struct ata_devic
                return -ENODEV;
  
        /* fail early if !ATA && !ATAPI to avoid issuing [P]IDENTIFY to PMP */
-       if (ata_class_enabled(new_class) &&
-           new_class != ATA_DEV_ATA &&
-           new_class != ATA_DEV_ATAPI &&
-           new_class != ATA_DEV_ZAC &&
-           new_class != ATA_DEV_SEMB) {
+       if (ata_class_enabled(new_class) && new_class == ATA_DEV_PMP) {
                ata_dev_info(dev, "class mismatch %u != %u\n",
                             dev->class, new_class);
                rc = -ENODEV;
@@@ -5348,7 -5344,7 +5344,7 @@@ struct ata_port *ata_port_alloc(struct 
  
        mutex_init(&ap->scsi_scan_mutex);
        INIT_DELAYED_WORK(&ap->hotplug_task, ata_scsi_hotplug);
 -      INIT_WORK(&ap->scsi_rescan_task, ata_scsi_dev_rescan);
 +      INIT_DELAYED_WORK(&ap->scsi_rescan_task, ata_scsi_dev_rescan);
        INIT_LIST_HEAD(&ap->eh_done_q);
        init_waitqueue_head(&ap->eh_wait_q);
        init_completion(&ap->park_req_pending);
@@@ -5954,7 -5950,6 +5950,7 @@@ static void ata_port_detach(struct ata_
        WARN_ON(!(ap->pflags & ATA_PFLAG_UNLOADED));
  
        cancel_delayed_work_sync(&ap->hotplug_task);
 +      cancel_delayed_work_sync(&ap->scsi_rescan_task);
  
   skip_eh:
        /* clean up zpodd on port removal */
@@@ -6142,13 -6137,11 +6138,11 @@@ EXPORT_SYMBOL_GPL(ata_pci_device_resume
   *    LOCKING:
   *    Inherited from platform layer (may sleep).
   */
int ata_platform_remove_one(struct platform_device *pdev)
void ata_platform_remove_one(struct platform_device *pdev)
  {
        struct ata_host *host = platform_get_drvdata(pdev);
  
        ata_host_detach(host);
-       return 0;
  }
  EXPORT_SYMBOL_GPL(ata_platform_remove_one);
  
diff --combined drivers/ata/libata-eh.c
index 6f8d141915939441dafd1a9852e2172da128cadf,b80e68000dd3c11cd6dd216130590f103610a137..b3b526411f363ea7169119e38fd3b2f3e8a7c114
@@@ -1817,9 -1817,7 +1817,7 @@@ static unsigned int ata_eh_speed_down(s
        verdict = ata_eh_speed_down_verdict(dev);
  
        /* turn off NCQ? */
-       if ((verdict & ATA_EH_SPDN_NCQ_OFF) &&
-           (dev->flags & (ATA_DFLAG_PIO | ATA_DFLAG_NCQ |
-                          ATA_DFLAG_NCQ_OFF)) == ATA_DFLAG_NCQ) {
+       if ((verdict & ATA_EH_SPDN_NCQ_OFF) && ata_ncq_enabled(dev)) {
                dev->flags |= ATA_DFLAG_NCQ_OFF;
                ata_dev_warn(dev, "NCQ disabled due to excessive errors\n");
                goto done;
@@@ -2984,7 -2982,7 +2982,7 @@@ static int ata_eh_revalidate_and_attach
                        ehc->i.flags |= ATA_EHI_SETMODE;
  
                        /* schedule the scsi_rescan_device() here */
 -                      schedule_work(&(ap->scsi_rescan_task));
 +                      schedule_delayed_work(&ap->scsi_rescan_task, 0);
                } else if (dev->class == ATA_DEV_UNKNOWN &&
                           ehc->tries[dev->devno] &&
                           ata_class_enabled(ehc->classes[dev->devno])) {
@@@ -3813,16 -3811,29 +3811,29 @@@ void ata_eh_finish(struct ata_port *ap
                         * generate sense data in this function,
                         * considering both err_mask and tf.
                         */
-                       if (qc->flags & ATA_QCFLAG_RETRY)
+                       if (qc->flags & ATA_QCFLAG_RETRY) {
+                               /*
+                                * Since qc->err_mask is set, ata_eh_qc_retry()
+                                * will not increment scmd->allowed, so upper
+                                * layer will only retry the command if it has
+                                * not already been retried too many times.
+                                */
                                ata_eh_qc_retry(qc);
-                       else
+                       } else {
                                ata_eh_qc_complete(qc);
+                       }
                } else {
                        if (qc->flags & ATA_QCFLAG_SENSE_VALID) {
                                ata_eh_qc_complete(qc);
                        } else {
                                /* feed zero TF to sense generation */
                                memset(&qc->result_tf, 0, sizeof(qc->result_tf));
+                               /*
+                                * Since qc->err_mask is not set,
+                                * ata_eh_qc_retry() will increment
+                                * scmd->allowed, so upper layer is guaranteed
+                                * to retry the command.
+                                */
                                ata_eh_qc_retry(qc);
                        }
                }
index 551077cea4e4e023e20e913e37ee7b939488083a,9e79998e3958103401cff926ec30b98adfe45135..4a5555cd8b6b9940ee6d9506c90a89d6c4fd3616
@@@ -1122,7 -1122,7 +1122,7 @@@ int ata_scsi_dev_config(struct scsi_dev
        if (dev->flags & ATA_DFLAG_AN)
                set_bit(SDEV_EVT_MEDIA_CHANGE, sdev->supported_events);
  
-       if (dev->flags & ATA_DFLAG_NCQ)
+       if (ata_ncq_supported(dev))
                depth = min(sdev->host->can_queue, ata_id_queue_depth(dev->id));
        depth = min(ATA_MAX_QUEUE, depth);
        scsi_change_queue_depth(sdev, depth);
@@@ -2694,36 -2694,18 +2694,36 @@@ static unsigned int atapi_xlat(struct a
        return 0;
  }
  
 -static struct ata_device *ata_find_dev(struct ata_port *ap, int devno)
 +static struct ata_device *ata_find_dev(struct ata_port *ap, unsigned int devno)
  {
 -      if (!sata_pmp_attached(ap)) {
 -              if (likely(devno >= 0 &&
 -                         devno < ata_link_max_devices(&ap->link)))
 +      /*
 +       * For the non-PMP case, ata_link_max_devices() returns 1 (SATA case),
 +       * or 2 (IDE master + slave case). However, the former case includes
 +       * libsas hosted devices which are numbered per scsi host, leading
 +       * to devno potentially being larger than 0 but with each struct
 +       * ata_device having its own struct ata_port and struct ata_link.
 +       * To accommodate these, ignore devno and always use device number 0.
 +       */
 +      if (likely(!sata_pmp_attached(ap))) {
 +              int link_max_devices = ata_link_max_devices(&ap->link);
 +
 +              if (link_max_devices == 1)
 +                      return &ap->link.device[0];
 +
 +              if (devno < link_max_devices)
                        return &ap->link.device[devno];
 -      } else {
 -              if (likely(devno >= 0 &&
 -                         devno < ap->nr_pmp_links))
 -                      return &ap->pmp_link[devno].device[0];
 +
 +              return NULL;
        }
  
 +      /*
 +       * For PMP-attached devices, the device number corresponds to C
 +       * (channel) of SCSI [H:C:I:L], indicating the port pmp link
 +       * for the device.
 +       */
 +      if (devno < ap->nr_pmp_links)
 +              return &ap->pmp_link[devno].device[0];
 +
        return NULL;
  }
  
@@@ -4597,11 -4579,10 +4597,11 @@@ int ata_scsi_user_scan(struct Scsi_Hos
  void ata_scsi_dev_rescan(struct work_struct *work)
  {
        struct ata_port *ap =
 -              container_of(work, struct ata_port, scsi_rescan_task);
 +              container_of(work, struct ata_port, scsi_rescan_task.work);
        struct ata_link *link;
        struct ata_device *dev;
        unsigned long flags;
 +      bool delay_rescan = false;
  
        mutex_lock(&ap->scsi_scan_mutex);
        spin_lock_irqsave(ap->lock, flags);
                        if (scsi_device_get(sdev))
                                continue;
  
 +                      /*
 +                       * If the rescan work was scheduled because of a resume
 +                       * event, the port is already fully resumed, but the
 +                       * SCSI device may not yet be fully resumed. In such
 +                       * case, executing scsi_rescan_device() may cause a
 +                       * deadlock with the PM code on device_lock(). Prevent
 +                       * this by giving up and retrying rescan after a short
 +                       * delay.
 +                       */
 +                      delay_rescan = sdev->sdev_gendev.power.is_suspended;
 +                      if (delay_rescan) {
 +                              scsi_device_put(sdev);
 +                              break;
 +                      }
 +
                        spin_unlock_irqrestore(ap->lock, flags);
                        scsi_rescan_device(&(sdev->sdev_gendev));
                        scsi_device_put(sdev);
  
        spin_unlock_irqrestore(ap->lock, flags);
        mutex_unlock(&ap->scsi_scan_mutex);
 +
 +      if (delay_rescan)
 +              schedule_delayed_work(&ap->scsi_rescan_task,
 +                                    msecs_to_jiffies(5));
  }
diff --combined include/linux/libata.h
index dd5797fb6305cb29b3edff708215b0459a7516b2,bc756f8586f360abab00de2692feaaaa1591eea4..b19c6028221dd8dfddedd05163d2f1e8d1648ace
@@@ -836,7 -836,7 +836,7 @@@ struct ata_port 
  
        struct mutex            scsi_scan_mutex;
        struct delayed_work     hotplug_task;
 -      struct work_struct      scsi_rescan_task;
 +      struct delayed_work     scsi_rescan_task;
  
        unsigned int            hsm_task_state;
  
@@@ -1144,8 -1144,8 +1144,8 @@@ extern int ata_scsi_slave_config(struc
  extern void ata_scsi_slave_destroy(struct scsi_device *sdev);
  extern int ata_scsi_change_queue_depth(struct scsi_device *sdev,
                                       int queue_depth);
- extern int ata_change_queue_depth(struct ata_port *ap, struct ata_device *dev,
-                                 struct scsi_device *sdev, int queue_depth);
+ extern int ata_change_queue_depth(struct ata_port *ap, struct scsi_device *sdev,
+                                 int queue_depth);
  extern struct ata_device *ata_dev_pair(struct ata_device *adev);
  extern int ata_do_set_mode(struct ata_link *link, struct ata_device **r_failed_dev);
  extern void ata_scsi_port_error_handler(struct Scsi_Host *host, struct ata_port *ap);
@@@ -1276,7 -1276,7 +1276,7 @@@ extern int ata_pci_device_resume(struc
  
  struct platform_device;
  
- extern int ata_platform_remove_one(struct platform_device *pdev);
+ extern void ata_platform_remove_one(struct platform_device *pdev);
  
  /*
   * ACPI - drivers/ata/libata-acpi.c
This page took 0.107926 seconds and 4 git commands to generate.