Skip to content

Commit 28361c4

Browse files
axboehtejun
authored andcommitted
libata: add extra internal command
Bump the internal tag to 32, instead of stealing the last tag in our regular command space. This works just fine, since we don't actually need a separate hardware tag for this. Internal commands cannot coexist with NCQ commands. As a bonus, we get rid of the special casing of what tag to use for the internal command. This is in preparation for utilizing all 32 commands for normal IO. Signed-off-by: Jens Axboe <axboe@kernel.dk> Signed-off-by: Tejun Heo <tj@kernel.org>
1 parent ba80c3a commit 28361c4

File tree

3 files changed

+15
-25
lines changed

3 files changed

+15
-25
lines changed

drivers/ata/libata-core.c

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1570,7 +1570,7 @@ unsigned ata_exec_internal_sg(struct ata_device *dev,
15701570
u8 command = tf->command;
15711571
int auto_timeout = 0;
15721572
struct ata_queued_cmd *qc;
1573-
unsigned int tag, preempted_tag;
1573+
unsigned int preempted_tag;
15741574
u32 preempted_sactive;
15751575
u64 preempted_qc_active;
15761576
int preempted_nr_active_links;
@@ -1588,20 +1588,10 @@ unsigned ata_exec_internal_sg(struct ata_device *dev,
15881588
}
15891589

15901590
/* initialize internal qc */
1591+
qc = __ata_qc_from_tag(ap, ATA_TAG_INTERNAL);
15911592

1592-
/* XXX: Tag 0 is used for drivers with legacy EH as some
1593-
* drivers choke if any other tag is given. This breaks
1594-
* ata_tag_internal() test for those drivers. Don't use new
1595-
* EH stuff without converting to it.
1596-
*/
1597-
if (ap->ops->error_handler)
1598-
tag = ATA_TAG_INTERNAL;
1599-
else
1600-
tag = 0;
1601-
1602-
qc = __ata_qc_from_tag(ap, tag);
1603-
1604-
qc->tag = qc->hw_tag = tag;
1593+
qc->tag = ATA_TAG_INTERNAL;
1594+
qc->hw_tag = 0;
16051595
qc->scsicmd = NULL;
16061596
qc->ap = ap;
16071597
qc->dev = dev;
@@ -5156,7 +5146,7 @@ void ata_qc_free(struct ata_queued_cmd *qc)
51565146

51575147
qc->flags = 0;
51585148
tag = qc->tag;
5159-
if (likely(ata_tag_valid(tag))) {
5149+
if (ata_tag_valid(tag)) {
51605150
qc->tag = ATA_TAG_POISON;
51615151
if (ap->flags & ATA_FLAG_SAS_HOST)
51625152
ata_sas_free_tag(tag, ap);
@@ -5415,7 +5405,7 @@ void ata_qc_issue(struct ata_queued_cmd *qc)
54155405
WARN_ON_ONCE(link->sactive);
54165406

54175407
ap->nr_active_links++;
5418-
link->active_tag = qc->hw_tag;
5408+
link->active_tag = qc->tag;
54195409
}
54205410

54215411
qc->flags |= ATA_QCFLAG_ACTIVE;

drivers/ata/libata-eh.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1057,7 +1057,8 @@ static int ata_do_link_abort(struct ata_port *ap, struct ata_link *link)
10571057
/* we're gonna abort all commands, no need for fast drain */
10581058
ata_eh_set_pending(ap, 0);
10591059

1060-
for (tag = 0; tag < ATA_MAX_QUEUE; tag++) {
1060+
/* include internal tag in iteration */
1061+
for (tag = 0; tag <= ATA_MAX_QUEUE; tag++) {
10611062
struct ata_queued_cmd *qc = ata_qc_from_tag(ap, tag);
10621063

10631064
if (qc && (!link || qc->dev->link == link)) {

include/linux/libata.h

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,8 @@ enum {
125125
LIBATA_MAX_PRD = ATA_MAX_PRD / 2,
126126
LIBATA_DUMB_MAX_PRD = ATA_MAX_PRD / 4, /* Worst case */
127127
ATA_DEF_QUEUE = 1,
128-
/* tag ATA_MAX_QUEUE - 1 is reserved for internal commands */
129128
ATA_MAX_QUEUE = 32,
130-
ATA_TAG_INTERNAL = ATA_MAX_QUEUE - 1,
129+
ATA_TAG_INTERNAL = ATA_MAX_QUEUE,
131130
ATA_SHORT_PAUSE = 16,
132131

133132
ATAPI_MAX_DRAIN = 16 << 10,
@@ -850,7 +849,7 @@ struct ata_port {
850849
unsigned int udma_mask;
851850
unsigned int cbl; /* cable type; ATA_CBL_xxx */
852851

853-
struct ata_queued_cmd qcmd[ATA_MAX_QUEUE];
852+
struct ata_queued_cmd qcmd[ATA_MAX_QUEUE + 1];
854853
unsigned long sas_tag_allocated; /* for sas tag allocation only */
855854
u64 qc_active;
856855
int nr_active_links; /* #links with active qcs */
@@ -1486,14 +1485,14 @@ extern void ata_port_pbar_desc(struct ata_port *ap, int bar, ssize_t offset,
14861485
const char *name);
14871486
#endif
14881487

1489-
static inline unsigned int ata_tag_valid(unsigned int tag)
1488+
static inline bool ata_tag_internal(unsigned int tag)
14901489
{
1491-
return (tag < ATA_MAX_QUEUE) ? 1 : 0;
1490+
return tag == ATA_TAG_INTERNAL;
14921491
}
14931492

1494-
static inline bool ata_tag_internal(unsigned int tag)
1493+
static inline bool ata_tag_valid(unsigned int tag)
14951494
{
1496-
return tag == ATA_TAG_INTERNAL;
1495+
return tag < ATA_MAX_QUEUE || ata_tag_internal(tag);
14971496
}
14981497

14991498
/*
@@ -1656,7 +1655,7 @@ static inline void ata_qc_set_polling(struct ata_queued_cmd *qc)
16561655
static inline struct ata_queued_cmd *__ata_qc_from_tag(struct ata_port *ap,
16571656
unsigned int tag)
16581657
{
1659-
if (likely(ata_tag_valid(tag)))
1658+
if (ata_tag_valid(tag))
16601659
return &ap->qcmd[tag];
16611660
return NULL;
16621661
}

0 commit comments

Comments
 (0)