aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/bnx2.c
diff options
context:
space:
mode:
authorMichael Chan <mchan@broadcom.com>2007-10-02 19:27:35 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2007-10-10 19:54:07 -0400
commitea1f8d5c3a593a791463c2efc07e5dfebd056500 (patch)
treee25bb6cffff8637b19c73f6ca68eeb901a2473a3 /drivers/net/bnx2.c
parentdad8c737962669240470923f951570ed716da1a1 (diff)
[BNX2]: Optimize firmware loading.
This is a follow up to the patches from Denys Vlasenkos <vda.linux@googlemail.com> to further optimize firmware loading. 1. In bnx2_init_cpus(), we allocate memory for decompression once and use it repeatedly instead of doing this for every firmware image. 2. We eliminate the BSS and SBSS firmware sections in bnx2_fw*.h since these are always zeros. Signed-off-by: Michael Chan <mchan@broadcom.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/bnx2.c')
-rw-r--r--drivers/net/bnx2.c40
1 files changed, 19 insertions, 21 deletions
diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c
index 6d6ea56fe384..00aef8b08da4 100644
--- a/drivers/net/bnx2.c
+++ b/drivers/net/bnx2.c
@@ -2810,21 +2810,16 @@ load_cpu_fw(struct bnx2 *bp, struct cpu_reg *cpu_reg, struct fw_info *fw)
2810 /* Load the Text area. */ 2810 /* Load the Text area. */
2811 offset = cpu_reg->spad_base + (fw->text_addr - cpu_reg->mips_view_base); 2811 offset = cpu_reg->spad_base + (fw->text_addr - cpu_reg->mips_view_base);
2812 if (fw->gz_text) { 2812 if (fw->gz_text) {
2813 u32 *text;
2814 int j; 2813 int j;
2815 2814
2816 text = vmalloc(FW_BUF_SIZE); 2815 rc = zlib_inflate_blob(fw->text, FW_BUF_SIZE, fw->gz_text,
2817 if (!text) 2816 fw->gz_text_len);
2818 return -ENOMEM; 2817 if (rc < 0)
2819 rc = zlib_inflate_blob(text, FW_BUF_SIZE, fw->gz_text, fw->gz_text_len);
2820 if (rc < 0) {
2821 vfree(text);
2822 return rc; 2818 return rc;
2823 } 2819
2824 for (j = 0; j < (fw->text_len / 4); j++, offset += 4) { 2820 for (j = 0; j < (fw->text_len / 4); j++, offset += 4) {
2825 REG_WR_IND(bp, offset, cpu_to_le32(text[j])); 2821 REG_WR_IND(bp, offset, cpu_to_le32(fw->text[j]));
2826 } 2822 }
2827 vfree(text);
2828 } 2823 }
2829 2824
2830 /* Load the Data area. */ 2825 /* Load the Data area. */
@@ -2839,21 +2834,21 @@ load_cpu_fw(struct bnx2 *bp, struct cpu_reg *cpu_reg, struct fw_info *fw)
2839 2834
2840 /* Load the SBSS area. */ 2835 /* Load the SBSS area. */
2841 offset = cpu_reg->spad_base + (fw->sbss_addr - cpu_reg->mips_view_base); 2836 offset = cpu_reg->spad_base + (fw->sbss_addr - cpu_reg->mips_view_base);
2842 if (fw->sbss) { 2837 if (fw->sbss_len) {
2843 int j; 2838 int j;
2844 2839
2845 for (j = 0; j < (fw->sbss_len / 4); j++, offset += 4) { 2840 for (j = 0; j < (fw->sbss_len / 4); j++, offset += 4) {
2846 REG_WR_IND(bp, offset, fw->sbss[j]); 2841 REG_WR_IND(bp, offset, 0);
2847 } 2842 }
2848 } 2843 }
2849 2844
2850 /* Load the BSS area. */ 2845 /* Load the BSS area. */
2851 offset = cpu_reg->spad_base + (fw->bss_addr - cpu_reg->mips_view_base); 2846 offset = cpu_reg->spad_base + (fw->bss_addr - cpu_reg->mips_view_base);
2852 if (fw->bss) { 2847 if (fw->bss_len) {
2853 int j; 2848 int j;
2854 2849
2855 for (j = 0; j < (fw->bss_len/4); j++, offset += 4) { 2850 for (j = 0; j < (fw->bss_len/4); j++, offset += 4) {
2856 REG_WR_IND(bp, offset, fw->bss[j]); 2851 REG_WR_IND(bp, offset, 0);
2857 } 2852 }
2858 } 2853 }
2859 2854
@@ -2894,19 +2889,16 @@ bnx2_init_cpus(struct bnx2 *bp)
2894 if (!text) 2889 if (!text)
2895 return -ENOMEM; 2890 return -ENOMEM;
2896 rc = zlib_inflate_blob(text, FW_BUF_SIZE, bnx2_rv2p_proc1, sizeof(bnx2_rv2p_proc1)); 2891 rc = zlib_inflate_blob(text, FW_BUF_SIZE, bnx2_rv2p_proc1, sizeof(bnx2_rv2p_proc1));
2897 if (rc < 0) { 2892 if (rc < 0)
2898 vfree(text);
2899 goto init_cpu_err; 2893 goto init_cpu_err;
2900 } 2894
2901 load_rv2p_fw(bp, text, rc /* == len */, RV2P_PROC1); 2895 load_rv2p_fw(bp, text, rc /* == len */, RV2P_PROC1);
2902 2896
2903 rc = zlib_inflate_blob(text, FW_BUF_SIZE, bnx2_rv2p_proc2, sizeof(bnx2_rv2p_proc2)); 2897 rc = zlib_inflate_blob(text, FW_BUF_SIZE, bnx2_rv2p_proc2, sizeof(bnx2_rv2p_proc2));
2904 if (rc < 0) { 2898 if (rc < 0)
2905 vfree(text);
2906 goto init_cpu_err; 2899 goto init_cpu_err;
2907 } 2900
2908 load_rv2p_fw(bp, text, rc /* == len */, RV2P_PROC2); 2901 load_rv2p_fw(bp, text, rc /* == len */, RV2P_PROC2);
2909 vfree(text);
2910 2902
2911 /* Initialize the RX Processor. */ 2903 /* Initialize the RX Processor. */
2912 cpu_reg.mode = BNX2_RXP_CPU_MODE; 2904 cpu_reg.mode = BNX2_RXP_CPU_MODE;
@@ -2927,6 +2919,7 @@ bnx2_init_cpus(struct bnx2 *bp)
2927 else 2919 else
2928 fw = &bnx2_rxp_fw_06; 2920 fw = &bnx2_rxp_fw_06;
2929 2921
2922 fw->text = text;
2930 rc = load_cpu_fw(bp, &cpu_reg, fw); 2923 rc = load_cpu_fw(bp, &cpu_reg, fw);
2931 if (rc) 2924 if (rc)
2932 goto init_cpu_err; 2925 goto init_cpu_err;
@@ -2950,6 +2943,7 @@ bnx2_init_cpus(struct bnx2 *bp)
2950 else 2943 else
2951 fw = &bnx2_txp_fw_06; 2944 fw = &bnx2_txp_fw_06;
2952 2945
2946 fw->text = text;
2953 rc = load_cpu_fw(bp, &cpu_reg, fw); 2947 rc = load_cpu_fw(bp, &cpu_reg, fw);
2954 if (rc) 2948 if (rc)
2955 goto init_cpu_err; 2949 goto init_cpu_err;
@@ -2973,6 +2967,7 @@ bnx2_init_cpus(struct bnx2 *bp)
2973 else 2967 else
2974 fw = &bnx2_tpat_fw_06; 2968 fw = &bnx2_tpat_fw_06;
2975 2969
2970 fw->text = text;
2976 rc = load_cpu_fw(bp, &cpu_reg, fw); 2971 rc = load_cpu_fw(bp, &cpu_reg, fw);
2977 if (rc) 2972 if (rc)
2978 goto init_cpu_err; 2973 goto init_cpu_err;
@@ -2996,6 +2991,7 @@ bnx2_init_cpus(struct bnx2 *bp)
2996 else 2991 else
2997 fw = &bnx2_com_fw_06; 2992 fw = &bnx2_com_fw_06;
2998 2993
2994 fw->text = text;
2999 rc = load_cpu_fw(bp, &cpu_reg, fw); 2995 rc = load_cpu_fw(bp, &cpu_reg, fw);
3000 if (rc) 2996 if (rc)
3001 goto init_cpu_err; 2997 goto init_cpu_err;
@@ -3017,11 +3013,13 @@ bnx2_init_cpus(struct bnx2 *bp)
3017 if (CHIP_NUM(bp) == CHIP_NUM_5709) { 3013 if (CHIP_NUM(bp) == CHIP_NUM_5709) {
3018 fw = &bnx2_cp_fw_09; 3014 fw = &bnx2_cp_fw_09;
3019 3015
3016 fw->text = text;
3020 rc = load_cpu_fw(bp, &cpu_reg, fw); 3017 rc = load_cpu_fw(bp, &cpu_reg, fw);
3021 if (rc) 3018 if (rc)
3022 goto init_cpu_err; 3019 goto init_cpu_err;
3023 } 3020 }
3024init_cpu_err: 3021init_cpu_err:
3022 vfree(text);
3025 return rc; 3023 return rc;
3026} 3024}
3027 3025