Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp5136550imu; Tue, 8 Jan 2019 12:10:12 -0800 (PST) X-Google-Smtp-Source: ALg8bN6NaMP71ALuySN1ygQMhQcUoU2LKpvtWRKaoDUYRrCNa1FyfjlaPSsVg4O98AHqt7bnn6+y X-Received: by 2002:a62:6408:: with SMTP id y8mr3079164pfb.202.1546978212504; Tue, 08 Jan 2019 12:10:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546978212; cv=none; d=google.com; s=arc-20160816; b=JsqHwFrW+PRDmMeEXBYmLvvmk6XBNG9dNPommYkGrvo7ObLghY54tmJzrSt7ieMZSe XoOnazVBPFQ9/bJdg3xbJAoeYMJlmTIPrsJun9fWQkIu3/ZqPzTpi4yQ45XWay98DTbG 2sT6szXvLsp9SkngaRLcuUctGJO/FjSEpVLYIZ7MeMooggQiznsD3BwVF1dplcAzaw+h LJPbFX1VFj1ksxDr0Lozd4qDe2VpZD6tEFKdmezdkFu7cnLxcESPj25dqXisuHN2QNwV LrRTmmkAJlcKnGJQHGihgFh2eJU1EfRxsUV34pGStYWwMBzARW6Xu5FNabyV1naafwVV cokw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=cwhmK0nYY+r41sqpOhrb47qGEnW/dsJ+iqe/1CuBboc=; b=sU+fhDF37LUTnefebPDym99P/szu61E+TvPggSt/LcVY+kEPSLuJ6QnNRBPk8V16/H fI4IoNiPjDfzLz0yW8O02ZP+u2duwhSjifqTP6MTSdrA/4nMubaOd24CPSvW35ZxTrJt B7u03vB6FctCxhaM3sbTjMANAIteE48IbxeaHsNzvOk2PGfWM+ZfGa9G9vFSuGu814KL 6A9tyVehfZE+GLlC/gozv+fdE345PQ8YoKCsz1Rs+IsrENK+vB56TBRhefEuCasp915x 4wM02p0SuP9zvl9QKyikwpxa73COnXkgiEcIZANRVOAPA7MMGc0MC0vPyCchNHO1s8Rm 2c9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=1BaLjOWN; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l36si29310772plb.433.2019.01.08.12.09.57; Tue, 08 Jan 2019 12:10:12 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=default header.b=1BaLjOWN; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730053AbfAHUGp (ORCPT + 99 others); Tue, 8 Jan 2019 15:06:45 -0500 Received: from mail.kernel.org ([198.145.29.99]:34824 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729875AbfAHT2D (ORCPT ); Tue, 8 Jan 2019 14:28:03 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C188720665; Tue, 8 Jan 2019 19:28:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1546975683; bh=+RygfPGvdr6e1c5HrjW0cz9VkYqFlt7GStkqWPuXTcs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1BaLjOWNQIAGy62bbGNvUYMQbPsiyZTaPlSfBMqHlk4DoVDB6wZKJ3mlRL6qfR5iZ UofJuUN7rwRrMhplyhlWFy8hUxPDrnamga1MSsWBpZNw+xkjGDq31nlQQP/+5bsGWK 3A+GzUZ4uPxyGaKO+PTPFVsmj8AVTsVKe9IJorZE= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Yu Zhao , Mark Brown , Sasha Levin Subject: [PATCH AUTOSEL 4.20 051/117] ASoC: use dma_ops of parent device for acp_audio_dma Date: Tue, 8 Jan 2019 14:25:19 -0500 Message-Id: <20190108192628.121270-51-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190108192628.121270-1-sashal@kernel.org> References: <20190108192628.121270-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yu Zhao [ Upstream commit 23aa128bb28d9da69bb1bdb2b70e50128857884a ] AMD platform device acp_audio_dma can only be created by parent PCI device driver (drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c). Pass struct device of the parent to snd_pcm_lib_preallocate_pages() so dma_alloc_coherent() can use correct dma_ops. Otherwise, it will use default dma_ops which is nommu_dma_ops on x86_64 even when IOMMU is enabled and set to non passthrough mode. Though platform device inherits some dma related fields during its creation in mfd_add_device(), we can't simply pass its struct device to snd_pcm_lib_preallocate_pages() because dma_ops is not among the inherited fields. Even it were, drivers/iommu/amd_iommu.c would ignore it because get_device_id() doesn't handle platform device. This change shouldn't give us any trouble even struct device of the parent becomes null or represents some non PCI device in the future, because get_dma_ops() correctly handles null struct device or uses the default dma_ops if struct device doesn't have it set. Signed-off-by: Yu Zhao Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- sound/soc/amd/acp-pcm-dma.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sound/soc/amd/acp-pcm-dma.c b/sound/soc/amd/acp-pcm-dma.c index cdebab2f8ce5..7ada2c1f4964 100644 --- a/sound/soc/amd/acp-pcm-dma.c +++ b/sound/soc/amd/acp-pcm-dma.c @@ -1151,18 +1151,21 @@ static int acp_dma_new(struct snd_soc_pcm_runtime *rtd) struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); struct audio_drv_data *adata = dev_get_drvdata(component->dev); + struct device *parent = component->dev->parent; switch (adata->asic_type) { case CHIP_STONEY: ret = snd_pcm_lib_preallocate_pages_for_all(rtd->pcm, SNDRV_DMA_TYPE_DEV, - NULL, ST_MIN_BUFFER, + parent, + ST_MIN_BUFFER, ST_MAX_BUFFER); break; default: ret = snd_pcm_lib_preallocate_pages_for_all(rtd->pcm, SNDRV_DMA_TYPE_DEV, - NULL, MIN_BUFFER, + parent, + MIN_BUFFER, MAX_BUFFER); break; } -- 2.19.1