From owner-svn-src-all@freebsd.org Tue Jul 21 15:28:09 2015 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0BE849A7E24; Tue, 21 Jul 2015 15:28:09 +0000 (UTC) (envelope-from zbb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D80761D6C; Tue, 21 Jul 2015 15:28:08 +0000 (UTC) (envelope-from zbb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.14.9/8.14.9) with ESMTP id t6LFS8fS014885; Tue, 21 Jul 2015 15:28:08 GMT (envelope-from zbb@FreeBSD.org) Received: (from zbb@localhost) by repo.freebsd.org (8.14.9/8.14.9/Submit) id t6LFS8Vq014884; Tue, 21 Jul 2015 15:28:08 GMT (envelope-from zbb@FreeBSD.org) Message-Id: <201507211528.t6LFS8Vq014884@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: zbb set sender to zbb@FreeBSD.org using -f From: Zbigniew Bodek Date: Tue, 21 Jul 2015 15:28:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r285755 - head/sys/arm64/arm64 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 Jul 2015 15:28:09 -0000 Author: zbb Date: Tue Jul 21 15:28:07 2015 New Revision: 285755 URL: https://svnweb.freebsd.org/changeset/base/285755 Log: Don't allow malloc() to wait for resource while holding a lock in ITS malloc() should not go to sleep in case of lack of resource while the kernel thread is holding a non-sleepable lock. - change malloc() flags to M_NOWAIT in such cases implement lpi_free_chunk() routine as it will be needed when ITT allocation fails in its_device_alloc_locked() - do not increase verbosity of this code since upper layers will communicate an error if the interrupt setup fails Obtained from: Semihalf Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D3121 Modified: head/sys/arm64/arm64/gic_v3_its.c Modified: head/sys/arm64/arm64/gic_v3_its.c ============================================================================== --- head/sys/arm64/arm64/gic_v3_its.c Tue Jul 21 15:08:13 2015 (r285754) +++ head/sys/arm64/arm64/gic_v3_its.c Tue Jul 21 15:28:07 2015 (r285755) @@ -814,6 +814,26 @@ retry: } static void +lpi_free_chunk(struct gic_v3_its_softc *sc, struct lpi_chunk *lpic) +{ + int start, end; + uint8_t *bitmap; + + bitmap = (uint8_t *)sc->its_lpi_bitmap; + + KASSERT((lpic->lpi_free == lpic->lpi_num), + ("Trying to free LPI chunk that is still in use.\n")); + + /* First bit of this chunk in a global bitmap */ + start = lpic->lpi_base - GIC_FIRST_LPI; + /* and last bit of this chunk... */ + end = start + lpic->lpi_num - 1; + + /* Finally free this chunk */ + bit_nclear(bitmap, start, end); +} + +static void lpi_configure(struct gic_v3_its_softc *sc, struct its_dev *its_dev, uint32_t lpinum, boolean_t unmask) { @@ -1322,7 +1342,10 @@ its_device_alloc_locked(struct gic_v3_it devid = its_get_devid(pci_dev); /* There was no previously created device. Create one now */ - newdev = malloc(sizeof(*newdev), M_GIC_V3_ITS, (M_WAITOK | M_ZERO)); + newdev = malloc(sizeof(*newdev), M_GIC_V3_ITS, (M_NOWAIT | M_ZERO)); + if (newdev == NULL) + return (NULL); + newdev->pci_dev = pci_dev; newdev->devid = devid; @@ -1340,7 +1363,12 @@ its_device_alloc_locked(struct gic_v3_it */ newdev->itt = (vm_offset_t)contigmalloc( roundup2(roundup2(nvecs, 2) * esize, 0x100), M_GIC_V3_ITS, - (M_WAITOK | M_ZERO), 0, ~0UL, 0x100, 0); + (M_NOWAIT | M_ZERO), 0, ~0UL, 0x100, 0); + if (newdev->itt == 0) { + lpi_free_chunk(sc, &newdev->lpis); + free(newdev, M_GIC_V3_ITS); + return (NULL); + } /* * XXX ARM64TODO: Currently all interrupts are going