Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp393092ybl; Wed, 11 Dec 2019 21:01:36 -0800 (PST) X-Google-Smtp-Source: APXvYqyP1shzxje8YZd4SoAfWv/fnlDdRgOFDuKuqImAqODrk3/nM9dFAP8LgD/aYV3G/pAni8AE X-Received: by 2002:a05:6830:1149:: with SMTP id x9mr6284458otq.156.1576126895950; Wed, 11 Dec 2019 21:01:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576126895; cv=none; d=google.com; s=arc-20160816; b=DS8c3uBjfRaAXfYKrq8kYm5CGoB5OBsT3AD2amyDpGg39VyCQpZGEJZCCkQoMdHGk6 IGIbUz3RonN93Ep8XiIeYrDX6RzQa0PDq7rq3wfCD/OtWSSw1jfu+bbgclaJF1wr+Et/ L1JvYi8xvNi6kWtN5SbRIHepkhGf9ThWmp+ACzRmMC2134JSGJJ/ZxEKj8c2IpQclJ78 HywidxW5wgtd8zMjmawUllwnH02U6TXxX4HUn9CvWjlalB8kBK0L/QKdcldoxMsxyVou hYcIItXx/mIy4nSsPccNCTcuYUD4w0PW7tc6nW4grNQyOVKO/Z6Lg4CcdEfbr9x9G8L2 kYQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:subject:cc:to:from:date:references :in-reply-to:message-id:mime-version:user-agent:dkim-signature :dkim-signature; bh=VvHehYcJTV2U7Yt+Z/LgcU3zIcaVlk20N9lTk/I0iE0=; b=TYg/3x4acgtBXqNc7y9reSOorsmzjd7tH+p6dWOC/0J03+WOcaCFVCzDfLhyyKuGon WzSkdUI/s3Qwz5DLWyiUCn6/Kee0O8L9XQ+XwJxynrowakCKt73y0hl76G267a7WsMdq 9fvk+mIz1bj7NaHYW3jyQZT5fMk1TM4wvN0VHK6cr8+04oWPDzKZpS4Fx3KnuNOjbPwc o02AyfxFdR47pP/9IEugGb1kKWNCkwcNHRBkXvYbCwMLxHyUhDieJKmmQE7OE7EvtseG 6VWlPatHOxdxyJQCgCwmZ6JdePJPkaTNysa5o2446NnPMV/56AS4+pdp61c2VMSTrlwb ERYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@aj.id.au header.s=fm1 header.b=cnFUZ0Ze; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b="KC/7LfJs"; 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 m24si2496865otn.67.2019.12.11.21.01.19; Wed, 11 Dec 2019 21:01:35 -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=@aj.id.au header.s=fm1 header.b=cnFUZ0Ze; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b="KC/7LfJs"; 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 S1725948AbfLLFAt (ORCPT + 99 others); Thu, 12 Dec 2019 00:00:49 -0500 Received: from out5-smtp.messagingengine.com ([66.111.4.29]:59325 "EHLO out5-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725379AbfLLFAt (ORCPT ); Thu, 12 Dec 2019 00:00:49 -0500 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id E201A2245B; Thu, 12 Dec 2019 00:00:47 -0500 (EST) Received: from imap2 ([10.202.2.52]) by compute4.internal (MEProxy); Thu, 12 Dec 2019 00:00:47 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aj.id.au; h= mime-version:message-id:in-reply-to:references:date:from:to:cc :subject:content-type; s=fm1; bh=VvHehYcJTV2U7Yt+Z/LgcU3zIcaVlk2 0N9lTk/I0iE0=; b=cnFUZ0ZeOJN+c+hgvl6PLP6hGO/c4siINbrl4shIs4Vn0g2 jcbYWipS5Ln5qP+8pzMqRkVKbUT+HZzMaLcDDo1q67nBH36hxuivO5OJ0X3HN/2T bE0lxljVqhjVafinlhgP+MqR4APxEOmBDjKPP/eaQv/OK6k5QmWbhPaAFfs7Amn8 je40H52KR2GAH3HIVOFBG7XfhNd03s2zAFKDf1cS3uQz1MER0vsv+g1ZQlOFn/aM /YGjV1jby6MQCqemunnamiK/x4bvMjzRHNTO3wIw1inutD1PUhCO2vUF/lDUMwSe zC41NeOO9OYNKhY7FUBrh9q2dUdTeg86PzXfCCA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=VvHehY cJTV2U7Yt+Z/LgcU3zIcaVlk20N9lTk/I0iE0=; b=KC/7LfJsHwJ15TWkCIwjKy E3gps055vLlIWBBa6mha9xlvaW5Yr2Fegfa4jWgpydSxZgrHPnIPbsHUJ5lAfGkq h7SFuD6vFgusvusDBCI1CZKigLtrLzB3DMIlwzThjVAgtTXJEn8KF3C3zD212ur1 Zu3gVQfWuPBzwqII0nGsHetouFT1yfDGHLyi7plXB8lcsS6vjg6K1gviv/ixq7ST lKRs4uFZ7MqewdsjUp/77jrL15UhnCmQ8rlcOdQnqoRhgw7SQoYFkA+U6zPR7DsA gHuCGh5eZQ3sfrAj72f3PqDX4YUno8prS60xRU12g2aJ9wvsZrsJYKD9T16VGzPg == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedufedrudeliedgjeehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvffutgesthdtredtreertdenucfhrhhomhepfdetnhgu rhgvficulfgvfhhfvghrhidfuceorghnughrvgifsegrjhdrihgurdgruheqnecurfgrrh grmhepmhgrihhlfhhrohhmpegrnhgurhgvfiesrghjrdhiugdrrghunecuvehluhhsthgv rhfuihiivgeptd X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id C6411E00B9; Thu, 12 Dec 2019 00:00:46 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.1.7-679-g1f7ccac-fmstable-20191210v1 Mime-Version: 1.0 Message-Id: <2fca83fb-b83a-4adb-9ff2-0658db1b2c66@www.fastmail.com> In-Reply-To: References: <1575566112-11658-1-git-send-email-eajames@linux.ibm.com> <1575566112-11658-8-git-send-email-eajames@linux.ibm.com> Date: Thu, 12 Dec 2019 15:32:25 +1030 From: "Andrew Jeffery" To: "Eddie James" , linux-kernel@vger.kernel.org Cc: devicetree@vger.kernel.org, "Jason Cooper" , linux-aspeed@lists.ozlabs.org, "Marc Zyngier" , "Rob Herring" , tglx@linutronix.de, mark.rutland@arm.com, "Joel Stanley" Subject: Re: [PATCH v2 07/12] drivers/soc: xdma: Add user interface Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 12 Dec 2019, at 07:13, Eddie James wrote: > > On 12/10/19 9:48 PM, Andrew Jeffery wrote: > > > > On Fri, 6 Dec 2019, at 03:45, Eddie James wrote: > >> + } > >> + } else { > >> + mutex_lock(&ctx->file_lock); > >> + > >> + rc = wait_event_interruptible(ctx->wait, !ctx->current_client); > >> + if (rc) { > >> + mutex_unlock(&ctx->file_lock); > >> + return -EINTR; > >> + } > >> + } > >> + > >> + aspeed_xdma_start(ctx, &op, ctx->vga_phys + offs, client); > >> + > >> + mutex_unlock(&ctx->file_lock); > > You've used file_lock here to protect aspeed_xdma_start() but start_lock > > above to protect aspeed_xdma_reset(), so it seems one client can disrupt > > another by resetting the engine while a DMA is in progress? > > > That's correct, that is the intention. In case the transfer hangs, > another client needs to be able to reset and clear up a blocking transfer. Ah. Can we log a noisy warning about resetting the engine while a DMA is in progress then? I'd hate to debug this otherwise. The more information we can log about both clients the better. We still need to make sure we're using consistent locking, even if we wind up with nested locking. > >> + > >> +static int aspeed_xdma_release(struct inode *inode, struct file *file) > >> +{ > >> + struct aspeed_xdma_client *client = file->private_data; > >> + > >> + if (client->ctx->current_client == client) > >> + client->ctx->current_client = NULL; > > Shouldn't we also cancel the DMA op? This seems like a DoS risk: set up > > a non-blocking, large downstream transfer then close the client. Also risks > > scribbling on memory we no-longer own given we don't cancel/wait for > > completion in vm close callback? > > > Right, better wait for completion. There's no way to cancel a transfer. Right, that's handy context. Cheers, Andrew