i2c: i2c-qcom-geni: Properly handle DMA safe buffers
authorStephen Boyd <swboyd@chromium.org>
Thu, 20 Sep 2018 18:03:22 +0000 (11:03 -0700)
committerWolfram Sang <wsa@the-dreams.de>
Mon, 24 Sep 2018 22:11:52 +0000 (00:11 +0200)
commit6697576788816985f9c79da190abfaad7c9e1738
tree2a8e8af967769a58cf93062c0ccece00657c74ee
parent6bf4ca7fbc85d80446ac01c0d1d77db4d91a6d84
i2c: i2c-qcom-geni: Properly handle DMA safe buffers

We shouldn't attempt to DMA map the message buffers passed into this
driver from the i2c core unless the message we're mapping have been
properly setup for DMA. The i2c core indicates such a situation by
setting the I2C_M_DMA_SAFE flag, so check for that flag before using DMA
mode. We can also bounce the buffer if it isn't already mapped properly
by using the i2c_get_dma_safe_msg_buf() APIs, so do that when we
want to use DMA for a message.

This fixes a problem where the kernel oopses cleaning pages for a buffer
that's mapped into the vmalloc space. The pages are returned from
request_firmware() and passed down directly to the i2c master to write
to the i2c touchscreen device. Mapping vmalloc buffers with
dma_map_single() won't work reliably, causing an oops like below:

 Unable to handle kernel paging request at virtual address ffffffc01391d000
 ...

Reported-by: Philip Chen <philipchen@chromium.org>
Signed-off-by: Stephen Boyd <swboyd@chromium.org>
Reviewed-by: Douglas Anderson <dianders@chromium.org>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
drivers/i2c/busses/i2c-qcom-geni.c