Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2439596pxb; Tue, 9 Mar 2021 02:33:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJzdOfJxRYMwKPZ/Yi85VtvH1dYTNT648HlTmfFDssYxahhoHK/aIaPrjhutOaFHw/phb4A+ X-Received: by 2002:a17:907:33c6:: with SMTP id zk6mr16304008ejb.228.1615285991067; Tue, 09 Mar 2021 02:33:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615285991; cv=none; d=google.com; s=arc-20160816; b=n83gnTc31//AlcWQ7b3kYNNcUB8Uo8o7rp05tqoA8wcRs933+FD4MkqOCGf8cSfBeN swnVhCLFMxcR1SRtwvjEVsUXMxNjteASCt+DsAsWn36cA1PNrrH6Bx1e1qRltzAyfTQi XMtFNUQ84+LGkUN6oWUnYerKMfEW6oYhypumIlzz3vcF2HCtISPjeNI8roQvRqT3Itf4 csAuuXNY5nmQfy8SVU94LzvN8GoYn0n3UQ+LJl0dLuIFu1vwXl4Y0m3S9sEw3tgtZG2Z EXYkhuRYUxSjLA29vzC3YPZwFU+wonT9HGUDRNQlVIWs7O2wTYY65dC10b2Hv5cknqwQ ibWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=3R967uwidd/6VhdSIvpZtsspm89w9JUKZtWswzsHzl8=; b=LSHfmdmiOR7XLGkdsXi0AIXPBKl0eYV66T1cHAUitsSJW25803go+hIafCBqQB/YfA ne/tZRQqxruV0TM5WqaM/UBQgVifeZinz4WMngqnM/qpBlLnvOygCnZxH5SRSVRuQkPU mzILHVyROELZlbxA3VftEX8DMM+xHdegDNv8C55JA4dVe4/iLINTZqeiH5DYfb8lfuBj CoS/lBTMYueZ6pB3I9PK087CjNiBbnEkbOcasUKeblIbTnjwik9I+Z3vVj1VwA4KqkZC c1dZiDE2mjQtQHwklMLzl44xP322FOH3NacwJdocenCTrRg18t54i132pZTfzuOfd8rf 7bvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=pKl79QOU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cb23si8595428ejb.496.2021.03.09.02.32.48; Tue, 09 Mar 2021 02:33:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=pKl79QOU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229851AbhCIKbo (ORCPT + 99 others); Tue, 9 Mar 2021 05:31:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35128 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229775AbhCIKbe (ORCPT ); Tue, 9 Mar 2021 05:31:34 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E0D1C06174A; Tue, 9 Mar 2021 02:31:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=3R967uwidd/6VhdSIvpZtsspm89w9JUKZtWswzsHzl8=; b=pKl79QOU1YVyMRaN3H7W3/Yjgj 3I0oTdKN8QiLNm2/EQe6fJHBAMiiY6qHhyPJp+iAcnxINwyG+O6/P7TByCD/Pe9EFDzYj5FE+cZ+Z socLpMnMLE6iXrWxd0h0WRBb5N6aMn936hmLhZOXlMGyjTrJWPqJQzsEe6GhgfQXo2nNAzGXWFai0 TwYDErqBrXP25rCf2peUmdYEtAH4EOgmLCgNI9P1jZEbS02w+V6TcI4D3tUge0mUXr1OMqszyZAV/ 7nl18ww36nCxC7y0eF9WVuHm2/jnSitomQpYwgoU+dFceORY6EJ/idV94zVV5Vvw1Q249iu6cJ38p NMpbnfAg==; Received: from hch by casper.infradead.org with local (Exim 4.94 #2 (Red Hat Linux)) id 1lJZe0-000Sip-W4; Tue, 09 Mar 2021 10:31:22 +0000 Date: Tue, 9 Mar 2021 10:31:16 +0000 From: Christoph Hellwig To: Sanket Parmar Cc: Christoph Hellwig , "peter.chen@kernel.org" , Pawel Laszczak , "a-govindraju@ti.com" , "linux-usb@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Rahul Kumar , "gregkh@linuxfoundation.org" , "kishon@ti.com" Subject: Re: [PATCH 2/2] usb: cdns3: Optimize DMA request buffer allocation Message-ID: <20210309103116.GA110148@infradead.org> References: <1615267180-9289-1-git-send-email-sparmar@cadence.com> <1615267180-9289-2-git-send-email-sparmar@cadence.com> <20210309092804.GA76839@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 09, 2021 at 10:18:43AM +0000, Sanket Parmar wrote: > > On Tue, Mar 09, 2021 at 06:19:40AM +0100, Sanket Parmar wrote: > > > dma_alloc_coherent() might fail on the platform with a small DMA region. > > > > > > To avoid such failure in cdns3_prepare_aligned_request_buf(), > > > dma_alloc_coherent() is replaced with kmalloc and dma_map API to > > > allocate aligned request buffer of dynamic length. > > > > dma_alloc_noncoherent is the proper API instead of using kmalloc, which > > can lead to unaddressable memory that might require bounce buffering. > > cdns3 device required DMA coherent buffer to perform operations. So > dma_alloc_noncoherent will not help here. > > Also all gadget classes(except g_ether) use kmalloc to allocated request buffer, > and device driver uses usb_gadget_map_request_by_dev to map the request > buffer. Similar approach is used to allocate aligned buffer. If you can use kmalloc and dma_map_single you can use dma_alloc_noncoherent per definition.