From patchwork Wed Mar 27 09:29:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 10873079 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E6F4217E0 for ; Wed, 27 Mar 2019 09:41:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CF28028BB3 for ; Wed, 27 Mar 2019 09:41:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C38B228CF0; Wed, 27 Mar 2019 09:41:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1BE8128BB3 for ; Wed, 27 Mar 2019 09:41:28 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 464A89F4; Wed, 27 Mar 2019 10:32:25 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 464A89F4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1553679195; bh=rYWzCbG36WNlRk9wVpFiWiaTKBLVXla9t2p0YtKEpuY=; h=From:To:Date:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=WjFw/u0ejiXCLyy0yBfaIK2pPeY3q44RvK09UJoSFkIjtVFqVbUoqsF3irsPAP3FH OEdX28o4+kUWL6td/jKH34Zq+UpcgLrF6W7Mj1cQIFS3c4iguMSe+PZtieoKVIXaq4 5GNpbz1PVdsQL2JhgnK8oRvdC55O8b9GMkW5K1lI= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id DD6D5F89720; Wed, 27 Mar 2019 10:30:13 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id 1EBBCF801D9; Wed, 27 Mar 2019 10:30:08 +0100 (CET) Received: from mx1.suse.de (mx2.suse.de [195.135.220.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id C7F0CF801D9 for ; Wed, 27 Mar 2019 10:30:01 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz C7F0CF801D9 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id EDE94ADAF; Wed, 27 Mar 2019 09:30:00 +0000 (UTC) From: Takashi Iwai To: alsa-devel@alsa-project.org Date: Wed, 27 Mar 2019 10:29:59 +0100 Message-Id: <20190327092959.30382-3-tiwai@suse.de> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190327092959.30382-1-tiwai@suse.de> References: <20190327092959.30382-1-tiwai@suse.de> Cc: Michal Hocko , Hugh Dickins , Vlastimil Babka Subject: [alsa-devel] [PATCH 2/2] ALSA: us122l: Use alloc_pages_exact() X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" X-Virus-Scanned: ClamAV using ClamSMTP alloc_pages_exact() is more suitable choice for allocating the sound buffers, as it doesn't need to align with power-of-two. Along with the conversion, we can drop __GFP_COMP as well. The patch also replace the error messages to be more explicit. Signed-off-by: Takashi Iwai --- sound/usb/usx2y/usb_stream.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/sound/usb/usx2y/usb_stream.c b/sound/usb/usx2y/usb_stream.c index 221adf68bd0c..51d73111263a 100644 --- a/sound/usb/usx2y/usb_stream.c +++ b/sound/usb/usx2y/usb_stream.c @@ -155,9 +155,9 @@ void usb_stream_free(struct usb_stream_kernel *sk) if (!s) return; - free_pages((unsigned long)sk->write_page, get_order(s->write_size)); + free_pages_exact(sk->write_page, s->write_size); sk->write_page = NULL; - free_pages((unsigned long)s, get_order(s->read_size)); + free_pages_exact(s, s->read_size); sk->s = NULL; } @@ -172,7 +172,6 @@ struct usb_stream *usb_stream_new(struct usb_stream_kernel *sk, int read_size = sizeof(struct usb_stream); int write_size; int usb_frames = dev->speed == USB_SPEED_HIGH ? 8000 : 1000; - int pg; in_pipe = usb_rcvisocpipe(dev, in_endpoint); out_pipe = usb_sndisocpipe(dev, out_endpoint); @@ -202,11 +201,10 @@ struct usb_stream *usb_stream_new(struct usb_stream_kernel *sk, goto out; } - pg = get_order(read_size); - sk->s = (void *) __get_free_pages(GFP_KERNEL|__GFP_COMP|__GFP_ZERO| - __GFP_NOWARN, pg); + sk->s = alloc_pages_exact(read_size, + GFP_KERNEL | __GFP_ZERO | __GFP_NOWARN); if (!sk->s) { - snd_printk(KERN_WARNING "couldn't __get_free_pages()\n"); + pr_warn("us122l: couldn't allocate read buffer\n"); goto out; } sk->s->cfg.version = USB_STREAM_INTERFACE_VERSION; @@ -221,13 +219,11 @@ struct usb_stream *usb_stream_new(struct usb_stream_kernel *sk, sk->s->period_size = frame_size * period_frames; sk->s->write_size = write_size; - pg = get_order(write_size); - sk->write_page = - (void *)__get_free_pages(GFP_KERNEL|__GFP_COMP|__GFP_ZERO| - __GFP_NOWARN, pg); + sk->write_page = alloc_pages_exact(write_size, + GFP_KERNEL | __GFP_ZERO | __GFP_NOWARN); if (!sk->write_page) { - snd_printk(KERN_WARNING "couldn't __get_free_pages()\n"); + pr_warn("us122l: couldn't allocate write buffer\n"); usb_stream_free(sk); return NULL; }