igb: Make arrays on stack static const to avoid reallocation
authorAlexander Duyck <alexander.h.duyck@redhat.com>
Fri, 6 Mar 2015 03:34:14 +0000 (03:34 +0000)
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>
Fri, 6 Mar 2015 10:47:09 +0000 (02:47 -0800)
While addressing the pin problem I noticed that all of the pin register
values where having to be pushed onto the stack each time the function was
called.  To avoid that I am making them static const so that they should
only need to be allocated once and we can avoid all the instructions to get
them onto the stack..

size before:
   text    data     bss     dec     hex filename
 161477   10512       8  171997   29fdd drivers/net/ethernet/intel/igb/igb.ko

size after:
   text    data     bss     dec     hex filename
 161205   10512       8  171725   29ecd drivers/net/ethernet/intel/igb/igb.ko

Signed-off-by: Alexander Duyck <alexander.h.duyck@redhat.com>
Tested-by: Aaron Brown <aaron.f.brown@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
drivers/net/ethernet/intel/igb/igb_ptp.c

index 525e5c461e791a7b8eb08bada878740498e2a07e..d6be4c69172d9ecaf1670f5ba761abdc4abb475e 100644 (file)
@@ -358,7 +358,7 @@ static int igb_ptp_settime_i210(struct ptp_clock_info *ptp,
 static void igb_pin_direction(int pin, int input, u32 *ctrl, u32 *ctrl_ext)
 {
        u32 *ptr = pin < 2 ? ctrl : ctrl_ext;
-       u32 mask[IGB_N_SDP] = {
+       static const u32 mask[IGB_N_SDP] = {
                E1000_CTRL_SDP0_DIR,
                E1000_CTRL_SDP1_DIR,
                E1000_CTRL_EXT_SDP2_DIR,
@@ -373,16 +373,16 @@ static void igb_pin_direction(int pin, int input, u32 *ctrl, u32 *ctrl_ext)
 
 static void igb_pin_extts(struct igb_adapter *igb, int chan, int pin)
 {
-       struct e1000_hw *hw = &igb->hw;
-       u32 aux0_sel_sdp[IGB_N_SDP] = {
+       static const u32 aux0_sel_sdp[IGB_N_SDP] = {
                AUX0_SEL_SDP0, AUX0_SEL_SDP1, AUX0_SEL_SDP2, AUX0_SEL_SDP3,
        };
-       u32 aux1_sel_sdp[IGB_N_SDP] = {
+       static const u32 aux1_sel_sdp[IGB_N_SDP] = {
                AUX1_SEL_SDP0, AUX1_SEL_SDP1, AUX1_SEL_SDP2, AUX1_SEL_SDP3,
        };
-       u32 ts_sdp_en[IGB_N_SDP] = {
+       static const u32 ts_sdp_en[IGB_N_SDP] = {
                TS_SDP0_EN, TS_SDP1_EN, TS_SDP2_EN, TS_SDP3_EN,
        };
+       struct e1000_hw *hw = &igb->hw;
        u32 ctrl, ctrl_ext, tssdp = 0;
 
        ctrl = rd32(E1000_CTRL);
@@ -409,28 +409,28 @@ static void igb_pin_extts(struct igb_adapter *igb, int chan, int pin)
 
 static void igb_pin_perout(struct igb_adapter *igb, int chan, int pin)
 {
-       struct e1000_hw *hw = &igb->hw;
-       u32 aux0_sel_sdp[IGB_N_SDP] = {
+       static const u32 aux0_sel_sdp[IGB_N_SDP] = {
                AUX0_SEL_SDP0, AUX0_SEL_SDP1, AUX0_SEL_SDP2, AUX0_SEL_SDP3,
        };
-       u32 aux1_sel_sdp[IGB_N_SDP] = {
+       static const u32 aux1_sel_sdp[IGB_N_SDP] = {
                AUX1_SEL_SDP0, AUX1_SEL_SDP1, AUX1_SEL_SDP2, AUX1_SEL_SDP3,
        };
-       u32 ts_sdp_en[IGB_N_SDP] = {
+       static const u32 ts_sdp_en[IGB_N_SDP] = {
                TS_SDP0_EN, TS_SDP1_EN, TS_SDP2_EN, TS_SDP3_EN,
        };
-       u32 ts_sdp_sel_tt0[IGB_N_SDP] = {
+       static const u32 ts_sdp_sel_tt0[IGB_N_SDP] = {
                TS_SDP0_SEL_TT0, TS_SDP1_SEL_TT0,
                TS_SDP2_SEL_TT0, TS_SDP3_SEL_TT0,
        };
-       u32 ts_sdp_sel_tt1[IGB_N_SDP] = {
+       static const u32 ts_sdp_sel_tt1[IGB_N_SDP] = {
                TS_SDP0_SEL_TT1, TS_SDP1_SEL_TT1,
                TS_SDP2_SEL_TT1, TS_SDP3_SEL_TT1,
        };
-       u32 ts_sdp_sel_clr[IGB_N_SDP] = {
+       static const u32 ts_sdp_sel_clr[IGB_N_SDP] = {
                TS_SDP0_SEL_FC1, TS_SDP1_SEL_FC1,
                TS_SDP2_SEL_FC1, TS_SDP3_SEL_FC1,
        };
+       struct e1000_hw *hw = &igb->hw;
        u32 ctrl, ctrl_ext, tssdp = 0;
 
        ctrl = rd32(E1000_CTRL);