From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759036AbbJ3ID2 (ORCPT ); Fri, 30 Oct 2015 04:03:28 -0400 Received: from bear.ext.ti.com ([192.94.94.41]:54212 "EHLO bear.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758633AbbJ3IDY (ORCPT ); Fri, 30 Oct 2015 04:03:24 -0400 Subject: Re: [PATCH 1/3] dmaengine: ti-dma-crossbar: dra7: Use bitops instead of idr To: , References: <1446107331-30041-1-git-send-email-peter.ujfalusi@ti.com> <1446107331-30041-2-git-send-email-peter.ujfalusi@ti.com> CC: , , , , , , From: Peter Ujfalusi Message-ID: <56332427.6000805@ti.com> Date: Fri, 30 Oct 2015 10:02:47 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: <1446107331-30041-2-git-send-email-peter.ujfalusi@ti.com> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org For the record... On 10/29/2015 10:28 AM, Peter Ujfalusi wrote: > The use of idr was nice, but it was a bit heavy and we did not need the > features it provides. Using simple bitmap to track allocated DMA channels > is adequate here and it will be easier to add support for reserving > channels later on. > > Signed-off-by: Peter Ujfalusi > - map->xbar_out = idr_alloc(&xbar->map_idr, NULL, 0, xbar->dma_requests, > - GFP_KERNEL); > + mutex_lock(&xbar->mutex); > + map->xbar_out = find_next_zero_bit(xbar->dma_inuse, xbar->dma_requests, > + 0); find_first_zero_bit() ;) > + mutex_unlock(&xbar->mutex); > + if (map->xbar_out) { Well, this is obviously wrong... Should have been: if (map->xbar_out == xbar->dma_requests) { > + dev_err(&pdev->dev, "Run out of free DMA requests\n"); > + kfree(map); > + return ERR_PTR(-ENOMEM); > + } > + set_bit(map->xbar_out, xbar->dma_inuse); > + -- Péter