public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
From: "Jiawen Wu" <jiawenwu@trustnetic.com>
To: "'Andy Shevchenko'" <andriy.shevchenko@linux.intel.com>
Cc: <andi.shyti@kernel.org>, <jarkko.nikula@linux.intel.com>,
	<mika.westerberg@linux.intel.com>, <jsd@semihalf.com>,
	<davem@davemloft.net>, <edumazet@google.com>, <kuba@kernel.org>,
	<pabeni@redhat.com>, <rmk+kernel@armlinux.org.uk>,
	<andrew@lunn.ch>, <linux-i2c@vger.kernel.org>,
	<netdev@vger.kernel.org>, <mengyuanlou@net-swift.com>,
	<duanqiangwen@net-swift.com>, <stable@vger.kernel.org>
Subject: RE: [PATCH net 3/3] i2c: designware: support hardware lock for Wangxun 10Gb NIC
Date: Thu, 29 Aug 2024 17:15:42 +0800	[thread overview]
Message-ID: <02a901daf9f4$063e8cf0$12bba6d0$@trustnetic.com> (raw)
In-Reply-To: <ZsiZALjnoUpb0H_I@smile.fi.intel.com>

On Fri, Aug 23, 2024 10:13 PM, Andy Shevchenko wrote:
> On Fri, Aug 23, 2024 at 11:02:42AM +0800, Jiawen Wu wrote:
> > Support acquire_lock() and release_lock() for Wangxun 10Gb NIC. Since the
> > firmware needs to access I2C all the time for some features, the semaphore
> > is used between software and firmware. The driver should set software
> > semaphore before accessing I2C bus and release it when it is finished.
> > Otherwise, there is probability that the correct information on I2C bus
> > will not be obtained.
> 
> ...
> 
> >  i2c-designware-core-$(CONFIG_I2C_DESIGNWARE_SLAVE) 	+= i2c-designware-slave.o
> 
> >  i2c-designware-platform-y 				:= i2c-designware-platdrv.o
> > +i2c-designware-platform-y 				+= i2c-designware-wx.o
> 
> These lines have TABs/spaces mixture. Please fix at least your entry to avoid
> this from happening.
> 
> 
> ...
> 
> >  int i2c_dw_amdpsp_probe_lock_support(struct dw_i2c_dev *dev);
> >  #endif
> 
> ^^^
> 
> > +int i2c_dw_txgbe_probe_lock_support(struct dw_i2c_dev *dev);
> 
> See below.
> 
> ...
> 
> >  		.probe = i2c_dw_amdpsp_probe_lock_support,
> >  	},
> >  #endif
> 
> ^^^
> 
> > +	{
> > +		.probe = i2c_dw_txgbe_probe_lock_support,
> > +	},
> 
> Do we all need this support? Even if the driver is not compiled? Why?

I'll add the macro CONFIG_I2C_DESIGNWARE_WX to control it.

> ...
> 
> > +#include <linux/platform_data/i2c-wx.h>
> > +#include <linux/platform_device.h>
> > +#include <linux/i2c.h>
> > +#include <linux/pci.h>
> 
> This is a semi-random list. Please, take your time to understand the core you
> wrote. Follow IWYU principle.
> 
> ...
> 
> > +static int i2c_dw_txgbe_acquire_lock(struct dw_i2c_dev *dev)
> > +{
> > +	void __iomem *req_addr;
> > +	u32 swsm;
> > +	int i;
> > +
> > +	req_addr = dev->ext + I2C_DW_TXGBE_MNG_SW;
> > +
> > +	for (i = 0; i < I2C_DW_TXGBE_REQ_RETRY_CNT; i++) {
> 
> Retry loops much better in a form of
> 
> 	unsigned int retries = ...;
> 	...
> 	do {
> 		...
> 	} while (--retries);
> 
> BUT... see below.
> 
> > +		writel(I2C_DW_TXGBE_MNG_SW_SM, req_addr);
> > +
> > +		/* If we set the bit successfully then we got semaphore. */
> > +		swsm = readl(req_addr);
> > +		if (swsm & I2C_DW_TXGBE_MNG_SW_SM)
> > +			break;
> > +
> > +		udelay(50);
> 
> So, can a macro from iopoll.h be utilised here? Why not?

I need to write the register first and then read it in this loop.
It does not seem to apply to the macros in iopoll.h.

> > +	}
> > +
> > +	if (i == I2C_DW_TXGBE_REQ_RETRY_CNT)
> > +		return -ETIMEDOUT;
> > +
> > +	return 0;
> > +}
> 
> > +int i2c_dw_txgbe_probe_lock_support(struct dw_i2c_dev *dev)
> > +{
> > +	struct platform_device *pdev = to_platform_device(dev->dev);
> 
> Why do you need this dance? I.o.w. how pdev is being used here?

I'll change to add the data in node property.
 


  reply	other threads:[~2024-08-29  9:16 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20240823030242.3083528-1-jiawenwu@trustnetic.com>
2024-08-23  3:02 ` [PATCH net 1/3] net: txgbe: add IO address in I2C platform device data Jiawen Wu
2024-08-23 14:14   ` Andy Shevchenko
2024-08-23  3:02 ` [PATCH net 2/3] i2c: designware: add device private data passing to lock functions Jiawen Wu
2024-08-23 14:06   ` Andy Shevchenko
2024-08-27 13:24   ` Paolo Abeni
2024-08-29  5:16   ` kernel test robot
2024-08-23  3:02 ` [PATCH net 3/3] i2c: designware: support hardware lock for Wangxun 10Gb NIC Jiawen Wu
2024-08-23 14:13   ` Andy Shevchenko
2024-08-29  9:15     ` Jiawen Wu [this message]
2024-08-29 10:59       ` 'Andy Shevchenko'

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='02a901daf9f4$063e8cf0$12bba6d0$@trustnetic.com' \
    --to=jiawenwu@trustnetic.com \
    --cc=andi.shyti@kernel.org \
    --cc=andrew@lunn.ch \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=davem@davemloft.net \
    --cc=duanqiangwen@net-swift.com \
    --cc=edumazet@google.com \
    --cc=jarkko.nikula@linux.intel.com \
    --cc=jsd@semihalf.com \
    --cc=kuba@kernel.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=mengyuanlou@net-swift.com \
    --cc=mika.westerberg@linux.intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=rmk+kernel@armlinux.org.uk \
    --cc=stable@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