From: Andrew Morton <akpm@linux-foundation.org>
To: "Yang, Bo" <Bo.Yang@lsi.com>
Cc: Bo.Yang@lsi.com, James.Bottomley@HansenPartnership.com,
linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org,
Winston.Austria@lsi.com
Subject: Re: [PATCH 5/9] scsi: megaraid_sas - Add memory support required by 0x73 controller
Date: Wed, 18 Feb 2009 16:30:02 -0800 [thread overview]
Message-ID: <20090218163002.5d1be3ce.akpm@linux-foundation.org> (raw)
In-Reply-To: <4B6A08C587958942AA3002690DD4F8C33A07FBD2@cosmail02.lsi.com>
On Tue, 17 Feb 2009 08:37:00 -0800
"Yang, Bo" <Bo.Yang@lsi.com> wrote:
> Add memory support required by 0x73 controller
>
> ...
>
> +static int
> +megasas_skinny_mem_alloc(struct megasas_instance *instance)
> +{
> + u8 i = 0, mem_alloc_done = 0;
> + u32 *virt, ind, num_bk = 0;
> + dma_addr_t paddr;
> + u32 mem_alloc_size = MEGASAS_SKINNY_SZ_MEM_BK * 256;
> + u32 *mem_tb = instance->skinny_mm_tb;
> +
> + instance->skinny_mm_tb = pci_alloc_consistent(instance->pdev,
> + MEGASAS_SKINNY_MAX_NUM_MEM_BK*sizeof(u32),
> + &instance->skinny_mm_tb_h);
> +
> + memset(instance->skinny_mm_tb, 0,
> + MEGASAS_SKINNY_MAX_NUM_MEM_BK * sizeof(u32));
This will crash the kernel if pci_alloc_consistent() failed.
> + instance->skinny_mm_alloc_ind = 0;
> +
> + while (!mem_alloc_done) {
> +
> + virt = pci_alloc_consistent(instance->pdev,
> + mem_alloc_size,
> + &paddr);
This code would be less of a mess if this block wasn't using 16-column
indenting.
Also, the entire patch appears to be using spacespacespacespace for
indenting. Kernel code should use hard tabs.
> + if (virt) {
> + num_bk = (mem_alloc_size/
> + MEGASAS_SKINNY_SZ_MEM_BK);
> +
> + for (ind = 0; ind < num_bk; ind++) {
> + if (instance->skinny_mm_alloc_ind <
> + MEGASAS_SKINNY_MAX_NUM_MEM_BK) {
> + *mem_tb = (u32)(paddr+
> + (MEGASAS_SKINNY_SZ_MEM_BK*ind));
> + mem_tb++;
> + instance->skinny_mm_alloc_ind++;
geeze that is hard to read.
> + } else {
> + mem_alloc_done = 1;
> + }
> + }
> +
> + instance->skinny_mm_bk[i].vir = virt;
> + instance->skinny_mm_bk[i].paddr = paddr;
> + instance->skinny_mm_bk[i].sz = mem_alloc_size;
> + } else {
> + if (mem_alloc_size > MEGASAS_SKINNY_SZ_MEM_BK)
> + mem_alloc_size = mem_alloc_size / 2;
> + }
> + }
The problem with this sort of decreasing-allocation-size loop is that
the earlier, large-sized allocations will generate large stack traces
from within the page allocator if they fail.
Normally we would just suppress those expected-to-happen failures with
__GFP_NOWARN. But thanks to pci_alloc_consistent() interface
deficiencies, this cannot be done here.
> + if (instance->skinny_mm_alloc_ind == 0)
> + return -1;
> +
> + return 0;
> +}
> +
next prev parent reply other threads:[~2009-02-19 0:30 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-07 17:09 [PATCH 1/6] scsi: megaraid_sas - add hibernation support bo yang
2007-11-16 21:31 ` Yang, Bo
2007-11-16 22:18 ` James Bottomley
[not found] ` <9738BCBE884FDB42801FAD8A7769C26501C9A4AF@NAMAIL1.ad.lsil.com>
2008-03-18 7:13 ` [PATCH 1/4] scsi: megaraid_sas - Rollback the sense info implementation bo yang
2008-03-17 7:36 ` [PATCH 2/4] scsi: megaraid_sas - Fix the frame count calculation bo yang
2008-03-17 8:13 ` [PATCH 3/4] scsi: megaraid_sas - Add the new controller Support to Driver bo yang
2008-08-01 16:48 ` [PATCH 2/4] scsi: megaraid_sas - Add the shutdown DCMD cmd to driver shutdown routine Yang, Bo
2008-08-01 21:17 ` [PATCH 3/4] scsi: megaraid_sas - Add the new controllers support Yang, Bo
2008-08-01 21:25 ` [PATCH 4/4] scsi: megaraid_sas - Version and Documentation Update Yang, Bo
2008-03-17 8:18 ` [PATCH 4/4] scsi: megaraid_sas - Update the Version and Changelog bo yang
2008-03-17 20:54 ` James Bottomley
2008-03-17 21:00 ` [PATCH 4/4] scsi: megaraid_sas - Update the Version andChangelog Yang, Bo
2009-02-17 14:44 ` [PATCH 1/9] scsi: megaraid_sas - Fix the tape drive support Yang, Bo
2009-02-17 15:25 ` [PATCH 2/9] scsi: megaraid_sas - Add poll wait support to megaraid sas driver - I Yang, Bo
2009-02-17 15:36 ` [PATCH 3/9] scsi: megaraid_sas - Add poll wait support to megaraid sas driver - II Yang, Bo
2009-02-17 15:51 ` [PATCH 4/9] scsi: megaraid_sas - Add new controller 0x73(new SAS2) support to the driver Yang, Bo
2009-02-17 16:37 ` [PATCH 5/9] scsi: megaraid_sas - Add memory support required by 0x73 controller Yang, Bo
2009-02-17 17:09 ` [PATCH 6/9] scsi: megaraid_sas - Report the unconfigured PD (system PD) to OS Yang, Bo
2009-02-17 17:21 ` [PATCH 7/9] scsi: megaraid_sas - Resign the Application cmds to 0x73 (new SAS2) controller Yang, Bo
2009-02-17 17:31 ` [PATCH 8/9] scsi: megaraid_sas - Add the IEEE SGL support to the driver Yang, Bo
2009-02-17 17:50 ` [PATCH 9/9] scsi: megaraid_sas - Update the Version and ChangeLog Yang, Bo
2009-02-19 0:38 ` [PATCH 8/9] scsi: megaraid_sas - Add the IEEE SGL support to the driver Andrew Morton
2009-02-19 0:30 ` Andrew Morton [this message]
2009-02-19 0:21 ` [PATCH 2/9] scsi: megaraid_sas - Add poll wait support to megaraid sas driver - I Andrew Morton
2009-02-19 13:55 ` Yang, Bo
2009-05-05 23:55 ` [PATCH 1/10] scsi: megaraid_sas - tape drive support fix Yang, Bo
2009-05-06 0:25 ` [PATCH 2/10] scsi: megaraid_sas - Add Poll Wait mechanism to MegaRAID SAS driver (PART-I) Yang, Bo
2009-05-06 0:41 ` [PATCH 3/10] scsi: megaraid_sas - Add Poll Wait mechanism to MegaRAID SAS driver (PART-II) Yang, Bo
2009-05-06 1:11 ` [PATCH 4/10] scsi: megaraid_sas - Add New SAS 2 (iMR) controller support to the driver Yang, Bo
2009-05-06 1:24 ` [PATCH 5/10] scsi: megaraid_sas - Fixed load/unload issue and Fire the system pd DCDB cmd to MegaRAID SAS FW to get the system PDs Yang, Bo
2009-05-06 1:35 ` [PATCH 6/10] scsi: megaraid_sas - Report the Unconfigured PD (system PD) to OS Yang, Bo
2009-05-06 1:43 ` [PATCH 7/10] scsi: megaraid_sas - Re-assign the Cmds to Application for the iMR controller Yang, Bo
2009-05-06 1:52 ` [PATCH 8/10] scsi: megaraid_sas - Driver adds the IEEE SGE format to support SAS 2 controller Yang, Bo
2009-05-06 2:08 ` [PATCH 9/10] scsi: megaraid_sas - Fixed the logic drives deleted and cmds pending in FW issue Yang, Bo
2009-05-06 2:12 ` [PATCH 10/10] scsi: megaraid_sas - Version and Documentation update Yang, Bo
2009-05-06 21:20 ` [PATCH 5/10] scsi: megaraid_sas - Fixed load/unload issue and Fire the system pd DCDB cmd to MegaRAID SAS FW to get the system PDs Andrew Morton
2009-05-07 15:05 ` Yang, Bo
2009-05-06 21:19 ` [PATCH 3/10] scsi: megaraid_sas - Add Poll Wait mechanism to MegaRAID SAS driver (PART-II) Andrew Morton
2009-05-06 21:17 ` [PATCH 2/10] scsi: megaraid_sas - Add Poll Wait mechanism to MegaRAID SAS driver (PART-I) Andrew Morton
2009-05-07 14:56 ` Yang, Bo
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=20090218163002.5d1be3ce.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=Bo.Yang@lsi.com \
--cc=James.Bottomley@HansenPartnership.com \
--cc=Winston.Austria@lsi.com \
--cc=linux-kernel@vger.kernel.org \
--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