libata-core: Allow longer timeout for drive spinup from PUIS

When spinning up a drive from powered on standby mode (PUIS),
SETFEATURES_SPINUP is executed with the default timeout used
for any SETFEATURES subcommand, that is 5+10 seconds. The
total 15s is too short for some drives to complete spinup
(e.g. drives with a large indirection table stored on media),
resulting in ata_dev_read_id to fail twice on the execution
of SETFEATURES_SPINUP. For this feature, allow a larger
default timeout of 30 seconds. However, in the same spirit
as with the timeout of other feature subcommands, do not
ignore ata_probe_timeout if it is set).

Signed-off-by: Damien Le Moal <damien.lemoal@hgst.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 55e257c..7b21021 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -4528,6 +4528,7 @@
 {
 	struct ata_taskfile tf;
 	unsigned int err_mask;
+	unsigned long timeout = 0;
 
 	/* set up set-features taskfile */
 	DPRINTK("set features - SATA features\n");
@@ -4539,7 +4540,10 @@
 	tf.protocol = ATA_PROT_NODATA;
 	tf.nsect = feature;
 
-	err_mask = ata_exec_internal(dev, &tf, NULL, DMA_NONE, NULL, 0, 0);
+	if (enable == SETFEATURES_SPINUP)
+		timeout = ata_probe_timeout ?
+			  ata_probe_timeout * 1000 : SETFEATURES_SPINUP_TIMEOUT;
+	err_mask = ata_exec_internal(dev, &tf, NULL, DMA_NONE, NULL, 0, timeout);
 
 	DPRINTK("EXIT, err_mask=%x\n", err_mask);
 	return err_mask;