linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Andrew Jeffery" <andrew@aj.id.au>
To: "Eddie James" <eajames@linux.ibm.com>, linux-kernel@vger.kernel.org
Cc: devicetree@vger.kernel.org, "Jason Cooper" <jason@lakedaemon.net>,
	linux-aspeed@lists.ozlabs.org, "Marc Zyngier" <maz@kernel.org>,
	"Rob Herring" <robh+dt@kernel.org>,
	tglx@linutronix.de, mark.rutland@arm.com,
	"Joel Stanley" <joel@jms.id.au>
Subject: Re: [PATCH v2 07/12] drivers/soc: xdma: Add user interface
Date: Thu, 12 Dec 2019 15:32:25 +1030	[thread overview]
Message-ID: <2fca83fb-b83a-4adb-9ff2-0658db1b2c66@www.fastmail.com> (raw)
In-Reply-To: <d5eee648-fc35-5f9e-9c73-5fa76a6e04c9@linux.ibm.com>



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

  reply	other threads:[~2019-12-12  5:00 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-05 17:15 [PATCH v2 00/12] Aspeed: Add SCU interrupt controller and XDMA engine drivers Eddie James
2019-12-05 17:15 ` [PATCH v2 01/12] dt-bindings: interrupt-controller: Add Aspeed SCU interrupt controller Eddie James
2019-12-10 23:32   ` Andrew Jeffery
2019-12-05 17:15 ` [PATCH v2 02/12] irqchip: " Eddie James
2019-12-11  0:32   ` Andrew Jeffery
2019-12-05 17:15 ` [PATCH v2 03/12] ARM: dts: aspeed: ast2500: Add " Eddie James
2019-12-11  0:36   ` Andrew Jeffery
2019-12-05 17:15 ` [PATCH v2 04/12] ARM: dts: aspeed: ast2600: Add SCU interrupt controllers Eddie James
2019-12-11  0:42   ` Andrew Jeffery
2019-12-05 17:15 ` [PATCH v2 05/12] dt-bindings: soc: Add Aspeed XDMA Engine Eddie James
2019-12-11  0:40   ` Andrew Jeffery
2019-12-05 17:15 ` [PATCH v2 06/12] drivers/soc: Add Aspeed XDMA Engine Driver Eddie James
2019-12-11  3:47   ` Andrew Jeffery
2019-12-11 20:39     ` Eddie James
2019-12-12  4:52       ` Andrew Jeffery
2019-12-12 19:16         ` Eddie James
2019-12-13  1:42           ` Andrew Jeffery
2019-12-05 17:15 ` [PATCH v2 07/12] drivers/soc: xdma: Add user interface Eddie James
2019-12-11  3:48   ` Andrew Jeffery
2019-12-11 20:43     ` Eddie James
2019-12-12  5:02       ` Andrew Jeffery [this message]
2019-12-05 17:15 ` [PATCH v2 08/12] ARM: dts: aspeed: ast2500: Add XDMA Engine Eddie James
2019-12-05 17:15 ` [PATCH v2 09/12] ARM: dts: aspeed: ast2600: " Eddie James
2019-12-11  3:48   ` Andrew Jeffery
2019-12-05 17:15 ` [PATCH v2 10/12] ARM: dts: aspeed: witherspoon: Enable " Eddie James
2019-12-05 17:15 ` [PATCH v2 11/12] ARM: dts: aspeed: rainier: Enable XDMA engine Eddie James
2019-12-05 17:15 ` [PATCH v2 12/12] ARM: dts: aspeed: tacoma: " Eddie James

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2fca83fb-b83a-4adb-9ff2-0658db1b2c66@www.fastmail.com \
    --to=andrew@aj.id.au \
    --cc=devicetree@vger.kernel.org \
    --cc=eajames@linux.ibm.com \
    --cc=jason@lakedaemon.net \
    --cc=joel@jms.id.au \
    --cc=linux-aspeed@lists.ozlabs.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=maz@kernel.org \
    --cc=robh+dt@kernel.org \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).