From owner-svn-src-all@freebsd.org Sat Oct 24 23:45:11 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 840D7A1EC06; Sat, 24 Oct 2015 23:45:11 +0000 (UTC) (envelope-from cem@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 mx1.freebsd.org (Postfix) with ESMTPS id 4DE44D83; Sat, 24 Oct 2015 23:45:11 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t9ONjAGE011812; Sat, 24 Oct 2015 23:45:10 GMT (envelope-from cem@FreeBSD.org) Received: (from cem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t9ONjAt7011811; Sat, 24 Oct 2015 23:45:10 GMT (envelope-from cem@FreeBSD.org) Message-Id: <201510242345.t9ONjAt7011811@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cem set sender to cem@FreeBSD.org using -f From: "Conrad E. Meyer" Date: Sat, 24 Oct 2015 23:45:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r289905 - head/sys/dev/ioat 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: Sat, 24 Oct 2015 23:45:11 -0000 Author: cem Date: Sat Oct 24 23:45:10 2015 New Revision: 289905 URL: https://svnweb.freebsd.org/changeset/base/289905 Log: ioat: Don't use sleeping allocation in lock path This is still the worst possible way to allocate memory if it will ever be under pressure, but at least it won't deadlock. Suggested by: WITNESS Sponsored by: EMC / Isilon Storage Division Modified: head/sys/dev/ioat/ioat.c Modified: head/sys/dev/ioat/ioat.c ============================================================================== --- head/sys/dev/ioat/ioat.c Sat Oct 24 23:44:58 2015 (r289904) +++ head/sys/dev/ioat/ioat.c Sat Oct 24 23:45:10 2015 (r289905) @@ -738,22 +738,33 @@ ioat_alloc_ring_entry(struct ioat_softc { struct ioat_dma_hw_descriptor *hw_desc; struct ioat_descriptor *desc; + int error; - desc = malloc(sizeof(struct ioat_descriptor), M_IOAT, M_NOWAIT); - if (desc == NULL) - return (NULL); + error = ENOMEM; + hw_desc = NULL; - bus_dmamem_alloc(ioat->hw_desc_tag, (void **)&hw_desc, BUS_DMA_ZERO, - &ioat->hw_desc_map); - if (hw_desc == NULL) { - free(desc, M_IOAT); - return (NULL); - } + desc = malloc(sizeof(*desc), M_IOAT, M_NOWAIT); + if (desc == NULL) + goto out; - bus_dmamap_load(ioat->hw_desc_tag, ioat->hw_desc_map, hw_desc, - sizeof(*hw_desc), ioat_dmamap_cb, &desc->hw_desc_bus_addr, 0); + bus_dmamem_alloc(ioat->hw_desc_tag, (void **)&hw_desc, + BUS_DMA_ZERO | BUS_DMA_NOWAIT, &ioat->hw_desc_map); + if (hw_desc == NULL) + goto out; desc->u.dma = hw_desc; + + error = bus_dmamap_load(ioat->hw_desc_tag, ioat->hw_desc_map, hw_desc, + sizeof(*hw_desc), ioat_dmamap_cb, &desc->hw_desc_bus_addr, + BUS_DMA_NOWAIT); + if (error) + goto out; + +out: + if (error) { + ioat_free_ring_entry(ioat, desc); + return (NULL); + } return (desc); }