All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thierry Reding <thierry.reding@gmail.com>
To: Dmitry Osipenko <digetx@gmail.com>
Cc: Sowjanya Komatineni <skomatineni@nvidia.com>,
	Jonathan Hunter <jonathanh@nvidia.com>,
	Mantravadi Karthik <mkarthik@nvidia.com>,
	Shardar Mohammed <smohammed@nvidia.com>,
	Timo Alho <talho@nvidia.com>,
	"linux-tegra@vger.kernel.org" <linux-tegra@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-i2c@vger.kernel.org" <linux-i2c@vger.kernel.org>
Subject: Re: [PATCH V14 3/5] i2c: tegra: Add DMA support
Date: Thu, 7 Feb 2019 17:06:30 +0100	[thread overview]
Message-ID: <20190207160630.GB17445@ulmo> (raw)
In-Reply-To: <0a7d62c4-9dcd-08dd-4e3f-877184848daa@gmail.com>

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

On Thu, Feb 07, 2019 at 07:01:45PM +0300, Dmitry Osipenko wrote:
> 07.02.2019 18:23, Sowjanya Komatineni пишет:
> > 
> >> It became apparent to me that there is a problem here. The size of dma_buf is 4096 bytes and maximum message length is 4096 too, we have pushed 12 bytes packet_header to the buffer >and now there are 4084 bytes left for the message in the buffer. Hence transfer of 4KB will cause buffer overflow and either crash kernel or corrupt memory. One solution is to just always >push packet_header using PIO, other to reduce max_write_len or increase dma_buf size.
> > 
> > Yes, This is known to me and I will add separate patch for this to update quirks to take care for t186 and t194 to exclude packet hdr lengths
> > There was separate patch when quirks were added and it got merged already from 5.0-rc1 but don’t want to sneak that here. Will send separate patch to take care of this.
> > Need to update quirk to exclude packet header
> > 
> 
> No. This is a bug of this patch, it must be fixed in this patch as well. 
> 
> Please include this snippet into the next version of this patch.
> 
> diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c
> index 7921d3e6237d..0ed8162a37e4 100644
> --- a/drivers/i2c/busses/i2c-tegra.c
> +++ b/drivers/i2c/busses/i2c-tegra.c
> @@ -1293,7 +1293,7 @@ static const struct i2c_algorithm tegra_i2c_algo = {
>  static const struct i2c_adapter_quirks tegra_i2c_quirks = {
>         .flags = I2C_AQ_NO_ZERO_LEN,
>         .max_read_len = 4096,
> -       .max_write_len = 4096,
> +       .max_write_len = 4096 - I2C_PACKET_HEADER_SIZE,
>  };
>  
>  static const struct i2c_adapter_quirks tegra194_i2c_quirks = {
> @@ -1545,7 +1545,7 @@ static int tegra_i2c_probe(struct platform_device *pdev)
>         i2c_dev->is_dvc = of_device_is_compatible(pdev->dev.of_node,
>                                                   "nvidia,tegra20-i2c-dvc");
>         i2c_dev->adapter.quirks = i2c_dev->hw->quirks;
> -       i2c_dev->dma_buf_size = i2c_dev->adapter.quirks->max_write_len;
> +       i2c_dev->dma_buf_size = i2c_dev->adapter.quirks->max_read_len;
>         init_completion(&i2c_dev->msg_complete);
>         init_completion(&i2c_dev->dma_complete);
>         spin_lock_init(&i2c_dev->xfer_lock);

I'm not sure we actually need this. My understanding is that it's really
the payload size that's 4 KiB and 64 KiB, respectively. I don't think
that includes the header.

Thierry

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2019-02-07 16:06 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-06 19:16 [PATCH V14 1/5] i2c: tegra: sort all the include headers alphabetically Sowjanya Komatineni
2019-02-06 19:16 ` Sowjanya Komatineni
2019-02-06 19:16 ` [PATCH V14 2/5] i2c: tegra: add bus clear Master Support Sowjanya Komatineni
2019-02-06 19:16   ` Sowjanya Komatineni
2019-02-07 18:26   ` Dmitry Osipenko
2019-02-06 19:16 ` [PATCH V14 3/5] i2c: tegra: Add DMA support Sowjanya Komatineni
2019-02-06 19:16   ` Sowjanya Komatineni
2019-02-07 11:01   ` Thierry Reding
2019-02-07 13:57   ` Dmitry Osipenko
2019-02-07 15:23     ` Sowjanya Komatineni
2019-02-07 16:01       ` Dmitry Osipenko
2019-02-07 16:06         ` Thierry Reding [this message]
2019-02-07 16:08           ` Sowjanya Komatineni
2019-02-07 16:17             ` Dmitry Osipenko
2019-02-07 18:02               ` Sowjanya Komatineni
2019-02-07 18:22                 ` Dmitry Osipenko
2019-02-07 14:52   ` Dmitry Osipenko
2019-02-07 15:11     ` Sowjanya Komatineni
2019-02-07 15:17       ` Dmitry Osipenko
2019-02-07 15:17       ` Sowjanya Komatineni
2019-02-07 15:56         ` Dmitry Osipenko
2019-02-07 16:02       ` Thierry Reding
2019-02-07 18:24   ` Dmitry Osipenko
2019-02-07 18:50   ` Dmitry Osipenko
2019-02-07 18:56     ` Sowjanya Komatineni
2019-02-07 19:03       ` Dmitry Osipenko
2019-02-07 19:14         ` Sowjanya Komatineni
2019-02-07 18:55   ` Dmitry Osipenko
2019-02-07 19:14   ` Dmitry Osipenko
2019-02-07 20:22     ` Dmitry Osipenko
2019-02-07 20:46   ` Dmitry Osipenko
2019-02-06 19:16 ` [PATCH V14 4/5] i2c: tegra: update transfer timeout Sowjanya Komatineni
2019-02-06 19:16   ` Sowjanya Komatineni
2019-02-06 19:16 ` [PATCH V14 5/5] i2c: tegra: add i2c interface timing support Sowjanya Komatineni
2019-02-06 19:16   ` Sowjanya Komatineni
2019-02-07 14:34   ` Dmitry Osipenko

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=20190207160630.GB17445@ulmo \
    --to=thierry.reding@gmail.com \
    --cc=digetx@gmail.com \
    --cc=jonathanh@nvidia.com \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=mkarthik@nvidia.com \
    --cc=skomatineni@nvidia.com \
    --cc=smohammed@nvidia.com \
    --cc=talho@nvidia.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.