Re: [PATCH v3 1/2] tty: hvc: pass DMA capable memory to put_chars()

2021-08-05 Thread Xianting Tian



在 2021/8/5 下午4:09, Jiri Slaby 写道:

On 05. 08. 21, 9:58, Jiri Slaby wrote:

Hi,

On 04. 08. 21, 4:54, Xianting Tian wrote:
@@ -933,6 +949,16 @@ struct hvc_struct *hvc_alloc(uint32_t vtermno, 
int data,

  hp->outbuf_size = outbuf_size;
  hp->outbuf = &((char *)hp)[ALIGN(sizeof(*hp), sizeof(long))];


This deserves cleanup too. Why is "outbuf" not "char outbuf[0] 
__ALIGNED__" at the end of the structure? The allocation would be 
easier (using struct_size()) and this line would be gone completely.

I will make the cleanup in v4.



+    /*
+ * hvc_con_outbuf is guaranteed to be aligned at least to the
+ * size(N_OUTBUF) by kmalloc().
+ */
+    hp->hvc_con_outbuf = kzalloc(N_OUTBUF, GFP_KERNEL);
+    if (!hp->hvc_con_outbuf)
+    return ERR_PTR(-ENOMEM);


This leaks hp, right?


Actually, why don't you make
char c[N_OUTBUF] __ALIGNED__;

part of struct hvc_struct directly?

thanks, it a good idea, I will change it in v4.



BTW your 2 patches are still not threaded, that is hard to follow.


+
+    spin_lock_init(>hvc_con_lock);
+
  tty_port_init(>port);
  hp->port.ops = _port_ops;


thanks,


Re: [PATCH v3 1/2] tty: hvc: pass DMA capable memory to put_chars()

2021-08-05 Thread Xianting Tian



在 2021/8/5 下午4:18, Greg KH 写道:

On Thu, Aug 05, 2021 at 04:08:46PM +0800, Xianting Tian wrote:

在 2021/8/5 下午3:58, Jiri Slaby 写道:

Hi,

On 04. 08. 21, 4:54, Xianting Tian wrote:

@@ -933,6 +949,16 @@ struct hvc_struct *hvc_alloc(uint32_t vtermno,
int data,
   hp->outbuf_size = outbuf_size;
   hp->outbuf = &((char *)hp)[ALIGN(sizeof(*hp), sizeof(long))];
   +    /*
+ * hvc_con_outbuf is guaranteed to be aligned at least to the
+ * size(N_OUTBUF) by kmalloc().
+ */
+    hp->hvc_con_outbuf = kzalloc(N_OUTBUF, GFP_KERNEL);
+    if (!hp->hvc_con_outbuf)
+    return ERR_PTR(-ENOMEM);

This leaks hp, right?

BTW your 2 patches are still not threaded, that is hard to follow.

yes, thanks, I found the bug, I am preparing to do this in v4.

It is the first time I send series patches(number >1), I checked the method
for sending series patch on LKML.org, I should send '0/2' which is the
history info for series patches.

Please use 'git send-email' to send the full series all at once,
otherwise it is hard to make the emails threaded "by hand" if you do not
do so.

I got it, thanks for your guide:)


thanks,

greg k-h


Re: [PATCH v3 1/2] tty: hvc: pass DMA capable memory to put_chars()

2021-08-05 Thread Xianting Tian


在 2021/8/5 下午3:58, Jiri Slaby 写道:

Hi,

On 04. 08. 21, 4:54, Xianting Tian wrote:
@@ -933,6 +949,16 @@ struct hvc_struct *hvc_alloc(uint32_t vtermno, 
int data,

  hp->outbuf_size = outbuf_size;
  hp->outbuf = &((char *)hp)[ALIGN(sizeof(*hp), sizeof(long))];
  +    /*
+ * hvc_con_outbuf is guaranteed to be aligned at least to the
+ * size(N_OUTBUF) by kmalloc().
+ */
+    hp->hvc_con_outbuf = kzalloc(N_OUTBUF, GFP_KERNEL);
+    if (!hp->hvc_con_outbuf)
+    return ERR_PTR(-ENOMEM);


This leaks hp, right?

BTW your 2 patches are still not threaded, that is hard to follow.


yes, thanks, I found the bug, I am preparing to do this in v4.

It is the first time I send series patches(number >1), I checked the 
method for sending series patch on LKML.org, I should send '0/2' which 
is the history info for series patches.


I will add 0/2 in v4, sorry again for this:(

beside avove things, the solution in this patch is for you? thanks




+
+    spin_lock_init(>hvc_con_lock);
+
  tty_port_init(>port);
  hp->port.ops = _port_ops;


thanks,


Re: [PATCH v3 1/2] tty: hvc: pass DMA capable memory to put_chars()

2021-08-05 Thread Greg KH
On Thu, Aug 05, 2021 at 04:08:46PM +0800, Xianting Tian wrote:
> 
> 在 2021/8/5 下午3:58, Jiri Slaby 写道:
> > Hi,
> > 
> > On 04. 08. 21, 4:54, Xianting Tian wrote:
> > > @@ -933,6 +949,16 @@ struct hvc_struct *hvc_alloc(uint32_t vtermno,
> > > int data,
> > >   hp->outbuf_size = outbuf_size;
> > >   hp->outbuf = &((char *)hp)[ALIGN(sizeof(*hp), sizeof(long))];
> > >   +    /*
> > > + * hvc_con_outbuf is guaranteed to be aligned at least to the
> > > + * size(N_OUTBUF) by kmalloc().
> > > + */
> > > +    hp->hvc_con_outbuf = kzalloc(N_OUTBUF, GFP_KERNEL);
> > > +    if (!hp->hvc_con_outbuf)
> > > +    return ERR_PTR(-ENOMEM);
> > 
> > This leaks hp, right?
> > 
> > BTW your 2 patches are still not threaded, that is hard to follow.
> 
> yes, thanks, I found the bug, I am preparing to do this in v4.
> 
> It is the first time I send series patches(number >1), I checked the method
> for sending series patch on LKML.org, I should send '0/2' which is the
> history info for series patches.

Please use 'git send-email' to send the full series all at once,
otherwise it is hard to make the emails threaded "by hand" if you do not
do so.

thanks,

greg k-h


Re: [PATCH v3 1/2] tty: hvc: pass DMA capable memory to put_chars()

2021-08-05 Thread Jiri Slaby

On 05. 08. 21, 9:58, Jiri Slaby wrote:

Hi,

On 04. 08. 21, 4:54, Xianting Tian wrote:
@@ -933,6 +949,16 @@ struct hvc_struct *hvc_alloc(uint32_t vtermno, 
int data,

  hp->outbuf_size = outbuf_size;
  hp->outbuf = &((char *)hp)[ALIGN(sizeof(*hp), sizeof(long))];


This deserves cleanup too. Why is "outbuf" not "char outbuf[0] 
__ALIGNED__" at the end of the structure? The allocation would be easier 
(using struct_size()) and this line would be gone completely.



+    /*
+ * hvc_con_outbuf is guaranteed to be aligned at least to the
+ * size(N_OUTBUF) by kmalloc().
+ */
+    hp->hvc_con_outbuf = kzalloc(N_OUTBUF, GFP_KERNEL);
+    if (!hp->hvc_con_outbuf)
+    return ERR_PTR(-ENOMEM);


This leaks hp, right?


Actually, why don't you make
char c[N_OUTBUF] __ALIGNED__;

part of struct hvc_struct directly?


BTW your 2 patches are still not threaded, that is hard to follow.


+
+    spin_lock_init(>hvc_con_lock);
+
  tty_port_init(>port);
  hp->port.ops = _port_ops;


thanks,

--
js
suse labs


Re: [PATCH v3 1/2] tty: hvc: pass DMA capable memory to put_chars()

2021-08-05 Thread Jiri Slaby

Hi,

On 04. 08. 21, 4:54, Xianting Tian wrote:

@@ -933,6 +949,16 @@ struct hvc_struct *hvc_alloc(uint32_t vtermno, int data,
hp->outbuf_size = outbuf_size;
hp->outbuf = &((char *)hp)[ALIGN(sizeof(*hp), sizeof(long))];
  
+	/*

+* hvc_con_outbuf is guaranteed to be aligned at least to the
+* size(N_OUTBUF) by kmalloc().
+*/
+   hp->hvc_con_outbuf = kzalloc(N_OUTBUF, GFP_KERNEL);
+   if (!hp->hvc_con_outbuf)
+   return ERR_PTR(-ENOMEM);


This leaks hp, right?

BTW your 2 patches are still not threaded, that is hard to follow.


+
+   spin_lock_init(>hvc_con_lock);
+
tty_port_init(>port);
hp->port.ops = _port_ops;
  


thanks,
--
js
suse labs