Skip to content

Commit 5f8319c

Browse files
committed
ata: libata: Introduce ata_dev_free_resources
Introduce the function ata_dev_free_resources() to free the resources allocated to support a device features. For now, this function is reduced to calling zpodd_exit() for devices that have this feature enabled. ata_dev_free_resources() is called from ata_eh_dev_disable() as this function is always called for all devices attached to a port that is being detached and for devices that are being disabled due to being removed (detached) from the system or due to errors. With this change, the call to zpodd_exit() done in ata_port_detach() and ata_scsi_handle_link_detach() are removed as these functions remove all devices attached to the link or port using libata EH, thus resulting in ata_eh_dev_disable() being called and the zpodd_exit() function being executed. Signed-off-by: Damien Le Moal <[email protected]> Reviewed-by: Niklas Cassel <[email protected]>
1 parent da65bbd commit 5f8319c

File tree

4 files changed

+24
-12
lines changed

4 files changed

+24
-12
lines changed

drivers/ata/libata-core.c

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5976,6 +5976,21 @@ int ata_host_activate(struct ata_host *host, int irq,
59765976
}
59775977
EXPORT_SYMBOL_GPL(ata_host_activate);
59785978

5979+
/**
5980+
* ata_dev_free_resources - Free a device resources
5981+
* @dev: Target ATA device
5982+
*
5983+
* Free resources allocated to support a device features.
5984+
*
5985+
* LOCKING:
5986+
* Kernel thread context (may sleep).
5987+
*/
5988+
void ata_dev_free_resources(struct ata_device *dev)
5989+
{
5990+
if (zpodd_dev_enabled(dev))
5991+
zpodd_exit(dev);
5992+
}
5993+
59795994
/**
59805995
* ata_port_detach - Detach ATA port in preparation of device removal
59815996
* @ap: ATA port to be detached
@@ -6030,19 +6045,15 @@ static void ata_port_detach(struct ata_port *ap)
60306045
cancel_delayed_work_sync(&ap->hotplug_task);
60316046
cancel_delayed_work_sync(&ap->scsi_rescan_task);
60326047

6033-
/* clean up zpodd on port removal */
6034-
ata_for_each_link(link, ap, HOST_FIRST) {
6035-
ata_for_each_dev(dev, link, ALL) {
6036-
if (zpodd_dev_enabled(dev))
6037-
zpodd_exit(dev);
6038-
}
6039-
}
6048+
/* Delete port multiplier link transport devices */
60406049
if (ap->pmp_link) {
60416050
int i;
6051+
60426052
for (i = 0; i < SATA_PMP_MAX_PORTS; i++)
60436053
ata_tlink_delete(&ap->pmp_link[i]);
60446054
}
6045-
/* remove the associated SCSI host */
6055+
6056+
/* Remove the associated SCSI host */
60466057
scsi_remove_host(ap->scsi_host);
60476058
ata_tport_delete(ap);
60486059
}

drivers/ata/libata-eh.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,10 +500,13 @@ static void ata_eh_dev_disable(struct ata_device *dev)
500500
ata_down_xfermask_limit(dev, ATA_DNXFER_FORCE_PIO0 | ATA_DNXFER_QUIET);
501501
dev->class++;
502502

503-
/* From now till the next successful probe, ering is used to
503+
/*
504+
* From now till the next successful probe, ering is used to
504505
* track probe failures. Clear accumulated device error info.
505506
*/
506507
ata_ering_clear(&dev->ering);
508+
509+
ata_dev_free_resources(dev);
507510
}
508511

509512
static void ata_eh_unload(struct ata_port *ap)

drivers/ata/libata-scsi.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4614,9 +4614,6 @@ static void ata_scsi_handle_link_detach(struct ata_link *link)
46144614
dev->flags &= ~ATA_DFLAG_DETACHED;
46154615
spin_unlock_irqrestore(ap->lock, flags);
46164616

4617-
if (zpodd_dev_enabled(dev))
4618-
zpodd_exit(dev);
4619-
46204617
ata_scsi_remove_dev(dev);
46214618
}
46224619
}

drivers/ata/libata.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ extern bool ata_dev_power_init_tf(struct ata_device *dev,
7171
struct ata_taskfile *tf, bool set_active);
7272
extern void ata_dev_power_set_standby(struct ata_device *dev);
7373
extern void ata_dev_power_set_active(struct ata_device *dev);
74+
void ata_dev_free_resources(struct ata_device *dev);
7475
extern int ata_down_xfermask_limit(struct ata_device *dev, unsigned int sel);
7576
extern unsigned int ata_dev_set_feature(struct ata_device *dev,
7677
u8 subcmd, u8 action);

0 commit comments

Comments
 (0)