Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751259AbdIPJeI (ORCPT ); Sat, 16 Sep 2017 05:34:08 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:18218 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1750909AbdIPJeG (ORCPT ); Sat, 16 Sep 2017 05:34:06 -0400 X-UUID: f34f9b77cb6243beb4036912f5ca37b7-20170916 Message-ID: <1505554439.31793.76.camel@mhfsdcap03> Subject: Re: [I2C] About warning 'DMA-API: device driver maps memory from stack' From: Jun Gao To: Wolfram Sang CC: , , , , , Date: Sat, 16 Sep 2017 17:33:59 +0800 In-Reply-To: <20170902215829.3jpwmbyy27cpu5rm@ninjato> References: <1504354088.31793.48.camel@mhfsdcap03> <20170902215829.3jpwmbyy27cpu5rm@ninjato> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.2.3-0ubuntu6 Content-Transfer-Encoding: 7bit MIME-Version: 1.0 X-MTK: N Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1209 Lines: 39 On Sat, 2017-09-02 at 23:58 +0200, Wolfram Sang wrote: > Hi, > > nice to see someone else interested in the I2C & DMA topic. > > Please check this series which I sent out recently: > > "[RFC PATCH v4 0/6] i2c: document DMA handling and add helpers for it" > > In that series, I proposed... > > > 3. kmalloc data buffer instead of local variables buf in function > > i2c_smbus_xfer_emulated(...) > > ... this solution. Although I have to check Mauro's general response to > the series first. I'd be interested in what you think of the series, > too. Sorry for late reply. As you said in "[RFC,v4,3/6]i2c: add docs to clarify DMA handling". Most i2c_msgs are register accesses and thus, small messages. And "[RFC,v4,4/6] i2c: sh_mobile: use helper to decide if DMA is useful". Maybe the solution as below will be better. Other drivers which will use i2c would not have to make buffer DMA safe especially register accesses(they like to use local variables when data_len = 1 or 2). solution: 2. use FIFO mode when length<=fifo_depth(mtk i2c fifo_depth=8), use the flag "I2C_M_DMA_SAFE" to check buffer for DMA mode when length>fifo_depth in i2c-mt65xx.c . Thanks. > > Kind regards, > > Wolfram >