driverdev-devel.linuxdriverproject.org archive mirror
 help / color / mirror / Atom feed
From: Benjamin Poirier <bpoirier@suse.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: devel@driverdev.osuosl.org, netdev@vger.kernel.org,
	GR-Linux-NIC-Dev@marvell.com, linux-kernel@vger.kernel.org,
	Manish Chopra <manishc@marvell.com>
Subject: [PATCH v2 03/17] staging: qlge: Remove page_chunk.last_flag
Date: Fri, 27 Sep 2019 19:11:57 +0900	[thread overview]
Message-ID: <20190927101210.23856-4-bpoirier@suse.com> (raw)
In-Reply-To: <20190927101210.23856-1-bpoirier@suse.com>

As already done in ql_get_curr_lchunk(), this member can be replaced by a
simple test.

Signed-off-by: Benjamin Poirier <bpoirier@suse.com>
Acked-by: Manish Chopra <manishc@marvell.com>
---
 drivers/staging/qlge/qlge.h      |  1 -
 drivers/staging/qlge/qlge_main.c | 13 +++++--------
 2 files changed, 5 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/qlge/qlge.h b/drivers/staging/qlge/qlge.h
index 5d9a36deda08..0a156a95e981 100644
--- a/drivers/staging/qlge/qlge.h
+++ b/drivers/staging/qlge/qlge.h
@@ -1363,7 +1363,6 @@ struct page_chunk {
 	char *va;		/* virt addr for this chunk */
 	u64 map;		/* mapping for master */
 	unsigned int offset;	/* offset for this chunk */
-	unsigned int last_flag; /* flag set for last chunk in page */
 };
 
 struct bq_desc {
diff --git a/drivers/staging/qlge/qlge_main.c b/drivers/staging/qlge/qlge_main.c
index 7a8d6390d5de..a82920776e6b 100644
--- a/drivers/staging/qlge/qlge_main.c
+++ b/drivers/staging/qlge/qlge_main.c
@@ -1077,11 +1077,9 @@ static int ql_get_next_chunk(struct ql_adapter *qdev, struct rx_ring *rx_ring,
 	rx_ring->pg_chunk.offset += rx_ring->lbq_buf_size;
 	if (rx_ring->pg_chunk.offset == ql_lbq_block_size(qdev)) {
 		rx_ring->pg_chunk.page = NULL;
-		lbq_desc->p.pg_chunk.last_flag = 1;
 	} else {
 		rx_ring->pg_chunk.va += rx_ring->lbq_buf_size;
 		get_page(rx_ring->pg_chunk.page);
-		lbq_desc->p.pg_chunk.last_flag = 0;
 	}
 	return 0;
 }
@@ -2778,6 +2776,8 @@ static int ql_alloc_tx_resources(struct ql_adapter *qdev,
 
 static void ql_free_lbq_buffers(struct ql_adapter *qdev, struct rx_ring *rx_ring)
 {
+	unsigned int last_offset = ql_lbq_block_size(qdev) -
+		rx_ring->lbq_buf_size;
 	struct bq_desc *lbq_desc;
 
 	uint32_t  curr_idx, clean_idx;
@@ -2787,13 +2787,10 @@ static void ql_free_lbq_buffers(struct ql_adapter *qdev, struct rx_ring *rx_ring
 	while (curr_idx != clean_idx) {
 		lbq_desc = &rx_ring->lbq[curr_idx];
 
-		if (lbq_desc->p.pg_chunk.last_flag) {
-			pci_unmap_page(qdev->pdev,
-				lbq_desc->p.pg_chunk.map,
-				ql_lbq_block_size(qdev),
+		if (lbq_desc->p.pg_chunk.offset == last_offset)
+			pci_unmap_page(qdev->pdev, lbq_desc->p.pg_chunk.map,
+				       ql_lbq_block_size(qdev),
 				       PCI_DMA_FROMDEVICE);
-			lbq_desc->p.pg_chunk.last_flag = 0;
-		}
 
 		put_page(lbq_desc->p.pg_chunk.page);
 		lbq_desc->p.pg_chunk.page = NULL;
-- 
2.23.0

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

  parent reply	other threads:[~2019-09-27 10:15 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-27 10:11 [PATCH v2 0/17] staging: qlge: Fix rx stall in case of allocation failures Benjamin Poirier
2019-09-27 10:11 ` [PATCH v2 01/17] staging: qlge: Fix irq masking in INTx mode Benjamin Poirier
2019-09-27 10:11 ` [PATCH v2 02/17] staging: qlge: Remove irq_cnt Benjamin Poirier
2019-09-27 10:11 ` Benjamin Poirier [this message]
2019-09-27 10:11 ` [PATCH v2 04/17] staging: qlge: Deduplicate lbq_buf_size Benjamin Poirier
2019-09-27 10:11 ` [PATCH v2 05/17] staging: qlge: Remove bq_desc.maplen Benjamin Poirier
2019-09-27 10:12 ` [PATCH v2 06/17] staging: qlge: Remove rx_ring.sbq_buf_size Benjamin Poirier
2019-09-27 10:12 ` [PATCH v2 07/17] staging: qlge: Remove useless dma synchronization calls Benjamin Poirier
2019-09-27 10:12 ` [PATCH v2 08/17] staging: qlge: Deduplicate rx buffer queue management Benjamin Poirier
2019-09-27 10:12 ` [PATCH v2 09/17] staging: qlge: Fix dma_sync_single calls Benjamin Poirier
2019-09-27 10:12 ` [PATCH v2 10/17] staging: qlge: Remove rx_ring.type Benjamin Poirier
2019-09-27 10:12 ` [PATCH v2 11/17] staging: qlge: Factor out duplicated expression Benjamin Poirier
2019-09-27 10:12 ` [PATCH v2 12/17] staging: qlge: Remove qlge_bq.len & size Benjamin Poirier
2019-09-27 10:12 ` [PATCH v2 13/17] staging: qlge: Remove useless memset Benjamin Poirier
2019-09-27 10:12 ` [PATCH v2 14/17] staging: qlge: Replace memset with assignment Benjamin Poirier
2019-09-27 10:12 ` [PATCH v2 15/17] staging: qlge: Update buffer queue prod index despite oom Benjamin Poirier
2019-09-27 10:12 ` [PATCH v2 16/17] staging: qlge: Refill rx buffers up to multiple of 16 Benjamin Poirier
2019-09-27 10:12 ` [PATCH v2 17/17] staging: qlge: Refill empty buffer queues from wq Benjamin Poirier
2019-10-04  8:19 ` [PATCH v2 0/17] staging: qlge: Fix rx stall in case of allocation failures Greg Kroah-Hartman
2019-10-04  9:15   ` Benjamin Poirier
2019-10-04 15:19     ` Greg Kroah-Hartman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190927101210.23856-4-bpoirier@suse.com \
    --to=bpoirier@suse.com \
    --cc=GR-Linux-NIC-Dev@marvell.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=manishc@marvell.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).