* [PATCH] net: atheros: atl1: use offset_in_page() macro [not found] <4dbc77ccaaed98b183cf4dba58a4fa325fd65048.1492758503.git.geliangtang@gmail.com> @ 2017-04-22 1:21 ` Geliang Tang 2017-04-24 17:58 ` David Miller 2017-04-22 1:21 ` [PATCH] xprtrdma: " Geliang Tang 1 sibling, 1 reply; 4+ messages in thread From: Geliang Tang @ 2017-04-22 1:21 UTC (permalink / raw) To: Jay Cliburn, Chris Snook, David S. Miller, Eric Dumazet Cc: Geliang Tang, netdev, linux-kernel Use offset_in_page() macro instead of open-coding. Signed-off-by: Geliang Tang <geliangtang@gmail.com> --- drivers/net/ethernet/atheros/atlx/atl1.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/atheros/atlx/atl1.c b/drivers/net/ethernet/atheros/atlx/atl1.c index 022772e..83d2db2 100644 --- a/drivers/net/ethernet/atheros/atlx/atl1.c +++ b/drivers/net/ethernet/atheros/atlx/atl1.c @@ -1886,7 +1886,7 @@ static u16 atl1_alloc_rx_buffers(struct atl1_adapter *adapter) buffer_info->skb = skb; buffer_info->length = (u16) adapter->rx_buffer_len; page = virt_to_page(skb->data); - offset = (unsigned long)skb->data & ~PAGE_MASK; + offset = offset_in_page(skb->data); buffer_info->dma = pci_map_page(pdev, page, offset, adapter->rx_buffer_len, PCI_DMA_FROMDEVICE); @@ -2230,7 +2230,7 @@ static void atl1_tx_map(struct atl1_adapter *adapter, struct sk_buff *skb, hdr_len = skb_transport_offset(skb) + tcp_hdrlen(skb); buffer_info->length = hdr_len; page = virt_to_page(skb->data); - offset = (unsigned long)skb->data & ~PAGE_MASK; + offset = offset_in_page(skb->data); buffer_info->dma = pci_map_page(adapter->pdev, page, offset, hdr_len, PCI_DMA_TODEVICE); @@ -2254,9 +2254,8 @@ static void atl1_tx_map(struct atl1_adapter *adapter, struct sk_buff *skb, data_len -= buffer_info->length; page = virt_to_page(skb->data + (hdr_len + i * ATL1_MAX_TX_BUF_LEN)); - offset = (unsigned long)(skb->data + - (hdr_len + i * ATL1_MAX_TX_BUF_LEN)) & - ~PAGE_MASK; + offset = offset_in_page(skb->data + + (hdr_len + i * ATL1_MAX_TX_BUF_LEN)); buffer_info->dma = pci_map_page(adapter->pdev, page, offset, buffer_info->length, PCI_DMA_TODEVICE); @@ -2268,7 +2267,7 @@ static void atl1_tx_map(struct atl1_adapter *adapter, struct sk_buff *skb, /* not TSO */ buffer_info->length = buf_len; page = virt_to_page(skb->data); - offset = (unsigned long)skb->data & ~PAGE_MASK; + offset = offset_in_page(skb->data); buffer_info->dma = pci_map_page(adapter->pdev, page, offset, buf_len, PCI_DMA_TODEVICE); if (++next_to_use == tpd_ring->count) -- 2.9.3 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] net: atheros: atl1: use offset_in_page() macro 2017-04-22 1:21 ` [PATCH] net: atheros: atl1: use offset_in_page() macro Geliang Tang @ 2017-04-24 17:58 ` David Miller 0 siblings, 0 replies; 4+ messages in thread From: David Miller @ 2017-04-24 17:58 UTC (permalink / raw) To: geliangtang; +Cc: jcliburn, chris.snook, edumazet, netdev, linux-kernel From: Geliang Tang <geliangtang@gmail.com> Date: Sat, 22 Apr 2017 09:21:10 +0800 > Use offset_in_page() macro instead of open-coding. > > Signed-off-by: Geliang Tang <geliangtang@gmail.com> Applied, thanks. ^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] xprtrdma: use offset_in_page() macro [not found] <4dbc77ccaaed98b183cf4dba58a4fa325fd65048.1492758503.git.geliangtang@gmail.com> 2017-04-22 1:21 ` [PATCH] net: atheros: atl1: use offset_in_page() macro Geliang Tang @ 2017-04-22 1:21 ` Geliang Tang 2017-04-22 3:37 ` Chuck Lever 1 sibling, 1 reply; 4+ messages in thread From: Geliang Tang @ 2017-04-22 1:21 UTC (permalink / raw) To: J. Bruce Fields, Jeff Layton, Trond Myklebust, Anna Schumaker, David S. Miller, Chuck Lever, Sagi Grimberg Cc: Geliang Tang, linux-nfs, netdev, linux-kernel Use offset_in_page() macro instead of open-coding. Signed-off-by: Geliang Tang <geliangtang@gmail.com> --- net/sunrpc/xprtrdma/rpc_rdma.c | 4 ++-- net/sunrpc/xprtrdma/svc_rdma_sendto.c | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/net/sunrpc/xprtrdma/rpc_rdma.c b/net/sunrpc/xprtrdma/rpc_rdma.c index a044be2..429beea 100644 --- a/net/sunrpc/xprtrdma/rpc_rdma.c +++ b/net/sunrpc/xprtrdma/rpc_rdma.c @@ -540,7 +540,7 @@ rpcrdma_prepare_msg_sges(struct rpcrdma_ia *ia, struct rpcrdma_req *req, goto out; page = virt_to_page(xdr->tail[0].iov_base); - page_base = (unsigned long)xdr->tail[0].iov_base & ~PAGE_MASK; + page_base = offset_in_page(xdr->tail[0].iov_base); /* If the content in the page list is an odd length, * xdr_write_pages() has added a pad at the beginning @@ -587,7 +587,7 @@ rpcrdma_prepare_msg_sges(struct rpcrdma_ia *ia, struct rpcrdma_req *req, */ if (xdr->tail[0].iov_len) { page = virt_to_page(xdr->tail[0].iov_base); - page_base = (unsigned long)xdr->tail[0].iov_base & ~PAGE_MASK; + page_base = offset_in_page(xdr->tail[0].iov_base); len = xdr->tail[0].iov_len; map_tail: diff --git a/net/sunrpc/xprtrdma/svc_rdma_sendto.c b/net/sunrpc/xprtrdma/svc_rdma_sendto.c index 1736337..60b3f29 100644 --- a/net/sunrpc/xprtrdma/svc_rdma_sendto.c +++ b/net/sunrpc/xprtrdma/svc_rdma_sendto.c @@ -306,12 +306,11 @@ static int svc_rdma_dma_map_buf(struct svcxprt_rdma *rdma, unsigned char *base, unsigned int len) { - unsigned long offset = (unsigned long)base & ~PAGE_MASK; struct ib_device *dev = rdma->sc_cm_id->device; dma_addr_t dma_addr; dma_addr = ib_dma_map_page(dev, virt_to_page(base), - offset, len, DMA_TO_DEVICE); + offset_in_page(base), len, DMA_TO_DEVICE); if (ib_dma_mapping_error(dev, dma_addr)) return -EIO; -- 2.9.3 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] xprtrdma: use offset_in_page() macro 2017-04-22 1:21 ` [PATCH] xprtrdma: " Geliang Tang @ 2017-04-22 3:37 ` Chuck Lever 0 siblings, 0 replies; 4+ messages in thread From: Chuck Lever @ 2017-04-22 3:37 UTC (permalink / raw) To: Geliang Tang Cc: J. Bruce Fields, Jeff Layton, Trond Myklebust, Anna Schumaker, David S. Miller, Sagi Grimberg, Linux NFS Mailing List, netdev, linux-kernel > On Apr 21, 2017, at 9:21 PM, Geliang Tang <geliangtang@gmail.com> wrote: > > Use offset_in_page() macro instead of open-coding. > > Signed-off-by: Geliang Tang <geliangtang@gmail.com> > --- > net/sunrpc/xprtrdma/rpc_rdma.c | 4 ++-- > net/sunrpc/xprtrdma/svc_rdma_sendto.c | 3 +-- > 2 files changed, 3 insertions(+), 4 deletions(-) > > diff --git a/net/sunrpc/xprtrdma/rpc_rdma.c b/net/sunrpc/xprtrdma/rpc_rdma.c > index a044be2..429beea 100644 > --- a/net/sunrpc/xprtrdma/rpc_rdma.c > +++ b/net/sunrpc/xprtrdma/rpc_rdma.c > @@ -540,7 +540,7 @@ rpcrdma_prepare_msg_sges(struct rpcrdma_ia *ia, struct rpcrdma_req *req, > goto out; > > page = virt_to_page(xdr->tail[0].iov_base); > - page_base = (unsigned long)xdr->tail[0].iov_base & ~PAGE_MASK; > + page_base = offset_in_page(xdr->tail[0].iov_base); > > /* If the content in the page list is an odd length, > * xdr_write_pages() has added a pad at the beginning > @@ -587,7 +587,7 @@ rpcrdma_prepare_msg_sges(struct rpcrdma_ia *ia, struct rpcrdma_req *req, > */ > if (xdr->tail[0].iov_len) { > page = virt_to_page(xdr->tail[0].iov_base); > - page_base = (unsigned long)xdr->tail[0].iov_base & ~PAGE_MASK; > + page_base = offset_in_page(xdr->tail[0].iov_base); > len = xdr->tail[0].iov_len; > > map_tail: There are several other sites that use PAGE_MASK in rpc_rdma.c. Should those be included in this patch? Do you have a way to test this change? If not I can take it (once the above comment is addressed), run it through the usual battery of NFS/RDMA testing, and then pass it along to Anna. > diff --git a/net/sunrpc/xprtrdma/svc_rdma_sendto.c b/net/sunrpc/xprtrdma/svc_rdma_sendto.c > index 1736337..60b3f29 100644 > --- a/net/sunrpc/xprtrdma/svc_rdma_sendto.c > +++ b/net/sunrpc/xprtrdma/svc_rdma_sendto.c > @@ -306,12 +306,11 @@ static int svc_rdma_dma_map_buf(struct svcxprt_rdma *rdma, > unsigned char *base, > unsigned int len) > { > - unsigned long offset = (unsigned long)base & ~PAGE_MASK; > struct ib_device *dev = rdma->sc_cm_id->device; > dma_addr_t dma_addr; > > dma_addr = ib_dma_map_page(dev, virt_to_page(base), > - offset, len, DMA_TO_DEVICE); > + offset_in_page(base), len, DMA_TO_DEVICE); > if (ib_dma_mapping_error(dev, dma_addr)) > return -EIO; > This hunk conflicts with a rewrite of svc_rdma_sendto.c that Bruce has already accepted for v4.12. I would prefer this be dropped. The rewritten code also has this issue. I can submit a patch separately that adds offset_in_page in the appropriate place. -- Chuck Lever ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-04-24 17:58 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <4dbc77ccaaed98b183cf4dba58a4fa325fd65048.1492758503.git.geliangtang@gmail.com>
2017-04-22 1:21 ` [PATCH] net: atheros: atl1: use offset_in_page() macro Geliang Tang
2017-04-24 17:58 ` David Miller
2017-04-22 1:21 ` [PATCH] xprtrdma: " Geliang Tang
2017-04-22 3:37 ` Chuck Lever
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).