Skip to content

Commit 5d65f6f

Browse files
committed
Merge tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi
Pull SCSI fix from James Bottomley: "One driver fix: the pm8001 has never actually worked on a system with an IOMMU and this fixes that use case" * tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi: scsi: pm8001: Fix phys_to_virt() usage on dma_addr_t
2 parents 9609134 + 2fe2434 commit 5d65f6f

File tree

1 file changed

+21
-17
lines changed

1 file changed

+21
-17
lines changed

drivers/scsi/pm8001/pm80xx_hwi.c

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3053,7 +3053,6 @@ mpi_smp_completion(struct pm8001_hba_info *pm8001_ha, void *piomb)
30533053
struct smp_completion_resp *psmpPayload;
30543054
struct task_status_struct *ts;
30553055
struct pm8001_device *pm8001_dev;
3056-
char *pdma_respaddr = NULL;
30573056

30583057
psmpPayload = (struct smp_completion_resp *)(piomb + 4);
30593058
status = le32_to_cpu(psmpPayload->status);
@@ -3080,19 +3079,23 @@ mpi_smp_completion(struct pm8001_hba_info *pm8001_ha, void *piomb)
30803079
if (pm8001_dev)
30813080
atomic_dec(&pm8001_dev->running_req);
30823081
if (pm8001_ha->smp_exp_mode == SMP_DIRECT) {
3082+
struct scatterlist *sg_resp = &t->smp_task.smp_resp;
3083+
u8 *payload;
3084+
void *to;
3085+
30833086
pm8001_dbg(pm8001_ha, IO,
30843087
"DIRECT RESPONSE Length:%d\n",
30853088
param);
3086-
pdma_respaddr = (char *)(phys_to_virt(cpu_to_le64
3087-
((u64)sg_dma_address
3088-
(&t->smp_task.smp_resp))));
3089+
to = kmap_atomic(sg_page(sg_resp));
3090+
payload = to + sg_resp->offset;
30893091
for (i = 0; i < param; i++) {
3090-
*(pdma_respaddr+i) = psmpPayload->_r_a[i];
3092+
*(payload + i) = psmpPayload->_r_a[i];
30913093
pm8001_dbg(pm8001_ha, IO,
30923094
"SMP Byte%d DMA data 0x%x psmp 0x%x\n",
3093-
i, *(pdma_respaddr + i),
3095+
i, *(payload + i),
30943096
psmpPayload->_r_a[i]);
30953097
}
3098+
kunmap_atomic(to);
30963099
}
30973100
break;
30983101
case IO_ABORTED:
@@ -4236,14 +4239,14 @@ static int pm80xx_chip_smp_req(struct pm8001_hba_info *pm8001_ha,
42364239
struct sas_task *task = ccb->task;
42374240
struct domain_device *dev = task->dev;
42384241
struct pm8001_device *pm8001_dev = dev->lldd_dev;
4239-
struct scatterlist *sg_req, *sg_resp;
4242+
struct scatterlist *sg_req, *sg_resp, *smp_req;
42404243
u32 req_len, resp_len;
42414244
struct smp_req smp_cmd;
42424245
u32 opc;
42434246
struct inbound_queue_table *circularQ;
4244-
char *preq_dma_addr = NULL;
4245-
__le64 tmp_addr;
42464247
u32 i, length;
4248+
u8 *payload;
4249+
u8 *to;
42474250

42484251
memset(&smp_cmd, 0, sizeof(smp_cmd));
42494252
/*
@@ -4280,16 +4283,17 @@ static int pm80xx_chip_smp_req(struct pm8001_hba_info *pm8001_ha,
42804283
pm8001_ha->smp_exp_mode = SMP_INDIRECT;
42814284

42824285

4283-
tmp_addr = cpu_to_le64((u64)sg_dma_address(&task->smp_task.smp_req));
4284-
preq_dma_addr = (char *)phys_to_virt(tmp_addr);
4286+
smp_req = &task->smp_task.smp_req;
4287+
to = kmap_atomic(sg_page(smp_req));
4288+
payload = to + smp_req->offset;
42854289

42864290
/* INDIRECT MODE command settings. Use DMA */
42874291
if (pm8001_ha->smp_exp_mode == SMP_INDIRECT) {
42884292
pm8001_dbg(pm8001_ha, IO, "SMP REQUEST INDIRECT MODE\n");
42894293
/* for SPCv indirect mode. Place the top 4 bytes of
42904294
* SMP Request header here. */
42914295
for (i = 0; i < 4; i++)
4292-
smp_cmd.smp_req16[i] = *(preq_dma_addr + i);
4296+
smp_cmd.smp_req16[i] = *(payload + i);
42934297
/* exclude top 4 bytes for SMP req header */
42944298
smp_cmd.long_smp_req.long_req_addr =
42954299
cpu_to_le64((u64)sg_dma_address
@@ -4320,20 +4324,20 @@ static int pm80xx_chip_smp_req(struct pm8001_hba_info *pm8001_ha,
43204324
pm8001_dbg(pm8001_ha, IO, "SMP REQUEST DIRECT MODE\n");
43214325
for (i = 0; i < length; i++)
43224326
if (i < 16) {
4323-
smp_cmd.smp_req16[i] = *(preq_dma_addr+i);
4327+
smp_cmd.smp_req16[i] = *(payload + i);
43244328
pm8001_dbg(pm8001_ha, IO,
43254329
"Byte[%d]:%x (DMA data:%x)\n",
43264330
i, smp_cmd.smp_req16[i],
4327-
*(preq_dma_addr));
4331+
*(payload));
43284332
} else {
4329-
smp_cmd.smp_req[i] = *(preq_dma_addr+i);
4333+
smp_cmd.smp_req[i] = *(payload + i);
43304334
pm8001_dbg(pm8001_ha, IO,
43314335
"Byte[%d]:%x (DMA data:%x)\n",
43324336
i, smp_cmd.smp_req[i],
4333-
*(preq_dma_addr));
4337+
*(payload));
43344338
}
43354339
}
4336-
4340+
kunmap_atomic(to);
43374341
build_smp_cmd(pm8001_dev->device_id, smp_cmd.tag,
43384342
&smp_cmd, pm8001_ha->smp_exp_mode, length);
43394343
rc = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &smp_cmd,

0 commit comments

Comments
 (0)