From patchwork Fri Feb 28 06:35:49 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dylan Reid X-Patchwork-Id: 3738921 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 6669D9F2ED for ; Fri, 28 Feb 2014 06:42:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6BF2820148 for ; Fri, 28 Feb 2014 06:42:42 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 18A6C20125 for ; Fri, 28 Feb 2014 06:42:41 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 31348265A65; Fri, 28 Feb 2014 07:42:40 +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, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 5006D26591D; Fri, 28 Feb 2014 07:38:15 +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 27AF5265904; Fri, 28 Feb 2014 07:38:09 +0100 (CET) Received: from mail-ie0-f201.google.com (mail-ie0-f201.google.com [209.85.223.201]) by alsa0.perex.cz (Postfix) with ESMTP id 7C53F26509D for ; Fri, 28 Feb 2014 07:37:13 +0100 (CET) Received: by mail-ie0-f201.google.com with SMTP id at1so711766iec.0 for ; Thu, 27 Feb 2014 22:37:12 -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=eRyK11PoSUOokLzRysR1wIX+Iy4npGviIBCE0uHmj3s=; b=KcVNQZzlC6cWN0urPUXKLPYrLPdXc9CZdf8W/C4aL95kFMwAb69DGQWrYkmEzohZwc RuCTvaMY+S5eP1tF/cC8+s1u6le++BLDY6O5aodBJgfPcWakAMEL5SV0R/CNeGaLEB5N JxqK0qhZYiziHS8b9JjZbp+pfrdRlxYSvltFHOOGvYJXqJHGko3+aRDE8Lh22UfGO3Aq +79Yx59+KVrJZ3KzQtQ8Fu1dfL7lGu+k1tX8mlhcCFxgr91JBgIxLabKQQE9gWNhy4hK cDPA0nIfwOpT8E4Z+2CW9KJWAWXTkF73/k0+6V34IL3NZvu8n/oUKMRMxKpZ/1wAYId0 YVFg== X-Gm-Message-State: ALoCoQkb9LDBVobrYpL0Mpzr8QCGrJyubYNIipYPjSyKe7D9ZQRq3WWfJBUCx1A8JjvloHr+Evyyh92BB5c0YbT5w6PYKmRLvh99JLuGJ09o9AiU4K+vUEM3iYBZUcxusHgjDeyp7nPkpoS8YbJ67zEw7W/4BT3/gfJGljlg6gP0fOWPUf3q+niymAzqp988LL/cr2Hu6cmWuye6JgnCXrXaWb2rtnmk62eRSCWXOIhmN15avvlslT4= X-Received: by 10.183.3.36 with SMTP id bt4mr5878586obd.29.1393569432613; Thu, 27 Feb 2014 22:37:12 -0800 (PST) Received: from corp2gmr1-2.hot.corp.google.com (corp2gmr1-2.hot.corp.google.com [172.24.189.93]) by gmr-mx.google.com with ESMTPS id k45si113837yhn.4.2014.02.27.22.37.12 for (version=TLSv1.1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 27 Feb 2014 22:37:12 -0800 (PST) Received: from hojo20.mtv.corp.google.com (hojo20.mtv.corp.google.com [172.22.72.28]) by corp2gmr1-2.hot.corp.google.com (Postfix) with ESMTP id 56DA15A4306; Thu, 27 Feb 2014 22:37:12 -0800 (PST) Received: by hojo20.mtv.corp.google.com (Postfix, from userid 123195) id CC017181A25; Thu, 27 Feb 2014 22:37:11 -0800 (PST) From: Dylan Reid To: alsa-devel@alsa-project.org Date: Thu, 27 Feb 2014 22:35:49 -0800 Message-Id: <1393569362-27285-7-git-send-email-dgreid@chromium.org> X-Mailer: git-send-email 1.8.1.3.605.g02339dd In-Reply-To: <1393569362-27285-1-git-send-email-dgreid@chromium.org> References: <1393569362-27285-1-git-send-email-dgreid@chromium.org> Cc: tiwai@suse.de, Dylan Reid , swarren@wwwdotorg.org Subject: [alsa-devel] [RFC 06/19] ALSA: hda - Pull pages allocation to shared file 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 the shared file. Short term this will allow the dsp loader to be moved to the shared file, because it takes the dsp lock. In later commits it will allow the same allocation to be used by the platform hda driver. Moving the freeing into hda shared will remove references to mark_pages_wc, and allow it to become static in hda_shared later on. Signed-off-by: Dylan Reid --- sound/pci/hda/hda_intel.c | 42 +++++-------------------------------- sound/pci/hda/hda_shared.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++ sound/pci/hda/hda_shared.h | 4 ++++ 3 files changed, 61 insertions(+), 37 deletions(-) diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c index 838d64e..c9c541b 100644 --- a/sound/pci/hda/hda_intel.c +++ b/sound/pci/hda/hda_intel.c @@ -1806,21 +1806,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) { - mark_pages_wc(chip, &chip->azx_dev[i].bdl, false); - snd_dma_free_pages(&chip->azx_dev[i].bdl); - } - } - if (chip->rb.area) { - mark_pages_wc(chip, &chip->rb, false); - snd_dma_free_pages(&chip->rb); - } - if (chip->posbuf.area) { - mark_pages_wc(chip, &chip->posbuf, false); - snd_dma_free_pages(&chip->posbuf); - } + azx_free_stream_pages(chip); if (chip->region_requested) pci_release_regions(chip->pci); pci_disable_device(chip->pci); @@ -2156,7 +2142,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 @@ -2268,27 +2254,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 = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, - chip->card->dev, - BDL_SIZE, &chip->azx_dev[i].bdl); - if (err < 0) { - dev_err(card->dev, "cannot allocate BDL\n"); - return -ENOMEM; - } - mark_pages_wc(chip, &chip->azx_dev[i].bdl, true); - } - /* allocate memory for the position buffer */ - err = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, - chip->card->dev, - chip->num_streams * 8, &chip->posbuf); - if (err < 0) { - dev_err(card->dev, "cannot allocate posbuf\n"); - return -ENOMEM; - } - mark_pages_wc(chip, &chip->posbuf, true); + err = azx_alloc_stream_pages(chip); + if (err < 0) + return err; /* allocate CORB/RIRB */ err = azx_alloc_cmd_io(chip); if (err < 0) diff --git a/sound/pci/hda/hda_shared.c b/sound/pci/hda/hda_shared.c index 55b0538..e921154 100644 --- a/sound/pci/hda/hda_shared.c +++ b/sound/pci/hda/hda_shared.c @@ -1101,5 +1101,57 @@ int azx_position_ok(struct azx *chip, struct azx_dev *azx_dev) return 1; /* OK, it's fine */ } +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 = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, + chip->card->dev, + BDL_SIZE, &chip->azx_dev[i].bdl); + if (err < 0) { + dev_err(card->dev, "cannot allocate BDL\n"); + return -ENOMEM; + } + mark_pages_wc(chip, &chip->azx_dev[i].bdl, true); + } + /* allocate memory for the position buffer */ + err = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, + chip->card->dev, + chip->num_streams * 8, &chip->posbuf); + if (err < 0) { + dev_err(card->dev, "cannot allocate posbuf\n"); + return -ENOMEM; + } + mark_pages_wc(chip, &chip->posbuf, true); + 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) { + mark_pages_wc(chip, &chip->azx_dev[i].bdl, + false); + snd_dma_free_pages(&chip->azx_dev[i].bdl); + } + } + if (chip->rb.area) { + mark_pages_wc(chip, &chip->rb, false); + snd_dma_free_pages(&chip->rb); + } + if (chip->posbuf.area) { + mark_pages_wc(chip, &chip->posbuf, false); + snd_dma_free_pages(&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_shared.h b/sound/pci/hda/hda_shared.h index bc06d34..ff1eeae 100644 --- a/sound/pci/hda/hda_shared.h +++ b/sound/pci/hda/hda_shared.h @@ -55,4 +55,8 @@ void azx_stream_stop(struct azx *chip, struct azx_dev *azx_dev); #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_SHARED_H */