git: 1ec7c672bc28 - main - mpi3mr: Assume dma_hiaddr is BUS_SPACE_MAXADDR

From: Warner Losh <imp_at_FreeBSD.org>
Date: Wed, 29 Nov 2023 01:55:46 UTC
The branch main has been updated by imp:

URL: https://cgit.FreeBSD.org/src/commit/?id=1ec7c672bc2854a1efb1d50f189d4881163c16c6

commit 1ec7c672bc2854a1efb1d50f189d4881163c16c6
Author:     Warner Losh <imp@FreeBSD.org>
AuthorDate: 2023-11-29 01:50:52 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2023-11-29 01:52:28 +0000

    mpi3mr: Assume dma_hiaddr is BUS_SPACE_MAXADDR
    
    No sense having a variable for this. So use BUS_SPACE_MAXADDR and remove
    dma_hiaddr from softc.
    
    Suggested by:           jhb
    Sponsored by:           Netflix
    Differential Revision:  https://reviews.freebsd.org/D42808
---
 sys/dev/mpi3mr/mpi3mr.c     | 47 ++++++++++++++++++++++-----------------------
 sys/dev/mpi3mr/mpi3mr.h     |  1 -
 sys/dev/mpi3mr/mpi3mr_app.c |  2 +-
 3 files changed, 24 insertions(+), 26 deletions(-)

diff --git a/sys/dev/mpi3mr/mpi3mr.c b/sys/dev/mpi3mr/mpi3mr.c
index cc970de00e8b..39cefd15d476 100644
--- a/sys/dev/mpi3mr/mpi3mr.c
+++ b/sys/dev/mpi3mr/mpi3mr.c
@@ -604,7 +604,7 @@ static int mpi3mr_create_op_reply_queue(struct mpi3mr_softc *sc, U16 qid)
 		if (bus_dma_tag_create(sc->mpi3mr_parent_dmat,    /* parent */
 					4, 0,			/* algnmnt, boundary */
 					sc->dma_loaddr,		/* lowaddr */
-					sc->dma_hiaddr,		/* highaddr */
+					BUS_SPACE_MAXADDR,	/* highaddr */
 					NULL, NULL,		/* filter, filterarg */
 					op_reply_q->qsz,		/* maxsize */
 					1,			/* nsegments */
@@ -750,7 +750,7 @@ static int mpi3mr_create_op_req_queue(struct mpi3mr_softc *sc, U16 req_qid, U8 r
 		if (bus_dma_tag_create(sc->mpi3mr_parent_dmat,    /* parent */
 					4, 0,			/* algnmnt, boundary */
 					sc->dma_loaddr,		/* lowaddr */
-					sc->dma_hiaddr,		/* highaddr */
+					BUS_SPACE_MAXADDR,	/* highaddr */
 					NULL, NULL,		/* filter, filterarg */
 					op_req_q->qsz,		/* maxsize */
 					1,			/* nsegments */
@@ -1440,10 +1440,10 @@ static int mpi3mr_issue_iocfacts(struct mpi3mr_softc *sc,
 
 
 	/*
-	 * We can't use sc->dma_loaddr / hiaddr here.  We set those only after
-	 * we get the iocfacts.  So allocate in the lower 4GB.  The amount of
-	 * data is tiny and we don't do this that often, so any bouncing we
-	 * might have to do isn't a cause for concern.
+	 * We can't use sc->dma_loaddr here.  We set those only after we get the
+	 * iocfacts.  So allocate in the lower 4GB.  The amount of data is tiny
+	 * and we don't do this that often, so any bouncing we might have to do
+	 * isn't a cause for concern.
 	 */
         if (bus_dma_tag_create(sc->mpi3mr_parent_dmat,    /* parent */
 				4, 0,			/* algnmnt, boundary */
@@ -1688,8 +1688,8 @@ static int mpi3mr_process_factsdata(struct mpi3mr_softc *sc,
 
 	/*
 	 * Set the DMA mask for the card.  dma_mask is the number of bits that
-	 * can have bits set in them.  Translate this into bus_dma loaddr/hiaddr
-	 * args.  Add sanity for more bits than address space or other overflow
+	 * can have bits set in them.  Translate this into bus_dma loaddr args.
+	 * Add sanity for more bits than address space or other overflow
 	 * situations.
 	 */
 	if (sc->facts.dma_mask == 0 ||
@@ -1697,10 +1697,9 @@ static int mpi3mr_process_factsdata(struct mpi3mr_softc *sc,
 		sc->dma_loaddr = BUS_SPACE_MAXADDR;
 	else
 		sc->dma_loaddr = ~((1ull << sc->facts.dma_mask) - 1);
-	sc->dma_hiaddr = BUS_SPACE_MAXADDR;
 	mpi3mr_dprint(sc, MPI3MR_INFO,
-	    "dma_mask bits: %d loaddr 0x%jx hiaddr 0x%jx\n",
-	    sc->facts.dma_mask, sc->dma_loaddr, sc->dma_hiaddr);
+	    "dma_mask bits: %d loaddr 0x%jx\n",
+	    sc->facts.dma_mask, sc->dma_loaddr);
 
 	return retval;
 }
@@ -1738,7 +1737,7 @@ static int mpi3mr_reply_dma_alloc(struct mpi3mr_softc *sc)
 	if (bus_dma_tag_create(sc->mpi3mr_parent_dmat,  /* parent */
 				16, 0,			/* algnmnt, boundary */
 				sc->dma_loaddr,		/* lowaddr */
-				sc->dma_hiaddr,		/* highaddr */
+				BUS_SPACE_MAXADDR,	/* highaddr */
 				NULL, NULL,		/* filter, filterarg */
                                 sz,			/* maxsize */
                                 1,			/* nsegments */
@@ -1774,7 +1773,7 @@ static int mpi3mr_reply_dma_alloc(struct mpi3mr_softc *sc)
         if (bus_dma_tag_create(sc->mpi3mr_parent_dmat,    /* parent */
 				8, 0,			/* algnmnt, boundary */
 				sc->dma_loaddr,		/* lowaddr */
-				sc->dma_hiaddr,		/* highaddr */
+				BUS_SPACE_MAXADDR,	/* highaddr */
 				NULL, NULL,		/* filter, filterarg */
                                 sz,			/* maxsize */
                                 1,			/* nsegments */
@@ -1808,7 +1807,7 @@ static int mpi3mr_reply_dma_alloc(struct mpi3mr_softc *sc)
         if (bus_dma_tag_create(sc->mpi3mr_parent_dmat,    /* parent */
 				4, 0,			/* algnmnt, boundary */
 				sc->dma_loaddr,		/* lowaddr */
-				sc->dma_hiaddr,		/* highaddr */
+				BUS_SPACE_MAXADDR,	/* highaddr */
 				NULL, NULL,		/* filter, filterarg */
                                 sz,			/* maxsize */
                                 1,			/* nsegments */
@@ -1842,7 +1841,7 @@ static int mpi3mr_reply_dma_alloc(struct mpi3mr_softc *sc)
         if (bus_dma_tag_create(sc->mpi3mr_parent_dmat,    /* parent */
 				8, 0,			/* algnmnt, boundary */
 				sc->dma_loaddr,		/* lowaddr */
-				sc->dma_hiaddr,		/* highaddr */
+				BUS_SPACE_MAXADDR,	/* highaddr */
 				NULL, NULL,		/* filter, filterarg */
                                 sz,			/* maxsize */
                                 1,			/* nsegments */
@@ -1979,7 +1978,7 @@ mpi3mr_print_fw_pkg_ver(struct mpi3mr_softc *sc)
 	if (bus_dma_tag_create(sc->mpi3mr_parent_dmat,  /* parent */
 				4, 0,			/* algnmnt, boundary */
 				sc->dma_loaddr,		/* lowaddr */
-				sc->dma_hiaddr,		/* highaddr */
+				BUS_SPACE_MAXADDR,	/* highaddr */
 				NULL, NULL,		/* filter, filterarg */
 				fw_pkg_ver_len,		/* maxsize */
 				1,			/* nsegments */
@@ -2101,7 +2100,7 @@ static int mpi3mr_issue_iocinit(struct mpi3mr_softc *sc)
 	if (bus_dma_tag_create(sc->mpi3mr_parent_dmat,  /* parent */
 				4, 0,			/* algnmnt, boundary */
 				sc->dma_loaddr,		/* lowaddr */
-				sc->dma_hiaddr,		/* highaddr */
+				BUS_SPACE_MAXADDR,	/* highaddr */
 				NULL, NULL,		/* filter, filterarg */
                                 drvr_info_len,		/* maxsize */
                                 1,			/* nsegments */
@@ -2514,7 +2513,7 @@ static int mpi3mr_alloc_chain_bufs(struct mpi3mr_softc *sc)
         if (bus_dma_tag_create(sc->mpi3mr_parent_dmat,  /* parent */
 				4096, 0,		/* algnmnt, boundary */
 				sc->dma_loaddr,		/* lowaddr */
-				sc->dma_hiaddr,		/* highaddr */
+				BUS_SPACE_MAXADDR,	/* highaddr */
 				NULL, NULL,		/* filter, filterarg */
                                 sz,			/* maxsize */
                                 1,			/* nsegments */
@@ -2589,8 +2588,8 @@ static int mpi3mr_pel_alloc(struct mpi3mr_softc *sc)
 		sc->pel_seq_number_sz = sizeof(Mpi3PELSeq_t);
 		if (bus_dma_tag_create(sc->mpi3mr_parent_dmat,   /* parent */
 				 4, 0,                           /* alignment, boundary */
-				 sc->dma_loaddr,	        /* lowaddr */
-				 sc->dma_hiaddr,	              /* highaddr */
+				 sc->dma_loaddr,	         /* lowaddr */
+				 BUS_SPACE_MAXADDR,		 /* highaddr */
 				 NULL, NULL,                     /* filter, filterarg */
 				 sc->pel_seq_number_sz,		 /* maxsize */
 				 1,                              /* nsegments */
@@ -4945,7 +4944,7 @@ mpi3mr_alloc_requests(struct mpi3mr_softc *sc)
 	ret = bus_dma_tag_create( sc->mpi3mr_parent_dmat,    /* parent */
 				1, 0,			/* algnmnt, boundary */
 				sc->dma_loaddr,		/* lowaddr */
-				sc->dma_hiaddr,		/* highaddr */
+				BUS_SPACE_MAXADDR,	/* highaddr */
 				NULL, NULL,		/* filter, filterarg */
 				BUS_SPACE_MAXSIZE,	/* maxsize */
                                 nsegs,			/* nsegments */
@@ -5119,7 +5118,7 @@ void mpi3mr_alloc_ioctl_dma_memory(struct mpi3mr_softc *sc)
 		if (bus_dma_tag_create(sc->mpi3mr_parent_dmat,    /* parent */
 					4, 0,			/* algnmnt, boundary */
 					sc->dma_loaddr,		/* lowaddr */
-					sc->dma_hiaddr,		/* highaddr */
+					BUS_SPACE_MAXADDR,	/* highaddr */
 					NULL, NULL,		/* filter, filterarg */
 					mem_desc->size,		/* maxsize */
 					1,			/* nsegments */
@@ -5149,7 +5148,7 @@ void mpi3mr_alloc_ioctl_dma_memory(struct mpi3mr_softc *sc)
 	if (bus_dma_tag_create(sc->mpi3mr_parent_dmat,    /* parent */
 				4, 0,			/* algnmnt, boundary */
 				sc->dma_loaddr,		/* lowaddr */
-				sc->dma_hiaddr,		/* highaddr */
+				BUS_SPACE_MAXADDR,	/* highaddr */
 				NULL, NULL,		/* filter, filterarg */
 				mem_desc->size,		/* maxsize */
 				1,			/* nsegments */
@@ -5178,7 +5177,7 @@ void mpi3mr_alloc_ioctl_dma_memory(struct mpi3mr_softc *sc)
 	if (bus_dma_tag_create(sc->mpi3mr_parent_dmat,    /* parent */
 				4, 0,			/* algnmnt, boundary */
 				sc->dma_loaddr,		/* lowaddr */
-				sc->dma_hiaddr,		/* highaddr */
+				BUS_SPACE_MAXADDR,	/* highaddr */
 				NULL, NULL,		/* filter, filterarg */
 				mem_desc->size,		/* maxsize */
 				1,			/* nsegments */
diff --git a/sys/dev/mpi3mr/mpi3mr.h b/sys/dev/mpi3mr/mpi3mr.h
index 2af94123c090..d93c53b286cb 100644
--- a/sys/dev/mpi3mr/mpi3mr.h
+++ b/sys/dev/mpi3mr/mpi3mr.h
@@ -544,7 +544,6 @@ struct mpi3mr_softc {
 	char driver_name[MPI3MR_NAME_LENGTH];
 	int bars;
 	bus_addr_t dma_loaddr;
-	bus_addr_t dma_hiaddr;
 	u_int mpi3mr_debug;
 	struct mpi3mr_reset reset;
 	int max_msix_vectors;
diff --git a/sys/dev/mpi3mr/mpi3mr_app.c b/sys/dev/mpi3mr/mpi3mr_app.c
index 14cea43db2ca..99a922b2bec9 100644
--- a/sys/dev/mpi3mr/mpi3mr_app.c
+++ b/sys/dev/mpi3mr/mpi3mr_app.c
@@ -336,7 +336,7 @@ mpi3mr_app_build_nvme_prp(struct mpi3mr_softc *sc,
 	if (bus_dma_tag_create(sc->mpi3mr_parent_dmat,		/* parent */
 				4, 0,				/* algnmnt, boundary */
 				sc->dma_loaddr,			/* lowaddr */
-				sc->dma_hiaddr,			/* highaddr */
+				BUS_SPACE_MAXADDR,		/* highaddr */
 				NULL, NULL,			/* filter, filterarg */
 				dev_pgsz,			/* maxsize */
                                 1,				/* nsegments */