linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V2] i2c: ismt: fix wrong device address when unmap the data buffer
@ 2017-06-13  4:59 Song liwei
  2017-06-13  7:42 ` Andy Shevchenko
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Song liwei @ 2017-06-13  4:59 UTC (permalink / raw)
  To: Wolfram Sang, Andy Shevchenko
  Cc: Seth Heasley, Neil Horman, linux-i2c, linux-kernel, LiweiSong

From: Liwei Song <liwei.song@windriver.com>

Fix the following kernel bug:

kernel BUG at drivers/iommu/intel-iommu.c:3260!
invalid opcode: 0000 [#5] PREEMPT SMP
Hardware name: Intel Corp. Harcuvar/Server, BIOS HAVLCRB0.X64.0013.D39.1608311820 08/31/2016
task: ffff880175389950 ti: ffff880176bec000 task.ti: ffff880176bec000
RIP: 0010:[<ffffffff8150a83b>]  [<ffffffff8150a83b>] intel_unmap+0x25b/0x260
RSP: 0018:ffff880176bef5e8  EFLAGS: 00010296
RAX: 0000000000000024 RBX: ffff8800773c7c88 RCX: 000000000000ce04
RDX: 0000000080000000 RSI: 0000000000000000 RDI: 0000000000000009
RBP: ffff880176bef638 R08: 0000000000000010 R09: 0000000000000004
R10: ffff880175389c78 R11: 0000000000000a4f R12: ffff8800773c7868
R13: 00000000ffffac88 R14: ffff8800773c7818 R15: 0000000000000001
FS:  00007fef21258700(0000) GS:ffff88017b5c0000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 000000000066d6d8 CR3: 000000007118c000 CR4: 00000000003406e0
Stack:
 00000000ffffac88 ffffffff8199867f ffff880176bef5f8 ffff880100000030
 ffff880176bef668 ffff8800773c7c88 ffff880178288098 ffff8800772c0010
 ffff8800773c7818 0000000000000001 ffff880176bef648 ffffffff8150a86e
Call Trace:
 [<ffffffff8199867f>] ? printk+0x46/0x48
 [<ffffffff8150a86e>] intel_unmap_page+0xe/0x10
 [<ffffffffa039d99b>] ismt_access+0x27b/0x8fa [i2c_ismt]
 [<ffffffff81554420>] ? __pm_runtime_suspend+0xa0/0xa0
 [<ffffffff815544a0>] ? pm_suspend_timer_fn+0x80/0x80
 [<ffffffff81554420>] ? __pm_runtime_suspend+0xa0/0xa0
 [<ffffffff815544a0>] ? pm_suspend_timer_fn+0x80/0x80
 [<ffffffff8143dfd0>] ? pci_bus_read_dev_vendor_id+0xf0/0xf0
 [<ffffffff8172b36c>] i2c_smbus_xfer+0xec/0x4b0
 [<ffffffff810aa4d5>] ? vprintk_emit+0x345/0x530
 [<ffffffffa038936b>] i2cdev_ioctl_smbus+0x12b/0x240 [i2c_dev]
 [<ffffffff810aa829>] ? vprintk_default+0x29/0x40
 [<ffffffffa0389b33>] i2cdev_ioctl+0x63/0x1ec [i2c_dev]
 [<ffffffff811b04c8>] do_vfs_ioctl+0x328/0x5d0
 [<ffffffff8119d8ec>] ? vfs_write+0x11c/0x190
 [<ffffffff8109d449>] ? rt_up_read+0x19/0x20
 [<ffffffff811b07f1>] SyS_ioctl+0x81/0xa0
 [<ffffffff819a351b>] system_call_fastpath+0x16/0x6e

This happen When run "i2cdetect -y 0" detect SMBus iSMT adapter.

After finished I2C block read/write, when unmap the data buffer,
a wrong device address was pass to dma_unmap_single().

To fix this, give dma_unmap_single() the "dev" parameter, just like
what dma_map_single() does, then unmap can find the right devices.

Fixes: 13f35ac14cd0 ("i2c: Adding support for Intel iSMT SMBus 2.0 host controller")
Signed-off-by: Liwei Song <liwei.song@windriver.com>
---
 drivers/i2c/busses/i2c-ismt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/i2c/busses/i2c-ismt.c b/drivers/i2c/busses/i2c-ismt.c
index f573448..e98e44e 100644
--- a/drivers/i2c/busses/i2c-ismt.c
+++ b/drivers/i2c/busses/i2c-ismt.c
@@ -584,7 +584,7 @@ static int ismt_access(struct i2c_adapter *adap, u16 addr,
 
 	/* unmap the data buffer */
 	if (dma_size != 0)
-		dma_unmap_single(&adap->dev, dma_addr, dma_size, dma_direction);
+		dma_unmap_single(dev, dma_addr, dma_size, dma_direction);
 
 	if (unlikely(!time_left)) {
 		dev_err(dev, "completion wait timed out\n");
-- 
2.7.4

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

* Re: [PATCH V2] i2c: ismt: fix wrong device address when unmap the data buffer
  2017-06-13  4:59 [PATCH V2] i2c: ismt: fix wrong device address when unmap the data buffer Song liwei
@ 2017-06-13  7:42 ` Andy Shevchenko
  2017-06-15 13:54 ` Wolfram Sang
  2018-08-15  2:26 ` Dmitry Safonov
  2 siblings, 0 replies; 6+ messages in thread
From: Andy Shevchenko @ 2017-06-13  7:42 UTC (permalink / raw)
  To: Song liwei
  Cc: Wolfram Sang, Seth Heasley, Neil Horman, linux-i2c, linux-kernel

On Tue, Jun 13, 2017 at 7:59 AM, Song liwei <liwei.song@windriver.com> wrote:
> From: Liwei Song <liwei.song@windriver.com>
>
> Fix the following kernel bug:
>
> kernel BUG at drivers/iommu/intel-iommu.c:3260!
> invalid opcode: 0000 [#5] PREEMPT SMP
> Hardware name: Intel Corp. Harcuvar/Server, BIOS HAVLCRB0.X64.0013.D39.1608311820 08/31/2016
> task: ffff880175389950 ti: ffff880176bec000 task.ti: ffff880176bec000
> RIP: 0010:[<ffffffff8150a83b>]  [<ffffffff8150a83b>] intel_unmap+0x25b/0x260
> RSP: 0018:ffff880176bef5e8  EFLAGS: 00010296
> RAX: 0000000000000024 RBX: ffff8800773c7c88 RCX: 000000000000ce04
> RDX: 0000000080000000 RSI: 0000000000000000 RDI: 0000000000000009
> RBP: ffff880176bef638 R08: 0000000000000010 R09: 0000000000000004
> R10: ffff880175389c78 R11: 0000000000000a4f R12: ffff8800773c7868
> R13: 00000000ffffac88 R14: ffff8800773c7818 R15: 0000000000000001
> FS:  00007fef21258700(0000) GS:ffff88017b5c0000(0000) knlGS:0000000000000000
> CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> CR2: 000000000066d6d8 CR3: 000000007118c000 CR4: 00000000003406e0
> Stack:
>  00000000ffffac88 ffffffff8199867f ffff880176bef5f8 ffff880100000030
>  ffff880176bef668 ffff8800773c7c88 ffff880178288098 ffff8800772c0010
>  ffff8800773c7818 0000000000000001 ffff880176bef648 ffffffff8150a86e
> Call Trace:
>  [<ffffffff8199867f>] ? printk+0x46/0x48
>  [<ffffffff8150a86e>] intel_unmap_page+0xe/0x10
>  [<ffffffffa039d99b>] ismt_access+0x27b/0x8fa [i2c_ismt]
>  [<ffffffff81554420>] ? __pm_runtime_suspend+0xa0/0xa0
>  [<ffffffff815544a0>] ? pm_suspend_timer_fn+0x80/0x80
>  [<ffffffff81554420>] ? __pm_runtime_suspend+0xa0/0xa0
>  [<ffffffff815544a0>] ? pm_suspend_timer_fn+0x80/0x80
>  [<ffffffff8143dfd0>] ? pci_bus_read_dev_vendor_id+0xf0/0xf0
>  [<ffffffff8172b36c>] i2c_smbus_xfer+0xec/0x4b0
>  [<ffffffff810aa4d5>] ? vprintk_emit+0x345/0x530
>  [<ffffffffa038936b>] i2cdev_ioctl_smbus+0x12b/0x240 [i2c_dev]
>  [<ffffffff810aa829>] ? vprintk_default+0x29/0x40
>  [<ffffffffa0389b33>] i2cdev_ioctl+0x63/0x1ec [i2c_dev]
>  [<ffffffff811b04c8>] do_vfs_ioctl+0x328/0x5d0
>  [<ffffffff8119d8ec>] ? vfs_write+0x11c/0x190
>  [<ffffffff8109d449>] ? rt_up_read+0x19/0x20
>  [<ffffffff811b07f1>] SyS_ioctl+0x81/0xa0
>  [<ffffffff819a351b>] system_call_fastpath+0x16/0x6e
>
> This happen When run "i2cdetect -y 0" detect SMBus iSMT adapter.
>
> After finished I2C block read/write, when unmap the data buffer,
> a wrong device address was pass to dma_unmap_single().
>
> To fix this, give dma_unmap_single() the "dev" parameter, just like
> what dma_map_single() does, then unmap can find the right devices.
>

Much better!

Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>

> Fixes: 13f35ac14cd0 ("i2c: Adding support for Intel iSMT SMBus 2.0 host controller")
> Signed-off-by: Liwei Song <liwei.song@windriver.com>
> ---
>  drivers/i2c/busses/i2c-ismt.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/i2c/busses/i2c-ismt.c b/drivers/i2c/busses/i2c-ismt.c
> index f573448..e98e44e 100644
> --- a/drivers/i2c/busses/i2c-ismt.c
> +++ b/drivers/i2c/busses/i2c-ismt.c
> @@ -584,7 +584,7 @@ static int ismt_access(struct i2c_adapter *adap, u16 addr,
>
>         /* unmap the data buffer */
>         if (dma_size != 0)
> -               dma_unmap_single(&adap->dev, dma_addr, dma_size, dma_direction);
> +               dma_unmap_single(dev, dma_addr, dma_size, dma_direction);
>
>         if (unlikely(!time_left)) {
>                 dev_err(dev, "completion wait timed out\n");
> --
> 2.7.4
>



-- 
With Best Regards,
Andy Shevchenko

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

* Re: [PATCH V2] i2c: ismt: fix wrong device address when unmap the data buffer
  2017-06-13  4:59 [PATCH V2] i2c: ismt: fix wrong device address when unmap the data buffer Song liwei
  2017-06-13  7:42 ` Andy Shevchenko
@ 2017-06-15 13:54 ` Wolfram Sang
  2018-08-15  2:26 ` Dmitry Safonov
  2 siblings, 0 replies; 6+ messages in thread
From: Wolfram Sang @ 2017-06-15 13:54 UTC (permalink / raw)
  To: Song liwei
  Cc: Andy Shevchenko, Seth Heasley, Neil Horman, linux-i2c, linux-kernel

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

On Tue, Jun 13, 2017 at 12:59:53AM -0400, Song liwei wrote:
> From: Liwei Song <liwei.song@windriver.com>
> 
> Fix the following kernel bug:
> 
> kernel BUG at drivers/iommu/intel-iommu.c:3260!
> invalid opcode: 0000 [#5] PREEMPT SMP
> Hardware name: Intel Corp. Harcuvar/Server, BIOS HAVLCRB0.X64.0013.D39.1608311820 08/31/2016
> task: ffff880175389950 ti: ffff880176bec000 task.ti: ffff880176bec000
> RIP: 0010:[<ffffffff8150a83b>]  [<ffffffff8150a83b>] intel_unmap+0x25b/0x260
> RSP: 0018:ffff880176bef5e8  EFLAGS: 00010296
> RAX: 0000000000000024 RBX: ffff8800773c7c88 RCX: 000000000000ce04
> RDX: 0000000080000000 RSI: 0000000000000000 RDI: 0000000000000009
> RBP: ffff880176bef638 R08: 0000000000000010 R09: 0000000000000004
> R10: ffff880175389c78 R11: 0000000000000a4f R12: ffff8800773c7868
> R13: 00000000ffffac88 R14: ffff8800773c7818 R15: 0000000000000001
> FS:  00007fef21258700(0000) GS:ffff88017b5c0000(0000) knlGS:0000000000000000
> CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> CR2: 000000000066d6d8 CR3: 000000007118c000 CR4: 00000000003406e0
> Stack:
>  00000000ffffac88 ffffffff8199867f ffff880176bef5f8 ffff880100000030
>  ffff880176bef668 ffff8800773c7c88 ffff880178288098 ffff8800772c0010
>  ffff8800773c7818 0000000000000001 ffff880176bef648 ffffffff8150a86e
> Call Trace:
>  [<ffffffff8199867f>] ? printk+0x46/0x48
>  [<ffffffff8150a86e>] intel_unmap_page+0xe/0x10
>  [<ffffffffa039d99b>] ismt_access+0x27b/0x8fa [i2c_ismt]
>  [<ffffffff81554420>] ? __pm_runtime_suspend+0xa0/0xa0
>  [<ffffffff815544a0>] ? pm_suspend_timer_fn+0x80/0x80
>  [<ffffffff81554420>] ? __pm_runtime_suspend+0xa0/0xa0
>  [<ffffffff815544a0>] ? pm_suspend_timer_fn+0x80/0x80
>  [<ffffffff8143dfd0>] ? pci_bus_read_dev_vendor_id+0xf0/0xf0
>  [<ffffffff8172b36c>] i2c_smbus_xfer+0xec/0x4b0
>  [<ffffffff810aa4d5>] ? vprintk_emit+0x345/0x530
>  [<ffffffffa038936b>] i2cdev_ioctl_smbus+0x12b/0x240 [i2c_dev]
>  [<ffffffff810aa829>] ? vprintk_default+0x29/0x40
>  [<ffffffffa0389b33>] i2cdev_ioctl+0x63/0x1ec [i2c_dev]
>  [<ffffffff811b04c8>] do_vfs_ioctl+0x328/0x5d0
>  [<ffffffff8119d8ec>] ? vfs_write+0x11c/0x190
>  [<ffffffff8109d449>] ? rt_up_read+0x19/0x20
>  [<ffffffff811b07f1>] SyS_ioctl+0x81/0xa0
>  [<ffffffff819a351b>] system_call_fastpath+0x16/0x6e
> 
> This happen When run "i2cdetect -y 0" detect SMBus iSMT adapter.
> 
> After finished I2C block read/write, when unmap the data buffer,
> a wrong device address was pass to dma_unmap_single().
> 
> To fix this, give dma_unmap_single() the "dev" parameter, just like
> what dma_map_single() does, then unmap can find the right devices.
> 
> Fixes: 13f35ac14cd0 ("i2c: Adding support for Intel iSMT SMBus 2.0 host controller")
> Signed-off-by: Liwei Song <liwei.song@windriver.com>

Applied to for-current, thanks!


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

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

* Re: [PATCH V2] i2c: ismt: fix wrong device address when unmap the data buffer
  2017-06-13  4:59 [PATCH V2] i2c: ismt: fix wrong device address when unmap the data buffer Song liwei
  2017-06-13  7:42 ` Andy Shevchenko
  2017-06-15 13:54 ` Wolfram Sang
@ 2018-08-15  2:26 ` Dmitry Safonov
  2018-08-15  9:25   ` Andy Shevchenko
  2 siblings, 1 reply; 6+ messages in thread
From: Dmitry Safonov @ 2018-08-15  2:26 UTC (permalink / raw)
  To: stable, Greg Kroah-Hartman
  Cc: Wolfram Sang, Andy Shevchenko, Seth Heasley, Neil Horman,
	linux-i2c, linux-kernel, Song liwei

+Cc: stable

Hi Greg, JFI:
This one has hit a couple of times on autotests on v4.9 stable.
The fix for BUG() is trivial, so probably worth to ship it to v4.9/v4.4/v3.18.

2017-06-13 5:59 GMT+01:00 Song liwei <liwei.song@windriver.com>:
> From: Liwei Song <liwei.song@windriver.com>
>
> Fix the following kernel bug:
>
> kernel BUG at drivers/iommu/intel-iommu.c:3260!
> invalid opcode: 0000 [#5] PREEMPT SMP
> Hardware name: Intel Corp. Harcuvar/Server, BIOS HAVLCRB0.X64.0013.D39.1608311820 08/31/2016
> task: ffff880175389950 ti: ffff880176bec000 task.ti: ffff880176bec000
> RIP: 0010:[<ffffffff8150a83b>]  [<ffffffff8150a83b>] intel_unmap+0x25b/0x260
> RSP: 0018:ffff880176bef5e8  EFLAGS: 00010296
> RAX: 0000000000000024 RBX: ffff8800773c7c88 RCX: 000000000000ce04
> RDX: 0000000080000000 RSI: 0000000000000000 RDI: 0000000000000009
> RBP: ffff880176bef638 R08: 0000000000000010 R09: 0000000000000004
> R10: ffff880175389c78 R11: 0000000000000a4f R12: ffff8800773c7868
> R13: 00000000ffffac88 R14: ffff8800773c7818 R15: 0000000000000001
> FS:  00007fef21258700(0000) GS:ffff88017b5c0000(0000) knlGS:0000000000000000
> CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> CR2: 000000000066d6d8 CR3: 000000007118c000 CR4: 00000000003406e0
> Stack:
>  00000000ffffac88 ffffffff8199867f ffff880176bef5f8 ffff880100000030
>  ffff880176bef668 ffff8800773c7c88 ffff880178288098 ffff8800772c0010
>  ffff8800773c7818 0000000000000001 ffff880176bef648 ffffffff8150a86e
> Call Trace:
>  [<ffffffff8199867f>] ? printk+0x46/0x48
>  [<ffffffff8150a86e>] intel_unmap_page+0xe/0x10
>  [<ffffffffa039d99b>] ismt_access+0x27b/0x8fa [i2c_ismt]
>  [<ffffffff81554420>] ? __pm_runtime_suspend+0xa0/0xa0
>  [<ffffffff815544a0>] ? pm_suspend_timer_fn+0x80/0x80
>  [<ffffffff81554420>] ? __pm_runtime_suspend+0xa0/0xa0
>  [<ffffffff815544a0>] ? pm_suspend_timer_fn+0x80/0x80
>  [<ffffffff8143dfd0>] ? pci_bus_read_dev_vendor_id+0xf0/0xf0
>  [<ffffffff8172b36c>] i2c_smbus_xfer+0xec/0x4b0
>  [<ffffffff810aa4d5>] ? vprintk_emit+0x345/0x530
>  [<ffffffffa038936b>] i2cdev_ioctl_smbus+0x12b/0x240 [i2c_dev]
>  [<ffffffff810aa829>] ? vprintk_default+0x29/0x40
>  [<ffffffffa0389b33>] i2cdev_ioctl+0x63/0x1ec [i2c_dev]
>  [<ffffffff811b04c8>] do_vfs_ioctl+0x328/0x5d0
>  [<ffffffff8119d8ec>] ? vfs_write+0x11c/0x190
>  [<ffffffff8109d449>] ? rt_up_read+0x19/0x20
>  [<ffffffff811b07f1>] SyS_ioctl+0x81/0xa0
>  [<ffffffff819a351b>] system_call_fastpath+0x16/0x6e
>
> This happen When run "i2cdetect -y 0" detect SMBus iSMT adapter.
>
> After finished I2C block read/write, when unmap the data buffer,
> a wrong device address was pass to dma_unmap_single().
>
> To fix this, give dma_unmap_single() the "dev" parameter, just like
> what dma_map_single() does, then unmap can find the right devices.
>
> Fixes: 13f35ac14cd0 ("i2c: Adding support for Intel iSMT SMBus 2.0 host controller")
> Signed-off-by: Liwei Song <liwei.song@windriver.com>
> ---
>  drivers/i2c/busses/i2c-ismt.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/i2c/busses/i2c-ismt.c b/drivers/i2c/busses/i2c-ismt.c
> index f573448..e98e44e 100644
> --- a/drivers/i2c/busses/i2c-ismt.c
> +++ b/drivers/i2c/busses/i2c-ismt.c
> @@ -584,7 +584,7 @@ static int ismt_access(struct i2c_adapter *adap, u16 addr,
>
>         /* unmap the data buffer */
>         if (dma_size != 0)
> -               dma_unmap_single(&adap->dev, dma_addr, dma_size, dma_direction);
> +               dma_unmap_single(dev, dma_addr, dma_size, dma_direction);
>
>         if (unlikely(!time_left)) {
>                 dev_err(dev, "completion wait timed out\n");
> --
> 2.7.4
>



-- 
             Dmitry

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

* Re: [PATCH V2] i2c: ismt: fix wrong device address when unmap the data buffer
  2018-08-15  2:26 ` Dmitry Safonov
@ 2018-08-15  9:25   ` Andy Shevchenko
  2018-08-16 15:22     ` Greg Kroah-Hartman
  0 siblings, 1 reply; 6+ messages in thread
From: Andy Shevchenko @ 2018-08-15  9:25 UTC (permalink / raw)
  To: Dmitry Safonov
  Cc: stable, Greg Kroah-Hartman, Wolfram Sang, Seth Heasley,
	Neil Horman, linux-i2c, linux-kernel, Song liwei

On Wed, Aug 15, 2018 at 5:26 AM, Dmitry Safonov <0x7f454c46@gmail.com> wrote:
> +Cc: stable
>
> Hi Greg, JFI:
> This one has hit a couple of times on autotests on v4.9 stable.
> The fix for BUG() is trivial, so probably worth to ship it to v4.9/v4.4/v3.18.
>

JFYI:

commit 17e83549e199d89aace7788a9f11c108671eecf5
Author: Liwei Song <liwei.song@windriver.com>
Date:   Tue Jun 13 00:59:53 2017 -0400

   i2c: ismt: fix wrong device address when unmap the data buffer


> 2017-06-13 5:59 GMT+01:00 Song liwei <liwei.song@windriver.com>:
>> From: Liwei Song <liwei.song@windriver.com>
>>
>> Fix the following kernel bug:
>>
>> kernel BUG at drivers/iommu/intel-iommu.c:3260!
>> invalid opcode: 0000 [#5] PREEMPT SMP
>> Hardware name: Intel Corp. Harcuvar/Server, BIOS HAVLCRB0.X64.0013.D39.1608311820 08/31/2016
>> task: ffff880175389950 ti: ffff880176bec000 task.ti: ffff880176bec000
>> RIP: 0010:[<ffffffff8150a83b>]  [<ffffffff8150a83b>] intel_unmap+0x25b/0x260
>> RSP: 0018:ffff880176bef5e8  EFLAGS: 00010296
>> RAX: 0000000000000024 RBX: ffff8800773c7c88 RCX: 000000000000ce04
>> RDX: 0000000080000000 RSI: 0000000000000000 RDI: 0000000000000009
>> RBP: ffff880176bef638 R08: 0000000000000010 R09: 0000000000000004
>> R10: ffff880175389c78 R11: 0000000000000a4f R12: ffff8800773c7868
>> R13: 00000000ffffac88 R14: ffff8800773c7818 R15: 0000000000000001
>> FS:  00007fef21258700(0000) GS:ffff88017b5c0000(0000) knlGS:0000000000000000
>> CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
>> CR2: 000000000066d6d8 CR3: 000000007118c000 CR4: 00000000003406e0
>> Stack:
>>  00000000ffffac88 ffffffff8199867f ffff880176bef5f8 ffff880100000030
>>  ffff880176bef668 ffff8800773c7c88 ffff880178288098 ffff8800772c0010
>>  ffff8800773c7818 0000000000000001 ffff880176bef648 ffffffff8150a86e
>> Call Trace:
>>  [<ffffffff8199867f>] ? printk+0x46/0x48
>>  [<ffffffff8150a86e>] intel_unmap_page+0xe/0x10
>>  [<ffffffffa039d99b>] ismt_access+0x27b/0x8fa [i2c_ismt]
>>  [<ffffffff81554420>] ? __pm_runtime_suspend+0xa0/0xa0
>>  [<ffffffff815544a0>] ? pm_suspend_timer_fn+0x80/0x80
>>  [<ffffffff81554420>] ? __pm_runtime_suspend+0xa0/0xa0
>>  [<ffffffff815544a0>] ? pm_suspend_timer_fn+0x80/0x80
>>  [<ffffffff8143dfd0>] ? pci_bus_read_dev_vendor_id+0xf0/0xf0
>>  [<ffffffff8172b36c>] i2c_smbus_xfer+0xec/0x4b0
>>  [<ffffffff810aa4d5>] ? vprintk_emit+0x345/0x530
>>  [<ffffffffa038936b>] i2cdev_ioctl_smbus+0x12b/0x240 [i2c_dev]
>>  [<ffffffff810aa829>] ? vprintk_default+0x29/0x40
>>  [<ffffffffa0389b33>] i2cdev_ioctl+0x63/0x1ec [i2c_dev]
>>  [<ffffffff811b04c8>] do_vfs_ioctl+0x328/0x5d0
>>  [<ffffffff8119d8ec>] ? vfs_write+0x11c/0x190
>>  [<ffffffff8109d449>] ? rt_up_read+0x19/0x20
>>  [<ffffffff811b07f1>] SyS_ioctl+0x81/0xa0
>>  [<ffffffff819a351b>] system_call_fastpath+0x16/0x6e
>>
>> This happen When run "i2cdetect -y 0" detect SMBus iSMT adapter.
>>
>> After finished I2C block read/write, when unmap the data buffer,
>> a wrong device address was pass to dma_unmap_single().
>>
>> To fix this, give dma_unmap_single() the "dev" parameter, just like
>> what dma_map_single() does, then unmap can find the right devices.
>>
>> Fixes: 13f35ac14cd0 ("i2c: Adding support for Intel iSMT SMBus 2.0 host controller")
>> Signed-off-by: Liwei Song <liwei.song@windriver.com>
>> ---
>>  drivers/i2c/busses/i2c-ismt.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/i2c/busses/i2c-ismt.c b/drivers/i2c/busses/i2c-ismt.c
>> index f573448..e98e44e 100644
>> --- a/drivers/i2c/busses/i2c-ismt.c
>> +++ b/drivers/i2c/busses/i2c-ismt.c
>> @@ -584,7 +584,7 @@ static int ismt_access(struct i2c_adapter *adap, u16 addr,
>>
>>         /* unmap the data buffer */
>>         if (dma_size != 0)
>> -               dma_unmap_single(&adap->dev, dma_addr, dma_size, dma_direction);
>> +               dma_unmap_single(dev, dma_addr, dma_size, dma_direction);
>>
>>         if (unlikely(!time_left)) {
>>                 dev_err(dev, "completion wait timed out\n");
>> --
>> 2.7.4
>>
>
>
>
> --
>              Dmitry



-- 
With Best Regards,
Andy Shevchenko

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

* Re: [PATCH V2] i2c: ismt: fix wrong device address when unmap the data buffer
  2018-08-15  9:25   ` Andy Shevchenko
@ 2018-08-16 15:22     ` Greg Kroah-Hartman
  0 siblings, 0 replies; 6+ messages in thread
From: Greg Kroah-Hartman @ 2018-08-16 15:22 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Dmitry Safonov, stable, Wolfram Sang, Seth Heasley, Neil Horman,
	linux-i2c, linux-kernel, Song liwei

On Wed, Aug 15, 2018 at 12:25:48PM +0300, Andy Shevchenko wrote:
> On Wed, Aug 15, 2018 at 5:26 AM, Dmitry Safonov <0x7f454c46@gmail.com> wrote:
> > +Cc: stable
> >
> > Hi Greg, JFI:
> > This one has hit a couple of times on autotests on v4.9 stable.
> > The fix for BUG() is trivial, so probably worth to ship it to v4.9/v4.4/v3.18.
> >
> 
> JFYI:
> 
> commit 17e83549e199d89aace7788a9f11c108671eecf5
> Author: Liwei Song <liwei.song@windriver.com>
> Date:   Tue Jun 13 00:59:53 2017 -0400
> 
>    i2c: ismt: fix wrong device address when unmap the data buffer

Thanks, that helped :)

greg k-h

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

end of thread, other threads:[~2018-08-16 15:22 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-13  4:59 [PATCH V2] i2c: ismt: fix wrong device address when unmap the data buffer Song liwei
2017-06-13  7:42 ` Andy Shevchenko
2017-06-15 13:54 ` Wolfram Sang
2018-08-15  2:26 ` Dmitry Safonov
2018-08-15  9:25   ` Andy Shevchenko
2018-08-16 15:22     ` Greg Kroah-Hartman

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