Re: [pm-core][PATCH v3 02/21] OMAP4: Use WARN_ON() instead of BUG_ON() with graceful exit

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Santosh Shilimkar <santosh.shilimkar@xxxxxx> writes:

> On 3/29/2011 2:23 AM, Tony Lindgren wrote:
>> * Santosh Shilimkar<santosh.shilimkar@xxxxxx>  [110328 02:20]:
>>> OMAP L2X0 and GIC initialisation code uses BUG_ON() for the
>>> ioremap() failure scenarios.
>>>
>>> Use WARN_ON() instead and allow graceful function exits.
>>>
>>> This was suggsted by Kevin Hilman<khilman@xxxxxx>  during
>>> OMAP4 PM code review.
>>>
>>> Signed-off-by: Santosh Shilimkar<santosh.shilimkar@xxxxxx>
>>> Cc: Kevin Hilman<khilman@xxxxxx>
>>> ---
>>>   arch/arm/mach-omap2/omap4-common.c |    9 ++++++---
>>>   1 files changed, 6 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/arch/arm/mach-omap2/omap4-common.c b/arch/arm/mach-omap2/omap4-common.c
>>> index 559d227..8f9b97d 100644
>>> --- a/arch/arm/mach-omap2/omap4-common.c
>>> +++ b/arch/arm/mach-omap2/omap4-common.c
>>> @@ -36,11 +36,13 @@ void __init gic_init_irq(void)
>>>
>>>   	/* Static mapping, never released */
>>>   	gic_dist_base_addr = ioremap(OMAP44XX_GIC_DIST_BASE, SZ_4K);
>>> -	BUG_ON(!gic_dist_base_addr);
>>> +	if (WARN_ON(!gic_dist_base_addr))
>>> +		return;
>>>
>>>   	/* Static mapping, never released */
>>>   	gic_cpu_base = ioremap(OMAP44XX_GIC_CPU_BASE, SZ_512);
>>> -	BUG_ON(!gic_cpu_base);
>>> +	if (WARN_ON(!gic_cpu_base))
>>> +		return;
>>>
>>>   	omap_wakeupgen_init();
>>>
>>> @@ -68,7 +70,8 @@ static int __init omap_l2_cache_init(void)
>>>
>>>   	/* Static mapping, never released */
>>>   	l2cache_base = ioremap(OMAP44XX_L2CACHE_BASE, SZ_4K);
>>> -	BUG_ON(!l2cache_base);
>>> +	if (WARN_ON(!l2cache_base))
>>> +		return -ENODEV;
>>>
>>>   	/*
>>>   	 * 16-way associativity, parity disabled
>>
>> Hmm to me it seems that if any of these we don't want to
>> continue.
>>
> L2 cache is no problem and kernel can boot without L2 cache
> support. I agree with you on interrupt controller init though.
>
> Will drop the interrupt related checks from this patch.
>
> Kevin, Are you ok with it ?

In general, BUG should only be used when the kernel really can not
possibly continue[1].  I suppose inability to map the GIC falls into
that category.

Kevin


[1] from asm-generic/bug.h:

/*
 * Don't use BUG() or BUG_ON() unless there's really no way out; one
 * example might be detecting data structure corruption in the middle
 * of an operation that can't be backed out of.  If the (sub)system
 * can somehow continue operating, perhaps with reduced functionality,
 * it's probably not BUG-worthy.
 *
 * If you're tempted to BUG(), think again:  is completely giving up
 * really the *only* solution?  There are usually better options, where
 * users don't need to reboot ASAP and can mostly shut down cleanly.
 */
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Arm (vger)]     [ARM Kernel]     [ARM MSM]     [Linux Tegra]     [Linux WPAN Networking]     [Linux Wireless Networking]     [Maemo Users]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux