From: Christoph Hellwig <hch@infradead.org>
To: Dan Williams <dan.j.williams@intel.com>
Cc: james.bottomley@suse.de, dave.jiang@intel.com,
linux-scsi@vger.kernel.org, jacek.danecki@intel.com,
ed.ciechanowski@intel.com, jeffrey.d.skirvin@intel.com,
edmund.nadolski@intel.com
Subject: Re: [RFC PATCH 3/6] isci: request (core request infrastructure)
Date: Fri, 18 Mar 2011 12:41:10 -0400 [thread overview]
Message-ID: <20110318164110.GB19008@infradead.org> (raw)
In-Reply-To: <20110207003450.27040.61422.stgit@localhost6.localdomain6>
> +static int isci_request_alloc_io(
> + struct isci_host *isci_host,
> + struct sas_task *task,
> + struct isci_request **isci_request,
> + struct isci_remote_device *isci_device,
> + gfp_t gfp_flags)
> +{
> + int retval = isci_request_alloc_core(isci_host, isci_request,
> + isci_device, gfp_flags);
> +
> + if (!retval) {
> + (*isci_request)->ttype_ptr.io_task_ptr = task;
> + (*isci_request)->ttype = io_task;
> +
> + task->lldd_task = *isci_request;
> + }
> + return retval;
> +}
This has just a single caller and would be much cleaner just inlined
there.
Btw, care to explain why you don't allocate the full sas_task for
TMF requests? It seems like a lot of code would benefit from that
generalization.
> +int isci_request_alloc_tmf(
> + struct isci_host *isci_host,
> + struct isci_tmf *isci_tmf,
> + struct isci_request **isci_request,
> + struct isci_remote_device *isci_device,
> + gfp_t gfp_flags)
> +{
> + int retval = isci_request_alloc_core(isci_host, isci_request,
> + isci_device, gfp_flags);
> +
> + if (!retval) {
> +
> + (*isci_request)->ttype_ptr.tmf_task_ptr = isci_tmf;
> + (*isci_request)->ttype = tmf_task;
> + }
> + return retval;
> +}
Again, much better opencoded in the only caller.
> + ret = isci_request_alloc_io(
> + isci_host,
> + task,
> + &request,
> + isci_device,
> + gfp_flags
> + );
How about reformatting arguments in the whole driver in the normal way,
e.g.
ret = isci_request_alloc_io(isci_host, task, &request, isci_device,
gfp_flags);
> + status = isci_io_request_build(isci_host, request, isci_device);
> + if (status == SCI_SUCCESS) {
just goto out here for the not successfull case here to keep the
indentation down.
> + status == SCI_FAILURE_REMOTE_DEVICE_RESET_REQUIRED) {
SCI_REMOTE_RESET_REQUIRED would be more than enough.
> + out:
> + if (status != SCI_SUCCESS) {
> +
> + /* release dma memory on failure. */
> + isci_request_free(isci_host, request);
> + request = NULL;
> + ret = SCI_FAILURE;
> + }
> +
> + *isci_request = request;
Just do the
*isci_request = request;
return SCI_SUCCESS;
before the out label and then simply the out label to:
isci_request_free(isci_host, request);
*isci_request = NULL;
return SCI_FAILURE;
btw, what exactly is the scope of the SCI_ return values? They seem to
be used for specific actions above, but also abused as simple true/fail
bools in other places. I think you want specific return values for
a couple functions and else 0/-errno in normal linux style.
> +static void isci_request_process_response_iu(
> + struct sas_task *task,
> + struct ssp_response_iu *resp_iu,
> + struct device *dev)
> +{
> + dev_dbg(dev,
> + "%s: resp_iu = %p "
> + "resp_iu->status = 0x%x,\nresp_iu->datapres = %d "
> + "resp_iu->response_data_len = %x, "
> + "resp_iu->sense_data_len = %x\nrepsonse data: ",
> + __func__,
> + resp_iu,
> + resp_iu->status,
> + resp_iu->datapres,
> + resp_iu->response_data_len,
> + resp_iu->sense_data_len);
> +
> + task->task_status.stat = resp_iu->status;
> +
> + /* libsas updates the task status fields based on the response iu. */
> + sas_ssp_task_response(dev, task, resp_iu);
Can be opencoded in it's only caller.
> +static void isci_request_set_open_reject_status(
> + struct isci_request *request,
> + struct sas_task *task,
> + enum service_response *response_ptr,
> + enum exec_status *status_ptr,
> + enum isci_completion_selection *complete_to_host_ptr,
> + enum sas_open_rej_reason open_rej_reason)
> +{
> + /* Task in the target is done. */
> + request->complete_in_target = true;
> + *response_ptr = SAS_TASK_UNDELIVERED;
> + *status_ptr = SAS_OPEN_REJECT;
> + *complete_to_host_ptr = isci_perform_normal_io_completion;
> + task->task_status.open_rej_reason = open_rej_reason;
> +}
Not a very useful helper. Just have a goto in the only calling function
to fill the field out - the only thing differing is the open rejection
reason, which can be stored in a local variable.
> + if ((isci_device->status == isci_stopping)
> + || (isci_device->status == isci_stopped)
> + )
very confusing indentation, this should be:
if (isci_device->status == isci_stopping ||
isci_device->status == isci_stopped)
> +void *isci_request_ssp_io_request_get_cdb_address(
> + struct isci_request *request)
> +{
> + struct sas_task *task = isci_request_access_task(request);
> +
> + dev_dbg(&request->isci_host->pdev->dev,
> + "%s: request->task->ssp_task.cdb = %p\n",
> + __func__,
> + task->ssp_task.cdb);
> + return task->ssp_task.cdb;
> +}
Just opencode it in the only caller. And get rid of the totally
mad isci_request_access_task obsfucation too please.
> +/**
> + * isci_request_ssp_io_request_get_cdb_length() - This function is called by
> + * the sci core to retrieve the cdb length for a given request.
> + * @request: This parameter is the isci_request object.
> + *
> + * cdb length for specified request.
> + */
> +u32 isci_request_ssp_io_request_get_cdb_length(
> + struct isci_request *request)
> +{
> + return 16;
> +}
Completely pointless. Either use a constant or better derive it from
the host template so that it's just set in one place.
> +u32 isci_request_ssp_io_request_get_lun(
> + struct isci_request *request)
> +{
> + struct sas_task *task = isci_request_access_task(request);
> +
> + return task->ssp_task.LUN[0];
> +}
Again, pointless.
> +u32 isci_request_ssp_io_request_get_task_attribute(
> + struct isci_request *request)
> +{
> + struct sas_task *task = isci_request_access_task(request);
> +
> + dev_dbg(&request->isci_host->pdev->dev,
> + "%s: request->task->ssp_task.task_attr = %x\n",
> + __func__,
> + task->ssp_task.task_attr);
> +
> + return task->ssp_task.task_attr;
> +}
Once more.
> +u32 isci_request_ssp_io_request_get_command_priority(
> + struct isci_request *request)
> +{
> + struct sas_task *task = isci_request_access_task(request);
> +
> + dev_dbg(&request->isci_host->pdev->dev,
> + "%s: request->task->ssp_task.task_prio = %x\n",
> + __func__,
> + task->ssp_task.task_prio);
> +
> + return task->ssp_task.task_prio;
> +}
And again..
> +static inline
> +enum isci_request_status isci_request_get_state(
> + struct isci_request *isci_request)
> +{
> + BUG_ON(isci_request == NULL);
> +
> + /*probably a bad sign... */
> + if (isci_request->status == unallocated)
> + dev_warn(&isci_request->isci_host->pdev->dev,
> + "%s: isci_request->status == unallocated\n",
> + __func__);
> +
> + return isci_request->status;
> +}
Here again.
> +static inline enum isci_request_status isci_request_change_started_to_newstate(
> + struct isci_request *isci_request,
> + struct completion *completion_ptr,
> + enum isci_request_status newstate)
> +{
> + enum isci_request_status old_state;
> + unsigned long flags;
> +
> + BUG_ON(isci_request == NULL);
> +
> + spin_lock_irqsave(&isci_request->state_lock, flags);
> +
> + old_state = isci_request->status;
> +
> + if (old_state == started) {
> + BUG_ON(isci_request->io_request_completion != NULL);
> +
> + isci_request->io_request_completion = completion_ptr;
> + isci_request->status = newstate;
> + }
> + spin_unlock_irqrestore(&isci_request->state_lock, flags);
> +
> + dev_dbg(&isci_request->isci_host->pdev->dev,
> + "%s: isci_request = %p, old_state = 0x%x\n",
> + __func__,
> + isci_request,
> + old_state);
> +
> + return old_state;
> +}
This one seems far too large to be inlined.
> +static inline enum isci_request_status isci_request_change_started_to_aborted(
> + struct isci_request *isci_request,
> + struct completion *completion_ptr)
> +{
> + return isci_request_change_started_to_newstate(
> + isci_request, completion_ptr, aborted
> + );
> +}
Another completely pointless wrapper.
> +
> +#define isci_request_access_task(RequestPtr) \
> + ((RequestPtr)->ttype_ptr.io_task_ptr)
> +
> +#define isci_request_access_tmf(RequestPtr) \
> + ((RequestPtr)->ttype_ptr.tmf_task_ptr)
Pretty pointless wrappers that are longer than their expansion.
> + if ((task->data_dir != PCI_DMA_NONE) &&
> + !sas_protocol_ata(task->task_proto)) {
> + if (task->num_scatter == 0)
> + /* 0 indicates a single dma address */
> + dma_unmap_single(
> + &pdev->dev,
> + request->zero_scatter_daddr,
> + task->total_xfer_len,
> + task->data_dir
> + );
> +
> + else /* unmap the sgl dma addresses */
> + dma_unmap_sg(
> + &pdev->dev,
> + task->scatter,
> + request->num_sg_entries,
> + task->data_dir
> + );
> + }
The driver should use S/G lists for it's internal commands as well to
next prev parent reply other threads:[~2011-03-18 16:41 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-07 0:34 [RFC PATCH 0/6] isci: initial driver release (part1: intro and lldd) Dan Williams
2011-02-07 0:34 ` [RFC PATCH 1/6] isci: initialization Dan Williams
2011-02-17 8:22 ` Jeff Garzik
2011-02-19 0:12 ` Dan Williams
2011-02-17 8:25 ` Christoph Hellwig
2011-02-19 0:23 ` Dan Williams
2011-03-04 23:35 ` James Bottomley
2011-03-08 1:51 ` Dan Williams
2011-03-18 16:51 ` Christoph Hellwig
2011-02-07 0:34 ` [RFC PATCH 2/6] isci: task (libsas interface support) Dan Williams
2011-02-09 15:01 ` David Milburn
2011-02-14 7:14 ` Dan Williams
2011-02-16 18:48 ` David Milburn
2011-02-16 19:35 ` David Milburn
2011-02-07 0:34 ` [RFC PATCH 3/6] isci: request (core request infrastructure) Dan Williams
2011-03-18 16:41 ` Christoph Hellwig [this message]
2011-02-07 0:34 ` [RFC PATCH 4/6] isci: hardware / topology event handling Dan Williams
2011-03-18 16:18 ` Christoph Hellwig
2011-03-23 8:15 ` Dan Williams
2011-03-23 8:40 ` Christoph Hellwig
2011-03-23 9:04 ` Dan Williams
2011-03-23 9:08 ` Christoph Hellwig
2011-03-24 0:07 ` Dan Williams
2011-03-24 6:26 ` Christoph Hellwig
2011-03-25 0:57 ` Dan Williams
2011-03-25 19:45 ` Christoph Hellwig
2011-03-25 21:39 ` Dan Williams
2011-03-25 22:07 ` Christoph Hellwig
2011-03-25 22:34 ` Dan Williams
2011-03-27 22:28 ` Christoph Hellwig
2011-03-29 1:11 ` Dan Williams
2011-03-30 0:37 ` Dan Williams
2011-02-07 0:35 ` [RFC PATCH 5/6] isci: phy, port, and remote device Dan Williams
2011-02-07 0:35 ` [RFC PATCH 6/6] isci: sata support and phy settings via request_firmware() Dan Williams
2011-02-07 7:58 ` [RFC PATCH 1/6] isci: initialization jack_wang
2011-02-14 7:49 ` Dan Williams
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=20110318164110.GB19008@infradead.org \
--to=hch@infradead.org \
--cc=dan.j.williams@intel.com \
--cc=dave.jiang@intel.com \
--cc=ed.ciechanowski@intel.com \
--cc=edmund.nadolski@intel.com \
--cc=jacek.danecki@intel.com \
--cc=james.bottomley@suse.de \
--cc=jeffrey.d.skirvin@intel.com \
--cc=linux-scsi@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).