Skip to content

Commit 15964ff

Browse files
bzolnieraxboe
authored andcommitted
ata: move ata_sas_*() to libata-sata.c
* un-inline: - ata_scsi_dump_cdb() - __ata_scsi_queuecmd() * un-static: - ata_scsi_sdev_config() - ata_scsi_dev_config() - ata_scsi_dump_cdb() - __ata_scsi_queuecmd() * move ata_sas_*() to libata-sata.c: * add static inlines for CONFIG_SATA_HOST=n case for ata_sas_{allocate,free}_tag() Code size savings on m68k arch using (modified) atari_defconfig: text data bss dec hex filename before: 19137 23 576 19736 4d18 drivers/ata/libata-scsi.o after: 18330 23 576 18929 49f1 drivers/ata/libata-scsi.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 ec811a9 commit 15964ff

4 files changed

Lines changed: 245 additions & 233 deletions

File tree

‎drivers/ata/libata-sata.c‎

Lines changed: 213 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@
88

99
#include <linux/kernel.h>
1010
#include <linux/module.h>
11+
#include <scsi/scsi_cmnd.h>
1112
#include <scsi/scsi_device.h>
1213
#include <linux/libata.h>
1314

1415
#include "libata.h"
16+
#include "libata-transport.h"
1517

1618
/* debounce timing parameters in msecs { interval, duration, timeout } */
1719
const unsigned long sata_deb_timing_normal[] = { 5, 100, 2000 };
@@ -1062,3 +1064,214 @@ int ata_scsi_change_queue_depth(struct scsi_device *sdev, int queue_depth)
10621064
return __ata_change_queue_depth(ap, sdev, queue_depth);
10631065
}
10641066
EXPORT_SYMBOL_GPL(ata_scsi_change_queue_depth);
1067+
1068+
/**
1069+
* port_alloc - Allocate port for a SAS attached SATA device
1070+
* @host: ATA host container for all SAS ports
1071+
* @port_info: Information from low-level host driver
1072+
* @shost: SCSI host that the scsi device is attached to
1073+
*
1074+
* LOCKING:
1075+
* PCI/etc. bus probe sem.
1076+
*
1077+
* RETURNS:
1078+
* ata_port pointer on success / NULL on failure.
1079+
*/
1080+
1081+
struct ata_port *ata_sas_port_alloc(struct ata_host *host,
1082+
struct ata_port_info *port_info,
1083+
struct Scsi_Host *shost)
1084+
{
1085+
struct ata_port *ap;
1086+
1087+
ap = ata_port_alloc(host);
1088+
if (!ap)
1089+
return NULL;
1090+
1091+
ap->port_no = 0;
1092+
ap->lock = &host->lock;
1093+
ap->pio_mask = port_info->pio_mask;
1094+
ap->mwdma_mask = port_info->mwdma_mask;
1095+
ap->udma_mask = port_info->udma_mask;
1096+
ap->flags |= port_info->flags;
1097+
ap->ops = port_info->port_ops;
1098+
ap->cbl = ATA_CBL_SATA;
1099+
1100+
return ap;
1101+
}
1102+
EXPORT_SYMBOL_GPL(ata_sas_port_alloc);
1103+
1104+
/**
1105+
* ata_sas_port_start - Set port up for dma.
1106+
* @ap: Port to initialize
1107+
*
1108+
* Called just after data structures for each port are
1109+
* initialized.
1110+
*
1111+
* May be used as the port_start() entry in ata_port_operations.
1112+
*
1113+
* LOCKING:
1114+
* Inherited from caller.
1115+
*/
1116+
int ata_sas_port_start(struct ata_port *ap)
1117+
{
1118+
/*
1119+
* the port is marked as frozen at allocation time, but if we don't
1120+
* have new eh, we won't thaw it
1121+
*/
1122+
if (!ap->ops->error_handler)
1123+
ap->pflags &= ~ATA_PFLAG_FROZEN;
1124+
return 0;
1125+
}
1126+
EXPORT_SYMBOL_GPL(ata_sas_port_start);
1127+
1128+
/**
1129+
* ata_port_stop - Undo ata_sas_port_start()
1130+
* @ap: Port to shut down
1131+
*
1132+
* May be used as the port_stop() entry in ata_port_operations.
1133+
*
1134+
* LOCKING:
1135+
* Inherited from caller.
1136+
*/
1137+
1138+
void ata_sas_port_stop(struct ata_port *ap)
1139+
{
1140+
}
1141+
EXPORT_SYMBOL_GPL(ata_sas_port_stop);
1142+
1143+
/**
1144+
* ata_sas_async_probe - simply schedule probing and return
1145+
* @ap: Port to probe
1146+
*
1147+
* For batch scheduling of probe for sas attached ata devices, assumes
1148+
* the port has already been through ata_sas_port_init()
1149+
*/
1150+
void ata_sas_async_probe(struct ata_port *ap)
1151+
{
1152+
__ata_port_probe(ap);
1153+
}
1154+
EXPORT_SYMBOL_GPL(ata_sas_async_probe);
1155+
1156+
int ata_sas_sync_probe(struct ata_port *ap)
1157+
{
1158+
return ata_port_probe(ap);
1159+
}
1160+
EXPORT_SYMBOL_GPL(ata_sas_sync_probe);
1161+
1162+
1163+
/**
1164+
* ata_sas_port_init - Initialize a SATA device
1165+
* @ap: SATA port to initialize
1166+
*
1167+
* LOCKING:
1168+
* PCI/etc. bus probe sem.
1169+
*
1170+
* RETURNS:
1171+
* Zero on success, non-zero on error.
1172+
*/
1173+
1174+
int ata_sas_port_init(struct ata_port *ap)
1175+
{
1176+
int rc = ap->ops->port_start(ap);
1177+
1178+
if (rc)
1179+
return rc;
1180+
ap->print_id = atomic_inc_return(&ata_print_id);
1181+
return 0;
1182+
}
1183+
EXPORT_SYMBOL_GPL(ata_sas_port_init);
1184+
1185+
int ata_sas_tport_add(struct device *parent, struct ata_port *ap)
1186+
{
1187+
return ata_tport_add(parent, ap);
1188+
}
1189+
EXPORT_SYMBOL_GPL(ata_sas_tport_add);
1190+
1191+
void ata_sas_tport_delete(struct ata_port *ap)
1192+
{
1193+
ata_tport_delete(ap);
1194+
}
1195+
EXPORT_SYMBOL_GPL(ata_sas_tport_delete);
1196+
1197+
/**
1198+
* ata_sas_port_destroy - Destroy a SATA port allocated by ata_sas_port_alloc
1199+
* @ap: SATA port to destroy
1200+
*
1201+
*/
1202+
1203+
void ata_sas_port_destroy(struct ata_port *ap)
1204+
{
1205+
if (ap->ops->port_stop)
1206+
ap->ops->port_stop(ap);
1207+
kfree(ap);
1208+
}
1209+
EXPORT_SYMBOL_GPL(ata_sas_port_destroy);
1210+
1211+
/**
1212+
* ata_sas_slave_configure - Default slave_config routine for libata devices
1213+
* @sdev: SCSI device to configure
1214+
* @ap: ATA port to which SCSI device is attached
1215+
*
1216+
* RETURNS:
1217+
* Zero.
1218+
*/
1219+
1220+
int ata_sas_slave_configure(struct scsi_device *sdev, struct ata_port *ap)
1221+
{
1222+
ata_scsi_sdev_config(sdev);
1223+
ata_scsi_dev_config(sdev, ap->link.device);
1224+
return 0;
1225+
}
1226+
EXPORT_SYMBOL_GPL(ata_sas_slave_configure);
1227+
1228+
/**
1229+
* ata_sas_queuecmd - Issue SCSI cdb to libata-managed device
1230+
* @cmd: SCSI command to be sent
1231+
* @ap: ATA port to which the command is being sent
1232+
*
1233+
* RETURNS:
1234+
* Return value from __ata_scsi_queuecmd() if @cmd can be queued,
1235+
* 0 otherwise.
1236+
*/
1237+
1238+
int ata_sas_queuecmd(struct scsi_cmnd *cmd, struct ata_port *ap)
1239+
{
1240+
int rc = 0;
1241+
1242+
ata_scsi_dump_cdb(ap, cmd);
1243+
1244+
if (likely(ata_dev_enabled(ap->link.device)))
1245+
rc = __ata_scsi_queuecmd(cmd, ap->link.device);
1246+
else {
1247+
cmd->result = (DID_BAD_TARGET << 16);
1248+
cmd->scsi_done(cmd);
1249+
}
1250+
return rc;
1251+
}
1252+
EXPORT_SYMBOL_GPL(ata_sas_queuecmd);
1253+
1254+
int ata_sas_allocate_tag(struct ata_port *ap)
1255+
{
1256+
unsigned int max_queue = ap->host->n_tags;
1257+
unsigned int i, tag;
1258+
1259+
for (i = 0, tag = ap->sas_last_tag + 1; i < max_queue; i++, tag++) {
1260+
tag = tag < max_queue ? tag : 0;
1261+
1262+
/* the last tag is reserved for internal command. */
1263+
if (ata_tag_internal(tag))
1264+
continue;
1265+
1266+
if (!test_and_set_bit(tag, &ap->sas_tag_allocated)) {
1267+
ap->sas_last_tag = tag;
1268+
return tag;
1269+
}
1270+
}
1271+
return -1;
1272+
}
1273+
1274+
void ata_sas_free_tag(unsigned int tag, struct ata_port *ap)
1275+
{
1276+
clear_bit(tag, &ap->sas_tag_allocated);
1277+
}

0 commit comments

Comments
 (0)