All of lore.kernel.org
 help / color / mirror / Atom feed
From: Shivasharan Srikanteshwara <shivasharan.srikanteshwara@broadcom.com>
To: Tomas Henzl <thenzl@redhat.com>, linux-scsi@vger.kernel.org
Cc: martin.petersen@oracle.com, jejb@linux.vnet.ibm.com,
	Kashyap Desai <kashyap.desai@broadcom.com>,
	Sumit Saxena <sumit.saxena@broadcom.com>,
	hare@suse.com, hch@lst.de
Subject: RE: [PATCH v2 09/15] megaraid_sas: use vmalloc for crash dump buffers and driver's local RAID map
Date: Tue, 11 Jul 2017 16:19:19 +0530	[thread overview]
Message-ID: <d0a00c6f287c39a06b994b1f0517b4fa@mail.gmail.com> (raw)
In-Reply-To: <172ecf69-15b3-b22f-fc14-93350a3b9964@redhat.com>

> -----Original Message-----
> From: Tomas Henzl [mailto:thenzl@redhat.com]
> Sent: Monday, July 10, 2017 7:15 PM
> To: Shivasharan S; linux-scsi@vger.kernel.org
> Cc: martin.petersen@oracle.com; jejb@linux.vnet.ibm.com;
> kashyap.desai@broadcom.com; sumit.saxena@broadcom.com;
> hare@suse.com; hch@lst.de
> Subject: Re: [PATCH v2 09/15] megaraid_sas: use vmalloc for crash dump
> buffers and driver's local RAID map
>
> On 5.7.2017 14:00, Shivasharan S wrote:
> > Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com>
> > Signed-off-by: Shivasharan S <shivasharan.srikanteshwara@broadcom.com>
> > Reviewed-by: Hannes Reinecke <hare@suse.com>
> > ---
> >  drivers/scsi/megaraid/megaraid_sas.h        |   1 -
> >  drivers/scsi/megaraid/megaraid_sas_base.c   |  12 ++-
> >  drivers/scsi/megaraid/megaraid_sas_fusion.c | 121
> > ++++++++++++++++++----------
> >  3 files changed, 88 insertions(+), 46 deletions(-)
> >
> > diff --git a/drivers/scsi/megaraid/megaraid_sas.h
> > b/drivers/scsi/megaraid/megaraid_sas.h
> > index 2b209bb..6d9f111 100644
> > --- a/drivers/scsi/megaraid/megaraid_sas.h
> > +++ b/drivers/scsi/megaraid/megaraid_sas.h
> > @@ -2115,7 +2115,6 @@ struct megasas_instance {
> >  	u32 *crash_dump_buf;
> >  	dma_addr_t crash_dump_h;
> >  	void *crash_buf[MAX_CRASH_DUMP_SIZE];
> > -	u32 crash_buf_pages;
> >  	unsigned int    fw_crash_buffer_size;
> >  	unsigned int    fw_crash_state;
> >  	unsigned int    fw_crash_buffer_offset;
> > diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c
> > b/drivers/scsi/megaraid/megaraid_sas_base.c
> > index e490272..c63ef88 100644
> > --- a/drivers/scsi/megaraid/megaraid_sas_base.c
> > +++ b/drivers/scsi/megaraid/megaraid_sas_base.c
> > @@ -49,6 +49,7 @@
> >  #include <linux/blkdev.h>
> >  #include <linux/mutex.h>
> >  #include <linux/poll.h>
> > +#include <linux/vmalloc.h>
> >
> >  #include <scsi/scsi.h>
> >  #include <scsi/scsi_cmnd.h>
> > @@ -6672,9 +6673,14 @@ static void megasas_detach_one(struct pci_dev
> *pdev)
> >  						  fusion->max_map_sz,
> >  						  fusion->ld_map[i],
> >  						  fusion->ld_map_phys[i]);
> > -			if (fusion->ld_drv_map[i])
> > -				free_pages((ulong)fusion->ld_drv_map[i],
> > -					fusion->drv_map_pages);
> > +			if (fusion->ld_drv_map[i]) {
> > +				if (is_vmalloc_addr(fusion->ld_drv_map[i]))
> > +					vfree(fusion->ld_drv_map[i]);
> > +				else
> > +					free_pages((ulong)fusion-
> >ld_drv_map[i],
> > +						   fusion->drv_map_pages);
> > +			}
> > +
> >  			if (fusion->pd_seq_sync[i])
> >  				dma_free_coherent(&instance->pdev->dev,
> >  					pd_seq_map_sz,
> > diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c
> > b/drivers/scsi/megaraid/megaraid_sas_fusion.c
> > index c239762..ff4a3a8 100644
> > --- a/drivers/scsi/megaraid/megaraid_sas_fusion.c
> > +++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c
> > @@ -1257,6 +1257,80 @@ static int
> > megasas_create_sg_sense_fusion(struct megasas_instance *instance)  }
> >
> >  /**
> > + * megasas_allocate_raid_maps -	Allocate memory for RAID maps
> > + * @instance:				Adapter soft state
> > + *
> > + * return:				if success: return 0
> > + *					failed:  return -ENOMEM
> > + */
> > +static inline int megasas_allocate_raid_maps(struct megasas_instance
> > +*instance) {
> > +	struct fusion_context *fusion;
> > +	int i = 0;
> > +
> > +	fusion = instance->ctrl_context;
> > +
> > +	fusion->drv_map_pages = get_order(fusion->drv_map_sz);
> > +
> > +	for (i = 0; i < 2; i++) {
> > +		fusion->ld_map[i] = NULL;
>
> Hi, does this assignment^ mean, that you need a fusion->ld_drv_map[0;1] =
> NULL setting before this for cycle as well or is it just superfluos ?
>
Hi Tomas,
Initializing ld_map[i] = NULL is not necessary but that got carried over
from
earlier code. We do not need to set fusion->ld_drv_map[0:1] to NULL here as
fusion_context is memset to zero during allocation.

>
> > +
> > +		fusion->ld_drv_map[i] = (void *)
> > +			__get_free_pages(__GFP_ZERO | GFP_KERNEL,
> > +					 fusion->drv_map_pages);
>
> The subject says - 'use vmalloc for ... and driver's local RAID map'
> in the code here you use vmalloc only if __get_free_pages fails is this
> intended ?
> (maybe an explanation in the mail body would be nice)
>
> tomash
>
I will send out v3 of the series with a more detailed commit description.
The use of __get_free_pages first for driver's local RAID map is intentional
as this
structure is frequently accessed. But we do not want to fail device probe
due
to unavailability of contiguous memory.

Thanks,
Shivasharan

> > +
> > +		if (!fusion->ld_drv_map[i]) {
> > +			fusion->ld_drv_map[i] = vzalloc(fusion->drv_map_sz);
> > +
> > +			if (!fusion->ld_drv_map[i]) {
> > +				dev_err(&instance->pdev->dev,
> > +					"Could not allocate memory for local
> map"
> > +					" size requested: %d\n",
> > +					fusion->drv_map_sz);
> > +				goto ld_drv_map_alloc_fail;
> > +			}
> > +		}
> > +	}
> > +
> > +	for (i = 0; i < 2; i++) {
> > +		fusion->ld_map[i] = dma_alloc_coherent(&instance->pdev-
> >dev,
> > +						       fusion->max_map_sz,
> > +						       &fusion->ld_map_phys[i],
> > +						       GFP_KERNEL);
> > +		if (!fusion->ld_map[i]) {
> > +			dev_err(&instance->pdev->dev,
> > +				"Could not allocate memory for map info
> %s:%d\n",
> > +				__func__, __LINE__);
> > +			goto ld_map_alloc_fail;
> > +		}
> > +	}
> > +
> > +	return 0;
> > +
> > +ld_map_alloc_fail:
> > +	for (i = 0; i < 2; i++) {
> > +		if (fusion->ld_map[i])
> > +			dma_free_coherent(&instance->pdev->dev,
> > +					  fusion->max_map_sz,
> > +					  fusion->ld_map[i],
> > +					  fusion->ld_map_phys[i]);
> > +	}
> > +
> > +ld_drv_map_alloc_fail:
> > +	for (i = 0; i < 2; i++) {
> > +		if (fusion->ld_drv_map[i]) {
> > +			if (is_vmalloc_addr(fusion->ld_drv_map[i]))
> > +				vfree(fusion->ld_drv_map[i]);
> > +			else
> > +				free_pages((ulong)fusion->ld_drv_map[i],
> > +					   fusion->drv_map_pages);
> > +		}
> > +	}
> > +
> > +	return -ENOMEM;
> > +}
> > +
> > +/**
> >   * megasas_init_adapter_fusion -	Initializes the FW
> >   * @instance:		Adapter soft state
> >   *
> > @@ -1375,45 +1449,14 @@ static int
> megasas_create_sg_sense_fusion(struct megasas_instance *instance)
> >  	instance->r1_ldio_hint_default =  MR_R1_LDIO_PIGGYBACK_DEFAULT;
> >  	fusion->fast_path_io = 0;
> >
> > -	fusion->drv_map_pages = get_order(fusion->drv_map_sz);
> > -	for (i = 0; i < 2; i++) {
> > -		fusion->ld_map[i] = NULL;
> > -		fusion->ld_drv_map[i] = (void
> *)__get_free_pages(GFP_KERNEL,
> > -			fusion->drv_map_pages);
> > -		if (!fusion->ld_drv_map[i]) {
> > -			dev_err(&instance->pdev->dev, "Could not allocate "
> > -				"memory for local map info for %d pages\n",
> > -				fusion->drv_map_pages);
> > -			if (i == 1)
> > -				free_pages((ulong)fusion->ld_drv_map[0],
> > -					fusion->drv_map_pages);
> > -			goto fail_ioc_init;
> > -		}
> > -		memset(fusion->ld_drv_map[i], 0,
> > -			((1 << PAGE_SHIFT) << fusion->drv_map_pages));
> > -	}
> > -
> > -	for (i = 0; i < 2; i++) {
> > -		fusion->ld_map[i] = dma_alloc_coherent(&instance->pdev-
> >dev,
> > -						       fusion->max_map_sz,
> > -						       &fusion->ld_map_phys[i],
> > -						       GFP_KERNEL);
> > -		if (!fusion->ld_map[i]) {
> > -			dev_err(&instance->pdev->dev, "Could not allocate
> memory "
> > -			       "for map info\n");
> > -			goto fail_map_info;
> > -		}
> > -	}
> > +	if (megasas_allocate_raid_maps(instance))
> > +		goto fail_ioc_init;
> >
> >  	if (!megasas_get_map_info(instance))
> >  		megasas_sync_map_info(instance);
> >
> >  	return 0;
> >
> > -fail_map_info:
> > -	if (i == 1)
> > -		dma_free_coherent(&instance->pdev->dev, fusion-
> >max_map_sz,
> > -				  fusion->ld_map[0], fusion->ld_map_phys[0]);
> >  fail_ioc_init:
> >  	megasas_free_cmds_fusion(instance);
> >  fail_alloc_cmds:
> > @@ -3365,17 +3408,13 @@ irqreturn_t megasas_isr_fusion(int irq, void
> > *devp)  {
> >  	unsigned int i;
> >
> > -	instance->crash_buf_pages = get_order(CRASH_DMA_BUF_SIZE);
> >  	for (i = 0; i < MAX_CRASH_DUMP_SIZE; i++) {
> > -		instance->crash_buf[i] = (void
> 	*)__get_free_pages(GFP_KERNEL,
> > -				instance->crash_buf_pages);
> > +		instance->crash_buf[i] = vzalloc(CRASH_DMA_BUF_SIZE);
> >  		if (!instance->crash_buf[i]) {
> >  			dev_info(&instance->pdev->dev, "Firmware crash dump
> "
> >  				"memory allocation failed at index %d\n", i);
> >  			break;
> >  		}
> > -		memset(instance->crash_buf[i], 0,
> > -			((1 << PAGE_SHIFT) << instance->crash_buf_pages));
> >  	}
> >  	instance->drv_buf_alloc = i;
> >  }
> > @@ -3387,12 +3426,10 @@ irqreturn_t megasas_isr_fusion(int irq, void
> > *devp)  void  megasas_free_host_crash_buffer(struct megasas_instance
> > *instance)  {
> > -	unsigned int i
> > -;
> > +	unsigned int i;
> >  	for (i = 0; i < instance->drv_buf_alloc; i++) {
> >  		if (instance->crash_buf[i])
> > -			free_pages((ulong)instance->crash_buf[i],
> > -					instance->crash_buf_pages);
> > +			vfree(instance->crash_buf[i]);
> >  	}
> >  	instance->drv_buf_index = 0;
> >  	instance->drv_buf_alloc = 0;
>

  reply	other threads:[~2017-07-11 10:49 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-05 12:00 [PATCH v2 00/15] megaraid_sas: Updates for scsi-next Shivasharan S
2017-07-05 12:00 ` [PATCH v2 01/15] megaraid_sas: mismatch of allocated MFI frame size and length exposed in MFI MPT pass through command Shivasharan S
2017-07-10 13:46   ` Tomas Henzl
2017-07-05 12:00 ` [PATCH v2 02/15] megaraid_sas: set minimum value of resetwaittime to be 1 secs Shivasharan S
2017-07-10 13:47   ` Tomas Henzl
2017-07-05 12:00 ` [PATCH v2 03/15] megaraid_sas: Use synchronize_irq in target reset case Shivasharan S
2017-07-10 13:50   ` Tomas Henzl
2017-07-05 12:00 ` [PATCH v2 04/15] megaraid_sas: Call megasas_complete_cmd_dpc_fusion every 1 second while there are pending commands Shivasharan S
2017-07-10 13:51   ` Tomas Henzl
2017-07-05 12:00 ` [PATCH v2 05/15] megaraid_sas: Do not re-fire shutdown DCMD after OCR Shivasharan S
2017-07-10 14:00   ` Tomas Henzl
2017-07-05 12:00 ` [PATCH v2 06/15] megaraid_sas: Fix endianness issues in DCMD handling Shivasharan S
2017-07-10 14:05   ` Tomas Henzl
2017-07-05 12:00 ` [PATCH v2 07/15] megaraid_sas: Check valid aen class range to avoid kernel panic Shivasharan S
2017-07-10 14:08   ` Tomas Henzl
2017-07-05 12:00 ` [PATCH v2 08/15] megaraid_sas: Use SMID for Task abort case only Shivasharan S
2017-07-18 11:06   ` Shivasharan Srikanteshwara
2017-07-18 11:51   ` Tomas Henzl
2017-07-05 12:00 ` [PATCH v2 09/15] megaraid_sas: use vmalloc for crash dump buffers and driver's local RAID map Shivasharan S
2017-07-10 13:44   ` Tomas Henzl
2017-07-11 10:49     ` Shivasharan Srikanteshwara [this message]
2017-07-11 13:21       ` Tomas Henzl
2017-07-05 12:00 ` [PATCH v2 10/15] megaraid_sas: Return pended IOCTLs with cmd_status MFI_STAT_WRONG_STATE in case adapter is dead Shivasharan S
2017-07-11 13:42   ` Tomas Henzl
2017-07-05 12:00 ` [PATCH v2 11/15] megaraid_sas: Set device queue_depth same as HBA can_queue value in scsi-mq mode Shivasharan S
2017-07-11 13:57   ` Tomas Henzl
2017-07-11 13:58   ` Christoph Hellwig
2017-07-11 15:47     ` Kashyap Desai
2017-07-12  8:21       ` Shivasharan Srikanteshwara
2017-07-19  8:42       ` Shivasharan Srikanteshwara
2017-07-20  7:47         ` Christoph Hellwig
2017-07-24 11:29           ` Shivasharan Srikanteshwara
2017-08-01 13:23           ` Shivasharan Srikanteshwara
2017-07-05 12:00 ` [PATCH v2 12/15] megaraid_sas: replace internal FALSE/TRUE definitions with false/true Shivasharan S
2017-07-11 13:57   ` Tomas Henzl
2017-07-05 12:00 ` [PATCH v2 13/15] megaraid_sas: modified few prints in OCR and IOC INIT path Shivasharan S
2017-07-11 14:07   ` Tomas Henzl
2017-07-05 12:00 ` [PATCH v2 14/15] megaraid_sas: call megasas_dump_frame with correct IO frame size Shivasharan S
2017-07-11 14:08   ` Tomas Henzl
2017-07-05 12:00 ` [PATCH v2 15/15] megaraid_sas: driver version upgrade Shivasharan S
2017-07-11 14:09   ` 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=d0a00c6f287c39a06b994b1f0517b4fa@mail.gmail.com \
    --to=shivasharan.srikanteshwara@broadcom.com \
    --cc=hare@suse.com \
    --cc=hch@lst.de \
    --cc=jejb@linux.vnet.ibm.com \
    --cc=kashyap.desai@broadcom.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=sumit.saxena@broadcom.com \
    --cc=thenzl@redhat.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.