Skip to content

Commit

Permalink
Merge tag 'libata-5.8-2020-06-19' of git://git.kernel.dk/linux-block
Browse files Browse the repository at this point in the history
Pull libata fixes from Jens Axboe:
 "A few minor changes that should go into this release"

* tag 'libata-5.8-2020-06-19' of git://git.kernel.dk/linux-block:
  libata: Use per port sync for detach
  ata/libata: Fix usage of page address by page_address in ata_scsi_mode_select_xlat function
  sata_rcar: handle pm_runtime_get_sync failure cases
  • Loading branch information
torvalds committed Jun 19, 2020
2 parents 62c91ea + b529211 commit 592be75
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 13 deletions.
11 changes: 5 additions & 6 deletions drivers/ata/libata-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
#include <linux/workqueue.h>
#include <linux/scatterlist.h>
#include <linux/io.h>
#include <linux/async.h>
#include <linux/log2.h>
#include <linux/slab.h>
#include <linux/glob.h>
Expand Down Expand Up @@ -5778,7 +5777,7 @@ int ata_host_register(struct ata_host *host, struct scsi_host_template *sht)
/* perform each probe asynchronously */
for (i = 0; i < host->n_ports; i++) {
struct ata_port *ap = host->ports[i];
async_schedule(async_port_probe, ap);
ap->cookie = async_schedule(async_port_probe, ap);
}

return 0;
Expand Down Expand Up @@ -5920,11 +5919,11 @@ void ata_host_detach(struct ata_host *host)
{
int i;

/* Ensure ata_port probe has completed */
async_synchronize_full();

for (i = 0; i < host->n_ports; i++)
for (i = 0; i < host->n_ports; i++) {
/* Ensure ata_port probe has completed */
async_synchronize_cookie(host->ports[i]->cookie + 1);
ata_port_detach(host->ports[i]);
}

/* the host is dead now, dissociate ACPI */
ata_acpi_dissociate(host);
Expand Down
9 changes: 6 additions & 3 deletions drivers/ata/libata-scsi.c
Original file line number Diff line number Diff line change
Expand Up @@ -3684,12 +3684,13 @@ static unsigned int ata_scsi_mode_select_xlat(struct ata_queued_cmd *qc)
{
struct scsi_cmnd *scmd = qc->scsicmd;
const u8 *cdb = scmd->cmnd;
const u8 *p;
u8 pg, spg;
unsigned six_byte, pg_len, hdr_len, bd_len;
int len;
u16 fp = (u16)-1;
u8 bp = 0xff;
u8 buffer[64];
const u8 *p = buffer;

VPRINTK("ENTER\n");

Expand Down Expand Up @@ -3723,12 +3724,14 @@ static unsigned int ata_scsi_mode_select_xlat(struct ata_queued_cmd *qc)
if (!scsi_sg_count(scmd) || scsi_sglist(scmd)->length < len)
goto invalid_param_len;

p = page_address(sg_page(scsi_sglist(scmd)));

/* Move past header and block descriptors. */
if (len < hdr_len)
goto invalid_param_len;

if (!sg_copy_to_buffer(scsi_sglist(scmd), scsi_sg_count(scmd),
buffer, sizeof(buffer)))
goto invalid_param_len;

if (six_byte)
bd_len = p[3];
else
Expand Down
11 changes: 7 additions & 4 deletions drivers/ata/sata_rcar.c
Original file line number Diff line number Diff line change
Expand Up @@ -907,7 +907,7 @@ static int sata_rcar_probe(struct platform_device *pdev)
pm_runtime_enable(dev);
ret = pm_runtime_get_sync(dev);
if (ret < 0)
goto err_pm_disable;
goto err_pm_put;

host = ata_host_alloc(dev, 1);
if (!host) {
Expand Down Expand Up @@ -937,7 +937,6 @@ static int sata_rcar_probe(struct platform_device *pdev)

err_pm_put:
pm_runtime_put(dev);
err_pm_disable:
pm_runtime_disable(dev);
return ret;
}
Expand Down Expand Up @@ -991,8 +990,10 @@ static int sata_rcar_resume(struct device *dev)
int ret;

ret = pm_runtime_get_sync(dev);
if (ret < 0)
if (ret < 0) {
pm_runtime_put(dev);
return ret;
}

if (priv->type == RCAR_GEN3_SATA) {
sata_rcar_init_module(priv);
Expand All @@ -1017,8 +1018,10 @@ static int sata_rcar_restore(struct device *dev)
int ret;

ret = pm_runtime_get_sync(dev);
if (ret < 0)
if (ret < 0) {
pm_runtime_put(dev);
return ret;
}

sata_rcar_setup_port(host);

Expand Down
3 changes: 3 additions & 0 deletions include/linux/libata.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <linux/acpi.h>
#include <linux/cdrom.h>
#include <linux/sched.h>
#include <linux/async.h>

/*
* Define if arch has non-standard setup. This is a _PCI_ standard
Expand Down Expand Up @@ -872,6 +873,8 @@ struct ata_port {
struct timer_list fastdrain_timer;
unsigned long fastdrain_cnt;

async_cookie_t cookie;

int em_message_type;
void *private_data;

Expand Down

0 comments on commit 592be75

Please sign in to comment.