[PATCH v3] aha1542: convert to DMA mapping API
aha1542 is one of the last users of the legacy isa_*_to_bus APIs, which also isn't portable enough. Convert it to the proper DMA mapping API. Thanks to Ondrej Zary for testing and finding and fixing a crucial bug. Signed-off-by: Christoph Hellwig --- Changes since v2: - fix another sizeof of the pointer instead of the pointed to type Changes since v1: - fix a sizeof of the pointer instead of the pointed to type drivers/scsi/aha1542.c | 126 + 1 file changed, 91 insertions(+), 35 deletions(-) diff --git a/drivers/scsi/aha1542.c b/drivers/scsi/aha1542.c index 41add33e3f1f..a9c29757172f 100644 --- a/drivers/scsi/aha1542.c +++ b/drivers/scsi/aha1542.c @@ -58,8 +58,15 @@ struct aha1542_hostdata { int aha1542_last_mbi_used; int aha1542_last_mbo_used; struct scsi_cmnd *int_cmds[AHA1542_MAILBOXES]; - struct mailbox mb[2 * AHA1542_MAILBOXES]; - struct ccb ccb[AHA1542_MAILBOXES]; + struct mailbox *mb; + dma_addr_t mb_handle; + struct ccb *ccb; + dma_addr_t ccb_handle; +}; + +struct aha1542_cmd { + struct chain *chain; + dma_addr_t chain_handle; }; static inline void aha1542_intr_reset(u16 base) @@ -233,6 +240,21 @@ static int aha1542_test_port(struct Scsi_Host *sh) return 1; } +static void aha1542_free_cmd(struct scsi_cmnd *cmd) +{ + struct aha1542_cmd *acmd = scsi_cmd_priv(cmd); + struct device *dev = cmd->device->host->dma_dev; + size_t len = scsi_sg_count(cmd) * sizeof(struct chain); + + if (acmd->chain) { + dma_unmap_single(dev, acmd->chain_handle, len, DMA_TO_DEVICE); + kfree(acmd->chain); + } + + acmd->chain = NULL; + scsi_dma_unmap(cmd); +} + static irqreturn_t aha1542_interrupt(int irq, void *dev_id) { struct Scsi_Host *sh = dev_id; @@ -303,7 +325,7 @@ static irqreturn_t aha1542_interrupt(int irq, void *dev_id) return IRQ_HANDLED; }; - mbo = (scsi2int(mb[mbi].ccbptr) - (isa_virt_to_bus([0]))) / sizeof(struct ccb); + mbo = (scsi2int(mb[mbi].ccbptr) - aha1542->ccb_handle) / sizeof(struct ccb); mbistatus = mb[mbi].status; mb[mbi].status = 0; aha1542->aha1542_last_mbi_used = mbi; @@ -331,8 +353,7 @@ static irqreturn_t aha1542_interrupt(int irq, void *dev_id) return IRQ_HANDLED; } my_done = tmp_cmd->scsi_done; - kfree(tmp_cmd->host_scribble); - tmp_cmd->host_scribble = NULL; + aha1542_free_cmd(tmp_cmd); /* Fetch the sense data, and tuck it away, in the required slot. The Adaptec automatically fetches it, and there is no guarantee that we will still have it in the cdb when we come back */ @@ -369,6 +390,7 @@ static irqreturn_t aha1542_interrupt(int irq, void *dev_id) static int aha1542_queuecommand(struct Scsi_Host *sh, struct scsi_cmnd *cmd) { + struct aha1542_cmd *acmd = scsi_cmd_priv(cmd); struct aha1542_hostdata *aha1542 = shost_priv(sh); u8 direction; u8 target = cmd->device->id; @@ -378,7 +400,6 @@ static int aha1542_queuecommand(struct Scsi_Host *sh, struct scsi_cmnd *cmd) int mbo, sg_count; struct mailbox *mb = aha1542->mb; struct ccb *ccb = aha1542->ccb; - struct chain *cptr; if (*cmd->cmnd == REQUEST_SENSE) { /* Don't do the command - we have the sense data already */ @@ -398,15 +419,17 @@ static int aha1542_queuecommand(struct Scsi_Host *sh, struct scsi_cmnd *cmd) print_hex_dump_bytes("command: ", DUMP_PREFIX_NONE, cmd->cmnd, cmd->cmd_len); } #endif - if (bufflen) { /* allocate memory before taking host_lock */ - sg_count = scsi_sg_count(cmd); - cptr = kmalloc_array(sg_count, sizeof(*cptr), -GFP_KERNEL | GFP_DMA); - if (!cptr) - return SCSI_MLQUEUE_HOST_BUSY; - } else { - sg_count = 0; - cptr = NULL; + sg_count = scsi_dma_map(cmd); + if (sg_count) { + size_t len = sg_count * sizeof(struct chain); + + acmd->chain = kmalloc(len, GFP_DMA); + if (!acmd->chain) + goto out_unmap; + acmd->chain_handle = dma_map_single(sh->dma_dev, acmd->chain, + len, DMA_TO_DEVICE); + if (dma_mapping_error(sh->dma_dev, acmd->chain_handle)) + goto out_free_chain; } /* Use the outgoing mailboxes in a round-robin fashion, because this @@ -437,7 +460,8 @@ static int aha1542_queuecommand(struct Scsi_Host *sh, struct scsi_cmnd *cmd) shost_printk(KERN_DEBUG, sh, "Sending command (%d %p)...", mbo, cmd->scsi_done);
Re: [PATCH] aha1542: convert to DMA mapping API
> > @@ -826,7 +881,8 @@ static int aha1542_dev_reset(struct scsi_cmnd *cmd) > > > > aha1542->aha1542_last_mbo_used = mbo; > > > > - any2scsi(mb[mbo].ccbptr, isa_virt_to_bus([mbo])); /* This gets > > trashed for some reason */ > > + /* This gets trashed for some reason */ > > + any2scsi(mb[mbo].ccbptr, aha1542->ccb_handle + mbo * sizeof(ccb)); > ^^^ > This looks wrong too. It's the same code as in aha1542_queuecommand. Indeed, I'll resend.
Re:Hi
How are you doing today,hope fine,My name is cynthia and i am a girl. I saw your contact email today and decided to extend my greetings to you. But I do have the mind that you could be a nice person is my believe and there are nice people out there who can appreciate the value of friendship.and i will like to be your friend even more than that,but as time goes on we will know better.Remember the distance,color or age does not matter but love matters a lot in life. I will tell you more about me as soon as i hear from you.
Re:Hi
How are you doing today,hope fine,My name is cynthia and i am a girl. I saw your contact email today and decided to extend my greetings to you. But I do have the mind that you could be a nice person is my believe and there are nice people out there who can appreciate the value of friendship.and i will like to be your friend even more than that,but as time goes on we will know better.Remember the distance,color or age does not matter but love matters a lot in life. I will tell you more about me as soon as i hear from you.
SPENDE
Sehr geehrter Herr/Frau, Wir freuen uns, Ihnen mitzuteilen, dass Sie ausgewählt wurden, um die Summe zu erhalten €2,000,000.00 Euro aus Mitteln der Mavis Wanczyk Hilfe. Mein Name ist Mavis Wanczyk der Gewinner des 758,7 Millionen US-Dollar in der Power Ball Lotterie Jackpot als der größte Preis aus einem einzigen Lottoschein in USA. Meine Wohltätigkeitsstiftung hat dich ausgewählt, als unsere glücklichen Empfänger erhalten die Summe von € 2,000,000.00 EURO. Nehmen Sie dieses Angebot an und kontaktieren Sie mich für Weitere Details.
[PATCH] scsi: csiostor: remove automatic irq affinity assignment
If number of interrupt vectors are more than num_online_cpus() then pci_alloc_irq_vectors_affinity() assigns cpumask based on num_possible_cpus() to the remaining vectors because of this interrupts are not generating for these vectors. This patch fixes this issue by using pci_alloc_irq_vectors() instead of pci_alloc_irq_vectors_affinity(). Signed-off-by: Varun Prakash Cc: Christoph Hellwig Cc: Thomas Gleixner --- drivers/scsi/csiostor/csio_isr.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/scsi/csiostor/csio_isr.c b/drivers/scsi/csiostor/csio_isr.c index 7c88147..8b92c59 100644 --- a/drivers/scsi/csiostor/csio_isr.c +++ b/drivers/scsi/csiostor/csio_isr.c @@ -480,7 +480,6 @@ csio_enable_msix(struct csio_hw *hw) int i, j, k, n, min, cnt; int extra = CSIO_EXTRA_VECS; struct csio_scsi_cpu_info *info; - struct irq_affinity desc = { .pre_vectors = 2 }; min = hw->num_pports + extra; cnt = hw->num_sqsets + extra; @@ -491,8 +490,7 @@ csio_enable_msix(struct csio_hw *hw) csio_dbg(hw, "FW supp #niq:%d, trying %d msix's\n", hw->cfg_niq, cnt); - cnt = pci_alloc_irq_vectors_affinity(hw->pdev, min, cnt, - PCI_IRQ_MSIX | PCI_IRQ_AFFINITY, ); + cnt = pci_alloc_irq_vectors(hw->pdev, min, cnt, PCI_IRQ_MSIX); if (cnt < 0) return cnt; -- 2.0.2
Re: [PATCH v1] sg3_utils: sg_write_buffer: convert string to integer while reading from stdio
Hi, Doug Gilbert >>On 2018-11-09 7:18 p.m., Bean Huo (beanhuo) wrote: >> This patch is to convert inputted string to the integer when read data >> from stdin. While entering data, the data between bytes can be >> separated by space, or by ',' or by '.'. > >Could you send me this patch against sg_write_buffer.c as found in the >recently released version 1.44 . In there the version string for >sg_write_buffer.c is: "1.28 20180628" > This patch is based on "1.23 20171008", and the version_str as below: static const char * version_str = "1.23 20171008";/* spc5r10 */ do you need me send one new version patch which is based on the latest sg3_utils? >> Signed-off-by: Bean Huo >> --- >> src/sg_write_buffer.c | 31 +++ >> 1 file changed, 31 insertions(+) >> >> diff --git a/src/sg_write_buffer.c b/src/sg_write_buffer.c index >> 7560e7e..902bc5d 100644 >> --- a/src/sg_write_buffer.c >> +++ b/src/sg_write_buffer.c >> @@ -195,6 +195,7 @@ main(int argc, char * argv[]) >> const char * device_name = NULL; >> const char * file_name = NULL; >> unsigned char * dop = NULL; >> +unsigned char * read_buf= NULL; > >For example the above 2 lines now use uint8_t In the latest sg3_utils, I saw that. Have changed. > >> char * cp; >> const struct mode_s * mp; >> char ebuff[EBUFF_SZ]; >> @@ -394,6 +395,33 @@ main(int argc, char * argv[]) >> } >> } >> } >> +if (infd == STDIN_FILENO) { >> +if (NULL == (read_buf = (unsigned char >*)malloc(DEF_XFER_LEN))) { >> +pr2serr(ME "out of memory\n"); >> +ret = SG_LIB_SYNTAX_ERROR; >> +goto err_out; >> +} >> +res = read(infd, read_buf, DEF_XFER_LEN); >> +if (res < 0) { >> +snprintf(ebuff, EBUFF_SZ, ME "couldn't read from >STDIN"); >> +perror(ebuff); >> +ret = SG_LIB_FILE_ERROR; >> +goto err_out; >> +} >> +char * pch; >> +int val = 0; >> +res = 0; >> +pch = strtok(read_buf, ",. "); >> +while (pch != NULL) { >> +printf("read %s ", pch); >> +val = sg_get_num_nomult(pch); >> +if (val > 0 && val < 255) { > >Hmm, perhaps: > if (val >= 0 && val < 256) > > else > > Yes, will do some change. thanks. >> +dop[res] = val; >> +res++; >> +} >> +pch = strtok(NULL, ",. "); >> +} >> +} else { >> res = read(infd, dop, wb_len); >> if (res < 0) { >> snprintf(ebuff, EBUFF_SZ, ME "couldn't read from >> %s", @@ -404,6 +432,7 @@ main(int argc, char * argv[]) >> ret = SG_LIB_FILE_ERROR; >> goto err_out; >> } >> +} > >Tabbing looks a little off here. > >Thanks >Doug Gilbert > >> if (res < wb_len) { >> if (wb_len_given) { >> pr2serr("tried to read %d bytes from %s, got %d >> bytes\n", @@ -472,6 +501,8 @@ main(int argc, char * argv[]) >> err_out: >> if (dop) >> free(dop); >> +if (read_buf) >> +free(read_buf); >> res = sg_cmds_close_device(sg_fd); >> if (res < 0) { >> pr2serr("close error: %s\n", safe_strerror(-res)); >> Thanks for review. //Bean Huo
RE,
I have a deal for you, in your region.