[PATCH net-next v2] net: octeontx2: Fix the confusion in buffer alloc failure path

2021-02-09 Thread Kevin Hao
ed on that value. Add a parameter for otx2_alloc_rbuf/__otx2_alloc_rbuf() to store the dma address and make the return value to indicate if the buffer allocation really fail or not. Reported-by: Pavel Machek Signed-off-by: Kevin Hao Tested-by: Subbaraya Sundeep --- v2: Just sort the var

[PATCH net-next] net: octeontx2: Fix the confusion in buffer alloc failure path

2021-02-07 Thread Kevin Hao
ed on that value. Add a parameter for otx2_alloc_rbuf/__otx2_alloc_rbuf() to store the dma address and make the return value to indicate if the buffer allocation really fail or not. Reported-by: Pavel Machek Signed-off-by: Kevin Hao --- .../marvell/octeontx2/nic/otx2_common.c

[PATCH net-next v3 4/4] net: dpaa2: Use napi_alloc_frag_align() to avoid the memory waste

2021-02-04 Thread Kevin Hao
The napi_alloc_frag_align() will guarantee that a correctly align buffer address is returned. So use this function to simplify the buffer alloc and avoid the unnecessary memory waste. Signed-off-by: Kevin Hao Reviewed-by: Ioana Ciornei --- v3: Add Reviewed-by from Ioana. drivers/net/ethernet

[PATCH net-next v3 2/4] net: Introduce {netdev,napi}_alloc_frag_align()

2021-02-04 Thread Kevin Hao
t for the page_frag functions, so add the corresponding {netdev,napi}_frag functions. Signed-off-by: Kevin Hao --- v3: Use align mask and refactor the {netdev,napi}_alloc_frag_align() as suggested by Alexander. include/linux/skbuff.h | 36 ++-- net/core/skb

[PATCH net-next v3 3/4] net: octeontx2: Use napi_alloc_frag_align() to avoid the memory waste

2021-02-04 Thread Kevin Hao
The napi_alloc_frag_align() will guarantee that a correctly align buffer address is returned. So use this function to simplify the buffer alloc and avoid the unnecessary memory waste. Signed-off-by: Kevin Hao Tested-by: Subbaraya Sundeep --- v3: Add Tested-by from Subbaraya. drivers/net

[PATCH net-next v3 1/4] mm: page_frag: Introduce page_frag_alloc_align()

2021-02-04 Thread Kevin Hao
that an aligned buffer address is returned. Signed-off-by: Kevin Hao Acked-by: Vlastimil Babka --- v3: Use align mask as suggested by Alexander. include/linux/gfp.h | 12 ++-- mm/page_alloc.c | 8 +--- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/include/

[PATCH net-next v3 0/4] net: Avoid the memory waste in some Ethernet drivers

2021-02-04 Thread Kevin Hao
align buffer is returned. Then we can drop the ugly workarounds and avoid the unnecessary memory waste. Kevin Hao (4): mm: page_frag: Introduce page_frag_alloc_align() net: Introduce {netdev,napi}_alloc_frag_align() net: octeontx2: Use napi_alloc_frag_align() to avoid the memory waste

Re: [PATCH net-next v2 2/4] net: Introduce {netdev,napi}_alloc_frag_align()

2021-02-03 Thread Kevin Hao
On Tue, Feb 02, 2021 at 08:26:19AM -0800, Alexander Duyck wrote: > On Sun, Jan 31, 2021 at 12:17 AM Kevin Hao wrote: > > > > In the current implementation of {netdev,napi}_alloc_frag(), it doesn't > > have any align guarantee for the returned buffer address, But for

Re: [PATCH net-next v2 1/4] mm: page_frag: Introduce page_frag_alloc_align()

2021-02-03 Thread Kevin Hao
On Tue, Feb 02, 2021 at 08:19:54AM -0800, Alexander Duyck wrote: > On Sat, Jan 30, 2021 at 11:54 PM Kevin Hao wrote: > > > > In the current implementation of page_frag_alloc(), it doesn't have > > any align guarantee for the returned buffer address. But for some > &g

[PATCH net-next v2 3/4] net: octeontx2: Use napi_alloc_frag_align() to avoid the memory waste

2021-01-31 Thread Kevin Hao
The napi_alloc_frag_align() will guarantee that a correctly align buffer address is returned. So use this function to simplify the buffer alloc and avoid the unnecessary memory waste. Signed-off-by: Kevin Hao --- v2: No change. drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c | 3

[PATCH net-next v2 2/4] net: Introduce {netdev,napi}_alloc_frag_align()

2021-01-30 Thread Kevin Hao
t for the page_frag functions, so add the corresponding {netdev,napi}_frag functions. Signed-off-by: Kevin Hao --- v2: Inline {netdev,napi}_alloc_frag(). include/linux/skbuff.h | 22 -- net/core/skbuff.c | 25 + 2 files changed, 29 insertions(+

[PATCH net-next v2 4/4] net: dpaa2: Use napi_alloc_frag_align() to avoid the memory waste

2021-01-30 Thread Kevin Hao
The napi_alloc_frag_align() will guarantee that a correctly align buffer address is returned. So use this function to simplify the buffer alloc and avoid the unnecessary memory waste. Signed-off-by: Kevin Hao --- v2: No change. drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c | 3 +-- 1 file

[PATCH net-next v2 1/4] mm: page_frag: Introduce page_frag_alloc_align()

2021-01-30 Thread Kevin Hao
that an aligned buffer address is returned. Signed-off-by: Kevin Hao Acked-by: Vlastimil Babka --- v2: - Inline page_frag_alloc() - Adopt Vlastimil's suggestion and add his Acked-by include/linux/gfp.h | 12 ++-- mm/page_alloc.c | 8 +--- 2 files changed, 15 insert

[PATCH net-next v2 0/4] net: Avoid the memory waste in some Ethernet drivers

2021-01-30 Thread Kevin Hao
ds to make sure that we can get a align buffer address for some Ethernet drivers. This patch series tries to introduce some helper functions to make sure that an align buffer is returned. Then we can drop the ugly workarounds and avoid the unnecessary memory waste. Kevin Hao (4): mm: page_frag:

Re: [PATCH net-next 1/4] mm: page_frag: Introduce page_frag_alloc_align()

2021-01-23 Thread Kevin Hao
On Sat, Jan 23, 2021 at 12:52:21PM -0800, Jakub Kicinski wrote: > On Sat, 23 Jan 2021 19:59:00 +0800 Kevin Hao wrote: > > +void *page_frag_alloc(struct page_frag_cache *nc, > > + unsigned int fragsz, gfp_t gfp_mask) > > +{ > > + return page_frag_alloc

[PATCH net-next 1/4] mm: page_frag: Introduce page_frag_alloc_align()

2021-01-23 Thread Kevin Hao
that an aligned buffer address is returned. Signed-off-by: Kevin Hao --- include/linux/gfp.h | 3 +++ mm/page_alloc.c | 12 ++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/include/linux/gfp.h b/include/linux/gfp.h index 6e479e9c48ce..e76e8618e9d7 100644 --- a/in

[PATCH net-next 3/4] net: octeontx2: Use napi_alloc_frag_align() to avoid the memory waste

2021-01-23 Thread Kevin Hao
The napi_alloc_frag_align() will guarantee that a correctly align buffer address is returned. So use this function to simplify the buffer alloc and avoid the unnecessary memory waste. Signed-off-by: Kevin Hao --- drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c | 3 +-- 1 file changed

[PATCH net-next 4/4] net: dpaa2: Use napi_alloc_frag_align() to avoid the memory waste

2021-01-23 Thread Kevin Hao
The napi_alloc_frag_align() will guarantee that a correctly align buffer address is returned. So use this function to simplify the buffer alloc and avoid the unnecessary memory waste. Signed-off-by: Kevin Hao --- drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c | 3 +-- 1 file changed, 1

[PATCH net-next 2/4] net: Introduce {netdev,napi}_alloc_frag_align()

2021-01-23 Thread Kevin Hao
t for the page_frag functions, so add the corresponding {netdev,napi}_frag functions. Signed-off-by: Kevin Hao --- include/linux/skbuff.h | 2 ++ net/core/skbuff.c | 40 ++-- 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/include/

[PATCH net-next 0/4] net: Avoid the memory waste in some Ethernet drivers

2021-01-23 Thread Kevin Hao
elper functions to make sure that an align buffer is returned. Then we can drop the ugly workarounds and avoid the unnecessary memory waste. Kevin Hao (4): mm: page_frag: Introduce page_frag_alloc_align() net: Introduce {netdev,napi}_alloc_frag_align() net: octeontx2: Use napi_alloc_frag_align

Re: [PATCH] net: octeontx2: Make sure the buffer is 128 byte aligned

2021-01-21 Thread Kevin Hao
On Thu, Jan 21, 2021 at 09:53:08AM +, David Laight wrote: > From: Kevin Hao > > Sent: 21 January 2021 07:09 > > > > The octeontx2 hardware needs the buffer to be 128 byte aligned. > > But in the current implementation of napi_alloc_frag(), it can't > > gu

[PATCH] net: octeontx2: Make sure the buffer is 128 byte aligned

2021-01-20 Thread Kevin Hao
() to make sure that the buffer is aligned correctly. Fixes: 7a36e4918e30 ("octeontx2-pf: Use the napi_alloc_frag() to alloc the pool buffers") Reported-by: Subbaraya Sundeep Signed-off-by: Kevin Hao --- drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c | 3 ++- 1 file change

Re: [PATCH] Revert "octeontx2-pf: Use the napi_alloc_frag() to alloc the pool buffers"

2021-01-20 Thread Kevin Hao
On Wed, Jan 20, 2021 at 09:13:20PM -0800, Jakub Kicinski wrote: > On Thu, 21 Jan 2021 13:09:10 +0800 Kevin Hao wrote: > > On Wed, Jan 20, 2021 at 08:59:14PM -0800, Jakub Kicinski wrote: > > > On Thu, 21 Jan 2021 12:20:35 +0800 Kevin Hao wrote: > > > &g

Re: [PATCH] Revert "octeontx2-pf: Use the napi_alloc_frag() to alloc the pool buffers"

2021-01-20 Thread Kevin Hao
On Wed, Jan 20, 2021 at 08:59:14PM -0800, Jakub Kicinski wrote: > On Thu, 21 Jan 2021 12:20:35 +0800 Kevin Hao wrote: > > Hmm, why not? > > buf = napi_alloc_frag(pool->rbsize + 128); > > buf = PTR_ALIGN(buf, 128); > > I'd keep the aligning in the driver u

Re: [PATCH] Revert "octeontx2-pf: Use the napi_alloc_frag() to alloc the pool buffers"

2021-01-20 Thread Kevin Hao
On Wed, Jan 20, 2021 at 10:32:35AM +0530, sundeep.l...@gmail.com wrote: > From: Subbaraya Sundeep > > Octeontx2 hardware needs buffer pointers which are 128 byte > aligned. napi_alloc_frag() returns buffer pointers which are > not 128 byte aligned sometimes because if napi_alloc_skb() is > called

[PATCH v3] octeontx2-pf: Use the napi_alloc_frag() to alloc the pool buffers

2020-05-09 Thread Kevin Hao
remain area of the allocated page wasted. On a kernel with 64K page, 62K area is wasted. IMHO it is really unnecessary to implement our own method for the buffers allocate, we can reuse the napi_alloc_frag() to simplify our code. Signed-off-by: Kevin Hao --- v3: 1. Use double underscore for

Re: [PATCH v2] octeontx2-pf: Use the napi_alloc_frag() to alloc the pool buffers

2020-05-08 Thread Kevin Hao
On Fri, May 08, 2020 at 05:38:33PM -0700, Jakub Kicinski wrote: > On Fri, 8 May 2020 19:49:53 +0800 Kevin Hao wrote: > > diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c > > b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c > > index f1d2d

[PATCH v2] octeontx2-pf: Use the napi_alloc_frag() to alloc the pool buffers

2020-05-08 Thread Kevin Hao
remain area of the allocated page wasted. On a kernel with 64K page, 62K area is wasted. IMHO it is really unnecessary to implement our own method for the buffers allocate, we can reuse the napi_alloc_frag() to simplify our code. Signed-off-by: Kevin Hao --- v2: Use DMA_ATTR_SKIP_CPU_SYNC

Re: [PATCH] octeontx2-pf: Use the napi_alloc_frag() to alloc the pool buffers

2020-05-08 Thread Kevin Hao
On Fri, May 08, 2020 at 01:10:00PM +0530, Sunil Kovvuri wrote: > On Fri, May 8, 2020 at 9:43 AM Kevin Hao wrote: > > > > In the current codes, the octeontx2 uses its own method to allocate > > the pool buffers, but there are some issues in this implementation. >

Re: [PATCH] octeontx2-pf: Use the napi_alloc_frag() to alloc the pool buffers

2020-05-07 Thread Kevin Hao
On Fri, May 08, 2020 at 10:18:27AM +0530, Sunil Kovvuri wrote: > On Fri, May 8, 2020 at 9:43 AM Kevin Hao wrote: > > > > In the current codes, the octeontx2 uses its own method to allocate > > the pool buffers, but there are some issues in this implementation. >

[PATCH] octeontx2-pf: Use the napi_alloc_frag() to alloc the pool buffers

2020-05-07 Thread Kevin Hao
remain area of the allocated page wasted. On a kernel with 64K page, 62K area is wasted. IMHO it is really unnecessary to implement our own method for the buffers allocate, we can reuse the napi_alloc_frag() to simplify our code. Signed-off-by: Kevin Hao --- .../marvell/octeontx2/nic

[PATCH v2 2/3] net: phy: realtek: Use the dummy stubs for MMD register access for rtl8211b

2018-03-19 Thread Kevin Hao
ault") Signed-off-by: Kevin Hao --- drivers/net/phy/realtek.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c index ee3ca4a2f12b..9f48ecf9c627 100644 --- a/drivers/net/phy/realtek.c +++ b/drivers/net/phy/realtek.c @@ -172,6 +172,8 @@

[PATCH v2 3/3] net: phy: micrel: Use the general dummy stubs for MMD register access

2018-03-19 Thread Kevin Hao
The new general dummy stubs for MMD register access were introduced. Use that for the codes reuse. Signed-off-by: Kevin Hao --- drivers/net/phy/micrel.c | 23 ++- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy

[PATCH v2 1/3] net: phy: Add general dummy stubs for MMD register access

2018-03-19 Thread Kevin Hao
ffect. Fixes: b6b5e8a69118 ("gianfar: Disable EEE autoneg by default") Signed-off-by: Kevin Hao --- drivers/net/phy/phy_device.c | 17 + include/linux/phy.h | 4 2 files changed, 21 insertions(+) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/p

[PATCH v2 0/3] net: phy: Add general dummy stubs for MMD register access

2018-03-19 Thread Kevin Hao
v2: As suggested by Andrew: - Add general dummy stubs - Also use that for the micrel phy This patch series fix the Ethernet broken on the mpc8315erdb board introduced by commit b6b5e8a69118 ("gianfar: Disable EEE autoneg by default"). Kevin Hao (3): net: phy: Add general dummy

Re: [PATCH] net: phy: realtek: Add dummy stubs for MMD register access for rtl8211b

2018-03-19 Thread Kevin Hao
On Mon, Mar 19, 2018 at 01:39:39PM +0100, Andrew Lunn wrote: > On Mon, Mar 19, 2018 at 08:05:47PM +0800, Kevin Hao wrote: > > The Ethernet on mpc8315erdb is broken since commit b6b5e8a69118 > > ("gianfar: Disable EEE autoneg by default"). The reason is that > > e

[PATCH] net: phy: realtek: Add dummy stubs for MMD register access for rtl8211b

2018-03-19 Thread Kevin Hao
indirect method. This makes it seem that the EEE is supported by this phy device. And the subsequent writing to the MMD registers does cause the phy malfunction. So add dummy stubs for the MMD register access to fix this issue. Fixes: b6b5e8a69118 ("gianfar: Disable EEE autoneg by default&qu

Re: [PATCH] Revert "net/phy: Add Vitesse 8641 phy ID"

2015-09-18 Thread Kevin Hao
On Fri, Sep 18, 2015 at 09:36:42AM +, Shaohui Xie wrote: > > -Original Message- > > From: Kevin Hao [mailto:haoke...@gmail.com] > > Sent: Friday, September 18, 2015 3:43 PM > > To: netdev@vger.kernel.org > > Cc: Florian Fainelli; Xie Shaohui-B21989 > &

[PATCH] Revert "net/phy: Add Vitesse 8641 phy ID"

2015-09-18 Thread Kevin Hao
Ethernet on p1010rdb-pa board. So we definitely need a rework in order to support the 8641 phy in this driver. Signed-off-by: Kevin Hao --- drivers/net/phy/vitesse.c | 14 -- 1 file changed, 14 deletions(-) diff --git a/drivers/net/phy/vitesse.c b/drivers/net/phy/vitesse.c index

[PATCH net-next] net: fec: fix the race between xmit and bdp reclaiming path

2015-08-06 Thread Kevin Hao
d the corresponding memory barrier to guarantee that the update to the bdps, dirty_tx and cur_tx performed in the proper order. Signed-off-by: Kevin Hao --- I have run into a kernel hang due to this race on a custom rt kernel. Even I can't reproduce it on the vanilla kernel, it seems that the