Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp7012865ybl; Wed, 15 Jan 2020 14:02:02 -0800 (PST) X-Google-Smtp-Source: APXvYqxOSuh3ZmnDQBxtU9K62ax6JGeJvtFwRoxNqnwUMpYFJuTPM9FeAiyf/LCtzQRypqqzv6Gg X-Received: by 2002:a05:6830:2110:: with SMTP id i16mr4174393otc.337.1579125721976; Wed, 15 Jan 2020 14:02:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579125721; cv=none; d=google.com; s=arc-20160816; b=kcx7EOjBTEHqHJOniHDngAyTLskGuvvKqcInblMvnu4UXUlAm+GE6oPdfM0JOLyfqc QN5Dh4kZEozKEsiH7bf5/I76gjMOT4Avqo3PQ0530eM7i6664VtL2vS0z9W4IprAV1t1 OhFaH030/8weOKmOM69r9aIg+829rau6or8bYqeZSq+sZSfsdqvIrwIs2r1foeQx1nxe qPRHR22zOibPRpyBvbb7DR4H6+Krakj8iLcluqHHwR0XkdKaO9P9UL1i1Q/NU0qLocHz MHoHp5vipT2D62cOEDOToNC9SsyNsT5czZatvoDGpz9odPNYayjXBZkcIkVg4vypmmE+ lFLg== 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=4EZJPqJTNPviYHBuDlaqLXqjDk5WpRY3Sh0Ji5Mgmn8=; b=eHqLwohKWZz0OpHIEcoZ4baeYBppaD/vUDolR2ujGpFpob/iftFMzd3kO+HpcSuY+Y AJpSm7zttB5gq/6fPxHwV2VvKed2tAyfGjWyrBr1SivrnYLGgmC6HKGUKez/i/+Q6Z96 +KM5YWaGFXk0KvwOeqYAKWRx+fSwMAeI0mV84R2aL2R8jVu3aPcGTcaV0ik1La4RqCZ9 QMua0tHMovjIWbBZJeGmj6z8hnsTieRW9hSeuxZtbOQiXN37BHObI6bkNPifUkSJLufG fvUlKi1PBDP08YAZp+DHoJrgwWMVvT8L/ZYLSuSA8wYJ+UF1LadevsjDG9s92ZGaScIS NsAw== 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 a7si4422731oti.135.2020.01.15.14.01.49; Wed, 15 Jan 2020 14:02:01 -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 S1729922AbgAOVaQ (ORCPT + 99 others); Wed, 15 Jan 2020 16:30:16 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:64708 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729752AbgAOVaO (ORCPT ); Wed, 15 Jan 2020 16:30:14 -0500 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 00FLRUIH112817; Wed, 15 Jan 2020 16:30:04 -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 2xhfeyqb3y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Jan 2020 16:30:03 -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 00FLSibW000913; Wed, 15 Jan 2020 21:30:02 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 2xf74ytm04-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Jan 2020 21:30:02 +0000 Received: from b03ledav001.gho.boulder.ibm.com (b03ledav001.gho.boulder.ibm.com [9.17.130.232]) by b03cxnp08026.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 00FLU0uf54067518 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 15 Jan 2020 21:30:00 GMT Received: from b03ledav001.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9AF056E05B; Wed, 15 Jan 2020 21:30:00 +0000 (GMT) Received: from b03ledav001.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B104B6E04C; Wed, 15 Jan 2020 21:29:59 +0000 (GMT) Received: from talon7.ibm.com (unknown [9.41.103.158]) by b03ledav001.gho.boulder.ibm.com (Postfix) with ESMTP; Wed, 15 Jan 2020 21:29:59 +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 v6 08/12] soc: aspeed: xdma: Add reset ioctl Date: Wed, 15 Jan 2020 15:29:46 -0600 Message-Id: <1579123790-6894-9-git-send-email-eajames@linux.ibm.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1579123790-6894-1-git-send-email-eajames@linux.ibm.com> References: <1579123790-6894-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.138,18.0.572 definitions=2020-01-15_03:2020-01-15,2020-01-15 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 impostorscore=0 lowpriorityscore=0 phishscore=0 bulkscore=0 mlxlogscore=999 clxscore=1015 suspectscore=1 malwarescore=0 mlxscore=0 priorityscore=1501 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1910280000 definitions=main-2001150161 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 Acked-by: Andrew Jeffery --- drivers/soc/aspeed/aspeed-xdma.c | 32 ++++++++++++++++++++++++++++++++ include/uapi/linux/aspeed-xdma.h | 4 ++++ 2 files changed, 36 insertions(+) diff --git a/drivers/soc/aspeed/aspeed-xdma.c b/drivers/soc/aspeed/aspeed-xdma.c index 1b81a08..361daca 100644 --- a/drivers/soc/aspeed/aspeed-xdma.c +++ b/drivers/soc/aspeed/aspeed-xdma.c @@ -615,6 +615,37 @@ 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->engine_lock, flags); + if (ctx->in_reset) { + spin_unlock_irqrestore(&ctx->engine_lock, flags); + return 0; + } + + ctx->in_reset = true; + spin_unlock_irqrestore(&ctx->engine_lock, flags); + + if (READ_ONCE(ctx->current_client)) + dev_warn(ctx->dev, + "User reset with transfer in progress.\n"); + + aspeed_xdma_reset(ctx); + break; + default: + return -EINVAL; + } + + return 0; +} + static void aspeed_xdma_vma_close(struct vm_area_struct *vma) { int rc; @@ -708,6 +739,7 @@ static int aspeed_xdma_release(struct inode *inode, struct file *file) .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 2efaa60..3a3646f 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 * -- 1.8.3.1