* [PATCH] usb: hso: obey DMA rules in tiocmget
@ 2019-10-17 9:53 Oliver Neukum
2019-10-17 18:19 ` David Miller
0 siblings, 1 reply; 4+ messages in thread
From: Oliver Neukum @ 2019-10-17 9:53 UTC (permalink / raw)
To: davem, netdev, johan; +Cc: Oliver Neukum
The serial state information must not be embedded into another
data structure, as this interferes with cache handling for DMA
on architectures without cache coherence..
That would result in data corruption on some architectures
Allocating it separately.
Signed-off-by: Oliver Neukum <oneukum@suse.com>
---
drivers/net/usb/hso.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
index a505b2ab88b8..b1d1d8ff1747 100644
--- a/drivers/net/usb/hso.c
+++ b/drivers/net/usb/hso.c
@@ -186,7 +186,7 @@ struct hso_tiocmget {
int intr_completed;
struct usb_endpoint_descriptor *endp;
struct urb *urb;
- struct hso_serial_state_notification serial_state_notification;
+ struct *hso_serial_state_notification serial_state_notification;
u16 prev_UART_state_bitmap;
struct uart_icount icount;
};
@@ -1432,7 +1432,7 @@ static int tiocmget_submit_urb(struct hso_serial *serial,
usb_rcvintpipe(usb,
tiocmget->endp->
bEndpointAddress & 0x7F),
- &tiocmget->serial_state_notification,
+ tiocmget->serial_state_notification,
sizeof(struct hso_serial_state_notification),
tiocmget_intr_callback, serial,
tiocmget->endp->bInterval);
@@ -1479,7 +1479,7 @@ static void tiocmget_intr_callback(struct urb *urb)
/* wIndex should be the USB interface number of the port to which the
* notification applies, which should always be the Modem port.
*/
- serial_state_notification = &tiocmget->serial_state_notification;
+ serial_state_notification = tiocmget->serial_state_notification;
if (serial_state_notification->bmRequestType != BM_REQUEST_TYPE ||
serial_state_notification->bNotification != B_NOTIFICATION ||
le16_to_cpu(serial_state_notification->wValue) != W_VALUE ||
@@ -2565,6 +2565,8 @@ static void hso_free_tiomget(struct hso_serial *serial)
usb_free_urb(tiocmget->urb);
tiocmget->urb = NULL;
serial->tiocmget = NULL;
+ kfree(tiocmget->serial_state_notification);
+ tiocmget->serial_state_notification = NULL;
kfree(tiocmget);
}
}
@@ -2615,10 +2617,13 @@ static struct hso_device *hso_create_bulk_serial_device(
num_urbs = 2;
serial->tiocmget = kzalloc(sizeof(struct hso_tiocmget),
GFP_KERNEL);
+ serial->tiocmget->serial_state_notification
+ = kzalloc(sizeof(struct hso_serial_state_notification),
+ GFP_KERNEL);
/* it isn't going to break our heart if serial->tiocmget
* allocation fails don't bother checking this.
*/
- if (serial->tiocmget) {
+ if (serial->tiocmget && serial->tiocmget->serial_state_notification) {
tiocmget = serial->tiocmget;
tiocmget->endp = hso_get_ep(interface,
USB_ENDPOINT_XFER_INT,
--
2.16.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] usb: hso: obey DMA rules in tiocmget
2019-10-17 9:53 [PATCH] usb: hso: obey DMA rules in tiocmget Oliver Neukum
@ 2019-10-17 18:19 ` David Miller
2019-10-17 18:20 ` David Miller
0 siblings, 1 reply; 4+ messages in thread
From: David Miller @ 2019-10-17 18:19 UTC (permalink / raw)
To: oneukum; +Cc: netdev, johan
From: Oliver Neukum <oneukum@suse.com>
Date: Thu, 17 Oct 2019 11:53:38 +0200
> The serial state information must not be embedded into another
> data structure, as this interferes with cache handling for DMA
> on architectures without cache coherence..
> That would result in data corruption on some architectures
> Allocating it separately.
>
> Signed-off-by: Oliver Neukum <oneukum@suse.com>
Applied, thanks Oliver.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] usb: hso: obey DMA rules in tiocmget
2019-10-17 18:19 ` David Miller
@ 2019-10-17 18:20 ` David Miller
2019-10-17 20:35 ` Oliver Neukum
0 siblings, 1 reply; 4+ messages in thread
From: David Miller @ 2019-10-17 18:20 UTC (permalink / raw)
To: oneukum; +Cc: netdev, johan
From: David Miller <davem@davemloft.net>
Date: Thu, 17 Oct 2019 14:19:55 -0400 (EDT)
> From: Oliver Neukum <oneukum@suse.com>
> Date: Thu, 17 Oct 2019 11:53:38 +0200
>
>> The serial state information must not be embedded into another
>> data structure, as this interferes with cache handling for DMA
>> on architectures without cache coherence..
>> That would result in data corruption on some architectures
>> Allocating it separately.
>>
>> Signed-off-by: Oliver Neukum <oneukum@suse.com>
>
> Applied, thanks Oliver.
Ugh, Oliver did you even build test this?
drivers/net/usb/hso.c:189:9: error: expected ‘{’ before ‘*’ token
189 | struct *hso_serial_state_notification serial_state_notification;
Seriously, I expect better from an experienced developer such as
yourself.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] usb: hso: obey DMA rules in tiocmget
2019-10-17 18:20 ` David Miller
@ 2019-10-17 20:35 ` Oliver Neukum
0 siblings, 0 replies; 4+ messages in thread
From: Oliver Neukum @ 2019-10-17 20:35 UTC (permalink / raw)
To: David Miller; +Cc: johan, netdev
Am Donnerstag, den 17.10.2019, 14:20 -0400 schrieb David Miller:
> From: David Miller <davem@davemloft.net>
> Date: Thu, 17 Oct 2019 14:19:55 -0400 (EDT)
>
> > From: Oliver Neukum <oneukum@suse.com>
> > Date: Thu, 17 Oct 2019 11:53:38 +0200
> >
> > > The serial state information must not be embedded into another
> > > data structure, as this interferes with cache handling for DMA
> > > on architectures without cache coherence..
> > > That would result in data corruption on some architectures
> > > Allocating it separately.
> > >
> > > Signed-off-by: Oliver Neukum <oneukum@suse.com>
> >
> > Applied, thanks Oliver.
>
> Ugh, Oliver did you even build test this?
>
> drivers/net/usb/hso.c:189:9: error: expected ‘{’ before ‘*’ token
> 189 | struct *hso_serial_state_notification serial_state_notification;
>
> Seriously, I expect better from an experienced developer such as
> yourself.
Sorry, that is why I sent a v2. I built it, but not alone. I have
a cleanup series for that driver in the works.
Sorry
Oliver
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-10-17 20:35 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-17 9:53 [PATCH] usb: hso: obey DMA rules in tiocmget Oliver Neukum
2019-10-17 18:19 ` David Miller
2019-10-17 18:20 ` David Miller
2019-10-17 20:35 ` Oliver Neukum
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).