From: Yanling Song <songyl@ramaxel.com>
To: Bart Van Assche <bvanassche@acm.org>
Cc: <martin.petersen@oracle.com>, <linux-scsi@vger.kernel.org>,
<songyl@ramaxel.com>
Subject: Re: [PATCH] spraid: initial commit of Ramaxel spraid driver
Date: Sat, 9 Oct 2021 13:32:07 +0000 [thread overview]
Message-ID: <20211009133207.789ad116@songyl> (raw)
In-Reply-To: <526271c5-a745-7666-6b18-9eb61898f1db@acm.org>
On Fri, 8 Oct 2021 20:58:17 -0700
Bart Van Assche <bvanassche@acm.org> wrote:
> On 9/29/21 20:47, Yanling Song wrote:
> > +#define dev_log_dbg(dev, fmt, ...) do { \
> > + if (unlikely(log_debug_switch)) \
> > + dev_info(dev, "[%s] [%d] " fmt, \
> > + __func__, __LINE__, ##__VA_ARGS__);
> > \ +} while (0)
>
> Please use pr_debug() instead of introducing dev_log_dbg().
Ok. Will use pr_debug in the next version.
>
> > +static inline
> > +struct spraid_admin_request *spraid_admin_req(struct request *req)
> > +{
> > + return blk_mq_rq_to_pdu(req);
> > +}
>
> Please read the section with the title "The inline disease" in
> Documentation/process/coding-style.rst.
Ok. Will use MACRO to replace inline in the next version.
>
> > +static inline bool spraid_is_rw_scmd(struct scsi_cmnd *scmd)
> > +{
> > + switch (scmd->cmnd[0]) {
> > + case READ_6:
> > + case READ_10:
> > + case READ_12:
> > + case READ_16:
> > + case READ_32:
> > + case WRITE_6:
> > + case WRITE_10:
> > + case WRITE_12:
> > + case WRITE_16:
> > + case WRITE_32:
> > + return true;
> > + default:
> > + return false;
> > + }
> > +}
>
> Please use op_is_write() instead of reimplementing it.
op_is_write() does not meet our requirement: Both read and write
commands have to be checked, not just write command.
>
> > + if (scmd->sc_data_direction == DMA_TO_DEVICE) {
> > + rw->opcode = SPRAID_CMD_WRITE;
> > + } else if (scmd->sc_data_direction == DMA_FROM_DEVICE) {
> > + rw->opcode = SPRAID_CMD_READ;
> > + } else {
> > + dev_err(hdev->dev, "Invalid IO for unsupported
> > data direction: %d\n",
> > + scmd->sc_data_direction);
> > + WARN_ON(1);
> > + }
> > +
> > + /* 6-byte READ(0x08) or WRITE(0x0A) cdb */
> > + if (scmd->cmd_len == 6) {
> > + datalength = (u32)(scmd->cmnd[4] == 0 ?
> > + IO_6_DEFAULT_TX_LEN :
> > scmd->cmnd[4]);
> > + start_lba_lo = ((u32)scmd->cmnd[1] << 16) |
> > + ((u32)scmd->cmnd[2] << 8) |
> > (u32)scmd->cmnd[3]; +
> > + start_lba_lo &= 0x1FFFFF;
> > + }
> > +
> > + /* 10-byte READ(0x28) or WRITE(0x2A) cdb */
> > + else if (scmd->cmd_len == 10) {
> > + datalength = (u32)scmd->cmnd[8] |
> > ((u32)scmd->cmnd[7] << 8);
> > + start_lba_lo = ((u32)scmd->cmnd[2] << 24) |
> > + ((u32)scmd->cmnd[3] << 16) |
> > + ((u32)scmd->cmnd[4] << 8) |
> > (u32)scmd->cmnd[5]; +
> > + if (scmd->cmnd[1] & FUA_MASK)
> > + control |= SPRAID_RW_FUA;
> > + }
> > +
> > + /* 12-byte READ(0xA8) or WRITE(0xAA) cdb */
> > + else if (scmd->cmd_len == 12) {
> > + datalength = ((u32)scmd->cmnd[6] << 24) |
> > + ((u32)scmd->cmnd[7] << 16) |
> > + ((u32)scmd->cmnd[8] << 8) |
> > (u32)scmd->cmnd[9];
> > + start_lba_lo = ((u32)scmd->cmnd[2] << 24) |
> > + ((u32)scmd->cmnd[3] << 16) |
> > + ((u32)scmd->cmnd[4] << 8) |
> > (u32)scmd->cmnd[5]; +
> > + if (scmd->cmnd[1] & FUA_MASK)
> > + control |= SPRAID_RW_FUA;
> > + }
> > + /* 16-byte READ(0x88) or WRITE(0x8A) cdb */
> > + else if (scmd->cmd_len == 16) {
> > + datalength = ((u32)scmd->cmnd[10] << 24) |
> > + ((u32)scmd->cmnd[11] << 16) |
> > + ((u32)scmd->cmnd[12] << 8) |
> > (u32)scmd->cmnd[13];
> > + start_lba_lo = ((u32)scmd->cmnd[6] << 24) |
> > + ((u32)scmd->cmnd[7] << 16) |
> > + ((u32)scmd->cmnd[8] << 8) |
> > (u32)scmd->cmnd[9];
> > + start_lba_hi = ((u32)scmd->cmnd[2] << 24) |
> > + ((u32)scmd->cmnd[3] << 16) |
> > + ((u32)scmd->cmnd[4] << 8) |
> > (u32)scmd->cmnd[5]; +
> > + if (scmd->cmnd[1] & FUA_MASK)
> > + control |= SPRAID_RW_FUA;
> > + }
> > + /* 32-byte READ(0x88) or WRITE(0x8A) cdb */
> > + else if (scmd->cmd_len == 32) {
> > + datalength = ((u32)scmd->cmnd[28] << 24) |
> > + ((u32)scmd->cmnd[29] << 16) |
> > + ((u32)scmd->cmnd[30] << 8) |
> > (u32)scmd->cmnd[31];
> > + start_lba_lo = ((u32)scmd->cmnd[16] << 24) |
> > + ((u32)scmd->cmnd[17] << 16) |
> > + ((u32)scmd->cmnd[18] << 8) |
> > (u32)scmd->cmnd[19];
> > + start_lba_hi = ((u32)scmd->cmnd[12] << 24) |
> > + ((u32)scmd->cmnd[13] << 16) |
> > + ((u32)scmd->cmnd[14] << 8) |
> > (u32)scmd->cmnd[15]; +
> > + if (scmd->cmnd[10] & FUA_MASK)
> > + control |= SPRAID_RW_FUA;
> > + }
>
> Please remove all of the above code and use blk_rq_pos(),
> blk_rq_sectors() and rq->cmd_flags & REQ_FUA instead.
I did not quite get your point. The above is commonly used in many
similar use cases. For example: megasas_build_ldio() in
megaraid_sas_base.c.
What's the benefit to switch to another way: use
blk_rq_pos(),blk_rq_sectors()?
>
> > + spraid_wq = alloc_workqueue("spraid-wq", WQ_UNBOUND |
> > WQ_MEM_RECLAIM | WQ_SYSFS, 0);
> > + if (!spraid_wq)
> > + return -ENOMEM;
>
> Why does this driver create a workqueue? Why is system_wq not good
> enough?
In my opinion, there is not much difference by using system_wq or using
a dedicated wq to execute a work.
but the dedicated wq is must to execute some serial works. It is easy
to add more serial works later if using a dedicated wq here.
>
> Thanks,
>
> Bart.
next prev parent reply other threads:[~2021-10-09 13:32 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-30 3:47 [PATCH] spraid: initial commit of Ramaxel spraid driver Yanling Song
2021-09-30 5:36 ` Randy Dunlap
2021-10-01 1:03 ` Yanling Song
2021-10-01 4:15 ` Christoph Hellwig
2021-10-08 9:22 ` Yanling Song
2021-10-09 3:58 ` Bart Van Assche
2021-10-09 13:32 ` Yanling Song [this message]
2021-10-10 3:52 ` Bart Van Assche
2021-10-11 8:34 ` Yanling Song
2021-10-11 19:40 ` Bart Van Assche
2021-10-12 11:10 ` Yanling Song
2021-10-11 19:54 ` Bart Van Assche
2021-10-12 14:49 ` Yanling Song
2021-10-12 16:59 ` Bart Van Assche
2021-10-13 6:50 ` Yanling Song
2021-10-13 22:00 ` Bart Van Assche
2021-10-15 5:48 ` Yanling Song
2021-10-20 0:33 ` Yanling Song
2021-10-20 3:24 ` Bart Van Assche
2021-11-03 1:43 ` Yanling Song
2021-11-05 13:02 ` Yanling Song
2021-11-05 16:13 ` Bart Van Assche
2021-11-06 8:30 ` Yanling Song
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211009133207.789ad116@songyl \
--to=songyl@ramaxel.com \
--cc=bvanassche@acm.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.