]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
ata: start separating SATA specific code from libata-eh.c
authorBartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Thu, 26 Mar 2020 15:58:20 +0000 (16:58 +0100)
committerJens Axboe <axboe@kernel.dk>
Thu, 26 Mar 2020 16:28:20 +0000 (10:28 -0600)
Start separating SATA specific code from libata-eh.c:

* move sata_async_notification() to libata-sata.c:

Code size savings on m68k arch using (modified) atari_defconfig:

   text    data     bss     dec     hex filename
before:
  16243      18       0   16261    3f85 drivers/ata/libata-eh.o
after:
  16164      18       0   16182    3f36 drivers/ata/libata-eh.o

Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/ata/libata-eh.c
drivers/ata/libata-sata.c
include/linux/libata.h

index 8dc33b6832f0db01a784d015265dc8ab71656829..ef4d606cd8c6bfc7e8d8b151e5c0f761d86fa1df 100644 (file)
@@ -1092,80 +1092,6 @@ int ata_port_freeze(struct ata_port *ap)
 }
 EXPORT_SYMBOL_GPL(ata_port_freeze);
 
-/**
- *     sata_async_notification - SATA async notification handler
- *     @ap: ATA port where async notification is received
- *
- *     Handler to be called when async notification via SDB FIS is
- *     received.  This function schedules EH if necessary.
- *
- *     LOCKING:
- *     spin_lock_irqsave(host lock)
- *
- *     RETURNS:
- *     1 if EH is scheduled, 0 otherwise.
- */
-int sata_async_notification(struct ata_port *ap)
-{
-       u32 sntf;
-       int rc;
-
-       if (!(ap->flags & ATA_FLAG_AN))
-               return 0;
-
-       rc = sata_scr_read(&ap->link, SCR_NOTIFICATION, &sntf);
-       if (rc == 0)
-               sata_scr_write(&ap->link, SCR_NOTIFICATION, sntf);
-
-       if (!sata_pmp_attached(ap) || rc) {
-               /* PMP is not attached or SNTF is not available */
-               if (!sata_pmp_attached(ap)) {
-                       /* PMP is not attached.  Check whether ATAPI
-                        * AN is configured.  If so, notify media
-                        * change.
-                        */
-                       struct ata_device *dev = ap->link.device;
-
-                       if ((dev->class == ATA_DEV_ATAPI) &&
-                           (dev->flags & ATA_DFLAG_AN))
-                               ata_scsi_media_change_notify(dev);
-                       return 0;
-               } else {
-                       /* PMP is attached but SNTF is not available.
-                        * ATAPI async media change notification is
-                        * not used.  The PMP must be reporting PHY
-                        * status change, schedule EH.
-                        */
-                       ata_port_schedule_eh(ap);
-                       return 1;
-               }
-       } else {
-               /* PMP is attached and SNTF is available */
-               struct ata_link *link;
-
-               /* check and notify ATAPI AN */
-               ata_for_each_link(link, ap, EDGE) {
-                       if (!(sntf & (1 << link->pmp)))
-                               continue;
-
-                       if ((link->device->class == ATA_DEV_ATAPI) &&
-                           (link->device->flags & ATA_DFLAG_AN))
-                               ata_scsi_media_change_notify(link->device);
-               }
-
-               /* If PMP is reporting that PHY status of some
-                * downstream ports has changed, schedule EH.
-                */
-               if (sntf & (1 << SATA_PMP_CTRL_PORT)) {
-                       ata_port_schedule_eh(ap);
-                       return 1;
-               }
-
-               return 0;
-       }
-}
-EXPORT_SYMBOL_GPL(sata_async_notification);
-
 /**
  *     ata_eh_freeze_port - EH helper to freeze port
  *     @ap: ATA port to freeze
index 2d934ccfc9305aaea59d5719fd0a9394c3785227..008468e516cdde64c412c5590a7ffcb469107e91 100644 (file)
@@ -4,6 +4,7 @@
  *
  *  Copyright 2003-2004 Red Hat, Inc.  All rights reserved.
  *  Copyright 2003-2004 Jeff Garzik
+ *  Copyright 2006 Tejun Heo <htejun@gmail.com>
  */
 
 #include <linux/kernel.h>
@@ -1275,3 +1276,77 @@ void ata_sas_free_tag(unsigned int tag, struct ata_port *ap)
 {
        clear_bit(tag, &ap->sas_tag_allocated);
 }
+
+/**
+ *     sata_async_notification - SATA async notification handler
+ *     @ap: ATA port where async notification is received
+ *
+ *     Handler to be called when async notification via SDB FIS is
+ *     received.  This function schedules EH if necessary.
+ *
+ *     LOCKING:
+ *     spin_lock_irqsave(host lock)
+ *
+ *     RETURNS:
+ *     1 if EH is scheduled, 0 otherwise.
+ */
+int sata_async_notification(struct ata_port *ap)
+{
+       u32 sntf;
+       int rc;
+
+       if (!(ap->flags & ATA_FLAG_AN))
+               return 0;
+
+       rc = sata_scr_read(&ap->link, SCR_NOTIFICATION, &sntf);
+       if (rc == 0)
+               sata_scr_write(&ap->link, SCR_NOTIFICATION, sntf);
+
+       if (!sata_pmp_attached(ap) || rc) {
+               /* PMP is not attached or SNTF is not available */
+               if (!sata_pmp_attached(ap)) {
+                       /* PMP is not attached.  Check whether ATAPI
+                        * AN is configured.  If so, notify media
+                        * change.
+                        */
+                       struct ata_device *dev = ap->link.device;
+
+                       if ((dev->class == ATA_DEV_ATAPI) &&
+                           (dev->flags & ATA_DFLAG_AN))
+                               ata_scsi_media_change_notify(dev);
+                       return 0;
+               } else {
+                       /* PMP is attached but SNTF is not available.
+                        * ATAPI async media change notification is
+                        * not used.  The PMP must be reporting PHY
+                        * status change, schedule EH.
+                        */
+                       ata_port_schedule_eh(ap);
+                       return 1;
+               }
+       } else {
+               /* PMP is attached and SNTF is available */
+               struct ata_link *link;
+
+               /* check and notify ATAPI AN */
+               ata_for_each_link(link, ap, EDGE) {
+                       if (!(sntf & (1 << link->pmp)))
+                               continue;
+
+                       if ((link->device->class == ATA_DEV_ATAPI) &&
+                           (link->device->flags & ATA_DFLAG_AN))
+                               ata_scsi_media_change_notify(link->device);
+               }
+
+               /* If PMP is reporting that PHY status of some
+                * downstream ports has changed, schedule EH.
+                */
+               if (sntf & (1 << SATA_PMP_CTRL_PORT)) {
+                       ata_port_schedule_eh(ap);
+                       return 1;
+               }
+
+               return 0;
+       }
+}
+EXPORT_SYMBOL_GPL(sata_async_notification);
index da899f18a3e91eee7c6da25bd307e46cb2aa70b5..9c7ca659dc947a9b70d52480481bb54c64782523 100644 (file)
@@ -1240,6 +1240,7 @@ extern void ata_tf_to_fis(const struct ata_taskfile *tf,
 extern void ata_tf_from_fis(const u8 *fis, struct ata_taskfile *tf);
 extern int ata_qc_complete_multiple(struct ata_port *ap, u64 qc_active);
 extern bool sata_lpm_ignore_phy_events(struct ata_link *link);
+extern int sata_async_notification(struct ata_port *ap);
 
 extern int ata_cable_40wire(struct ata_port *ap);
 extern int ata_cable_80wire(struct ata_port *ap);
@@ -1332,7 +1333,6 @@ extern void ata_port_wait_eh(struct ata_port *ap);
 extern int ata_link_abort(struct ata_link *link);
 extern int ata_port_abort(struct ata_port *ap);
 extern int ata_port_freeze(struct ata_port *ap);
-extern int sata_async_notification(struct ata_port *ap);
 
 extern void ata_eh_freeze_port(struct ata_port *ap);
 extern void ata_eh_thaw_port(struct ata_port *ap);