From patchwork Tue Apr 24 12:06:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "\(Exiting\) Baolin Wang" X-Patchwork-Id: 134070 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp2151201lji; Tue, 24 Apr 2018 05:08:03 -0700 (PDT) X-Google-Smtp-Source: AIpwx49Qh9kmk7HeHXjIx2QxjXaxwLn14Ms8nmNYkXYGbyTy9m+qaNKTPAJXoDIjLI3dRwtURt8M X-Received: by 10.98.46.5 with SMTP id u5mr23519840pfu.247.1524571683121; Tue, 24 Apr 2018 05:08:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524571683; cv=none; d=google.com; s=arc-20160816; b=PQbtc/otv5EwZTDeCj7gGeIF1/M4QyXGnq+g28XvcdO2CLmN+/+cPM8Q7AKkYfzbTF nEXngEDLcBcDUVsFVZ7px6Dzprd/oNqP9M7btfLh70gVhagiKXnI6ibqyAvfc3A/FOKt rXegVjbfw78+QF8MZ5P4Tnr+C451x6mz92jFHPc6rsL2Qnp55/J/tFEn8l6Zzbq5mjqb dTmvms1NtWmeXCbK7Q/CkCRQvuAtqUlCecOFYO1KPxqlVzA3uap+946IWGLarirWFA2y IMTPe/3lJsRTD85BxNC8KtozgxubYlhEUjaSTUvFUABtJhVZ+Mn3I7X1FKVGW36r6i1h ofPQ== 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:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=aunNegfER/ThwhOW7tasRBcKq6tgy4rgmskT3vXl1aw=; b=FIDbpMvL6x2CKdJZSXIvjI2UBe9y8LOY91tC1Wei2EAW6h4CQi38c3On/E0fbTsMQN gkkqFsvRMW0s3/cXU8IvdcSWeWK9FrvMHp1gqrs646hB6CrVcDXLrLNqc5Er2JhzTlZy sI8m84WxBCG4cF8DTPhHaO3ELViqrPIjUnuIp3hipNpHxSjr6dKRSmSZ1hio/pQAjv/S 77k1pkgabUMEcOPT4hKIg0no2juqqYLZDulkdavrFemT6aIkLMhNAbpICUBwtCYKTxQK sG6QhkjCU1toOzae8HBrgUlZ2NLss3XQ00aJdBtUFK/h5tfCUd3ih69RS0pqPPv3UC43 orag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Eh2X9Njt; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 68si11746716pgd.511.2018.04.24.05.08.02; Tue, 24 Apr 2018 05:08:03 -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; dkim=pass header.i=@linaro.org header.s=google header.b=Eh2X9Njt; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757143AbeDXMH5 (ORCPT + 29 others); Tue, 24 Apr 2018 08:07:57 -0400 Received: from mail-pg0-f66.google.com ([74.125.83.66]:46752 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756817AbeDXMHt (ORCPT ); Tue, 24 Apr 2018 08:07:49 -0400 Received: by mail-pg0-f66.google.com with SMTP id t12so10716100pgp.13 for ; Tue, 24 Apr 2018 05:07:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=aunNegfER/ThwhOW7tasRBcKq6tgy4rgmskT3vXl1aw=; b=Eh2X9NjtnjLhuJYclEOnA6LkoIKCA6laZYRNA0Iy7kv1vljAYrPpVMI+9sPuFAYMYG S+1G/b0QdJITh6qmc4CMHGtaymea2HBRgR6kaLEgcPtIHSYv1nvy1p6A2734D2m9AxD4 g/Dem3KzePUeCUwO5g9goeY27Co7OVhgXpnto= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=aunNegfER/ThwhOW7tasRBcKq6tgy4rgmskT3vXl1aw=; b=hz8DjyAjYZpEV1W5yIBodtCMcgSaAKNMvhN0QSa5OhQNpUB7I5q/4x6J1Xn8z5QGht GOcPZ+8J7b/igZSRsfQ2b/pudGfB4yeSLJzUmnMS6abTxJ/ltlV4SScPan5rb3SeSIpJ OiVwsQta16sapfYJUSZVOJ6uPL/kWcll+vL6NrnfGZ2xl1WFMYp0vI7INNgpaAoMcwa5 9XLceMfOBDjFb8sm9lybO1wZUgVGRv8OmNWJ0PSsVqpbVkbaWbAwAdJdj90ry/pOE4kD MWNNfKck68eB6El/fhBJFEqUJIxZ9JOmEfQnjeOAzIY0Yfx5WkfTBIgMDzBE4NlogiKI IdlA== X-Gm-Message-State: ALQs6tD4e1uFk+JsxMKMEOssLk2t7PV0CrzHwV/KCznHlKlFsgITQAAo ixgKzt2z/8qFq45w5x7uI4XMNg== X-Received: by 2002:a17:902:694a:: with SMTP id k10-v6mr23968917plt.161.1524571668995; Tue, 24 Apr 2018 05:07:48 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.82]) by smtp.gmail.com with ESMTPSA id c7sm46350567pfg.81.2018.04.24.05.07.44 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 24 Apr 2018 05:07:48 -0700 (PDT) From: Baolin Wang To: perex@perex.cz, tiwai@suse.com, arnd@arndb.de Cc: baolin.wang@linaro.org, lgirdwood@gmail.com, broonie@kernel.org, o-takashi@sakamocchi.jp, mingo@kernel.org, elfring@users.sourceforge.net, dan.carpenter@oracle.com, jeeja.kp@intel.com, vinod.koul@intel.com, guneshwor.o.singh@intel.com, subhransu.s.prusty@intel.com, bhumirks@gmail.com, gudishax.kranthikumar@intel.com, naveen.m@intel.com, hardik.t.shah@intel.com, arvind.yadav.cs@gmail.com, fabf@skynet.be, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Subject: [PATCH 7/8] ALSA: move snd_pcm_ioctl_sync_ptr_compat into pcm_native.c Date: Tue, 24 Apr 2018 20:06:14 +0800 Message-Id: <1d250179d195adac2ba479f62ad56e0240173715.1524570852.git.baolin.wang@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Arnd Bergmann This is a preparation patch, moving the compat handler for snd_pcm_ioctl_sync_ptr_compat from pcm_compat.c to pcm_native.c. No other changes are indented. Signed-off-by: Arnd Bergmann Signed-off-by: Baolin Wang --- sound/core/pcm_compat.c | 98 --------------------------------------------- sound/core/pcm_native.c | 101 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 101 insertions(+), 98 deletions(-) -- 1.7.9.5 diff --git a/sound/core/pcm_compat.c b/sound/core/pcm_compat.c index a4ef13b..5ed30aa 100644 --- a/sound/core/pcm_compat.c +++ b/sound/core/pcm_compat.c @@ -102,19 +102,6 @@ struct snd_pcm_sw_params32 { unsigned char reserved[56]; }; -/* recalcuate the boundary within 32bit */ -static snd_pcm_uframes_t recalculate_boundary(struct snd_pcm_runtime *runtime) -{ - snd_pcm_uframes_t boundary; - - if (! runtime->buffer_size) - return 0; - boundary = runtime->buffer_size; - while (boundary * 2 <= 0x7fffffffUL - runtime->buffer_size) - boundary *= 2; - return boundary; -} - static int snd_pcm_ioctl_sw_params_compat(struct snd_pcm_substream *substream, struct snd_pcm_sw_params32 __user *src) { @@ -405,91 +392,6 @@ static int snd_pcm_ioctl_xfern_compat(struct snd_pcm_substream *substream, return err; } - -struct snd_pcm_mmap_status32 { - s32 state; - s32 pad1; - u32 hw_ptr; - struct compat_timespec tstamp; - s32 suspended_state; - struct compat_timespec audio_tstamp; -} __attribute__((packed)); - -struct snd_pcm_mmap_control32 { - u32 appl_ptr; - u32 avail_min; -}; - -struct snd_pcm_sync_ptr32 { - u32 flags; - union { - struct snd_pcm_mmap_status32 status; - unsigned char reserved[64]; - } s; - union { - struct snd_pcm_mmap_control32 control; - unsigned char reserved[64]; - } c; -} __attribute__((packed)); - -static int snd_pcm_ioctl_sync_ptr_compat(struct snd_pcm_substream *substream, - struct snd_pcm_sync_ptr32 __user *src) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - volatile struct snd_pcm_mmap_status *status; - volatile struct snd_pcm_mmap_control *control; - u32 sflags; - struct snd_pcm_mmap_control scontrol; - struct snd_pcm_mmap_status sstatus; - snd_pcm_uframes_t boundary; - int err; - - if (snd_BUG_ON(!runtime)) - return -EINVAL; - - if (get_user(sflags, &src->flags) || - get_user(scontrol.appl_ptr, &src->c.control.appl_ptr) || - get_user(scontrol.avail_min, &src->c.control.avail_min)) - return -EFAULT; - if (sflags & SNDRV_PCM_SYNC_PTR_HWSYNC) { - err = snd_pcm_hwsync(substream); - if (err < 0) - return err; - } - status = runtime->status; - control = runtime->control; - boundary = recalculate_boundary(runtime); - if (! boundary) - boundary = 0x7fffffff; - snd_pcm_stream_lock_irq(substream); - /* FIXME: we should consider the boundary for the sync from app */ - if (!(sflags & SNDRV_PCM_SYNC_PTR_APPL)) - control->appl_ptr = scontrol.appl_ptr; - else - scontrol.appl_ptr = control->appl_ptr % boundary; - if (!(sflags & SNDRV_PCM_SYNC_PTR_AVAIL_MIN)) - control->avail_min = scontrol.avail_min; - else - scontrol.avail_min = control->avail_min; - sstatus.state = status->state; - sstatus.hw_ptr = status->hw_ptr % boundary; - sstatus.tstamp = status->tstamp; - sstatus.suspended_state = status->suspended_state; - sstatus.audio_tstamp = status->audio_tstamp; - snd_pcm_stream_unlock_irq(substream); - if (put_user(sstatus.state, &src->s.status.state) || - put_user(sstatus.hw_ptr, &src->s.status.hw_ptr) || - compat_put_timespec(&sstatus.tstamp, &src->s.status.tstamp) || - put_user(sstatus.suspended_state, &src->s.status.suspended_state) || - compat_put_timespec(&sstatus.audio_tstamp, - &src->s.status.audio_tstamp) || - put_user(scontrol.appl_ptr, &src->c.control.appl_ptr) || - put_user(scontrol.avail_min, &src->c.control.avail_min)) - return -EFAULT; - - return 0; -} - #ifdef CONFIG_X86_X32 /* X32 ABI has 64bit timespec and 64bit alignment */ struct snd_pcm_mmap_status_x32 { diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c index 0c2ec6d..158e85d 100644 --- a/sound/core/pcm_native.c +++ b/sound/core/pcm_native.c @@ -19,6 +19,7 @@ * */ +#include #include #include #include @@ -2819,6 +2820,106 @@ static int snd_pcm_sync_ptr(struct snd_pcm_substream *substream, return 0; } +#ifdef CONFIG_COMPAT +struct snd_pcm_mmap_status32 { + s32 state; + s32 pad1; + u32 hw_ptr; + struct compat_timespec tstamp; + s32 suspended_state; + struct compat_timespec audio_tstamp; +} __attribute__((packed)); + +struct snd_pcm_mmap_control32 { + u32 appl_ptr; + u32 avail_min; +}; + +struct snd_pcm_sync_ptr32 { + u32 flags; + union { + struct snd_pcm_mmap_status32 status; + unsigned char reserved[64]; + } s; + union { + struct snd_pcm_mmap_control32 control; + unsigned char reserved[64]; + } c; +} __attribute__((packed)); + +/* recalcuate the boundary within 32bit */ +static snd_pcm_uframes_t recalculate_boundary(struct snd_pcm_runtime *runtime) +{ + snd_pcm_uframes_t boundary; + + if (! runtime->buffer_size) + return 0; + boundary = runtime->buffer_size; + while (boundary * 2 <= 0x7fffffffUL - runtime->buffer_size) + boundary *= 2; + return boundary; +} + +static int snd_pcm_ioctl_sync_ptr_compat(struct snd_pcm_substream *substream, + struct snd_pcm_sync_ptr32 __user *src) +{ + struct snd_pcm_runtime *runtime = substream->runtime; + volatile struct snd_pcm_mmap_status *status; + volatile struct snd_pcm_mmap_control *control; + u32 sflags; + struct snd_pcm_mmap_control scontrol; + struct snd_pcm_mmap_status sstatus; + snd_pcm_uframes_t boundary; + int err; + + if (snd_BUG_ON(!runtime)) + return -EINVAL; + + if (get_user(sflags, &src->flags) || + get_user(scontrol.appl_ptr, &src->c.control.appl_ptr) || + get_user(scontrol.avail_min, &src->c.control.avail_min)) + return -EFAULT; + if (sflags & SNDRV_PCM_SYNC_PTR_HWSYNC) { + err = snd_pcm_hwsync(substream); + if (err < 0) + return err; + } + status = runtime->status; + control = runtime->control; + boundary = recalculate_boundary(runtime); + if (! boundary) + boundary = 0x7fffffff; + snd_pcm_stream_lock_irq(substream); + /* FIXME: we should consider the boundary for the sync from app */ + if (!(sflags & SNDRV_PCM_SYNC_PTR_APPL)) + control->appl_ptr = scontrol.appl_ptr; + else + scontrol.appl_ptr = control->appl_ptr % boundary; + if (!(sflags & SNDRV_PCM_SYNC_PTR_AVAIL_MIN)) + control->avail_min = scontrol.avail_min; + else + scontrol.avail_min = control->avail_min; + sstatus.state = status->state; + sstatus.hw_ptr = status->hw_ptr % boundary; + sstatus.tstamp = status->tstamp; + sstatus.suspended_state = status->suspended_state; + sstatus.audio_tstamp = status->audio_tstamp; + snd_pcm_stream_unlock_irq(substream); + if (put_user(sstatus.state, &src->s.status.state) || + put_user(sstatus.hw_ptr, &src->s.status.hw_ptr) || + compat_put_timespec(&sstatus.tstamp, &src->s.status.tstamp) || + put_user(sstatus.suspended_state, &src->s.status.suspended_state) || + compat_put_timespec(&sstatus.audio_tstamp, + &src->s.status.audio_tstamp) || + put_user(scontrol.appl_ptr, &src->c.control.appl_ptr) || + put_user(scontrol.avail_min, &src->c.control.avail_min)) + return -EFAULT; + + return 0; +} +#define __SNDRV_PCM_IOCTL_SYNC_PTR32 = _IOWR('A', 0x23, struct snd_pcm_sync_ptr32), +#endif + static int snd_pcm_tstamp(struct snd_pcm_substream *substream, int __user *_arg) { struct snd_pcm_runtime *runtime = substream->runtime;