Skip to content

Commit a695de2

Browse files
bzolnieraxboe
authored andcommitted
ata: start separating SATA specific code from libata-eh.c
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>
1 parent 15964ff commit a695de2

3 files changed

Lines changed: 76 additions & 75 deletions

File tree

‎drivers/ata/libata-eh.c‎

Lines changed: 0 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1092,80 +1092,6 @@ int ata_port_freeze(struct ata_port *ap)
10921092
}
10931093
EXPORT_SYMBOL_GPL(ata_port_freeze);
10941094

1095-
/**
1096-
* sata_async_notification - SATA async notification handler
1097-
* @ap: ATA port where async notification is received
1098-
*
1099-
* Handler to be called when async notification via SDB FIS is
1100-
* received. This function schedules EH if necessary.
1101-
*
1102-
* LOCKING:
1103-
* spin_lock_irqsave(host lock)
1104-
*
1105-
* RETURNS:
1106-
* 1 if EH is scheduled, 0 otherwise.
1107-
*/
1108-
int sata_async_notification(struct ata_port *ap)
1109-
{
1110-
u32 sntf;
1111-
int rc;
1112-
1113-
if (!(ap->flags & ATA_FLAG_AN))
1114-
return 0;
1115-
1116-
rc = sata_scr_read(&ap->link, SCR_NOTIFICATION, &sntf);
1117-
if (rc == 0)
1118-
sata_scr_write(&ap->link, SCR_NOTIFICATION, sntf);
1119-
1120-
if (!sata_pmp_attached(ap) || rc) {
1121-
/* PMP is not attached or SNTF is not available */
1122-
if (!sata_pmp_attached(ap)) {
1123-
/* PMP is not attached. Check whether ATAPI
1124-
* AN is configured. If so, notify media
1125-
* change.
1126-
*/
1127-
struct ata_device *dev = ap->link.device;
1128-
1129-
if ((dev->class == ATA_DEV_ATAPI) &&
1130-
(dev->flags & ATA_DFLAG_AN))
1131-
ata_scsi_media_change_notify(dev);
1132-
return 0;
1133-
} else {
1134-
/* PMP is attached but SNTF is not available.
1135-
* ATAPI async media change notification is
1136-
* not used. The PMP must be reporting PHY
1137-
* status change, schedule EH.
1138-
*/
1139-
ata_port_schedule_eh(ap);
1140-
return 1;
1141-
}
1142-
} else {
1143-
/* PMP is attached and SNTF is available */
1144-
struct ata_link *link;
1145-
1146-
/* check and notify ATAPI AN */
1147-
ata_for_each_link(link, ap, EDGE) {
1148-
if (!(sntf & (1 << link->pmp)))
1149-
continue;
1150-
1151-
if ((link->device->class == ATA_DEV_ATAPI) &&
1152-
(link->device->flags & ATA_DFLAG_AN))
1153-
ata_scsi_media_change_notify(link->device);
1154-
}
1155-
1156-
/* If PMP is reporting that PHY status of some
1157-
* downstream ports has changed, schedule EH.
1158-
*/
1159-
if (sntf & (1 << SATA_PMP_CTRL_PORT)) {
1160-
ata_port_schedule_eh(ap);
1161-
return 1;
1162-
}
1163-
1164-
return 0;
1165-
}
1166-
}
1167-
EXPORT_SYMBOL_GPL(sata_async_notification);
1168-
11691095
/**
11701096
* ata_eh_freeze_port - EH helper to freeze port
11711097
* @ap: ATA port to freeze

‎drivers/ata/libata-sata.c‎

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*
55
* Copyright 2003-2004 Red Hat, Inc. All rights reserved.
66
* Copyright 2003-2004 Jeff Garzik
7+
* Copyright 2006 Tejun Heo <htejun@gmail.com>
78
*/
89

910
#include <linux/kernel.h>
@@ -1275,3 +1276,77 @@ void ata_sas_free_tag(unsigned int tag, struct ata_port *ap)
12751276
{
12761277
clear_bit(tag, &ap->sas_tag_allocated);
12771278
}
1279+
1280+
/**
1281+
* sata_async_notification - SATA async notification handler
1282+
* @ap: ATA port where async notification is received
1283+
*
1284+
* Handler to be called when async notification via SDB FIS is
1285+
* received. This function schedules EH if necessary.
1286+
*
1287+
* LOCKING:
1288+
* spin_lock_irqsave(host lock)
1289+
*
1290+
* RETURNS:
1291+
* 1 if EH is scheduled, 0 otherwise.
1292+
*/
1293+
int sata_async_notification(struct ata_port *ap)
1294+
{
1295+
u32 sntf;
1296+
int rc;
1297+
1298+
if (!(ap->flags & ATA_FLAG_AN))
1299+
return 0;
1300+
1301+
rc = sata_scr_read(&ap->link, SCR_NOTIFICATION, &sntf);
1302+
if (rc == 0)
1303+
sata_scr_write(&ap->link, SCR_NOTIFICATION, sntf);
1304+
1305+
if (!sata_pmp_attached(ap) || rc) {
1306+
/* PMP is not attached or SNTF is not available */
1307+
if (!sata_pmp_attached(ap)) {
1308+
/* PMP is not attached. Check whether ATAPI
1309+
* AN is configured. If so, notify media
1310+
* change.
1311+
*/
1312+
struct ata_device *dev = ap->link.device;
1313+
1314+
if ((dev->class == ATA_DEV_ATAPI) &&
1315+
(dev->flags & ATA_DFLAG_AN))
1316+
ata_scsi_media_change_notify(dev);
1317+
return 0;
1318+
} else {
1319+
/* PMP is attached but SNTF is not available.
1320+
* ATAPI async media change notification is
1321+
* not used. The PMP must be reporting PHY
1322+
* status change, schedule EH.
1323+
*/
1324+
ata_port_schedule_eh(ap);
1325+
return 1;
1326+
}
1327+
} else {
1328+
/* PMP is attached and SNTF is available */
1329+
struct ata_link *link;
1330+
1331+
/* check and notify ATAPI AN */
1332+
ata_for_each_link(link, ap, EDGE) {
1333+
if (!(sntf & (1 << link->pmp)))
1334+
continue;
1335+
1336+
if ((link->device->class == ATA_DEV_ATAPI) &&
1337+
(link->device->flags & ATA_DFLAG_AN))
1338+
ata_scsi_media_change_notify(link->device);
1339+
}
1340+
1341+
/* If PMP is reporting that PHY status of some
1342+
* downstream ports has changed, schedule EH.
1343+
*/
1344+
if (sntf & (1 << SATA_PMP_CTRL_PORT)) {
1345+
ata_port_schedule_eh(ap);
1346+
return 1;
1347+
}
1348+
1349+
return 0;
1350+
}
1351+
}
1352+
EXPORT_SYMBOL_GPL(sata_async_notification);

‎include/linux/libata.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1240,6 +1240,7 @@ extern void ata_tf_to_fis(const struct ata_taskfile *tf,
12401240
extern void ata_tf_from_fis(const u8 *fis, struct ata_taskfile *tf);
12411241
extern int ata_qc_complete_multiple(struct ata_port *ap, u64 qc_active);
12421242
extern bool sata_lpm_ignore_phy_events(struct ata_link *link);
1243+
extern int sata_async_notification(struct ata_port *ap);
12431244

12441245
extern int ata_cable_40wire(struct ata_port *ap);
12451246
extern int ata_cable_80wire(struct ata_port *ap);
@@ -1332,7 +1333,6 @@ extern void ata_port_wait_eh(struct ata_port *ap);
13321333
extern int ata_link_abort(struct ata_link *link);
13331334
extern int ata_port_abort(struct ata_port *ap);
13341335
extern int ata_port_freeze(struct ata_port *ap);
1335-
extern int sata_async_notification(struct ata_port *ap);
13361336

13371337
extern void ata_eh_freeze_port(struct ata_port *ap);
13381338
extern void ata_eh_thaw_port(struct ata_port *ap);

0 commit comments

Comments
 (0)