From owner-svn-src-head@freebsd.org Fri Sep 11 22:27:36 2020 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E5BDF3E85AB; Fri, 11 Sep 2020 22:27:36 +0000 (UTC) (envelope-from scottl@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Bp9P45Z2Cz3gxY; Fri, 11 Sep 2020 22:27:36 +0000 (UTC) (envelope-from scottl@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 9E206AE3A; Fri, 11 Sep 2020 22:27:36 +0000 (UTC) (envelope-from scottl@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 08BMRa71092940; Fri, 11 Sep 2020 22:27:36 GMT (envelope-from scottl@FreeBSD.org) Received: (from scottl@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 08BMRaRn092938; Fri, 11 Sep 2020 22:27:36 GMT (envelope-from scottl@FreeBSD.org) Message-Id: <202009112227.08BMRaRn092938@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: scottl set sender to scottl@FreeBSD.org using -f From: Scott Long Date: Fri, 11 Sep 2020 22:27:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r365644 - head/sys/dev/mps X-SVN-Group: head X-SVN-Commit-Author: scottl X-SVN-Commit-Paths: head/sys/dev/mps X-SVN-Commit-Revision: 365644 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Sep 2020 22:27:37 -0000 Author: scottl Date: Fri Sep 11 22:27:35 2020 New Revision: 365644 URL: https://svnweb.freebsd.org/changeset/base/365644 Log: Convert the mps driver to use busdma templates Modified: head/sys/dev/mps/mps.c head/sys/dev/mps/mps_pci.c head/sys/dev/mps/mps_user.c Modified: head/sys/dev/mps/mps.c ============================================================================== --- head/sys/dev/mps/mps.c Fri Sep 11 20:49:36 2020 (r365643) +++ head/sys/dev/mps/mps.c Fri Sep 11 22:27:35 2020 (r365644) @@ -1278,6 +1278,7 @@ mps_alloc_queues(struct mps_softc *sc) static int mps_alloc_hw_queues(struct mps_softc *sc) { + bus_dma_tag_template_t t; bus_addr_t queues_busaddr; uint8_t *queues; int qsize, fqsize, pqsize; @@ -1299,17 +1300,12 @@ mps_alloc_hw_queues(struct mps_softc *sc) pqsize = sc->pqdepth * 8; qsize = fqsize + pqsize; - if (bus_dma_tag_create( sc->mps_parent_dmat, /* parent */ - 16, 0, /* algnmnt, boundary */ - BUS_SPACE_MAXADDR_32BIT,/* lowaddr */ - BUS_SPACE_MAXADDR, /* highaddr */ - NULL, NULL, /* filter, filterarg */ - qsize, /* maxsize */ - 1, /* nsegments */ - qsize, /* maxsegsize */ - 0, /* flags */ - NULL, NULL, /* lockfunc, lockarg */ - &sc->queues_dmat)) { + bus_dma_template_init(&t, sc->mps_parent_dmat); + t.alignment = 16; + t.lowaddr = BUS_SPACE_MAXADDR_32BIT; + t.maxsize = t.maxsegsize = qsize; + t.nsegments = 1; + if (bus_dma_template_tag(&t, &sc->queues_dmat)) { mps_dprint(sc, MPS_ERROR, "Cannot allocate queues DMA tag\n"); return (ENOMEM); } @@ -1337,6 +1333,7 @@ mps_alloc_hw_queues(struct mps_softc *sc) static int mps_alloc_replies(struct mps_softc *sc) { + bus_dma_tag_template_t t; int rsize, num_replies; /* Store the reply frame size in bytes rather than as 32bit words */ @@ -1350,17 +1347,12 @@ mps_alloc_replies(struct mps_softc *sc) num_replies = max(sc->fqdepth, sc->num_replies); rsize = sc->replyframesz * num_replies; - if (bus_dma_tag_create( sc->mps_parent_dmat, /* parent */ - 4, 0, /* algnmnt, boundary */ - BUS_SPACE_MAXADDR_32BIT,/* lowaddr */ - BUS_SPACE_MAXADDR, /* highaddr */ - NULL, NULL, /* filter, filterarg */ - rsize, /* maxsize */ - 1, /* nsegments */ - rsize, /* maxsegsize */ - 0, /* flags */ - NULL, NULL, /* lockfunc, lockarg */ - &sc->reply_dmat)) { + bus_dma_template_init(&t, sc->mps_parent_dmat); + t.alignment = 4; + t.lowaddr = BUS_SPACE_MAXADDR_32BIT; + t.maxsize = t.maxsegsize = rsize; + t.nsegments = 1; + if (bus_dma_template_tag(&t, &sc->reply_dmat)) { mps_dprint(sc, MPS_ERROR, "Cannot allocate replies DMA tag\n"); return (ENOMEM); } @@ -1408,21 +1400,17 @@ mps_load_chains_cb(void *arg, bus_dma_segment_t *segs, static int mps_alloc_requests(struct mps_softc *sc) { + bus_dma_tag_template_t t; struct mps_command *cm; int i, rsize, nsegs; rsize = sc->reqframesz * sc->num_reqs; - if (bus_dma_tag_create( sc->mps_parent_dmat, /* parent */ - 16, 0, /* algnmnt, boundary */ - BUS_SPACE_MAXADDR_32BIT,/* lowaddr */ - BUS_SPACE_MAXADDR, /* highaddr */ - NULL, NULL, /* filter, filterarg */ - rsize, /* maxsize */ - 1, /* nsegments */ - rsize, /* maxsegsize */ - 0, /* flags */ - NULL, NULL, /* lockfunc, lockarg */ - &sc->req_dmat)) { + bus_dma_template_init(&t, sc->mps_parent_dmat); + t.alignment = 16; + t.lowaddr = BUS_SPACE_MAXADDR_32BIT; + t.maxsize = t.maxsegsize = rsize; + t.nsegments = 1; + if (bus_dma_template_tag(&t, &sc->req_dmat)) { mps_dprint(sc, MPS_ERROR, "Cannot allocate request DMA tag\n"); return (ENOMEM); } @@ -1444,17 +1432,10 @@ mps_alloc_requests(struct mps_softc *sc) return (ENOMEM); } rsize = sc->reqframesz * sc->num_chains; - if (bus_dma_tag_create( sc->mps_parent_dmat, /* parent */ - 16, 0, /* algnmnt, boundary */ - BUS_SPACE_MAXADDR_32BIT,/* lowaddr */ - BUS_SPACE_MAXADDR, /* highaddr */ - NULL, NULL, /* filter, filterarg */ - rsize, /* maxsize */ - howmany(rsize, PAGE_SIZE), /* nsegments */ - rsize, /* maxsegsize */ - 0, /* flags */ - NULL, NULL, /* lockfunc, lockarg */ - &sc->chain_dmat)) { + bus_dma_template_clone(&t, sc->req_dmat); + t.maxsize = t.maxsegsize = rsize; + t.nsegments = howmany(rsize, PAGE_SIZE); + if (bus_dma_template_tag(&t, &sc->chain_dmat)) { mps_dprint(sc, MPS_ERROR, "Cannot allocate chain DMA tag\n"); return (ENOMEM); } @@ -1472,17 +1453,10 @@ mps_alloc_requests(struct mps_softc *sc) } rsize = MPS_SENSE_LEN * sc->num_reqs; - if (bus_dma_tag_create( sc->mps_parent_dmat, /* parent */ - 1, 0, /* algnmnt, boundary */ - BUS_SPACE_MAXADDR_32BIT,/* lowaddr */ - BUS_SPACE_MAXADDR, /* highaddr */ - NULL, NULL, /* filter, filterarg */ - rsize, /* maxsize */ - 1, /* nsegments */ - rsize, /* maxsegsize */ - 0, /* flags */ - NULL, NULL, /* lockfunc, lockarg */ - &sc->sense_dmat)) { + bus_dma_template_clone(&t, sc->req_dmat); + t.maxsize = t.maxsegsize = rsize; + t.alignment = 1; + if (bus_dma_template_tag(&t, &sc->sense_dmat)) { mps_dprint(sc, MPS_ERROR, "Cannot allocate sense DMA tag\n"); return (ENOMEM); } @@ -1498,18 +1472,14 @@ mps_alloc_requests(struct mps_softc *sc) (uintmax_t)sc->sense_busaddr, rsize); nsegs = (sc->maxio / PAGE_SIZE) + 1; - if (bus_dma_tag_create( sc->mps_parent_dmat, /* parent */ - 1, 0, /* algnmnt, boundary */ - BUS_SPACE_MAXADDR, /* lowaddr */ - BUS_SPACE_MAXADDR, /* highaddr */ - NULL, NULL, /* filter, filterarg */ - BUS_SPACE_MAXSIZE_32BIT,/* maxsize */ - nsegs, /* nsegments */ - BUS_SPACE_MAXSIZE_24BIT,/* maxsegsize */ - BUS_DMA_ALLOCNOW, /* flags */ - busdma_lock_mutex, /* lockfunc */ - &sc->mps_mtx, /* lockarg */ - &sc->buffer_dmat)) { + bus_dma_template_init(&t, sc->mps_parent_dmat); + t.maxsize = BUS_SPACE_MAXSIZE_32BIT; + t.nsegments = nsegs; + t.maxsegsize = BUS_SPACE_MAXSIZE_24BIT; + t.flags = BUS_DMA_ALLOCNOW; + t.lockfunc = busdma_lock_mutex; + t.lockfuncarg = &sc->mps_mtx; + if (bus_dma_template_tag(&t, &sc->buffer_dmat)) { mps_dprint(sc, MPS_ERROR, "Cannot allocate buffer DMA tag\n"); return (ENOMEM); } Modified: head/sys/dev/mps/mps_pci.c ============================================================================== --- head/sys/dev/mps/mps_pci.c Fri Sep 11 20:49:36 2020 (r365643) +++ head/sys/dev/mps/mps_pci.c Fri Sep 11 22:27:35 2020 (r365644) @@ -185,6 +185,7 @@ mps_pci_probe(device_t dev) static int mps_pci_attach(device_t dev) { + bus_dma_tag_template_t t; struct mps_softc *sc; struct mps_ident *m; int error; @@ -211,17 +212,8 @@ mps_pci_attach(device_t dev) sc->mps_bhandle = rman_get_bushandle(sc->mps_regs_resource); /* Allocate the parent DMA tag */ - if (bus_dma_tag_create( bus_get_dma_tag(dev), /* parent */ - 1, 0, /* algnmnt, boundary */ - BUS_SPACE_MAXADDR, /* lowaddr */ - BUS_SPACE_MAXADDR, /* highaddr */ - NULL, NULL, /* filter, filterarg */ - BUS_SPACE_MAXSIZE_32BIT,/* maxsize */ - BUS_SPACE_UNRESTRICTED, /* nsegments */ - BUS_SPACE_MAXSIZE_32BIT,/* maxsegsize */ - 0, /* flags */ - NULL, NULL, /* lockfunc, lockarg */ - &sc->mps_parent_dmat)) { + bus_dma_template_init(&t, bus_get_dma_tag(dev)); + if (bus_dma_template_tag(&t, &sc->mps_parent_dmat)) { mps_printf(sc, "Cannot allocate parent DMA tag\n"); mps_pci_free(sc); return (ENOMEM); Modified: head/sys/dev/mps/mps_user.c ============================================================================== --- head/sys/dev/mps/mps_user.c Fri Sep 11 20:49:36 2020 (r365643) +++ head/sys/dev/mps/mps_user.c Fri Sep 11 22:27:35 2020 (r365644) @@ -1346,6 +1346,7 @@ static int mps_diag_register(struct mps_softc *sc, mps_fw_diag_register_t *diag_register, uint32_t *return_code) { + bus_dma_tag_template_t t; mps_fw_diagnostic_buffer_t *pBuffer; struct mps_busdma_context *ctx; uint8_t extended_type, buffer_type, i; @@ -1408,17 +1409,11 @@ mps_diag_register(struct mps_softc *sc, mps_fw_diag_re *return_code = MPS_FW_DIAG_ERROR_NO_BUFFER; return (MPS_DIAG_FAILURE); } - if (bus_dma_tag_create( sc->mps_parent_dmat, /* parent */ - 1, 0, /* algnmnt, boundary */ - BUS_SPACE_MAXADDR_32BIT,/* lowaddr */ - BUS_SPACE_MAXADDR, /* highaddr */ - NULL, NULL, /* filter, filterarg */ - buffer_size, /* maxsize */ - 1, /* nsegments */ - buffer_size, /* maxsegsize */ - 0, /* flags */ - NULL, NULL, /* lockfunc, lockarg */ - &sc->fw_diag_dmat)) { + bus_dma_template_init(&t, sc->mps_parent_dmat); + t.lowaddr = BUS_SPACE_MAXADDR_32BIT; + t.maxsize = t.maxsegsize = buffer_size; + t.nsegments = 1; + if (bus_dma_template_tag(&t, &sc->fw_diag_dmat)) { mps_dprint(sc, MPS_ERROR, "Cannot allocate FW diag buffer DMA tag\n"); *return_code = MPS_FW_DIAG_ERROR_NO_BUFFER;