Commit dd08a8d9 authored by raymond pang's avatar raymond pang Committed by Jens Axboe

libata: fix using DMA buffers on stack

When CONFIG_VMAP_STACK=y, __pa() returns incorrect physical address for
a stack virtual address. Stack DMA buffers must be avoided.
Signed-off-by: default avatarraymond pang <raymondpangxd@gmail.com>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 9bf7933f
...@@ -52,38 +52,52 @@ static int eject_tray(struct ata_device *dev) ...@@ -52,38 +52,52 @@ static int eject_tray(struct ata_device *dev)
/* Per the spec, only slot type and drawer type ODD can be supported */ /* Per the spec, only slot type and drawer type ODD can be supported */
static enum odd_mech_type zpodd_get_mech_type(struct ata_device *dev) static enum odd_mech_type zpodd_get_mech_type(struct ata_device *dev)
{ {
char buf[16]; char *buf;
unsigned int ret; unsigned int ret;
struct rm_feature_desc *desc = (void *)(buf + 8); struct rm_feature_desc *desc;
struct ata_taskfile tf; struct ata_taskfile tf;
static const char cdb[] = { GPCMD_GET_CONFIGURATION, static const char cdb[] = { GPCMD_GET_CONFIGURATION,
2, /* only 1 feature descriptor requested */ 2, /* only 1 feature descriptor requested */
0, 3, /* 3, removable medium feature */ 0, 3, /* 3, removable medium feature */
0, 0, 0,/* reserved */ 0, 0, 0,/* reserved */
0, sizeof(buf), 0, 16,
0, 0, 0, 0, 0, 0,
}; };
buf = kzalloc(16, GFP_KERNEL);
if (!buf)
return ODD_MECH_TYPE_UNSUPPORTED;
desc = (void *)(buf + 8);
ata_tf_init(dev, &tf); ata_tf_init(dev, &tf);
tf.flags = ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; tf.flags = ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE;
tf.command = ATA_CMD_PACKET; tf.command = ATA_CMD_PACKET;
tf.protocol = ATAPI_PROT_PIO; tf.protocol = ATAPI_PROT_PIO;
tf.lbam = sizeof(buf); tf.lbam = 16;
ret = ata_exec_internal(dev, &tf, cdb, DMA_FROM_DEVICE, ret = ata_exec_internal(dev, &tf, cdb, DMA_FROM_DEVICE,
buf, sizeof(buf), 0); buf, 16, 0);
if (ret) if (ret) {
kfree(buf);
return ODD_MECH_TYPE_UNSUPPORTED; return ODD_MECH_TYPE_UNSUPPORTED;
}
if (be16_to_cpu(desc->feature_code) != 3) if (be16_to_cpu(desc->feature_code) != 3) {
kfree(buf);
return ODD_MECH_TYPE_UNSUPPORTED; return ODD_MECH_TYPE_UNSUPPORTED;
}
if (desc->mech_type == 0 && desc->load == 0 && desc->eject == 1) if (desc->mech_type == 0 && desc->load == 0 && desc->eject == 1) {
kfree(buf);
return ODD_MECH_TYPE_SLOT; return ODD_MECH_TYPE_SLOT;
else if (desc->mech_type == 1 && desc->load == 0 && desc->eject == 1) } else if (desc->mech_type == 1 && desc->load == 0 &&
desc->eject == 1) {
kfree(buf);
return ODD_MECH_TYPE_DRAWER; return ODD_MECH_TYPE_DRAWER;
else } else {
kfree(buf);
return ODD_MECH_TYPE_UNSUPPORTED; return ODD_MECH_TYPE_UNSUPPORTED;
}
} }
/* Test if ODD is zero power ready by sense code */ /* Test if ODD is zero power ready by sense code */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment