All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] 2.6 aacraid: rx check health function update
@ 2004-11-05  0:09 Mark Haverkamp
  2004-11-05  7:25 ` Jens Axboe
  0 siblings, 1 reply; 4+ messages in thread
From: Mark Haverkamp @ 2004-11-05  0:09 UTC (permalink / raw)
  To: James Bottomley; +Cc: linux-scsi, Mark Salyzyn

This patch updates the rx check health function.  My previous only
updated the rkt check health code.  This and the previous patch should
fix the kmalloc return checking bug:

http://bugme.osdl.org/show_bug.cgi?id=3699 

Signed-off-by: Mark Haverkamp <markh@osdl.org>


===== drivers/scsi/aacraid/rx.c 1.12 vs edited =====
--- 1.12/drivers/scsi/aacraid/rx.c	2004-11-04 09:32:56 -08:00
+++ edited/drivers/scsi/aacraid/rx.c	2004-11-04 09:37:33 -08:00
@@ -274,7 +274,7 @@
  */
 static int aac_rx_check_health(struct aac_dev *dev)
 {
-	long status = rx_readl(dev, IndexRegs.Mailbox[7]);
+	u32 status = le32_to_cpu(rx_readl(dev, MUnit.OMRx[0]));
 
 	/*
 	 *	Check to see if the board failed any self tests.
@@ -285,29 +285,39 @@
 	 *	Check to see if the board panic'd.
 	 */
 	if (status & KERNEL_PANIC) {
-		char * buffer = kmalloc(512, GFP_KERNEL);
+		char * buffer;
 		struct POSTSTATUS {
 			u32 Post_Command;
 			u32 Post_Address;
-		} * post = kmalloc(sizeof(struct POSTSTATUS), GFP_KERNEL);
-		dma_addr_t paddr = pci_map_single(dev->pdev, post, sizeof(struct POSTSTATUS), 2);
-		dma_addr_t baddr = pci_map_single(dev->pdev, buffer, 512, 1);
-		u32 status = -1;
-		int ret = -2;
+		} * post;
+		dma_addr_t paddr, baddr;
+		int ret;
+
+		if ((status & 0xFF000000L) == 0xBC000000L)
+			return (status >> 16) & 0xFF;
+		buffer = pci_alloc_consistent(dev->pdev, 512, &baddr);
+		ret = -2;
+		if (buffer == NULL)
+			return ret;
+		post = pci_alloc_consistent(dev->pdev,
+		  sizeof(struct POSTSTATUS), &paddr);
+		if (post == NULL) {
+			pci_free_consistent(dev->pdev, 512, buffer, baddr);
+			return ret;
+		}
 		memset(buffer, 0, 512);
 		post->Post_Command = cpu_to_le32(COMMAND_POST_RESULTS);
 		post->Post_Address = cpu_to_le32(baddr);
 		rx_writel(dev, MUnit.IMRx[0], cpu_to_le32(paddr));
 		rx_sync_cmd(dev, COMMAND_POST_RESULTS, baddr, &status);
-		pci_unmap_single(dev->pdev, paddr, sizeof(struct POSTSTATUS), 2);
-		kfree(post);
+		pci_free_consistent(dev->pdev, sizeof(struct POSTSTATUS),
+		  post, paddr);
 		if ((buffer[0] == '0') && (buffer[1] == 'x')) {
 			ret = (buffer[2] <= '9') ? (buffer[2] - '0') : (buffer[2] - 'A' + 10);
 			ret <<= 4;
 			ret += (buffer[3] <= '9') ? (buffer[3] - '0') : (buffer[3] - 'A' + 10);
 		}
-		pci_unmap_single(dev->pdev, baddr, 512, 1);
-		kfree(buffer);
+		pci_free_consistent(dev->pdev, 512, buffer, baddr);
 		return ret;
 	}
 	/*
@@ -319,7 +329,7 @@
 	 *	Everything is OK
 	 */
 	return 0;
-} /* aac_rx_check_health */
+}
 
 /**
  *	aac_rx_init	-	initialize an i960 based AAC card

-- 
Mark Haverkamp <markh@osdl.org>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] 2.6 aacraid: rx check health function update
  2004-11-05  0:09 Mark Haverkamp
@ 2004-11-05  7:25 ` Jens Axboe
  0 siblings, 0 replies; 4+ messages in thread
From: Jens Axboe @ 2004-11-05  7:25 UTC (permalink / raw)
  To: Mark Haverkamp; +Cc: James Bottomley, linux-scsi, Mark Salyzyn

On Thu, Nov 04 2004, Mark Haverkamp wrote:
> This patch updates the rx check health function.  My previous only
> updated the rkt check health code.  This and the previous patch should
> fix the kmalloc return checking bug:
> 
> http://bugme.osdl.org/show_bug.cgi?id=3699 
> 
> Signed-off-by: Mark Haverkamp <markh@osdl.org>
> 
> 
> ===== drivers/scsi/aacraid/rx.c 1.12 vs edited =====
> --- 1.12/drivers/scsi/aacraid/rx.c	2004-11-04 09:32:56 -08:00
> +++ edited/drivers/scsi/aacraid/rx.c	2004-11-04 09:37:33 -08:00
> @@ -274,7 +274,7 @@
>   */
>  static int aac_rx_check_health(struct aac_dev *dev)
>  {
> -	long status = rx_readl(dev, IndexRegs.Mailbox[7]);
> +	u32 status = le32_to_cpu(rx_readl(dev, MUnit.OMRx[0]));
>  
>  	/*
>  	 *	Check to see if the board failed any self tests.
> @@ -285,29 +285,39 @@
>  	 *	Check to see if the board panic'd.
>  	 */
>  	if (status & KERNEL_PANIC) {
> -		char * buffer = kmalloc(512, GFP_KERNEL);
> +		char * buffer;
>  		struct POSTSTATUS {
>  			u32 Post_Command;
>  			u32 Post_Address;
> -		} * post = kmalloc(sizeof(struct POSTSTATUS), GFP_KERNEL);
> -		dma_addr_t paddr = pci_map_single(dev->pdev, post, sizeof(struct POSTSTATUS), 2);
> -		dma_addr_t baddr = pci_map_single(dev->pdev, buffer, 512, 1);
> -		u32 status = -1;
> -		int ret = -2;
> +		} * post;
> +		dma_addr_t paddr, baddr;
> +		int ret;
> +
> +		if ((status & 0xFF000000L) == 0xBC000000L)
> +			return (status >> 16) & 0xFF;
> +		buffer = pci_alloc_consistent(dev->pdev, 512, &baddr);
> +		ret = -2;
> +		if (buffer == NULL)
> +			return ret;

I don't think it's a good idea to return bad adapter health, because you
have an allocation failure.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: [PATCH] 2.6 aacraid: rx check health function update
@ 2004-11-05 13:06 Salyzyn, Mark
  2004-11-05 13:16 ` Jens Axboe
  0 siblings, 1 reply; 4+ messages in thread
From: Salyzyn, Mark @ 2004-11-05 13:06 UTC (permalink / raw)
  To: Jens Axboe, Mark Haverkamp; +Cc: James Bottomley, linux-scsi

The bad adapter health is the KERNEL_PANIC (Adapter Kernel Panic, an
indication that a serious hardware problem has been detected inside the
adapter), the allocation failure means we provide a less detailed
indication of failure to the upper layers. If the allocation succeeds,
then the result will indicate the `blink code' which our technical
support departments can decode into a pinpoint of a subsystem failure.

Sincerely -- Mark Salyzyn

-----Original Message-----
From: Jens Axboe [mailto:axboe@suse.de] 
Sent: Friday, November 05, 2004 2:25 AM
To: Mark Haverkamp
Cc: James Bottomley; linux-scsi; Salyzyn, Mark
Subject: Re: [PATCH] 2.6 aacraid: rx check health function update

On Thu, Nov 04 2004, Mark Haverkamp wrote:
> This patch updates the rx check health function.  My previous only
> updated the rkt check health code.  This and the previous patch should
> fix the kmalloc return checking bug:
> 
> http://bugme.osdl.org/show_bug.cgi?id=3699 
> 
> Signed-off-by: Mark Haverkamp <markh@osdl.org>
> 
> 
> ===== drivers/scsi/aacraid/rx.c 1.12 vs edited =====
> --- 1.12/drivers/scsi/aacraid/rx.c	2004-11-04 09:32:56 -08:00
> +++ edited/drivers/scsi/aacraid/rx.c	2004-11-04 09:37:33 -08:00
> @@ -274,7 +274,7 @@
>   */
>  static int aac_rx_check_health(struct aac_dev *dev)
>  {
> -	long status = rx_readl(dev, IndexRegs.Mailbox[7]);
> +	u32 status = le32_to_cpu(rx_readl(dev, MUnit.OMRx[0]));
>  
>  	/*
>  	 *	Check to see if the board failed any self tests.
> @@ -285,29 +285,39 @@
>  	 *	Check to see if the board panic'd.
>  	 */
>  	if (status & KERNEL_PANIC) {
> -		char * buffer = kmalloc(512, GFP_KERNEL);
> +		char * buffer;
>  		struct POSTSTATUS {
>  			u32 Post_Command;
>  			u32 Post_Address;
> -		} * post = kmalloc(sizeof(struct POSTSTATUS),
GFP_KERNEL);
> -		dma_addr_t paddr = pci_map_single(dev->pdev, post,
sizeof(struct POSTSTATUS), 2);
> -		dma_addr_t baddr = pci_map_single(dev->pdev, buffer,
512, 1);
> -		u32 status = -1;
> -		int ret = -2;
> +		} * post;
> +		dma_addr_t paddr, baddr;
> +		int ret;
> +
> +		if ((status & 0xFF000000L) == 0xBC000000L)
> +			return (status >> 16) & 0xFF;
> +		buffer = pci_alloc_consistent(dev->pdev, 512, &baddr);
> +		ret = -2;
> +		if (buffer == NULL)
> +			return ret;

I don't think it's a good idea to return bad adapter health, because you
have an allocation failure.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] 2.6 aacraid: rx check health function update
  2004-11-05 13:06 [PATCH] 2.6 aacraid: rx check health function update Salyzyn, Mark
@ 2004-11-05 13:16 ` Jens Axboe
  0 siblings, 0 replies; 4+ messages in thread
From: Jens Axboe @ 2004-11-05 13:16 UTC (permalink / raw)
  To: Salyzyn, Mark; +Cc: Mark Haverkamp, James Bottomley, linux-scsi

On Fri, Nov 05 2004, Salyzyn, Mark wrote:
> The bad adapter health is the KERNEL_PANIC (Adapter Kernel Panic, an
> indication that a serious hardware problem has been detected inside the
> adapter), the allocation failure means we provide a less detailed
> indication of failure to the upper layers. If the allocation succeeds,
> then the result will indicate the `blink code' which our technical
> support departments can decode into a pinpoint of a subsystem failure.

Makes sense, in that case the patch is fine.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2004-11-05 13:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-11-05 13:06 [PATCH] 2.6 aacraid: rx check health function update Salyzyn, Mark
2004-11-05 13:16 ` Jens Axboe
  -- strict thread matches above, loose matches on Subject: below --
2004-11-05  0:09 Mark Haverkamp
2004-11-05  7:25 ` Jens Axboe

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.