* [PATCH v2] Input: elants_i2c - Use DMA safe i2c when possible
@ 2018-10-10 20:00 Stephen Boyd
2018-10-11 0:11 ` Dmitry Torokhov
2018-10-11 7:29 ` Wolfram Sang
0 siblings, 2 replies; 4+ messages in thread
From: Stephen Boyd @ 2018-10-10 20:00 UTC (permalink / raw)
To: Dmitry Torokhov; +Cc: linux-kernel, linux-input, Wolfram Sang
This irq handler is always reading bytes from the device into a
kmalloced buffer, so it's safe to mark this transaction as DMA safe.
This avoids bouncing the buffer when an i2c controller decides to use
DMA for a transaction.
Cc: Wolfram Sang <wsa@the-dreams.de>
Signed-off-by: Stephen Boyd <swboyd@chromium.org>
---
Changes from v1:
* Moved buf to end of structure to keep it cacheline aligned and DMA
safe
drivers/input/touchscreen/elants_i2c.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/input/touchscreen/elants_i2c.c b/drivers/input/touchscreen/elants_i2c.c
index d21ca39b0fdb..f2cb23121833 100644
--- a/drivers/input/touchscreen/elants_i2c.c
+++ b/drivers/input/touchscreen/elants_i2c.c
@@ -147,10 +147,11 @@ struct elants_data {
u8 cmd_resp[HEADER_SIZE];
struct completion cmd_done;
- u8 buf[MAX_PACKET_SIZE];
-
bool wake_irq_enabled;
bool keep_power_in_suspend;
+
+ /* Must be last to be used for DMA operations */
+ u8 buf[MAX_PACKET_SIZE] ____cacheline_aligned;
};
static int elants_i2c_send(struct i2c_client *client,
@@ -863,7 +864,7 @@ static irqreturn_t elants_i2c_irq(int irq, void *_dev)
int i;
int len;
- len = i2c_master_recv(client, ts->buf, sizeof(ts->buf));
+ len = i2c_master_recv_dmasafe(client, ts->buf, sizeof(ts->buf));
if (len < 0) {
dev_err(&client->dev, "%s: failed to read data: %d\n",
__func__, len);
--
Sent by a computer through tubes
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2] Input: elants_i2c - Use DMA safe i2c when possible
2018-10-10 20:00 [PATCH v2] Input: elants_i2c - Use DMA safe i2c when possible Stephen Boyd
@ 2018-10-11 0:11 ` Dmitry Torokhov
2018-10-11 7:29 ` Wolfram Sang
1 sibling, 0 replies; 4+ messages in thread
From: Dmitry Torokhov @ 2018-10-11 0:11 UTC (permalink / raw)
To: Stephen Boyd; +Cc: linux-kernel, linux-input, Wolfram Sang
On Wed, Oct 10, 2018 at 01:00:17PM -0700, Stephen Boyd wrote:
> This irq handler is always reading bytes from the device into a
> kmalloced buffer, so it's safe to mark this transaction as DMA safe.
> This avoids bouncing the buffer when an i2c controller decides to use
> DMA for a transaction.
>
> Cc: Wolfram Sang <wsa@the-dreams.de>
> Signed-off-by: Stephen Boyd <swboyd@chromium.org>
Changed patch description a bit (now that we are actually making the
buffer DMA-safe) and applied, thank you.
> ---
>
> Changes from v1:
> * Moved buf to end of structure to keep it cacheline aligned and DMA
> safe
>
> drivers/input/touchscreen/elants_i2c.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/input/touchscreen/elants_i2c.c b/drivers/input/touchscreen/elants_i2c.c
> index d21ca39b0fdb..f2cb23121833 100644
> --- a/drivers/input/touchscreen/elants_i2c.c
> +++ b/drivers/input/touchscreen/elants_i2c.c
> @@ -147,10 +147,11 @@ struct elants_data {
> u8 cmd_resp[HEADER_SIZE];
> struct completion cmd_done;
>
> - u8 buf[MAX_PACKET_SIZE];
> -
> bool wake_irq_enabled;
> bool keep_power_in_suspend;
> +
> + /* Must be last to be used for DMA operations */
> + u8 buf[MAX_PACKET_SIZE] ____cacheline_aligned;
> };
>
> static int elants_i2c_send(struct i2c_client *client,
> @@ -863,7 +864,7 @@ static irqreturn_t elants_i2c_irq(int irq, void *_dev)
> int i;
> int len;
>
> - len = i2c_master_recv(client, ts->buf, sizeof(ts->buf));
> + len = i2c_master_recv_dmasafe(client, ts->buf, sizeof(ts->buf));
> if (len < 0) {
> dev_err(&client->dev, "%s: failed to read data: %d\n",
> __func__, len);
> --
> Sent by a computer through tubes
>
--
Dmitry
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] Input: elants_i2c - Use DMA safe i2c when possible
2018-10-10 20:00 [PATCH v2] Input: elants_i2c - Use DMA safe i2c when possible Stephen Boyd
2018-10-11 0:11 ` Dmitry Torokhov
@ 2018-10-11 7:29 ` Wolfram Sang
1 sibling, 0 replies; 4+ messages in thread
From: Wolfram Sang @ 2018-10-11 7:29 UTC (permalink / raw)
To: Stephen Boyd; +Cc: Dmitry Torokhov, linux-kernel, linux-input
[-- Attachment #1: Type: text/plain, Size: 465 bytes --]
On Wed, Oct 10, 2018 at 01:00:17PM -0700, Stephen Boyd wrote:
> This irq handler is always reading bytes from the device into a
> kmalloced buffer, so it's safe to mark this transaction as DMA safe.
> This avoids bouncing the buffer when an i2c controller decides to use
> DMA for a transaction.
>
> Cc: Wolfram Sang <wsa@the-dreams.de>
> Signed-off-by: Stephen Boyd <swboyd@chromium.org>
For the record:
Acked-by: Wolfram Sang <wsa@the-dreams.de>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2] Input: elants_i2c - Use DMA safe i2c when possible
@ 2018-10-10 19:59 Stephen Boyd
0 siblings, 0 replies; 4+ messages in thread
From: Stephen Boyd @ 2018-10-10 19:59 UTC (permalink / raw)
Cc: linux-kernel, Wolfram Sang
This irq handler is always reading bytes from the device into a
kmalloced buffer, so it's safe to mark this transaction as DMA safe.
This avoids bouncing the buffer when an i2c controller decides to use
DMA for a transaction.
Cc: Wolfram Sang <wsa@the-dreams.de>
Signed-off-by: Stephen Boyd <swboyd@chromium.org>
---
Changes from v1:
* Moved buf to end of structure to keep it cacheline aligned and DMA
safe
drivers/input/touchscreen/elants_i2c.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/input/touchscreen/elants_i2c.c b/drivers/input/touchscreen/elants_i2c.c
index d21ca39b0fdb..f2cb23121833 100644
--- a/drivers/input/touchscreen/elants_i2c.c
+++ b/drivers/input/touchscreen/elants_i2c.c
@@ -147,10 +147,11 @@ struct elants_data {
u8 cmd_resp[HEADER_SIZE];
struct completion cmd_done;
- u8 buf[MAX_PACKET_SIZE];
-
bool wake_irq_enabled;
bool keep_power_in_suspend;
+
+ /* Must be last to be used for DMA operations */
+ u8 buf[MAX_PACKET_SIZE] ____cacheline_aligned;
};
static int elants_i2c_send(struct i2c_client *client,
@@ -863,7 +864,7 @@ static irqreturn_t elants_i2c_irq(int irq, void *_dev)
int i;
int len;
- len = i2c_master_recv(client, ts->buf, sizeof(ts->buf));
+ len = i2c_master_recv_dmasafe(client, ts->buf, sizeof(ts->buf));
if (len < 0) {
dev_err(&client->dev, "%s: failed to read data: %d\n",
__func__, len);
--
Sent by a computer through tubes
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-10-11 7:30 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-10 20:00 [PATCH v2] Input: elants_i2c - Use DMA safe i2c when possible Stephen Boyd
2018-10-11 0:11 ` Dmitry Torokhov
2018-10-11 7:29 ` Wolfram Sang
-- strict thread matches above, loose matches on Subject: below --
2018-10-10 19:59 Stephen Boyd
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).