netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Jiawen Wu" <jiawenwu@trustnetic.com>
To: "'Andrew Lunn'" <andrew@lunn.ch>
Cc: <netdev@vger.kernel.org>, <mengyuanlou@net-swift.com>
Subject: RE: [PATCH net-next v2 01/16] net: txgbe: Store PCI info
Date: Wed, 31 Aug 2022 10:20:18 +0800	[thread overview]
Message-ID: <025701d8bce0$36fc7300$a4f55900$@trustnetic.com> (raw)
In-Reply-To: <Yw6mFbl8abA1lgma@lunn.ch>

On Wednesday, August 31, 2022 8:07 AM, Andrew Lunn wrote:
> > +/* cmd_addr is used for some special command:
> > + * 1. to be sector address, when implemented erase sector command
> > + * 2. to be flash address when implemented read, write flash address
> > +*/ int txgbe_fmgr_cmd_op(struct txgbe_hw *hw, u32 cmd, u32 cmd_addr)
> > +{
> > +	u32 cmd_val = 0, val = 0;
> > +
> > +	cmd_val = (cmd << SPI_CLK_CMD_OFFSET) |
> > +		  (SPI_CLK_DIV << SPI_CLK_DIV_OFFSET) | cmd_addr;
> > +	wr32(hw, SPI_H_CMD_REG_ADDR, cmd_val);
> > +
> > +	return read_poll_timeout(rd32, val, (val & 0x1), 10,
> SPI_TIME_OUT_VALUE,
> > +				 false, hw, SPI_H_STA_REG_ADDR);
> > +}
> > +
> 
> > +int txgbe_flash_read_dword(struct txgbe_hw *hw, u32 addr, u32 *data)
> > +{
> > +	int ret = 0;
> > +
> > +	ret = txgbe_fmgr_cmd_op(hw, SPI_CMD_READ_DWORD, addr);
> > +	if (ret == -ETIMEDOUT)
> > +		return ret;
> 
> Are you absolutely sure it will never return any other error code?
> The pattern in the kernel is
> 
> > +	if (ret)
> > +		return ret;
> 
> or
> 
> > +	if (ret < 0)
> > +		return ret;
> 

I found that the function 'read_poll_timeout()' only returns 0 or
-ETIMEDOUT.
But I'll fix it to be safe.

> > +int txgbe_check_flash_load(struct txgbe_hw *hw, u32 check_bit) {
> > +	u32 i = 0, reg = 0;
> > +	int err = 0;
> > +
> > +	/* if there's flash existing */
> > +	if (!(rd32(hw, TXGBE_SPI_STATUS) &
> > +	      TXGBE_SPI_STATUS_FLASH_BYPASS)) {
> > +		/* wait hw load flash done */
> > +		for (i = 0; i < TXGBE_MAX_FLASH_LOAD_POLL_TIME; i++) {
> > +			reg = rd32(hw, TXGBE_SPI_ILDR_STATUS);
> > +			if (!(reg & check_bit)) {
> > +				/* done */
> > +				break;
> > +			}
> > +			msleep(200);
> > +		}
> 
> This is what iopoll.h is for. Any sort of loop waiting for something to
happen
> should use one of the helpers in there.
> 

The description of functions in iopoll.h states that maximum sleep time
should be less than 20ms, is it okay to call it here for 200ms.



  reply	other threads:[~2022-08-31  2:21 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-30  7:04 [PATCH net-next v2 00/16] net: WangXun txgbe ethernet driver Jiawen Wu
2022-08-30  7:04 ` [PATCH net-next v2 01/16] net: txgbe: Store PCI info Jiawen Wu
2022-08-31  0:06   ` Andrew Lunn
2022-08-31  2:20     ` Jiawen Wu [this message]
2022-08-31 23:59       ` Andrew Lunn
2022-08-30  7:04 ` [PATCH net-next v2 02/16] net: txgbe: Reset hardware Jiawen Wu
2022-08-31  0:39   ` Andrew Lunn
2022-08-31  2:54     ` Jiawen Wu
2022-09-01  0:03       ` Andrew Lunn
2022-08-30  7:04 ` [PATCH net-next v2 03/16] net: txgbe: Set MAC address and register netdev Jiawen Wu
2022-08-31  1:02   ` Andrew Lunn
2022-09-22  9:58     ` Jiawen Wu
2022-08-30  7:04 ` [PATCH net-next v2 04/16] net: txgbe: Add operations to interact with firmware Jiawen Wu
2022-08-30  7:04 ` [PATCH net-next v2 05/16] net: txgbe: Identify PHY and SFP module Jiawen Wu
2022-08-30  7:04 ` [PATCH net-next v2 06/16] net: txgbe: Initialize service task Jiawen Wu
2022-08-30  7:04 ` [PATCH net-next v2 07/16] net: txgbe: Support to setup link Jiawen Wu
2022-08-30  7:04 ` [PATCH net-next v2 08/16] net: txgbe: Add interrupt support Jiawen Wu
2022-08-30  7:04 ` [PATCH net-next v2 09/16] net: txgbe: Handle various event interrupts Jiawen Wu
2022-08-30  7:04 ` [PATCH net-next v2 10/16] net: txgbe: Configure Rx and Tx unit of the MAC Jiawen Wu
2022-08-30  7:04 ` [PATCH net-next v2 11/16] net: txgbe: Allocate Rx and Tx resources Jiawen Wu
2022-08-30 23:31   ` kernel test robot
2022-08-30  7:04 ` [PATCH net-next v2 12/16] net: txgbe: Add Rx and Tx cleanup routine Jiawen Wu
2022-08-30  7:04 ` [PATCH net-next v2 13/16] net: txgbe: Add device Rx features Jiawen Wu
2022-09-03 19:50   ` kernel test robot
2022-08-30  7:04 ` [PATCH net-next v2 14/16] net: txgbe: Add transmit path to process packets Jiawen Wu
2022-08-30  7:04 ` [PATCH net-next v2 15/16] net: txgbe: Support to get system network statistics Jiawen Wu
2022-08-30  7:04 ` [PATCH net-next v2 16/16] net: txgbe: support to respond Tx hang Jiawen Wu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='025701d8bce0$36fc7300$a4f55900$@trustnetic.com' \
    --to=jiawenwu@trustnetic.com \
    --cc=andrew@lunn.ch \
    --cc=mengyuanlou@net-swift.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).