lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YyY1vESf5JalT6GR@shikoro>
Date:   Sat, 17 Sep 2022 23:01:48 +0200
From:   Wolfram Sang <wsa@...nel.org>
To:     Tharun Kumar P <tharunkumar.pasumarthi@...rochip.com>
Cc:     linux-i2c@...r.kernel.org, linux-kernel@...r.kernel.org,
        andriy.shevchenko@...ux.intel.com, krzk@...nel.org,
        jarkko.nikula@...ux.intel.com, robh@...nel.org,
        semen.protsenko@...aro.org, sven@...npeter.dev, jsd@...ihalf.com,
        rafal@...ecki.pl, olof@...om.net, arnd@...db.de,
        UNGLinuxDriver@...rochip.com
Subject: Re: [PATCH v4 i2c-master] i2c: microchip: pci1xxxx: Add driver for
 I2C host controller in multifunction endpoint of pci1xxxx switch

Hi,

On Wed, Sep 07, 2022 at 09:41:43PM +0530, Tharun Kumar P wrote:
> Microchip pci1xxxx is an unmanaged PCIe3.1a Switch for Consumer,
> Industrial and Automotive applications. This switch has multiple
> downstream ports. In one of the Switch's Downstream port, there
> is a multifunction endpoint for peripherals which includes an I2C
> host controller. The I2C function in the endpoint operates at 100KHz,
> 400KHz and 1 MHz and has buffer depth of 128 bytes.
> This patch provides the I2C controller driver for the I2C function
> of the switch.
> 
> Signed-off-by: Tharun Kumar P <tharunkumar.pasumarthi@...rochip.com>

Thank you for the driver and thanks to Andy for reviewing it this far.
He is right, some nits are there which can be fixed later. But a few
things I need to comment on:

> +static u32 pci1xxxx_i2c_get_funcs(struct i2c_adapter *adap)
> +{
> +	return I2C_FUNC_I2C | I2C_FUNC_PROTOCOL_MANGLING |
> +		I2C_FUNC_SMBUS_BLOCK_PROC_CALL |
> +		I2C_FUNC_SMBUS_READ_BYTE | I2C_FUNC_SMBUS_WRITE_BYTE |
> +		I2C_FUNC_SMBUS_READ_BYTE_DATA |
> +		I2C_FUNC_SMBUS_WRITE_BYTE_DATA |
> +		I2C_FUNC_SMBUS_READ_WORD_DATA |
> +		I2C_FUNC_SMBUS_WRITE_WORD_DATA |
> +		I2C_FUNC_SMBUS_PROC_CALL | I2C_FUNC_SMBUS_READ_BLOCK_DATA |
> +		I2C_FUNC_SMBUS_WRITE_BLOCK_DATA;
> +}

If you can't do I2C_FUNC_SMBUS_QUICK, then you need an i2c_adapter_quirk
struct saying that your HW cannot do 0 byte length transfers.

Also, a lot can be simplified here, e.g. I2C_FUNC_SMBUS_BYTE covers both
cases, read and write.

...

> +	/* Register the isr. We are not using any isr flags here. */

Why not use then simply 0 instead of a define and a comment?

> +	ret = devm_request_irq(dev, pci_irq_vector(pdev, 0), pci1xxxx_i2c_isr,
> +			       PCI1XXXX_IRQ_FLAGS, pci_name(pdev), i2c);
> +	if (ret)
> +		return ret;
> +
> +	i2c->adap = pci1xxxx_i2c_ops;
> +	i2c->adap.class = I2C_CLASS_SPD;

I need to make sure: do you intentionally want autoprobing for SPD? I
ask because it could be needed but it costs boottime when not needed.
And changing the class once exposed is troublesome.

Happy hacking,

   Wolfram


Download attachment "signature.asc" of type "application/pgp-signature" (834 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ