From owner-svn-src-head@freebsd.org Mon Nov 18 19:28:10 2019 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 CA5BD1C746B; Mon, 18 Nov 2019 19:28:10 +0000 (UTC) (envelope-from kevans@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) server-signature RSA-PSS (4096 bits) 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 47GzWZ24gBz4QYc; Mon, 18 Nov 2019 19:28:10 +0000 (UTC) (envelope-from kevans@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 2ABAC2E9BE; Mon, 18 Nov 2019 19:28:10 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xAIJSARA080100; Mon, 18 Nov 2019 19:28:10 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xAIJSAiD080099; Mon, 18 Nov 2019 19:28:10 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201911181928.xAIJSAiD080099@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Mon, 18 Nov 2019 19:28:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r354825 - head/sys/arm/broadcom/bcm2835 X-SVN-Group: head X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: head/sys/arm/broadcom/bcm2835 X-SVN-Commit-Revision: 354825 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.29 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: Mon, 18 Nov 2019 19:28:10 -0000 Author: kevans Date: Mon Nov 18 19:28:09 2019 New Revision: 354825 URL: https://svnweb.freebsd.org/changeset/base/354825 Log: bcm2835_sdhci: use a macro for interrupts we handle This is just further simplification, very little functional change. In the DMA interrupt handler, we *do* now acknowledge both DATA_AVAIL | SPACE_AVAIL every time -- these operations are mutually exclusive, so while this is a functional change, it's effectively a nop. Removing the 'mask' local allows us to further simplify in a future change. Modified: head/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c Modified: head/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c ============================================================================== --- head/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c Mon Nov 18 19:05:52 2019 (r354824) +++ head/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c Mon Nov 18 19:28:09 2019 (r354825) @@ -68,6 +68,8 @@ __FBSDID("$FreeBSD$"); #define BCM_SDHCI_BUFFER_SIZE 512 #define NUM_DMA_SEGS 2 +#define DATA_PENDING_MASK (SDHCI_INT_DATA_AVAIL | SDHCI_INT_SPACE_AVAIL) + #ifdef DEBUG static int bcm2835_sdhci_debug = 0; @@ -548,8 +550,7 @@ bcm_sdhci_start_dma_seg(struct bcm_sdhci_softc *sc) */ if (idx == 0) { bus_dmamap_sync(sc->sc_dma_tag, sc->sc_dma_map, sync_op); - slot->intmask &= ~(SDHCI_INT_DATA_AVAIL | - SDHCI_INT_SPACE_AVAIL); + slot->intmask &= ~DATA_PENDING_MASK; bcm_sdhci_write_4(sc->sc_dev, &sc->sc_slot, SDHCI_SIGNAL_ENABLE, slot->intmask); } @@ -567,7 +568,7 @@ bcm_sdhci_dma_intr(int ch, void *arg) { struct bcm_sdhci_softc *sc = (struct bcm_sdhci_softc *)arg; struct sdhci_slot *slot = &sc->sc_slot; - uint32_t reg, mask; + uint32_t reg; int left, sync_op; mtx_lock(&slot->mtx); @@ -588,13 +589,10 @@ bcm_sdhci_dma_intr(int ch, void *arg) return; } - if (slot->curcmd->data->flags & MMC_DATA_READ) { + if (slot->curcmd->data->flags & MMC_DATA_READ) sync_op = BUS_DMASYNC_POSTREAD; - mask = SDHCI_INT_DATA_AVAIL; - } else { + else sync_op = BUS_DMASYNC_POSTWRITE; - mask = SDHCI_INT_SPACE_AVAIL; - } if (sc->dmamap_seg_count != 0) { bus_dmamap_sync(sc->sc_dma_tag, sc->sc_dma_map, sync_op); @@ -615,7 +613,7 @@ bcm_sdhci_dma_intr(int ch, void *arg) */ if (left < BCM_SDHCI_BUFFER_SIZE) { /* Re-enable data interrupts. */ - slot->intmask |= SDHCI_INT_DATA_AVAIL | SDHCI_INT_SPACE_AVAIL; + slot->intmask |= DATA_PENDING_MASK; bcm_sdhci_write_4(slot->bus, slot, SDHCI_SIGNAL_ENABLE, slot->intmask); mtx_unlock(&slot->mtx); @@ -625,11 +623,11 @@ bcm_sdhci_dma_intr(int ch, void *arg) reg = bcm_sdhci_read_4(slot->bus, slot, SDHCI_INT_STATUS); /* already available? */ - if (reg & mask) { + if ((reg & DATA_PENDING_MASK) != 0) { /* ACK for DATA_AVAIL or SPACE_AVAIL */ bcm_sdhci_write_4(slot->bus, slot, - SDHCI_INT_STATUS, mask); + SDHCI_INT_STATUS, DATA_PENDING_MASK); /* continue next DMA transfer */ if (bus_dmamap_load(sc->sc_dma_tag, sc->sc_dma_map, @@ -645,8 +643,7 @@ bcm_sdhci_dma_intr(int ch, void *arg) /* wait for next data by INT */ /* enable INT */ - slot->intmask |= SDHCI_INT_DATA_AVAIL | - SDHCI_INT_SPACE_AVAIL; + slot->intmask |= DATA_PENDING_MASK; bcm_sdhci_write_4(slot->bus, slot, SDHCI_SIGNAL_ENABLE, slot->intmask); } @@ -767,13 +764,12 @@ bcm_sdhci_finish_transfer(device_t dev, struct sdhci_s sc->dmamap_seg_count = 0; sc->dmamap_seg_index = 0; - slot->intmask |= SDHCI_INT_DATA_AVAIL | - SDHCI_INT_SPACE_AVAIL; + slot->intmask |= DATA_PENDING_MASK; bcm_sdhci_write_4(slot->bus, slot, SDHCI_SIGNAL_ENABLE, slot->intmask); } else { - KASSERT((slot->intmask & SDHCI_INT_DATA_AVAIL) != 0 && - (slot->intmask & SDHCI_INT_SPACE_AVAIL) != 0, + KASSERT((slot->intmask & DATA_PENDING_MASK) == + DATA_PENDING_MASK, ("%s: interrupt mask not restored", __func__)); } sdhci_finish_data(slot);