Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp17760132ybl; Thu, 2 Jan 2020 11:30:40 -0800 (PST) X-Google-Smtp-Source: APXvYqwgZFPOs/GIjyfuy+gsq/daEe/x+qzH3tgTP4vuNnax1w+trpEck/PLzbmBTt12GraN/ODM X-Received: by 2002:a05:6830:689:: with SMTP id q9mr91080404otr.285.1577993440155; Thu, 02 Jan 2020 11:30:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577993440; cv=none; d=google.com; s=arc-20160816; b=I2i9YBeqXYkKZmPel4aMbfk5ePaEDQsJdqpI+sT50vT3tGm/ss5FpptXEC+4v437Fr 6wzof+OfnyfFL5yZqMGlecoVnfOXBN/gz28V09pAhDiS/9s6Rm+3SrRFhqGntbaVhgyd ZcLowpkv9k8MvLMZY2Z/Gto760YBdTGLoG+zfv/feIRHSQVXerSIUkVixxaq2yAdTKkx YFI+OGkPi2HzrizO4ayl8a9SiUmwp1KAvNNVS3bC/6g1Cvs7Aq24B2Yd+GX+hP6yQ2qD F4/jiYPqHWj4soCjfI2IFlzAUCqYcXBMfq3ZT4BKca92XTnVnuUw7vUrz1htVfss3hbs UmRQ== 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; bh=E5XOgoTpjTYckl+HM/2IH4yubtSk9JHPhRZfz2n6510=; b=E+brIWvVvxsaIqx+g5sZ5RqwJRQkf2Af57LP2q8ep45Z2tsxtcnl9PJNYKANbnB35M utbBc2Lzqj+Y2d51Ujqx0zOiR5sW/RmoAhJEdCiZPrE4aKjCL6ZCymsGnCwWtTU7W1Ys VOhDN3lzDApnBuhDQSMzn7TlveDD5G5r5A4CH5Xfere7ffGvmpbJ8KOWhZ5Za0ooPBeT voOtUIF1z0DSsOQqWrnTrQUxlaHenR1CiC1fQd3nOgDNvd6PKuXZNih0g+TBEWtuTndu aZkqH9gtNHVBdHWNMlmIjB/WYr68SOTyRrSz1Gnlkk+vhvj9V7JJArimwMbweT6ClGwY fPzQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i9si30656513otp.139.2020.01.02.11.30.28; Thu, 02 Jan 2020 11:30:40 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728631AbgABT2h (ORCPT + 99 others); Thu, 2 Jan 2020 14:28:37 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:21278 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728362AbgABT2S (ORCPT ); Thu, 2 Jan 2020 14:28:18 -0500 Received: from pps.filterd (m0187473.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 002JH4Ax067143; Thu, 2 Jan 2020 14:28:06 -0500 Received: from ppma03dal.us.ibm.com (b.bd.3ea9.ip4.static.sl-reverse.com [169.62.189.11]) by mx0a-001b2d01.pphosted.com with ESMTP id 2x63k0mnyb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 02 Jan 2020 14:28:06 -0500 Received: from pps.filterd (ppma03dal.us.ibm.com [127.0.0.1]) by ppma03dal.us.ibm.com (8.16.0.27/8.16.0.27) with SMTP id 002JQtOo020722; Thu, 2 Jan 2020 19:28:05 GMT Received: from b03cxnp08026.gho.boulder.ibm.com (b03cxnp08026.gho.boulder.ibm.com [9.17.130.18]) by ppma03dal.us.ibm.com with ESMTP id 2x5xp6wrs5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 02 Jan 2020 19:28:05 +0000 Received: from b03ledav005.gho.boulder.ibm.com (b03ledav005.gho.boulder.ibm.com [9.17.130.236]) by b03cxnp08026.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 002JS3vo47317332 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 2 Jan 2020 19:28:03 GMT Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6F333BE051; Thu, 2 Jan 2020 19:28:03 +0000 (GMT) Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BE322BE04F; Thu, 2 Jan 2020 19:28:02 +0000 (GMT) Received: from talon7.ibm.com (unknown [9.41.103.158]) by b03ledav005.gho.boulder.ibm.com (Postfix) with ESMTP; Thu, 2 Jan 2020 19:28:02 +0000 (GMT) From: Eddie James To: linux-aspeed@lists.ozlabs.org Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, mark.rutland@arm.com, jason@lakedaemon.net, maz@kernel.org, robh+dt@kernel.org, tglx@linutronix.de, joel@jms.id.au, andrew@aj.id.au, eajames@linux.ibm.com Subject: [PATCH v4 08/12] soc: aspeed: xdma: Add reset ioctl Date: Thu, 2 Jan 2020 13:27:52 -0600 Message-Id: <1577993276-2184-9-git-send-email-eajames@linux.ibm.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1577993276-2184-1-git-send-email-eajames@linux.ibm.com> References: <1577993276-2184-1-git-send-email-eajames@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,18.0.572 definitions=2020-01-02_06:2020-01-02,2020-01-02 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 phishscore=0 spamscore=0 priorityscore=1501 lowpriorityscore=0 malwarescore=0 suspectscore=1 bulkscore=0 adultscore=0 mlxscore=0 mlxlogscore=999 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1910280000 definitions=main-2001020156 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Users of the XDMA engine need a way to reset it if something goes wrong. Problems on the host side, or user error, such as incorrect host address, may result in the DMA operation never completing and no way to determine what went wrong. Therefore, add an ioctl to reset the engine so that users can recover in this situation. Signed-off-by: Eddie James --- drivers/soc/aspeed/aspeed-xdma.c | 36 ++++++++++++++++++++++++++++++++ include/uapi/linux/aspeed-xdma.h | 4 ++++ 2 files changed, 40 insertions(+) diff --git a/drivers/soc/aspeed/aspeed-xdma.c b/drivers/soc/aspeed/aspeed-xdma.c index 5ad0efaf6e05..f11615ef8013 100644 --- a/drivers/soc/aspeed/aspeed-xdma.c +++ b/drivers/soc/aspeed/aspeed-xdma.c @@ -616,6 +616,41 @@ static __poll_t aspeed_xdma_poll(struct file *file, return mask; } +static long aspeed_xdma_ioctl(struct file *file, unsigned int cmd, + unsigned long param) +{ + unsigned long flags; + struct aspeed_xdma_client *client = file->private_data; + struct aspeed_xdma *ctx = client->ctx; + + switch (cmd) { + case ASPEED_XDMA_IOCTL_RESET: + spin_lock_irqsave(&ctx->reset_lock, flags); + if (ctx->in_reset) { + spin_unlock_irqrestore(&ctx->reset_lock, flags); + return 0; + } + + ctx->in_reset = true; + spin_unlock_irqrestore(&ctx->reset_lock, flags); + + if (ctx->current_client) + dev_warn(ctx->dev, + "User reset with transfer in progress.\n"); + + mutex_lock(&ctx->start_lock); + + aspeed_xdma_reset(ctx); + + mutex_unlock(&ctx->start_lock); + break; + default: + return -EINVAL; + } + + return 0; +} + static void aspeed_xdma_vma_close(struct vm_area_struct *vma) { int rc; @@ -709,6 +744,7 @@ static const struct file_operations aspeed_xdma_fops = { .owner = THIS_MODULE, .write = aspeed_xdma_write, .poll = aspeed_xdma_poll, + .unlocked_ioctl = aspeed_xdma_ioctl, .mmap = aspeed_xdma_mmap, .open = aspeed_xdma_open, .release = aspeed_xdma_release, diff --git a/include/uapi/linux/aspeed-xdma.h b/include/uapi/linux/aspeed-xdma.h index 2efaa6067c39..3a3646fd1e9e 100644 --- a/include/uapi/linux/aspeed-xdma.h +++ b/include/uapi/linux/aspeed-xdma.h @@ -4,8 +4,12 @@ #ifndef _UAPI_LINUX_ASPEED_XDMA_H_ #define _UAPI_LINUX_ASPEED_XDMA_H_ +#include #include +#define __ASPEED_XDMA_IOCTL_MAGIC 0xb7 +#define ASPEED_XDMA_IOCTL_RESET _IO(__ASPEED_XDMA_IOCTL_MAGIC, 0) + /* * aspeed_xdma_direction * -- 2.24.0