Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752419AbdFLJLs (ORCPT ); Mon, 12 Jun 2017 05:11:48 -0400 Received: from mail-qt0-f194.google.com ([209.85.216.194]:36148 "EHLO mail-qt0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752246AbdFLJLj (ORCPT ); Mon, 12 Jun 2017 05:11:39 -0400 MIME-Version: 1.0 In-Reply-To: <1497238928-41066-1-git-send-email-liwei.song@windriver.com> References: <1497238928-41066-1-git-send-email-liwei.song@windriver.com> From: Andy Shevchenko Date: Mon, 12 Jun 2017 12:11:37 +0300 Message-ID: Subject: Re: [PATCH] i2c: ismt: fix wrong device address when unmap the data buffer To: Song liwei Cc: Wolfram Sang , Seth Heasley , Neil Horman , linux-i2c , linux-kernel Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1823 Lines: 61 On Mon, Jun 12, 2017 at 6:42 AM, Song liwei wrote: > From: Liwei Song > > Fix the following calltrace: No, you don't fix a call trace, you are fixing a bug. > 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(), > the right > device address should be "dev" not "&adap->dev", the relation is > *(&adap->dev) == dev. This is confusing. You are telling that there are two copies of struct device here? Otherwise if one is a pointer to the real struct device, there shouldn't be a problem. > When come into Intel IOMMU routine, the wrong > devices address was operated. This basically duplicates what you have said previously. > To fix this, give dma_unmap_single() the "dev" parameter, just like > what dma_map_single() does, then unmap can find the right devices. Fix per se looks good, explanation is confusing. > > Signed-off-by: Liwei Song > --- > 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 1db3e0d..605d44e 100644 > --- a/drivers/i2c/busses/i2c-ismt.c > +++ b/drivers/i2c/busses/i2c-ismt.c > @@ -585,7 +585,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