From: Brian King <brking@linux.vnet.ibm.com>
To: Hannes Reinecke <hare@suse.de>,
Bart Van Assche <bart.vanassche@wdc.com>,
Jens Axboe <axboe@kernel.dk>
Cc: linux-block@vger.kernel.org, linux-scsi@vger.kernel.org,
linux-nvme@lists.infradead.org, linux-crypto@vger.kernel.org,
"Martin K . Petersen" <martin.petersen@oracle.com>
Subject: Re: [PATCH v2 6/8] scsi/ipr: Use sgl_alloc_order() and sgl_free_order()
Date: Wed, 18 Oct 2017 15:57:28 -0500 [thread overview]
Message-ID: <ce6f2f5b-b4bc-380f-8ac1-1e91e4d6bf24@linux.vnet.ibm.com> (raw)
In-Reply-To: <c804098f-5543-395c-1395-5778ef74a61b@suse.de>
On 10/17/2017 01:19 AM, Hannes Reinecke wrote:
> On 10/17/2017 12:49 AM, Bart Van Assche wrote:
>> Use the sgl_alloc_order() and sgl_free_order() functions instead
>> of open coding these functions.
>>
>> Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
>> Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
>> Cc: linux-scsi@vger.kernel.org
>> Cc: Martin K. Petersen <martin.petersen@oracle.com>
>> Cc: Brian King <brking@linux.vnet.ibm.com>
>> ---
>> drivers/scsi/Kconfig | 1 +
>> drivers/scsi/ipr.c | 49 ++++++++-----------------------------------------
>> drivers/scsi/ipr.h | 2 +-
>> 3 files changed, 10 insertions(+), 42 deletions(-)
>>
>> diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig
>> index 41366339b950..d11e75e76195 100644
>> --- a/drivers/scsi/Kconfig
>> +++ b/drivers/scsi/Kconfig
>> @@ -1058,6 +1058,7 @@ config SCSI_IPR
>> depends on PCI && SCSI && ATA
>> select FW_LOADER
>> select IRQ_POLL
>> + select SGL_ALLOC
>> ---help---
>> This driver supports the IBM Power Linux family RAID adapters.
>> This includes IBM pSeries 5712, 5703, 5709, and 570A, as well
>> diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c
>> index f838bd73befa..6fed5db6255e 100644
>> --- a/drivers/scsi/ipr.c
>> +++ b/drivers/scsi/ipr.c
>> @@ -3815,10 +3815,8 @@ static struct device_attribute ipr_iopoll_weight_attr = {
>> **/
>> static struct ipr_sglist *ipr_alloc_ucode_buffer(int buf_len)
>> {
>> - int sg_size, order, bsize_elem, num_elem, i, j;
>> + int sg_size, order;
>> struct ipr_sglist *sglist;
>> - struct scatterlist *scatterlist;
>> - struct page *page;
>>
>> /* Get the minimum size per scatter/gather element */
>> sg_size = buf_len / (IPR_MAX_SGLIST - 1);
>> @@ -3826,45 +3824,18 @@ static struct ipr_sglist *ipr_alloc_ucode_buffer(int buf_len)
>> /* Get the actual size per element */
>> order = get_order(sg_size);
>>
>> - /* Determine the actual number of bytes per element */
>> - bsize_elem = PAGE_SIZE * (1 << order);
>> -
>> - /* Determine the actual number of sg entries needed */
>> - if (buf_len % bsize_elem)
>> - num_elem = (buf_len / bsize_elem) + 1;
>> - else
>> - num_elem = buf_len / bsize_elem;
>> -
>> /* Allocate a scatter/gather list for the DMA */
>> - sglist = kzalloc(sizeof(struct ipr_sglist) +
>> - (sizeof(struct scatterlist) * (num_elem - 1)),
>> - GFP_KERNEL);
>> -
>> + sglist = kzalloc(sizeof(struct ipr_sglist), GFP_KERNEL);
>> if (sglist == NULL) {
>> ipr_trace;
>> return NULL;
>> }
>> -
>> - scatterlist = sglist->scatterlist;
>> - sg_init_table(scatterlist, num_elem);
>> -
>> sglist->order = order;
>> - sglist->num_sg = num_elem;
>> -
>> - /* Allocate a bunch of sg elements */
>> - for (i = 0; i < num_elem; i++) {
>> - page = alloc_pages(GFP_KERNEL, order);
>> - if (!page) {
>> - ipr_trace;
>> -
>> - /* Free up what we already allocated */
>> - for (j = i - 1; j >= 0; j--)
>> - __free_pages(sg_page(&scatterlist[j]), order);
>> - kfree(sglist);
>> - return NULL;
>> - }
>> -
>> - sg_set_page(&scatterlist[i], page, 0, 0);
>> + sglist->scatterlist = sgl_alloc_order(buf_len, order, false, GFP_KERNEL,
>> + &sglist->num_sg);
>> + if (!sglist->scatterlist) {
>> + kfree(sglist);
>> + return NULL;
>> }
>>
>> return sglist;
>> @@ -3882,11 +3853,7 @@ static struct ipr_sglist *ipr_alloc_ucode_buffer(int buf_len)
>> **/
>> static void ipr_free_ucode_buffer(struct ipr_sglist *sglist)
>> {
>> - int i;
>> -
>> - for (i = 0; i < sglist->num_sg; i++)
>> - __free_pages(sg_page(&sglist->scatterlist[i]), sglist->order);
>> -
>> + sgl_free_order(sglist->scatterlist, sglist->order);
>> kfree(sglist);
>> }
>>
>> diff --git a/drivers/scsi/ipr.h b/drivers/scsi/ipr.h
>> index c7f0e9e3cd7d..93570734cbfb 100644
>> --- a/drivers/scsi/ipr.h
>> +++ b/drivers/scsi/ipr.h
>> @@ -1454,7 +1454,7 @@ struct ipr_sglist {
>> u32 num_sg;
>> u32 num_dma_sg;
>> u32 buffer_len;
>> - struct scatterlist scatterlist[1];
>> + struct scatterlist *scatterlist;
>> };
>>
>> enum ipr_sdt_state {
>>
> Not sure if this is a valid conversion.
> Originally the driver would allocate a single buffer; with this buffer
> we have two distinct buffers.
> Given that this is used to download the microcode I'm not sure if this
> isn't a hardware-dependent structure which requires a single buffer
> including the sglist.
> Brian, can you shed some light here?
The struct ipr_sglist is not a hardware defined data structure, so on initial
glance, this should be OK. I'll load it up and give it a try to make sure
it doesn't break code download.
Thanks,
Brian
--
Brian King
Power Linux I/O
IBM Linux Technology Center
next prev parent reply other threads:[~2017-10-18 20:57 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-16 22:49 [PATCH v2 0/8] Introduce sgl_alloc() and sgl_free() Bart Van Assche
2017-10-16 22:49 ` [PATCH v2 1/8] lib/scatterlist: " Bart Van Assche
2017-10-17 6:06 ` Hannes Reinecke
2017-10-17 9:20 ` Johannes Thumshirn
2017-10-16 22:49 ` [PATCH v2 2/8] crypto: scompress - use " Bart Van Assche
2017-10-17 6:07 ` Hannes Reinecke
2017-11-01 14:50 ` Bart Van Assche
2017-11-01 15:17 ` Ard Biesheuvel
2017-11-01 15:45 ` Bart Van Assche
2017-11-01 15:51 ` Ard Biesheuvel
2017-10-16 22:49 ` [PATCH v2 3/8] nvmet/fc: Use " Bart Van Assche
2017-10-17 6:07 ` Hannes Reinecke
2017-10-16 22:49 ` [PATCH v2 4/8] nvmet/rdma: " Bart Van Assche
2017-10-17 6:08 ` Hannes Reinecke
2017-10-16 22:49 ` [PATCH v2 5/8] target: Use sgl_alloc_order() " Bart Van Assche
2017-10-17 6:14 ` Hannes Reinecke
2017-10-17 14:31 ` Bart Van Assche
2017-10-16 22:49 ` [PATCH v2 6/8] scsi/ipr: Use sgl_alloc_order() and sgl_free_order() Bart Van Assche
2017-10-17 6:19 ` Hannes Reinecke
2017-10-18 20:57 ` Brian King [this message]
2017-10-30 20:37 ` Bart Van Assche
2017-10-30 21:01 ` Brian King
2017-11-01 11:13 ` Hannes Reinecke
2017-10-16 22:49 ` [PATCH v2 7/8] scsi/pmcraid: Remove an unused structure member Bart Van Assche
2017-10-17 6:21 ` Hannes Reinecke
2017-10-17 14:28 ` Bart Van Assche
2017-10-16 22:49 ` [PATCH v2 8/8] scsi/pmcraid: Use sgl_alloc_order() and sgl_free_order() Bart Van Assche
2017-10-17 6:22 ` Hannes Reinecke
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=ce6f2f5b-b4bc-380f-8ac1-1e91e4d6bf24@linux.vnet.ibm.com \
--to=brking@linux.vnet.ibm.com \
--cc=axboe@kernel.dk \
--cc=bart.vanassche@wdc.com \
--cc=hare@suse.de \
--cc=linux-block@vger.kernel.org \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-nvme@lists.infradead.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 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).