Patchwork megasas: Replace trace_megasas_dcmd_dump_frame()

login
register
mail settings
Submitter Hannes Reinecke
Date July 11, 2012, 11:35 a.m.
Message ID <1342006516-14026-1-git-send-email-hare@suse.de>
Download mbox | patch
Permalink /patch/170433/
State New
Headers show

Comments

Hannes Reinecke - July 11, 2012, 11:35 a.m.
trace_megasas_dcmd_dump_frame() takes 9 arguments, which is
rather much. Plus the trace infrastructure doesn't support
it anymore.
As we can get the information via other means it's pointless
to have it in the driver, so rather use some proper trace
point here and remove the old one.

Signed-off-by: Hannes Reinecke <hare@suse.de>
Cc: Stefan Weil <sw@weilnetz.de>
---
 hw/megasas.c |   39 ++++++++++-----------------------------
 trace-events |    2 +-
 2 files changed, 11 insertions(+), 30 deletions(-)
Paolo Bonzini - July 11, 2012, 5:10 p.m.
Il 11/07/2012 13:35, Hannes Reinecke ha scritto:
> trace_megasas_dcmd_dump_frame() takes 9 arguments, which is
> rather much. Plus the trace infrastructure doesn't support
> it anymore.
> As we can get the information via other means it's pointless
> to have it in the driver, so rather use some proper trace
> point here and remove the old one.
> 
> Signed-off-by: Hannes Reinecke <hare@suse.de>
> Cc: Stefan Weil <sw@weilnetz.de>
> ---
>  hw/megasas.c |   39 ++++++++++-----------------------------
>  trace-events |    2 +-
>  2 files changed, 11 insertions(+), 30 deletions(-)
> 
> diff --git a/hw/megasas.c b/hw/megasas.c
> index b9b0cad..c68c7f9 100644
> --- a/hw/megasas.c
> +++ b/hw/megasas.c
> @@ -1295,35 +1295,16 @@ static int megasas_cluster_reset_ld(MegasasState *s, MegasasCmd *cmd)
>  
>  static int megasas_dcmd_set_properties(MegasasState *s, MegasasCmd *cmd)
>  {
> -    uint8_t *dummy = g_malloc(cmd->iov_size);
> -
> -    dma_buf_write(dummy, cmd->iov_size, &cmd->qsg);
> -
> -    trace_megasas_dcmd_dump_frame(0,
> -            dummy[0x00], dummy[0x01], dummy[0x02], dummy[0x03],
> -            dummy[0x04], dummy[0x05], dummy[0x06], dummy[0x07]);
> -    trace_megasas_dcmd_dump_frame(1,
> -            dummy[0x08], dummy[0x09], dummy[0x0a], dummy[0x0b],
> -            dummy[0x0c], dummy[0x0d], dummy[0x0e], dummy[0x0f]);
> -    trace_megasas_dcmd_dump_frame(2,
> -            dummy[0x10], dummy[0x11], dummy[0x12], dummy[0x13],
> -            dummy[0x14], dummy[0x15], dummy[0x16], dummy[0x17]);
> -    trace_megasas_dcmd_dump_frame(3,
> -            dummy[0x18], dummy[0x19], dummy[0x1a], dummy[0x1b],
> -            dummy[0x1c], dummy[0x1d], dummy[0x1e], dummy[0x1f]);
> -    trace_megasas_dcmd_dump_frame(4,
> -            dummy[0x20], dummy[0x21], dummy[0x22], dummy[0x23],
> -            dummy[0x24], dummy[0x25], dummy[0x26], dummy[0x27]);
> -    trace_megasas_dcmd_dump_frame(5,
> -            dummy[0x28], dummy[0x29], dummy[0x2a], dummy[0x2b],
> -            dummy[0x2c], dummy[0x2d], dummy[0x2e], dummy[0x2f]);
> -    trace_megasas_dcmd_dump_frame(6,
> -            dummy[0x30], dummy[0x31], dummy[0x32], dummy[0x33],
> -            dummy[0x34], dummy[0x35], dummy[0x36], dummy[0x37]);
> -    trace_megasas_dcmd_dump_frame(7,
> -            dummy[0x38], dummy[0x39], dummy[0x3a], dummy[0x3b],
> -            dummy[0x3c], dummy[0x3d], dummy[0x3e], dummy[0x3f]);
> -    g_free(dummy);
> +    struct mfi_ctrl_props info;
> +    size_t dcmd_size = sizeof(info);
> +
> +    if (cmd->iov_size < dcmd_size) {
> +        trace_megasas_dcmd_invalid_xfer_len(cmd->index, cmd->iov_size,
> +                                            dcmd_size);
> +        return MFI_STAT_INVALID_PARAMETER;
> +    }
> +    dma_buf_write((uint8_t *)&info, cmd->iov_size, &cmd->qsg);
> +    trace_megasas_dcmd_unsupported(cmd->index, cmd->iov_size);
>      return MFI_STAT_OK;
>  }
>  
> diff --git a/trace-events b/trace-events
> index 1f9fc98..4c67601 100644
> --- a/trace-events
> +++ b/trace-events
> @@ -577,7 +577,7 @@ megasas_dcmd_ld_get_list(int cmd, int num, int max) "scmd %d: DCMD LD get list:
>  megasas_dcmd_ld_get_info(int cmd, int ld_id) "scmd %d: DCMD LD get info for dev %d"
>  megasas_dcmd_pd_get_info(int cmd, int pd_id) "scmd %d: DCMD PD get info for dev %d"
>  megasas_dcmd_pd_list_query(int cmd, int flags) "scmd %d: DCMD PD list query flags %x"
> -megasas_dcmd_dump_frame(int offset, char f0, char f1, char f2, char f3, char f4, char f5, char f6, char f7) "0x%x: %02x %02x %02x %02x %02x %02x %02x %02x"
> +megasas_dcmd_unsupported(int cmd, unsigned long size) "scmd %d: set properties len %ld"
>  megasas_abort_frame(int cmd, int abort_cmd) "scmd %d: aborting frame %x"
>  megasas_abort_no_cmd(int cmd, uint64_t context) "scmd %d: no active command for frame context %" PRIx64 ""
>  megasas_abort_invalid_context(int cmd, uint64_t context, int abort_cmd) "scmd %d: invalid frame context %" PRIx64 " for abort frame %x"
> 

Thanks, applied to scsi-next branch.

Paolo

Patch

diff --git a/hw/megasas.c b/hw/megasas.c
index b9b0cad..c68c7f9 100644
--- a/hw/megasas.c
+++ b/hw/megasas.c
@@ -1295,35 +1295,16 @@  static int megasas_cluster_reset_ld(MegasasState *s, MegasasCmd *cmd)
 
 static int megasas_dcmd_set_properties(MegasasState *s, MegasasCmd *cmd)
 {
-    uint8_t *dummy = g_malloc(cmd->iov_size);
-
-    dma_buf_write(dummy, cmd->iov_size, &cmd->qsg);
-
-    trace_megasas_dcmd_dump_frame(0,
-            dummy[0x00], dummy[0x01], dummy[0x02], dummy[0x03],
-            dummy[0x04], dummy[0x05], dummy[0x06], dummy[0x07]);
-    trace_megasas_dcmd_dump_frame(1,
-            dummy[0x08], dummy[0x09], dummy[0x0a], dummy[0x0b],
-            dummy[0x0c], dummy[0x0d], dummy[0x0e], dummy[0x0f]);
-    trace_megasas_dcmd_dump_frame(2,
-            dummy[0x10], dummy[0x11], dummy[0x12], dummy[0x13],
-            dummy[0x14], dummy[0x15], dummy[0x16], dummy[0x17]);
-    trace_megasas_dcmd_dump_frame(3,
-            dummy[0x18], dummy[0x19], dummy[0x1a], dummy[0x1b],
-            dummy[0x1c], dummy[0x1d], dummy[0x1e], dummy[0x1f]);
-    trace_megasas_dcmd_dump_frame(4,
-            dummy[0x20], dummy[0x21], dummy[0x22], dummy[0x23],
-            dummy[0x24], dummy[0x25], dummy[0x26], dummy[0x27]);
-    trace_megasas_dcmd_dump_frame(5,
-            dummy[0x28], dummy[0x29], dummy[0x2a], dummy[0x2b],
-            dummy[0x2c], dummy[0x2d], dummy[0x2e], dummy[0x2f]);
-    trace_megasas_dcmd_dump_frame(6,
-            dummy[0x30], dummy[0x31], dummy[0x32], dummy[0x33],
-            dummy[0x34], dummy[0x35], dummy[0x36], dummy[0x37]);
-    trace_megasas_dcmd_dump_frame(7,
-            dummy[0x38], dummy[0x39], dummy[0x3a], dummy[0x3b],
-            dummy[0x3c], dummy[0x3d], dummy[0x3e], dummy[0x3f]);
-    g_free(dummy);
+    struct mfi_ctrl_props info;
+    size_t dcmd_size = sizeof(info);
+
+    if (cmd->iov_size < dcmd_size) {
+        trace_megasas_dcmd_invalid_xfer_len(cmd->index, cmd->iov_size,
+                                            dcmd_size);
+        return MFI_STAT_INVALID_PARAMETER;
+    }
+    dma_buf_write((uint8_t *)&info, cmd->iov_size, &cmd->qsg);
+    trace_megasas_dcmd_unsupported(cmd->index, cmd->iov_size);
     return MFI_STAT_OK;
 }
 
diff --git a/trace-events b/trace-events
index 1f9fc98..4c67601 100644
--- a/trace-events
+++ b/trace-events
@@ -577,7 +577,7 @@  megasas_dcmd_ld_get_list(int cmd, int num, int max) "scmd %d: DCMD LD get list:
 megasas_dcmd_ld_get_info(int cmd, int ld_id) "scmd %d: DCMD LD get info for dev %d"
 megasas_dcmd_pd_get_info(int cmd, int pd_id) "scmd %d: DCMD PD get info for dev %d"
 megasas_dcmd_pd_list_query(int cmd, int flags) "scmd %d: DCMD PD list query flags %x"
-megasas_dcmd_dump_frame(int offset, char f0, char f1, char f2, char f3, char f4, char f5, char f6, char f7) "0x%x: %02x %02x %02x %02x %02x %02x %02x %02x"
+megasas_dcmd_unsupported(int cmd, unsigned long size) "scmd %d: set properties len %ld"
 megasas_abort_frame(int cmd, int abort_cmd) "scmd %d: aborting frame %x"
 megasas_abort_no_cmd(int cmd, uint64_t context) "scmd %d: no active command for frame context %" PRIx64 ""
 megasas_abort_invalid_context(int cmd, uint64_t context, int abort_cmd) "scmd %d: invalid frame context %" PRIx64 " for abort frame %x"