Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2725390imm; Tue, 4 Sep 2018 09:02:32 -0700 (PDT) X-Google-Smtp-Source: ANB0VdY30tuG1vO/aHmhiheC7ziJzbOnOKfBZpp/A2aX3oL2aXgTkQ0hjtS9R5giwlwOwkN9IGpa X-Received: by 2002:a17:902:3081:: with SMTP id v1-v6mr34811856plb.58.1536076952554; Tue, 04 Sep 2018 09:02:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536076952; cv=none; d=google.com; s=arc-20160816; b=eZIbeLO4Gb0HeYw5gQRXzh3GJYNLeb+3NQvceTkH2wsM6gYAF2+xQeI3reE2+ws05N 2iMWDQhNDlgY8fgXiNYGWrtI3gTFYI2XvFl+1VyusW2RhYBq2Voxq5kmnR7MXrhCQF4B y7iEB75o/E9bMa4CHwUkgQxSX+aPSuiu8c1eGsqs6oNVMNtGE1Bcoqv47aLvOlXe76lL y+aTuB4xzygSu5AcPj/cZdcB+b1/ZzjWv3ZY2uGuXH/HsWAqrsP8NDGhYI/bScCs1UXa Xh7QD2UazjHBCjm9qjmr0hE54pDUGHSHuyuxR/x7wmR4B8Um/FRkEdlqELo8jdKXrQ9r gg5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=961rEZmLcSikY/dhMS6Xh5FtaqYPTQuoowz/58U7cQU=; b=X/EoxNG7zoMJn2BLhDByUDSQStf0zZYge5hiPQ5hnU0vm7+lO1hhIHNa8UBBUT6B+1 dEgYRv+49k0UIoVgYi6w8bHsoKQmvqmGBmZcnO27yx3Af1hjAlnQM259+kPvVvfAhPY5 xMxqAzALP4o0d9/sgbef4bDVBVJ81h3qB7FkYPJIr6rhWHVkT/0QUikwONDw3njVYlRa dOsjWRE1MQd40zh7yPGl/U2fgYmnKpIN8gtPIwm1AtsJJywZVkA2LIKBM2B3eKqFXRRb KfrurBTsbqOFYrzPkUKV1lUqAp6MldaP01Zjjx4rPhmeIL7s21fwjlezpcqeA0B0754C Kxfg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t24-v6si18211001plr.22.2018.09.04.09.02.10; Tue, 04 Sep 2018 09:02:32 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728040AbeIDUZe (ORCPT + 99 others); Tue, 4 Sep 2018 16:25:34 -0400 Received: from mx2.suse.de ([195.135.220.15]:51058 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727791AbeIDUYv (ORCPT ); Tue, 4 Sep 2018 16:24:51 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id D8DE4B0B4; Tue, 4 Sep 2018 15:59:02 +0000 (UTC) From: Takashi Iwai To: Greg Kroah-Hartman Cc: Eric Anholt , Stefan Wahren , linux-rpi-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 25/29] staging: bcm2835-audio: Use coherent device buffers Date: Tue, 4 Sep 2018 17:58:54 +0200 Message-Id: <20180904155858.8001-26-tiwai@suse.de> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180904155858.8001-1-tiwai@suse.de> References: <20180904155858.8001-1-tiwai@suse.de> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The memory access to the pages allocated with SNDRV_DMA_TYPE_CONTINUOUS are basically non-coherent, and it becomes a problem when a process accesses via mmap. For the more consistent access, use the device coherent memory, just by replacing the call pattern in the allocator helpers. The only point we need to be careful for is the device object passed there; since bcm2835-audio driver creates fake devices and each card is created on top of that, we need to pass its parent device as the real device object. Signed-off-by: Takashi Iwai --- .../vc04_services/bcm2835-audio/bcm2835-pcm.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c index d2373e4a4d53..8b8e286587cb 100644 --- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c +++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c @@ -345,8 +345,8 @@ int snd_bcm2835_new_pcm(struct bcm2835_chip *chip, u32 numchannels) /* pre-allocation of buffers */ /* NOTE: this may fail */ - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_CONTINUOUS, - snd_dma_continuous_data(GFP_KERNEL), + snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, + chip->card->dev->parent, snd_bcm2835_playback_hw.buffer_bytes_max, snd_bcm2835_playback_hw.buffer_bytes_max); @@ -371,8 +371,8 @@ int snd_bcm2835_new_spdif_pcm(struct bcm2835_chip *chip) /* pre-allocation of buffers */ /* NOTE: this may fail */ - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_CONTINUOUS, - snd_dma_continuous_data(GFP_KERNEL), + snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, + chip->card->dev->parent, snd_bcm2835_playback_spdif_hw.buffer_bytes_max, snd_bcm2835_playback_spdif_hw.buffer_bytes_max); return 0; @@ -404,8 +404,8 @@ int snd_bcm2835_new_simple_pcm(struct bcm2835_chip *chip, snd_pcm_lib_preallocate_pages_for_all( pcm, - SNDRV_DMA_TYPE_CONTINUOUS, - snd_dma_continuous_data(GFP_KERNEL), + SNDRV_DMA_TYPE_DEV, + chip->card->dev->parent, snd_bcm2835_playback_hw.buffer_bytes_max, snd_bcm2835_playback_hw.buffer_bytes_max); -- 2.18.0