netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [net-next PATCH 0/2] Fix some minor issues in igb driver
@ 2015-03-05 19:24 Alexander Duyck
  2015-03-05 19:24 ` [net-next PATCH 1/2] igb: Fix warning ‘pin’ may be used uninitialized Alexander Duyck
  2015-03-05 19:25 ` [net-next PATCH 2/2] igb: Make arrays on stack static const to avoid reallocation Alexander Duyck
  0 siblings, 2 replies; 5+ messages in thread
From: Alexander Duyck @ 2015-03-05 19:24 UTC (permalink / raw)
  To: netdev; +Cc: e1000-devel, jeffrey.t.kirsher

These patches fix a warning I have been seeing from the igb driver when
building the net-next kernel on my Fedora 20 system.

The 'pin' patch contains the fix for the warning, the other is a minor
cleanup for the fact that the function was placing several arrays onto the
stack when it would have been much more efficient to just store them as 
static const arrays.

---

Alexander Duyck (2):
      igb: Fix warning ‘pin’ may be used uninitialized
      igb: Make arrays on stack static const to avoid reallocation


 drivers/net/ethernet/intel/igb/igb_ptp.c |   26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

--

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

* [net-next PATCH 1/2] igb: Fix warning ‘pin’ may be used uninitialized
  2015-03-05 19:24 [net-next PATCH 0/2] Fix some minor issues in igb driver Alexander Duyck
@ 2015-03-05 19:24 ` Alexander Duyck
  2015-03-05 19:27   ` Jeff Kirsher
  2015-03-05 19:25 ` [net-next PATCH 2/2] igb: Make arrays on stack static const to avoid reallocation Alexander Duyck
  1 sibling, 1 reply; 5+ messages in thread
From: Alexander Duyck @ 2015-03-05 19:24 UTC (permalink / raw)
  To: netdev; +Cc: e1000-devel

When building the kernel using the gcc 4.8.3 compiler included in Fedora 20
I was repeatedly seeing the warning:

 drivers/net/ethernet/intel/igb/igb_ptp.c: In function ‘igb_ptp_feature_enable_i210’:
 drivers/net/ethernet/intel/igb/igb_ptp.c:395:21: warning: ‘pin’ may be used uninitialized in this function
 [-Wmaybe-uninitialized]
   tssdp &= ~ts_sdp_en[pin];
                     ^
 drivers/net/ethernet/intel/igb/igb_ptp.c:471:6: note: ‘pin’ was declared here
   int pin;
       ^

To resolve it I am assigning the pin a value of -1 when it is instantiated.

Signed-off-by: Alexander Duyck <alexander.h.duyck@redhat.com>
---
 drivers/net/ethernet/intel/igb/igb_ptp.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/intel/igb/igb_ptp.c b/drivers/net/ethernet/intel/igb/igb_ptp.c
index d20fc8e..525e5c4 100644
--- a/drivers/net/ethernet/intel/igb/igb_ptp.c
+++ b/drivers/net/ethernet/intel/igb/igb_ptp.c
@@ -468,7 +468,7 @@ static int igb_ptp_feature_enable_i210(struct ptp_clock_info *ptp,
 	u32 tsauxc, tsim, tsauxc_mask, tsim_mask, trgttiml, trgttimh;
 	unsigned long flags;
 	struct timespec ts;
-	int pin;
+	int pin = -1;
 	s64 ns;
 
 	switch (rq->type) {


------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
E1000-devel mailing list
E1000-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/e1000-devel
To learn more about Intel&#174; Ethernet, visit http://communities.intel.com/community/wired

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

* [net-next PATCH 2/2] igb: Make arrays on stack static const to avoid reallocation
  2015-03-05 19:24 [net-next PATCH 0/2] Fix some minor issues in igb driver Alexander Duyck
  2015-03-05 19:24 ` [net-next PATCH 1/2] igb: Fix warning ‘pin’ may be used uninitialized Alexander Duyck
@ 2015-03-05 19:25 ` Alexander Duyck
  2015-03-05 19:27   ` Jeff Kirsher
  1 sibling, 1 reply; 5+ messages in thread
From: Alexander Duyck @ 2015-03-05 19:25 UTC (permalink / raw)
  To: netdev; +Cc: e1000-devel, jeffrey.t.kirsher

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>
---
 drivers/net/ethernet/intel/igb/igb_ptp.c |   24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/net/ethernet/intel/igb/igb_ptp.c b/drivers/net/ethernet/intel/igb/igb_ptp.c
index 525e5c4..d6be4c6 100644
--- a/drivers/net/ethernet/intel/igb/igb_ptp.c
+++ b/drivers/net/ethernet/intel/igb/igb_ptp.c
@@ -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);

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

* Re: [net-next PATCH 1/2] igb: Fix warning ‘pin’ may be used uninitialized
  2015-03-05 19:24 ` [net-next PATCH 1/2] igb: Fix warning ‘pin’ may be used uninitialized Alexander Duyck
@ 2015-03-05 19:27   ` Jeff Kirsher
  0 siblings, 0 replies; 5+ messages in thread
From: Jeff Kirsher @ 2015-03-05 19:27 UTC (permalink / raw)
  To: Alexander Duyck; +Cc: netdev, e1000-devel

[-- Attachment #1: Type: text/plain, Size: 921 bytes --]

On Thu, 2015-03-05 at 11:24 -0800, Alexander Duyck wrote:
> When building the kernel using the gcc 4.8.3 compiler included in
> Fedora 20
> I was repeatedly seeing the warning:
> 
>  drivers/net/ethernet/intel/igb/igb_ptp.c: In function
> ‘igb_ptp_feature_enable_i210’:
>  drivers/net/ethernet/intel/igb/igb_ptp.c:395:21: warning: ‘pin’ may
> be used uninitialized in this function
>  [-Wmaybe-uninitialized]
>    tssdp &= ~ts_sdp_en[pin];
>                      ^
>  drivers/net/ethernet/intel/igb/igb_ptp.c:471:6: note: ‘pin’ was
> declared here
>    int pin;
>        ^
> 
> To resolve it I am assigning the pin a value of -1 when it is
> instantiated.
> 
> Signed-off-by: Alexander Duyck <alexander.h.duyck@redhat.com>
> ---
>  drivers/net/ethernet/intel/igb/igb_ptp.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Thanks Alex, I have added your patch to my queue.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* Re: [net-next PATCH 2/2] igb: Make arrays on stack static const to avoid reallocation
  2015-03-05 19:25 ` [net-next PATCH 2/2] igb: Make arrays on stack static const to avoid reallocation Alexander Duyck
@ 2015-03-05 19:27   ` Jeff Kirsher
  0 siblings, 0 replies; 5+ messages in thread
From: Jeff Kirsher @ 2015-03-05 19:27 UTC (permalink / raw)
  To: Alexander Duyck; +Cc: netdev, e1000-devel

[-- Attachment #1: Type: text/plain, Size: 974 bytes --]

On Thu, 2015-03-05 at 11:25 -0800, Alexander Duyck wrote:
> 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>
> ---
>  drivers/net/ethernet/intel/igb/igb_ptp.c |   24
> ++++++++++++------------
>  1 file changed, 12 insertions(+), 12 deletions(-)

Thanks Alex, I have added your patch to my queue.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

end of thread, other threads:[~2015-03-05 19:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-05 19:24 [net-next PATCH 0/2] Fix some minor issues in igb driver Alexander Duyck
2015-03-05 19:24 ` [net-next PATCH 1/2] igb: Fix warning ‘pin’ may be used uninitialized Alexander Duyck
2015-03-05 19:27   ` Jeff Kirsher
2015-03-05 19:25 ` [net-next PATCH 2/2] igb: Make arrays on stack static const to avoid reallocation Alexander Duyck
2015-03-05 19:27   ` Jeff Kirsher

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).