All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kashyap Desai <kashyap.desai@broadcom.com>
To: Hannes Reinecke <hare@suse.de>, linux-scsi@vger.kernel.org
Cc: jejb@linux.ibm.com, martin.petersen@oracle.com,
	Steve Hagan <steve.hagan@broadcom.com>,
	Peter Rivera <peter.rivera@broadcom.com>,
	mpi3mr-drvr-developers <mpi3mr-linuxdrv.pdl@broadcom.com>,
	Sathya Prakash Veerichetty <sathya.prakash@broadcom.com>
Subject: RE: [PATCH 04/24] mpi3mr: add support of queue command processing
Date: Mon, 8 Mar 2021 23:55:22 +0530	[thread overview]
Message-ID: <26666bbf526cf240b204500ecdfbafa0@mail.gmail.com> (raw)
In-Reply-To: <3dcff2d5-46d2-d9fe-e7d8-21918a4efc12@suse.de>

[-- Attachment #1: Type: text/plain, Size: 7632 bytes --]

> > +
> > +/**
> > + * struct mpi3mr_stgt_priv_data - SCSI device private structure
> > + *
> > + * @tgt_priv_data: Scsi_target private data pointer
> > + * @lun_id: LUN ID of the device
> > + * @ncq_prio_enable: NCQ priority enable for SATA device  */ struct
> > +mpi3mr_sdev_priv_data {
> > +	struct mpi3mr_stgt_priv_data *tgt_priv_data;
> > +	u32 lun_id;
> > +	u8 ncq_prio_enable;
> > +};
> >
> Why is there a separate 'lun_id' field?
H/W is multi lun capable and driver store lun_id so that it can pass the
same to the FW in qcmd() and other path like task management etc.

>
> >   typedef struct mpi3mr_drv_cmd DRV_CMD;
> >   typedef void (*DRV_CMD_CALLBACK)(struct mpi3mr_ioc *mrioc, @@
> > -443,12 +481,16 @@ struct scmd_priv {
> >    * @sbq_lock: Sense buffer queue lock
> >    * @sbq_host_index: Sense buffer queuehost index
> >    * @is_driver_loading: Is driver still loading
> > + * @scan_started: Async scan started
> > + * @scan_failed: Asycn scan failed
> > + * @stop_drv_processing: Stop all command processing
> >    * @max_host_ios: Maximum host I/O count
> >    * @chain_buf_count: Chain buffer count
> >    * @chain_buf_pool: Chain buffer pool
> >    * @chain_sgl_list: Chain SGL list
> >    * @chain_bitmap_sz: Chain buffer allocator bitmap size
> >    * @chain_bitmap: Chain buffer allocator bitmap
> > + * @chain_buf_lock: Chain buffer list lock
> >    * @reset_in_progress: Reset in progress flag
> >    * @unrecoverable: Controller unrecoverable flag
> >    * @logging_level: Controller debug logging level @@ -533,6 +575,9
> > @@ struct mpi3mr_ioc {
> >   	u32 sbq_host_index;
> >
> >   	u8 is_driver_loading;
> > +	u8 scan_started;
> > +	u16 scan_failed;
> > +	u8 stop_drv_processing;
> >
> >   	u16 max_host_ios;
> >
> > @@ -541,6 +586,7 @@ struct mpi3mr_ioc {
> >   	struct chain_element *chain_sgl_list;
> >   	u16  chain_bitmap_sz;
> >   	void *chain_bitmap;
> > +	spinlock_t chain_buf_lock;
> >
> >   	u8 reset_in_progress;
> >   	u8 unrecoverable;
> > @@ -557,8 +603,11 @@ int mpi3mr_setup_resources(struct mpi3mr_ioc
> *mrioc);
> >   void mpi3mr_cleanup_resources(struct mpi3mr_ioc *mrioc);
> >   int mpi3mr_init_ioc(struct mpi3mr_ioc *mrioc);
> >   void mpi3mr_cleanup_ioc(struct mpi3mr_ioc *mrioc);
> > +int mpi3mr_issue_port_enable(struct mpi3mr_ioc *mrioc, u8 async);
> >   int mpi3mr_admin_request_post(struct mpi3mr_ioc *mrioc, void
> *admin_req,
> >   u16 admin_req_sz, u8 ignore_reset);
> > +int mpi3mr_op_request_post(struct mpi3mr_ioc *mrioc,
> > +			   struct op_req_qinfo *opreqq, u8 *req);
> >   void mpi3mr_add_sg_single(void *paddr, u8 flags, u32 length,
> >   			  dma_addr_t dma_addr);
> >   void mpi3mr_build_zero_len_sge(void *paddr); @@ -569,6 +618,9 @@
> > void *mpi3mr_get_reply_virt_addr(struct mpi3mr_ioc *mrioc,
> >   void mpi3mr_repost_sense_buf(struct mpi3mr_ioc *mrioc,
> >   				     u64 sense_buf_dma);
> >
> > +void mpi3mr_process_op_reply_desc(struct mpi3mr_ioc *mrioc,
> > +				  Mpi3DefaultReplyDescriptor_t
*reply_desc,
> > +				  u64 *reply_dma, u16 qidx);
> >   void mpi3mr_start_watchdog(struct mpi3mr_ioc *mrioc);
> >   void mpi3mr_stop_watchdog(struct mpi3mr_ioc *mrioc);
> >
> > diff --git a/drivers/scsi/mpi3mr/mpi3mr_fw.c
> > b/drivers/scsi/mpi3mr/mpi3mr_fw.c index 6fb28983038e..abdf8c653e6b
> > 100644
> > --- a/drivers/scsi/mpi3mr/mpi3mr_fw.c
> > +++ b/drivers/scsi/mpi3mr/mpi3mr_fw.c
> > @@ -24,6 +24,23 @@ static inline void mpi3mr_writeq(__u64 b, volatile
> void __iomem *addr)
> >   }
> >   #endif
> >
> > +static inline bool
> > +mpi3mr_check_req_qfull(struct op_req_qinfo *op_req_q) {
> > +	u16 pi, ci, max_entries;
> > +	bool is_qfull = false;
> > +
> > +	pi = op_req_q->pi;
> > +	ci = op_req_q->ci;
> > +	max_entries = op_req_q->num_requests;
> > +
> > +	if ((ci == (pi + 1)) || ((!ci) && (pi == (max_entries - 1))))
> > +		is_qfull = true;
> > +
> > +	return is_qfull;
> > +}
> > + > +
>
> This needs to be protected by a lock to ensure the 'ci' and 'pi' values
won't
> change during processing; alternatively you'd need to use
> READ_ONCE() here.

I will add READ_ONCE() for op_req_q->ci.

> Please modify or add respective lockdep annotations.
I will discuss with you.

>
> >   static void mpi3mr_sync_irqs(struct mpi3mr_ioc *mrioc)
> >   {
> >   	u16 i, max_vectors;
> > @@ -282,6 +299,87 @@ static int mpi3mr_process_admin_reply_q(struct
> mpi3mr_ioc *mrioc)
> >   	return num_admin_replies;
> >   }
> >
> > +/**
> > + * mpi3mr_get_reply_desc - get reply descriptor frame corresponding
to
> > + *	queue's consumer index from operational reply descriptor queue.
> > + * @op_reply_q: op_reply_qinfo object
> > + * @reply_ci: operational reply descriptor's queue consumer index
> > + *
> > + * Returns reply descriptor frame address  */ static inline
> > +Mpi3DefaultReplyDescriptor_t * mpi3mr_get_reply_desc(struct
> > +op_reply_qinfo *op_reply_q, u32 reply_ci) {
> > +	void *segment_base_addr;
> > +	struct segments *segments = op_reply_q->q_segments;
> > +	Mpi3DefaultReplyDescriptor_t *reply_desc = NULL;
> > +
> > +	segment_base_addr =
> > +	    segments[reply_ci / op_reply_q->segment_qd].segment;
> > +	reply_desc = (Mpi3DefaultReplyDescriptor_t *)segment_base_addr +
> > +	    (reply_ci % op_reply_q->segment_qd);
> > +	return reply_desc;
> > +}
> > +
> > +
> > +static int mpi3mr_process_op_reply_q(struct mpi3mr_ioc *mrioc,
> > +	struct mpi3mr_intr_info *intr_info)
> > +{
> > +	struct op_reply_qinfo *op_reply_q = intr_info->op_reply_q;
> > +	struct op_req_qinfo *op_req_q;
> > +	u32 exp_phase;
> > +	u32 reply_ci;
> > +	u32 num_op_reply = 0;
> > +	u64 reply_dma = 0;
> > +	Mpi3DefaultReplyDescriptor_t *reply_desc;
> > +	u16 req_q_idx = 0, reply_qidx;
> > +
> > +	reply_qidx = op_reply_q->qid - 1;
> > +
> > +	exp_phase = op_reply_q->ephase;
> > +	reply_ci = op_reply_q->ci;
> > +
> > +	reply_desc = mpi3mr_get_reply_desc(op_reply_q, reply_ci);
> > +	if ((le16_to_cpu(reply_desc->ReplyFlags) &
> > +	    MPI3_REPLY_DESCRIPT_FLAGS_PHASE_MASK) != exp_phase) {
> > +		return 0;
> > +	}
> > +
> > +	do {
> > +		req_q_idx = le16_to_cpu(reply_desc->RequestQueueID) - 1;
> > +		op_req_q = &mrioc->req_qinfo[req_q_idx];
> > +
> > +		op_req_q->ci =
> > +		    le16_to_cpu(reply_desc->RequestQueueCI);
> > +
>
> This introduces an interlock with request processing; from what I can
see
> request processing is guarded by a spinlock, yet I don't see any
protection
> here.
As of now there is only one path to process reply queue (from interrupt).
Going forward, blk_mq_poll interface in this driver require interlock in
this area.

> How do you ensure a timely update of the 'ci' value if there is parallel
> execution of requests and responses (note: you cannot always assume that
> you will have a 1:1 relationship between queuepairs, CPUs, and
interrupts).
> I would have expected at least a WRITE_ONCE() here.

I will add WRITE_ONCE.
>
> Question is why you need to modify this at all; in most implementations
I
> know of the 'ci' index is modified by firmware, as really it's the
firmware
> consuming the request.
> Why not here?
Each request queue need separate memory space of queue_depth for that
particular request queue. Currently we are restricting 256 queue depth for
each request queue to get better memory utilization. If we allocate each
request queue same as can_queue, we may not have require this queue_full
check (there may be some corner case, but we can work on those.).  "ci" on
request queue is updated by FW only, but driver is reading those value to
know if there are enough space to post more request. If we see frequent
queue_full with 256 queue depth, we will increase the queue_depth value in
future.

~ Kashyap

[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4212 bytes --]

  reply	other threads:[~2021-03-08 18:26 UTC|newest]

Thread overview: 75+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-22 10:11 [PATCH 00/24] Introducing mpi3mr driver Kashyap Desai
2020-12-22 10:11 ` [PATCH 01/24] mpi3mr: add mpi30 Rev-R headers and Kconfig Kashyap Desai
2020-12-22 18:15   ` Bart Van Assche
2020-12-23 13:33     ` Kashyap Desai
2021-02-23 12:30   ` Hannes Reinecke
2021-03-02 18:11     ` Kashyap Desai
2020-12-22 10:11 ` [PATCH 02/24] mpi3mr: base driver code Kashyap Desai
2020-12-27 14:14   ` kernel test robot
2020-12-27 14:14     ` kernel test robot
2021-02-23 12:55   ` Hannes Reinecke
2021-03-02 18:36     ` Kashyap Desai
2020-12-22 10:11 ` [PATCH 03/24] mpi3mr: create operational request and reply queue pair Kashyap Desai
2020-12-22 18:18   ` Bart Van Assche
2020-12-23 13:16     ` Kashyap Desai
2021-02-28 13:04   ` Hannes Reinecke
2021-03-02 19:05     ` Kashyap Desai
2020-12-22 10:11 ` [PATCH 04/24] mpi3mr: add support of queue command processing Kashyap Desai
2021-02-22 15:23   ` Tomas Henzl
2021-02-25 13:24     ` Kashyap Desai
2021-02-25 14:11       ` Tomas Henzl
2021-02-28 13:22   ` Hannes Reinecke
2021-03-08 18:25     ` Kashyap Desai [this message]
2020-12-22 10:11 ` [PATCH 05/24] mpi3mr: add support of internal watchdog thread Kashyap Desai
2021-02-28 13:24   ` Hannes Reinecke
2020-12-22 10:11 ` [PATCH 06/24] mpi3mr: add support of event handling part-1 Kashyap Desai
2020-12-27 13:14   ` kernel test robot
2020-12-27 13:14     ` kernel test robot
2021-02-22 15:31   ` Tomas Henzl
2021-02-25 13:36     ` Kashyap Desai
2021-03-01  6:47   ` Hannes Reinecke
2020-12-22 10:11 ` [PATCH 07/24] mpi3mr: add support of event handling pcie devices part-2 Kashyap Desai
2021-03-01  6:52   ` Hannes Reinecke
2020-12-22 10:11 ` [PATCH 08/24] mpi3mr: add support of event handling part-3 Kashyap Desai
2021-03-01  6:53   ` Hannes Reinecke
2020-12-22 10:11 ` [PATCH 09/24] mpi3mr: add support for recovering controller Kashyap Desai
2021-03-01  6:56   ` Hannes Reinecke
2020-12-22 10:11 ` [PATCH 10/24] mpi3mr: add support of timestamp sync with firmware Kashyap Desai
2021-03-01  6:57   ` Hannes Reinecke
2020-12-22 10:11 ` [PATCH 11/24] mpi3mr: print ioc info for debugging Kashyap Desai
2021-03-01  6:59   ` Hannes Reinecke
2020-12-22 10:11 ` [PATCH 12/24] mpi3mr: add bios_param shost template hook Kashyap Desai
2021-03-01  7:00   ` Hannes Reinecke
2020-12-22 10:11 ` [PATCH 13/24] mpi3mr: implement scsi error handler hooks Kashyap Desai
2021-03-01  7:09   ` Hannes Reinecke
2021-04-16 14:12     ` Kashyap Desai
2021-04-16 14:31       ` Hannes Reinecke
2020-12-22 10:11 ` [PATCH 14/24] mpi3mr: add change queue depth support Kashyap Desai
2021-03-01  7:10   ` Hannes Reinecke
2020-12-22 10:11 ` [PATCH 15/24] mpi3mr: allow certain commands during pci-remove hook Kashyap Desai
2021-03-01  7:11   ` Hannes Reinecke
2020-12-22 10:11 ` [PATCH 16/24] mpi3mr: hardware workaround for UNMAP commands to nvme drives Kashyap Desai
2021-03-01  7:13   ` Hannes Reinecke
2020-12-22 10:11 ` [PATCH 17/24] mpi3mr: add support of threaded isr Kashyap Desai
2020-12-27 13:51   ` kernel test robot
2020-12-27 13:51     ` kernel test robot
2021-03-01  7:14   ` Hannes Reinecke
2020-12-22 10:11 ` [PATCH 18/24] mpi3mr: add complete support of soft reset Kashyap Desai
2021-03-01  7:16   ` Hannes Reinecke
2020-12-22 10:11 ` [PATCH 19/24] mpi3mr: print pending host ios for debug Kashyap Desai
2021-03-01  7:16   ` Hannes Reinecke
2020-12-22 10:11 ` [PATCH 20/24] mpi3mr: wait for pending IO completions upon detection of VD IO timeout Kashyap Desai
2021-03-01  7:17   ` Hannes Reinecke
2020-12-22 10:11 ` [PATCH 21/24] mpi3mr: add support of PM suspend and resume Kashyap Desai
2021-02-22 15:32   ` Tomas Henzl
2021-02-25 13:37     ` Kashyap Desai
2021-03-01  7:18   ` Hannes Reinecke
2020-12-22 10:11 ` [PATCH 22/24] mpi3mr: add support of DSN secure fw check Kashyap Desai
2021-03-01  7:19   ` Hannes Reinecke
2020-12-22 10:11 ` [PATCH 23/24] mpi3mr: add eedp dif dix support Kashyap Desai
2021-02-22 15:37   ` Tomas Henzl
2021-02-25 13:39     ` Kashyap Desai
2021-03-01  7:20   ` Hannes Reinecke
2020-12-22 10:11 ` [PATCH 24/24] mpi3mr: add event handling debug prints Kashyap Desai
2021-03-01  7:20   ` Hannes Reinecke
2021-02-22 15:39 ` [PATCH 00/24] Introducing mpi3mr driver Tomas Henzl

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=26666bbf526cf240b204500ecdfbafa0@mail.gmail.com \
    --to=kashyap.desai@broadcom.com \
    --cc=hare@suse.de \
    --cc=jejb@linux.ibm.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=mpi3mr-linuxdrv.pdl@broadcom.com \
    --cc=peter.rivera@broadcom.com \
    --cc=sathya.prakash@broadcom.com \
    --cc=steve.hagan@broadcom.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.