netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Possible read-modify-write bug in ixgbe x550 phy setup
@ 2018-02-01 23:46 Shannon Nelson
  2018-02-02  0:34 ` [Intel-wired-lan] " Tantilov, Emil S
  0 siblings, 1 reply; 6+ messages in thread
From: Shannon Nelson @ 2018-02-01 23:46 UTC (permalink / raw)
  To: Emil Tantilov; +Cc: intel-wired-lan, netdev

Hi Emil,

I was looking through a set of ixgbe patches and came across this commit

     commit 410a494902777c11f95031d9ed757d7f8f09c5c6
     ixgbe: add write flush when configuring CS4223/7

and am wondering about the setting of reg_phy_ext in the middle of 
ixgbe_setup_mac_link_sfp_x550a().  It looks like it is read from the 
PHY, modified to remove the CX1 and SR mode bits, but then those bits 
are overwritten in the "if (setup_linear)" block immediately following, 
and that is what gets written back out.

	ret_val = hw->phy.ops.read_reg(hw, reg_slice,
				       IXGBE_MDIO_ZERO_DEV_TYPE, &reg_phy_ext);
	if (ret_val)
		return ret_val;

	reg_phy_ext &= ~((IXGBE_CS4227_EDC_MODE_CX1 << 1) |
			 (IXGBE_CS4227_EDC_MODE_SR << 1));

	if (setup_linear)
		reg_phy_ext = (IXGBE_CS4227_EDC_MODE_CX1 << 1) | 1;
	else
		reg_phy_ext = (IXGBE_CS4227_EDC_MODE_SR << 1) | 1;

	ret_val = hw->phy.ops.write_reg(hw, reg_slice,
					IXGBE_MDIO_ZERO_DEV_TYPE, reg_phy_ext);
	if (ret_val)
		return ret_val;


The assignments to reg_phy_ext look wrong to me - perhaps those should 
be '|=' rather than '='?

sln

-- 
==================================================
Shannon Nelson           shannon.nelson@oracle.com
Parents can't afford to be squeamish

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

* RE: [Intel-wired-lan] Possible read-modify-write bug in ixgbe x550 phy setup
  2018-02-01 23:46 Possible read-modify-write bug in ixgbe x550 phy setup Shannon Nelson
@ 2018-02-02  0:34 ` Tantilov, Emil S
  2018-02-02  0:43   ` Shannon Nelson
  0 siblings, 1 reply; 6+ messages in thread
From: Tantilov, Emil S @ 2018-02-02  0:34 UTC (permalink / raw)
  To: Shannon Nelson; +Cc: netdev, intel-wired-lan

>-----Original Message-----
>From: Intel-wired-lan [mailto:intel-wired-lan-bounces@osuosl.org] On
>Behalf Of Shannon Nelson
>Sent: Thursday, February 01, 2018 3:46 PM
>To: Tantilov, Emil S <emil.s.tantilov@intel.com>
>Cc: netdev@vger.kernel.org; intel-wired-lan@lists.osuosl.org
>Subject: [Intel-wired-lan] Possible read-modify-write bug in ixgbe x550
>phy setup
>
>Hi Emil,
>
>I was looking through a set of ixgbe patches and came across this commit
>
>     commit 410a494902777c11f95031d9ed757d7f8f09c5c6
>     ixgbe: add write flush when configuring CS4223/7
>
>and am wondering about the setting of reg_phy_ext in the middle of
>ixgbe_setup_mac_link_sfp_x550a().  It looks like it is read from the
>PHY, modified to remove the CX1 and SR mode bits, but then those bits
>are overwritten in the "if (setup_linear)" block immediately following,
>and that is what gets written back out.

Hi Shannon,

This is pretty standard clear before set, so you're right that it would
make more sense to have |= rather than =.

Are you seeing an issue, or did you catch this via code inspection?

Thanks,
Emil

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

* Re: [Intel-wired-lan] Possible read-modify-write bug in ixgbe x550 phy setup
  2018-02-02  0:34 ` [Intel-wired-lan] " Tantilov, Emil S
@ 2018-02-02  0:43   ` Shannon Nelson
  2018-02-02  0:58     ` Tantilov, Emil S
  0 siblings, 1 reply; 6+ messages in thread
From: Shannon Nelson @ 2018-02-02  0:43 UTC (permalink / raw)
  To: Tantilov, Emil S; +Cc: netdev, intel-wired-lan

On 2/1/2018 4:34 PM, Tantilov, Emil S wrote:
>> -----Original Message-----
>> From: Intel-wired-lan [mailto:intel-wired-lan-bounces@osuosl.org] On
>> Behalf Of Shannon Nelson
>> Sent: Thursday, February 01, 2018 3:46 PM
>> To: Tantilov, Emil S <emil.s.tantilov@intel.com>
>> Cc: netdev@vger.kernel.org; intel-wired-lan@lists.osuosl.org
>> Subject: [Intel-wired-lan] Possible read-modify-write bug in ixgbe x550
>> phy setup
>>
>> Hi Emil,
>>
>> I was looking through a set of ixgbe patches and came across this commit
>>
>>      commit 410a494902777c11f95031d9ed757d7f8f09c5c6
>>      ixgbe: add write flush when configuring CS4223/7
>>
>> and am wondering about the setting of reg_phy_ext in the middle of
>> ixgbe_setup_mac_link_sfp_x550a().  It looks like it is read from the
>> PHY, modified to remove the CX1 and SR mode bits, but then those bits
>> are overwritten in the "if (setup_linear)" block immediately following,
>> and that is what gets written back out.
> 
> Hi Shannon,
> 
> This is pretty standard clear before set, so you're right that it would
> make more sense to have |= rather than =.
> 
> Are you seeing an issue, or did you catch this via code inspection?

Purely a code inspection, I saw this while looking at something else.

sln

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

* RE: [Intel-wired-lan] Possible read-modify-write bug in ixgbe x550 phy setup
  2018-02-02  0:43   ` Shannon Nelson
@ 2018-02-02  0:58     ` Tantilov, Emil S
  2018-02-02 21:08       ` Tantilov, Emil S
  0 siblings, 1 reply; 6+ messages in thread
From: Tantilov, Emil S @ 2018-02-02  0:58 UTC (permalink / raw)
  To: Shannon Nelson; +Cc: netdev, intel-wired-lan

>-----Original Message-----
>From: Shannon Nelson [mailto:shannon.nelson@oracle.com]
>Sent: Thursday, February 01, 2018 4:44 PM
>To: Tantilov, Emil S <emil.s.tantilov@intel.com>
>Cc: netdev@vger.kernel.org; intel-wired-lan@lists.osuosl.org
>Subject: Re: [Intel-wired-lan] Possible read-modify-write bug in ixgbe
>x550 phy setup
>
>On 2/1/2018 4:34 PM, Tantilov, Emil S wrote:
>>> -----Original Message-----
>>> From: Intel-wired-lan [mailto:intel-wired-lan-bounces@osuosl.org] On
>>> Behalf Of Shannon Nelson
>>> Sent: Thursday, February 01, 2018 3:46 PM
>>> To: Tantilov, Emil S <emil.s.tantilov@intel.com>
>>> Cc: netdev@vger.kernel.org; intel-wired-lan@lists.osuosl.org
>>> Subject: [Intel-wired-lan] Possible read-modify-write bug in ixgbe
>x550
>>> phy setup
>>>
>>> Hi Emil,
>>>
>>> I was looking through a set of ixgbe patches and came across this
>commit
>>>
>>>      commit 410a494902777c11f95031d9ed757d7f8f09c5c6
>>>      ixgbe: add write flush when configuring CS4223/7
>>>
>>> and am wondering about the setting of reg_phy_ext in the middle of
>>> ixgbe_setup_mac_link_sfp_x550a().  It looks like it is read from the
>>> PHY, modified to remove the CX1 and SR mode bits, but then those bits
>>> are overwritten in the "if (setup_linear)" block immediately
>following,
>>> and that is what gets written back out.
>>
>> Hi Shannon,
>>
>> This is pretty standard clear before set, so you're right that it
>would
>> make more sense to have |= rather than =.
>>
>> Are you seeing an issue, or did you catch this via code inspection?
>
>Purely a code inspection, I saw this while looking at something else.
>
>sln

Thanks for letting us know. I will do some more testing with the actual HW
before changing the code.

Emil

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

* RE: [Intel-wired-lan] Possible read-modify-write bug in ixgbe x550 phy setup
  2018-02-02  0:58     ` Tantilov, Emil S
@ 2018-02-02 21:08       ` Tantilov, Emil S
  2018-02-02 21:21         ` Shannon Nelson
  0 siblings, 1 reply; 6+ messages in thread
From: Tantilov, Emil S @ 2018-02-02 21:08 UTC (permalink / raw)
  To: Tantilov, Emil S, Shannon Nelson; +Cc: netdev, intel-wired-lan, Greenwalt, Paul

>-----Original Message-----
>From: Intel-wired-lan [mailto:intel-wired-lan-bounces@osuosl.org] On
>Behalf Of Tantilov, Emil S
>Sent: Thursday, February 01, 2018 4:58 PM
>To: Shannon Nelson <shannon.nelson@oracle.com>
>Cc: netdev@vger.kernel.org; intel-wired-lan@lists.osuosl.org
>Subject: Re: [Intel-wired-lan] Possible read-modify-write bug in ixgbe
>x550 phy setup
>
>>-----Original Message-----
>>From: Shannon Nelson [mailto:shannon.nelson@oracle.com]
>>Sent: Thursday, February 01, 2018 4:44 PM
>>To: Tantilov, Emil S <emil.s.tantilov@intel.com>
>>Cc: netdev@vger.kernel.org; intel-wired-lan@lists.osuosl.org
>>Subject: Re: [Intel-wired-lan] Possible read-modify-write bug in ixgbe
>>x550 phy setup
>>
>>On 2/1/2018 4:34 PM, Tantilov, Emil S wrote:
>>>> -----Original Message-----
>>>> From: Intel-wired-lan [mailto:intel-wired-lan-bounces@osuosl.org] On
>>>> Behalf Of Shannon Nelson
>>>> Sent: Thursday, February 01, 2018 3:46 PM
>>>> To: Tantilov, Emil S <emil.s.tantilov@intel.com>
>>>> Cc: netdev@vger.kernel.org; intel-wired-lan@lists.osuosl.org
>>>> Subject: [Intel-wired-lan] Possible read-modify-write bug in ixgbe
>>x550
>>>> phy setup
>>>>
>>>> Hi Emil,
>>>>
>>>> I was looking through a set of ixgbe patches and came across this
>>commit
>>>>
>>>>      commit 410a494902777c11f95031d9ed757d7f8f09c5c6
>>>>      ixgbe: add write flush when configuring CS4223/7
>>>>
>>>> and am wondering about the setting of reg_phy_ext in the middle of
>>>> ixgbe_setup_mac_link_sfp_x550a().  It looks like it is read from the
>>>> PHY, modified to remove the CX1 and SR mode bits, but then those
>bits
>>>> are overwritten in the "if (setup_linear)" block immediately
>>following,
>>>> and that is what gets written back out.
>>>
>>> Hi Shannon,
>>>
>>> This is pretty standard clear before set, so you're right that it
>>would
>>> make more sense to have |= rather than =.
>>>
>>> Are you seeing an issue, or did you catch this via code inspection?
>>
>>Purely a code inspection, I saw this while looking at something else.
>>
>>sln
>
>Thanks for letting us know. I will do some more testing with the actual
>HW before changing the code.

Just FYI - we looked at the reads and confirmed that there is no functional
bug in the code because as it happens the CX1/SR bits is the only bits that
are read and set and as such we don't lose any data. This of course means
that the read is not needed and we'll just remove it.

Thanks,
Emil

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

* Re: [Intel-wired-lan] Possible read-modify-write bug in ixgbe x550 phy setup
  2018-02-02 21:08       ` Tantilov, Emil S
@ 2018-02-02 21:21         ` Shannon Nelson
  0 siblings, 0 replies; 6+ messages in thread
From: Shannon Nelson @ 2018-02-02 21:21 UTC (permalink / raw)
  To: Tantilov, Emil S; +Cc: netdev, intel-wired-lan, Greenwalt, Paul

On 2/2/2018 1:08 PM, Tantilov, Emil S wrote:
> Just FYI - we looked at the reads and confirmed that there is no functional
> bug in the code because as it happens the CX1/SR bits is the only bits that
> are read and set and as such we don't lose any data. This of course means
> that the read is not needed and we'll just remove it.

Great - I'm glad to see it happens to work.  You might think about 
keeping that read for future safety and fixing the '=', but I'm not 
going to worry about it.

sln

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

end of thread, other threads:[~2018-02-02 21:21 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-01 23:46 Possible read-modify-write bug in ixgbe x550 phy setup Shannon Nelson
2018-02-02  0:34 ` [Intel-wired-lan] " Tantilov, Emil S
2018-02-02  0:43   ` Shannon Nelson
2018-02-02  0:58     ` Tantilov, Emil S
2018-02-02 21:08       ` Tantilov, Emil S
2018-02-02 21:21         ` Shannon Nelson

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).