From patchwork Fri Feb 28 23:41:23 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dylan Reid X-Patchwork-Id: 3745241 X-Patchwork-Delegate: tiwai@suse.de Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id CBE399F35F for ; Fri, 28 Feb 2014 23:43:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E0B5520265 for ; Fri, 28 Feb 2014 23:43:58 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 4CADC2024D for ; Fri, 28 Feb 2014 23:43:56 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id D7323265CBE; Sat, 1 Mar 2014 00:43:54 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,NO_DNS_FOR_FROM, UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 744282659EA; Sat, 1 Mar 2014 00:43:01 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 41B2F2659E2; Sat, 1 Mar 2014 00:42:59 +0100 (CET) Received: from mail-oa0-f73.google.com (mail-oa0-f73.google.com [209.85.219.73]) by alsa0.perex.cz (Postfix) with ESMTP id 3CD9326598D for ; Sat, 1 Mar 2014 00:42:52 +0100 (CET) Received: by mail-oa0-f73.google.com with SMTP id n16so60863oag.0 for ; Fri, 28 Feb 2014 15:42:51 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=kz4ACMI9uc0WBugxlOKPk+izO6vkapsDR4pl47/4WDs=; b=JL2lkorcGxUdDY02i4QBvdthuEjkZxVcoQLOrMYz0DgEA7xLKZllzYobPAhLB2kwFU pjC1bXugYtech3um9RfQsPLGmVnT0EKt1PCeR3ffPC7NXTLlJaT4gdBfIBNrGZwr9bXt t8eOFJhKI9HRNk5S6BVFTtJ3gCWxwUoFS93zishdhFLu59IL4RUrnY06BHheyoA3VhzQ aaDj40uYXPGcderQ5X56+8kl3pyhsyBjVJ+NL8NzO1Zz7TM03CYHL+tMcrCpbxSPJTgH CgVgYxAy/DS9IRolJr45nMn83xE875+UbvFJ87P5BoixPHBY4SR7u9V/PXxlWe2+NMzI Ew1Q== X-Gm-Message-State: ALoCoQkDUrWD7m44eyr6w1pv10LVgBFhIcd7ph8jN483HCjPXM+5ql0fcGkzJaewcw4cafks+VzgJMp0mDhRD1+/WLwRs6+jrixzsj6juFKJyDAgtmqxKY8gdg0/lUHZWA8XkM3dhazs68t6BIWusiczmlt3Jm3mhjWN3/Y58S4AANjALsVJ8YoA+wtwu7s46zdkzxIDQmKf/cpq3NbQPZhQ63doonK1Vy/Vy8fUeuKmsZd8OIFKtNw= X-Received: by 10.50.20.71 with SMTP id l7mr2997971ige.5.1393630971504; Fri, 28 Feb 2014 15:42:51 -0800 (PST) Received: from corp2gmr1-1.hot.corp.google.com (corp2gmr1-1.hot.corp.google.com [172.24.189.92]) by gmr-mx.google.com with ESMTPS id o7si544243yhj.3.2014.02.28.15.42.51 for (version=TLSv1.1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 28 Feb 2014 15:42:51 -0800 (PST) Received: from hojo20.mtv.corp.google.com (hojo20.mtv.corp.google.com [172.22.72.28]) by corp2gmr1-1.hot.corp.google.com (Postfix) with ESMTP id 395B031C268; Fri, 28 Feb 2014 15:42:51 -0800 (PST) Received: by hojo20.mtv.corp.google.com (Postfix, from userid 123195) id 12E61180D8D; Fri, 28 Feb 2014 15:42:50 -0800 (PST) From: Dylan Reid To: alsa-devel@alsa-project.org Date: Fri, 28 Feb 2014 15:41:23 -0800 Message-Id: <1393630893-29010-13-git-send-email-dgreid@chromium.org> X-Mailer: git-send-email 1.8.1.3.605.g02339dd In-Reply-To: <1393630893-29010-1-git-send-email-dgreid@chromium.org> References: <1393630893-29010-1-git-send-email-dgreid@chromium.org> Cc: tiwai@suse.de, Dylan Reid , swarren@wwwdotorg.org Subject: [alsa-devel] [RFCv2 12/22] ALSA: hda - Pull pages allocation to hda_controller X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 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-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP Pull allocation from first_init to a new function in hda_controller.c. Short term this will allow the dsp loader to be moved as well. In later commits it will allow the same allocation to be used by the platform hda driver. Signed-off-by: Dylan Reid --- sound/pci/hda/hda_controller.c | 43 ++++++++++++++++++++++++++++++++++++++++++ sound/pci/hda/hda_controller.h | 4 ++++ sound/pci/hda/hda_intel.c | 34 +++++---------------------------- 3 files changed, 52 insertions(+), 29 deletions(-) diff --git a/sound/pci/hda/hda_controller.c b/sound/pci/hda/hda_controller.c index fcc5c30..bf5e890 100644 --- a/sound/pci/hda/hda_controller.c +++ b/sound/pci/hda/hda_controller.c @@ -1014,5 +1014,48 @@ int azx_attach_pcm_stream(struct hda_bus *bus, struct hda_codec *codec, } EXPORT_SYMBOL_GPL(azx_attach_pcm_stream); +int azx_alloc_stream_pages(struct azx *chip) +{ + int i, err; + struct snd_card *card = chip->card; + + for (i = 0; i < chip->num_streams; i++) { + dsp_lock_init(&chip->azx_dev[i]); + /* allocate memory for the BDL for each stream */ + err = chip->ops->dma_alloc_pages(chip, SNDRV_DMA_TYPE_DEV, + BDL_SIZE, + &chip->azx_dev[i].bdl); + if (err < 0) { + dev_err(card->dev, "cannot allocate BDL\n"); + return -ENOMEM; + } + } + /* allocate memory for the position buffer */ + err = chip->ops->dma_alloc_pages(chip, SNDRV_DMA_TYPE_DEV, + chip->num_streams * 8, &chip->posbuf); + if (err < 0) { + dev_err(card->dev, "cannot allocate posbuf\n"); + return -ENOMEM; + } + return 0; +} +EXPORT_SYMBOL_GPL(azx_alloc_stream_pages); + +void azx_free_stream_pages(struct azx *chip) +{ + int i; + if (chip->azx_dev) { + for (i = 0; i < chip->num_streams; i++) + if (chip->azx_dev[i].bdl.area) + chip->ops->dma_free_pages( + chip, &chip->azx_dev[i].bdl); + } + if (chip->rb.area) + chip->ops->dma_free_pages(chip, &chip->rb); + if (chip->posbuf.area) + chip->ops->dma_free_pages(chip, &chip->posbuf); +} +EXPORT_SYMBOL_GPL(azx_free_stream_pages); + MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("Common HDA driver funcitons"); diff --git a/sound/pci/hda/hda_controller.h b/sound/pci/hda/hda_controller.h index a62cdde..9ea6b44 100644 --- a/sound/pci/hda/hda_controller.h +++ b/sound/pci/hda/hda_controller.h @@ -54,4 +54,8 @@ int setup_bdle(struct azx *chip, #define dsp_is_locked(dev) 0 #endif +/* Allocation functions. */ +int azx_alloc_stream_pages(struct azx *chip); +void azx_free_stream_pages(struct azx *chip); + #endif /* __SOUND_HDA_CONTROLLER_H */ diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c index f86ee2b..4a0b228 100644 --- a/sound/pci/hda/hda_intel.c +++ b/sound/pci/hda/hda_intel.c @@ -1864,16 +1864,7 @@ static int azx_free(struct azx *chip) if (chip->remap_addr) iounmap(chip->remap_addr); - if (chip->azx_dev) { - for (i = 0; i < chip->num_streams; i++) - if (chip->azx_dev[i].bdl.area) - chip->ops->dma_free_pages( - chip, &chip->azx_dev[i].bdl); - } - if (chip->rb.area) - chip->ops->dma_free_pages(chip, &chip->rb); - if (chip->posbuf.area) - chip->ops->dma_free_pages(chip, &chip->posbuf); + azx_free_stream_pages(chip); if (chip->region_requested) pci_release_regions(chip->pci); pci_disable_device(chip->pci); @@ -2210,7 +2201,7 @@ static int azx_first_init(struct azx *chip) int dev = chip->dev_index; struct pci_dev *pci = chip->pci; struct snd_card *card = chip->card; - int i, err; + int err; unsigned short gcap; #if BITS_PER_LONG != 64 @@ -2322,24 +2313,9 @@ static int azx_first_init(struct azx *chip) return -ENOMEM; } - for (i = 0; i < chip->num_streams; i++) { - dsp_lock_init(&chip->azx_dev[i]); - /* allocate memory for the BDL for each stream */ - err = chip->ops->dma_alloc_pages(chip, SNDRV_DMA_TYPE_DEV, - BDL_SIZE, - &chip->azx_dev[i].bdl); - if (err < 0) { - dev_err(card->dev, "cannot allocate BDL\n"); - return -ENOMEM; - } - } - /* allocate memory for the position buffer */ - err = chip->ops->dma_alloc_pages(chip, SNDRV_DMA_TYPE_DEV, - chip->num_streams * 8, &chip->posbuf); - if (err < 0) { - dev_err(card->dev, "cannot allocate posbuf\n"); - return -ENOMEM; - } + err = azx_alloc_stream_pages(chip); + if (err < 0) + return err; /* allocate CORB/RIRB */ err = azx_alloc_cmd_io(chip); if (err < 0)