Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752389AbdFLJ2k (ORCPT ); Mon, 12 Jun 2017 05:28:40 -0400 Received: from mail-eopbgr00106.outbound.protection.outlook.com ([40.107.0.106]:45412 "EHLO EUR02-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751984AbdFLJ2i (ORCPT ); Mon, 12 Jun 2017 05:28:38 -0400 Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=axentia.se; Subject: Re: [PATCH] i2c: ismt: fix wrong device address when unmap the data buffer To: Andy Shevchenko , Song liwei Cc: Wolfram Sang , Seth Heasley , Neil Horman , linux-i2c , linux-kernel References: <1497238928-41066-1-git-send-email-liwei.song@windriver.com> From: Peter Rosin Organization: Axentia Technologies AB Message-ID: <3d211ade-77e8-0ec7-582b-085686ddd4c1@axentia.se> Date: Mon, 12 Jun 2017 11:28:29 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.1.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [81.224.171.159] X-ClientProxiedBy: DB6PR07CA0163.eurprd07.prod.outlook.com (2603:10a6:6:43::17) To AM5PR0202MB2547.eurprd02.prod.outlook.com (2603:10a6:203:6d::8) X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM5PR0202MB2547: X-MS-Office365-Filtering-Correlation-Id: 8f86b0ff-b7f3-418d-cfd0-08d4b175661f X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(201703131423075);SRVR:AM5PR0202MB2547; X-Microsoft-Exchange-Diagnostics: 1;AM5PR0202MB2547;3:ypi1xo8ubuv90pBu7Mk9byqbr6LNIMyx3STFI8PAG8atzgSJ0V6qrf/mVxl90os3y6jkgviWkGUdkR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Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(5005006)(8121501046)(100000703101)(100105400095)(10201501046)(3002001)(93006095)(93001095)(6041248)(20161123562025)(20161123555025)(20161123560025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123564025)(20161123558100)(2016111802025)(6072148)(6043046)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:AM5PR0202MB2547;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:AM5PR0202MB2547; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtBTTVQUjAyMDJNQjI1NDc7NDpCWjhEeDVEOHhHQzhZdzgyNHMzNzNueWtE?= =?utf-8?B?L0ZoM0RES3VIRWRzQS9KUEF0bzJNZUt2RUxjcVNVNWcwdlJFUXFGM1hGUWYr?= =?utf-8?B?Y0NpaDhXRUtMK2JVVnpXZG13TVVreGhhaHoxYVhGK2VIZ3N6ZTd2aEZuekNy?= =?utf-8?B?Y3ExUTJCMTJ6dllQcXpsaUlYeTZwM2Fqd29hdi85Nm1NOFdwUW15d2RQaTlD?= =?utf-8?B?a29YeUZWNFRUZzNEN1o5bVBqbm00dWl1VSs2RlhReC9MSkxGKzhFY2ZjWGg1?= =?utf-8?B?VW5JeEEwNDVEb3FXd1ZXVm5NUm1URjdybXEycUluNGNHWHdLV3lTTXIxYURO?= =?utf-8?B?Ky9LSms2N2FkWmJwRG5kdEh4Q1RXQnRBdnpjQ1hnckE5bTZVNU82VER2NGx4?= =?utf-8?B?WTR4L1ZYTkY3YUEwMzRzUWp6dTh5Z0htdFdQRkNDNGVmMGJXS2dNZ3h5QmEw?= =?utf-8?B?ZTVKUDVkRHRCT0IwZ3l4Z1Ivd2NDb2QvYXlEYmVJa0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dDWGRuV1dHWmRHbVZRQ09hbEVPbVdKdHM4?= =?utf-8?B?aEQ5S0wrZ2JiS3p1a3lEalRscVFBMGllMWc4ZnNBSkttUkNpbFZLcnd1Mmlq?= =?utf-8?B?QWV5RmV4RC85eHZLSVBLZy9xTVJXc3JHZ255aFVFZ0ozVUNnbjNTRHY5NWtw?= =?utf-8?B?Zld5SkZzbFkyNElLVHJhT2c2dVg3dFVFWnM4cVBkS2ZNeWEyeWdiR0t6bzZk?= =?utf-8?Q?CDnyP1O+ZLQuG3LAKpMGd?= X-Forefront-PRVS: 03361FCC43 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(4630300001)(6009001)(6049001)(39410400002)(39830400002)(39400400002)(39450400003)(377424004)(377454003)(24454002)(7736002)(53936002)(8676002)(5660300001)(189998001)(81166006)(42186005)(31686004)(74482002)(65956001)(64126003)(305945005)(229853002)(47776003)(3846002)(23676002)(36756003)(66066001)(65806001)(3260700006)(25786009)(53546009)(230700001)(478600001)(31696002)(86362001)(54906002)(575784001)(54356999)(6666003)(6486002)(77096006)(38730400002)(2906002)(6246003)(2950100002)(4326008)(65826007)(50986999)(33646002)(76176999)(117156002)(42262002);DIR:OUT;SFP:1102;SCL:1;SRVR:AM5PR0202MB2547;H:[192.168.0.125];FPR:;SPF:None;MLV:sfv;LANG:en; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtBTTVQUjAyMDJNQjI1NDc7MjM6T0t2MXhNN3hhUTRRMFIwbHM5T2JKQnZu?= =?utf-8?B?Qm1kQnBYejBaUEk2WUFHM3ovc0dsOVNwcUlpaTVnL3RGRU1oSUxkajdqWDNj?= =?utf-8?B?dnQ5NU5GTTRVd1p4NGVkUUdVQzd2RHVIeXVhSWlsZ1paQUhUUGJ2MGdkMGpW?= =?utf-8?B?OVlRd3FVRXRIbmRpeTdEV3ljK2RFYTZjRUFkWVAvUGhjWE8rQkg1WTZqYnB4?= =?utf-8?B?WFFVV3MwZGhjUkFRTnJmZGRER3pE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4wrO9MQ8ANCOqUls0rZVMs+55pvHo7qPeSD9ga8scTI8a13yNpEuPbWhjTro1+qX98Zaa4Tgq8xovI7QkG1uBW9uvJUeCS29Ani0/huNC8JrIfq1xankCW8IuCmIZDSkvVH0BMqXDn9jBe6JUB26HsZCV3EtCpWLYlqbuYKLtfIOxrvJBRFPdueXr+3y01rWwRpZ6nL4x87Ri74xacvTsQJw4djejlGk67q8ZaWiINXTGbb4GhQg== X-Microsoft-Exchange-Diagnostics: 1;AM5PR0202MB2547;5:TmnS7GgEJBKaa3bGN1dDgd0OsQ2LeTwfjq2XnX6ruREUsHa5lNf2aZuyum6LGzfw1ezgteo9i+/3hwZqK/VbEeetikey+qoguf70yAooogjojql7aC0xxYS5mhQw2J8ME5Job2CqsTyo9djiVPTHo9cwIFrRC6sk13YX8MwLuPtXpiSUVJeEbMY1HF3Bc7qRw2o26ehBePG+qiQokW1H/Vzxhh/RIfDGYRD0TbNrZRoD7MFydtwi9b9mGdjZWH+ILTzvvTCgW2ukAdZOd7CPdKuLvchZmaesEf+hk25ScmGMYmeyv8rfcI9JsqMqDw/ItpHijV3Kgu+jBKIl7aVohwDMS+Pkj0gsLltkK2rinwNWwTRq8IlKzpo+fBTpW9+MCzc7M/ZOIBjVFCSY4oA0qCGXxd+1b5azPILpQPnYjrFckaFZsXzdd/uqsy6tMHfwKFhljYOR9gpuemK5zuFa6CifyaRdUKM5AEYD3peeD3HJEWnQTDl3imMMjs82PTD7;24:ExsiReOOCYWQoS5D5WmwhJshVakZ7OuAj+W5aoBv8iF0rPCa1gK4NkxBY47oK1hspkI6WScqGByTXxXrgeXFokvnyK4FX/1R2h8XF+d3lnQ= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;AM5PR0202MB2547;7:OfSI8Z8ynSOQH7kyNLHHSaj67IMJe7VG3SPFGsdcByYqSMBGyshwbdHt8bavZVKShIDoOhDn24atwVdIkdPQrIa1Y9akCB2QIbuU7Zprrhqy7o1wNgHWfm9pWKoj76gca9xh89fb4IvZRl7mJRVW/JWBGwA0/O4/1kQOpw96xdjSOmXOPf0si4g27Ieq6ahrdmAAQw5rAzoOdIqWnqj/leMs1MYtsEoAfTAbBnBLZmgNaCRvzKWzElofaOrMK5iyo2MSCWr1H8+CsJTEAv4tTvotWKd+QrGhtNXLMcC/UJFbsPaIm55BSwgWeA91QcKTOJKuJGLZ2QuvVfNKOvv0fA== X-OriginatorOrg: axentia.se X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jun 2017 09:28:33.9305 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0202MB2547 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2464 Lines: 76 On 2017-06-12 11:11, Andy Shevchenko wrote: > 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? Yes, there are two copies. There's the local dev variable that is like this: struct device *dev = &priv->pci_dev->dev; And then there's the adapter device in adap->dev (inlined in adap, so the explanation that the relations is "*(&adap->dev) == dev" is doubly wrong). The bug is that the first argument to dma_unmap_single is not the same as the first argument to dma_map_single that appears a few lines up. I cannot tell if that argument should be "dev" or "&adap->dev" though, but the two calls must refer to the same struct device *. Cheers, peda > 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 >> > > >