From patchwork Thu Feb 15 22:07:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eddie James X-Patchwork-Id: 1899773 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=P/cT8Tkn; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=112.213.38.117; helo=lists.ozlabs.org; envelope-from=linux-fsi-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=patchwork.ozlabs.org) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TbTjH0qqnz23j8 for ; Fri, 16 Feb 2024 09:08:35 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=P/cT8Tkn; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4TbTjG6tlfz3vY7 for ; Fri, 16 Feb 2024 09:08:34 +1100 (AEDT) X-Original-To: linux-fsi@lists.ozlabs.org Delivered-To: linux-fsi@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=P/cT8Tkn; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=linux.ibm.com (client-ip=148.163.158.5; helo=mx0b-001b2d01.pphosted.com; envelope-from=eajames@linux.ibm.com; receiver=lists.ozlabs.org) Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4TbTj21cX0z3dTm for ; Fri, 16 Feb 2024 09:08:21 +1100 (AEDT) Received: from pps.filterd (m0353725.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 41FK0sSO029381; Thu, 15 Feb 2024 22:08:14 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=ETtwT8LcMCJW+mcR7ZD5Qq2B6I2ZwqYbef+CZ36s+uQ=; b=P/cT8Tkniy6tjjfK7Ahp1PYULCUzd2CmKz8ncZo/UXc2Er35U/y0F3oMwIDUpff9+kDw 85dRjVoP5kAvK0PKTUI+Flu40pNk8t2iUjC25CBDJOV8cPki1vjT3OuL/6KTUYTJqqCq wOE4JINt6VyDYDRh07YN8AOORc5kpEN9ykLcyohQaPA//q2S3iqB2kwUiWetTuGhysjJ FC3QaY9ITlA2gsb1XHGosmuzHtqEsSaDqrYmcUMLTArYyTlQU6s2xyz2M3js1EbU/ETh 0rt5zGnx4zkCy7MJzIxqPGcX2AsyO1kE63ug1GHQ7qLifdldlo7U9l4dP28K1EiZOAvk GQ== Received: from ppma11.dal12v.mail.ibm.com (db.9e.1632.ip4.static.sl-reverse.com [50.22.158.219]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3w9q0v5yec-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 15 Feb 2024 22:08:13 +0000 Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 41FLHWtA009935; Thu, 15 Feb 2024 22:08:12 GMT Received: from smtprelay01.wdc07v.mail.ibm.com ([172.16.1.68]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 3w6p6374qr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 15 Feb 2024 22:08:12 +0000 Received: from smtpav03.dal12v.mail.ibm.com (smtpav03.dal12v.mail.ibm.com [10.241.53.102]) by smtprelay01.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 41FM89Ro53281072 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 15 Feb 2024 22:08:11 GMT Received: from smtpav03.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 107E45805A; Thu, 15 Feb 2024 22:08:09 +0000 (GMT) Received: from smtpav03.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B8F7E58076; Thu, 15 Feb 2024 22:08:08 +0000 (GMT) Received: from slate16.aus.stglabs.ibm.com (unknown [9.61.14.18]) by smtpav03.dal12v.mail.ibm.com (Postfix) with ESMTP; Thu, 15 Feb 2024 22:08:08 +0000 (GMT) From: Eddie James To: linux-fsi@lists.ozlabs.org Subject: [PATCH 20/33] fsi: aspeed: Switch to spinlock Date: Thu, 15 Feb 2024 16:07:46 -0600 Message-Id: <20240215220759.976998-21-eajames@linux.ibm.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240215220759.976998-1-eajames@linux.ibm.com> References: <20240215220759.976998-1-eajames@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: kCcQoYcjx-H77gRE48q4mt9faj7S84xb X-Proofpoint-GUID: kCcQoYcjx-H77gRE48q4mt9faj7S84xb X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-15_20,2024-02-14_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 adultscore=0 suspectscore=0 phishscore=0 mlxlogscore=999 clxscore=1015 impostorscore=0 malwarescore=0 lowpriorityscore=0 spamscore=0 bulkscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2402150171 X-BeenThere: linux-fsi@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: robh@kernel.org, devicetree@vger.kernel.org, conor+dt@kernel.org, andi.shyti@kernel.org, sboyd@kernel.org, alistair@popple.id.au, mturquette@baylibre.com, linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, krzysztof.kozlowski+dt@linaro.org, linux-clk@vger.kernel.org Errors-To: linux-fsi-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "linux-fsi" In preparation for interrupt support, switch to a spinlock rather than a mutex. Signed-off-by: Eddie James --- drivers/fsi/fsi-master-aspeed.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/drivers/fsi/fsi-master-aspeed.c b/drivers/fsi/fsi-master-aspeed.c index 83f84ee6d6f4..1cb5bf6c05d2 100644 --- a/drivers/fsi/fsi-master-aspeed.c +++ b/drivers/fsi/fsi-master-aspeed.c @@ -8,11 +8,11 @@ #include #include #include -#include #include #include #include #include +#include #include #include @@ -24,7 +24,7 @@ struct fsi_master_aspeed_data { struct fsi_master_aspeed { struct fsi_master master; - struct mutex lock; /* protect HW access */ + spinlock_t lock; /* protect HW access */ struct device *dev; void __iomem *base; struct clk *clk; @@ -245,6 +245,7 @@ static int aspeed_master_read(struct fsi_master *master, int link, uint8_t id, uint32_t addr, void *val, size_t size) { struct fsi_master_aspeed *aspeed = to_fsi_master_aspeed(master); + unsigned long flags; int ret; if (id > 0x3) @@ -253,7 +254,7 @@ static int aspeed_master_read(struct fsi_master *master, int link, addr |= id << 21; addr += link * FSI_HUB_LINK_SIZE; - mutex_lock(&aspeed->lock); + spin_lock_irqsave(&aspeed->lock, flags); switch (size) { case 1: @@ -272,7 +273,7 @@ static int aspeed_master_read(struct fsi_master *master, int link, ret = check_errors(aspeed, ret); done: - mutex_unlock(&aspeed->lock); + spin_unlock_irqrestore(&aspeed->lock, flags); return ret; } @@ -280,6 +281,7 @@ static int aspeed_master_write(struct fsi_master *master, int link, uint8_t id, uint32_t addr, const void *val, size_t size) { struct fsi_master_aspeed *aspeed = to_fsi_master_aspeed(master); + unsigned long flags; int ret; if (id > 0x3) @@ -288,7 +290,7 @@ static int aspeed_master_write(struct fsi_master *master, int link, addr |= id << 21; addr += link * FSI_HUB_LINK_SIZE; - mutex_lock(&aspeed->lock); + spin_lock_irqsave(&aspeed->lock, flags); switch (size) { case 1: @@ -307,7 +309,7 @@ static int aspeed_master_write(struct fsi_master *master, int link, ret = check_errors(aspeed, ret); done: - mutex_unlock(&aspeed->lock); + spin_unlock_irqrestore(&aspeed->lock, flags); return ret; } @@ -369,15 +371,16 @@ static ssize_t cfam_reset_store(struct device *dev, struct device_attribute *att const char *buf, size_t count) { struct fsi_master_aspeed *aspeed = dev_get_drvdata(dev); + unsigned long flags; trace_fsi_master_aspeed_cfam_reset(true); - mutex_lock(&aspeed->lock); + spin_lock_irqsave(&aspeed->lock, flags); gpiod_set_value(aspeed->cfam_reset_gpio, 1); - usleep_range(900, 1000); + udelay(900); gpiod_set_value(aspeed->cfam_reset_gpio, 0); - usleep_range(900, 1000); + udelay(900); opb_writel(aspeed, ctrl_base + FSI_MRESP0, cpu_to_be32(FSI_MRESP_RST_ALL_MASTER)); - mutex_unlock(&aspeed->lock); + spin_unlock_irqrestore(&aspeed->lock, flags); trace_fsi_master_aspeed_cfam_reset(false); return count; @@ -468,6 +471,7 @@ static int fsi_master_aspeed_probe(struct platform_device *pdev) return -ENOMEM; aspeed->dev = &pdev->dev; + spin_lock_init(&aspeed->lock); aspeed->base = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(aspeed->base)) { @@ -543,7 +547,6 @@ static int fsi_master_aspeed_probe(struct platform_device *pdev) dev_set_drvdata(&pdev->dev, aspeed); - mutex_init(&aspeed->lock); rc = fsi_master_init(&aspeed->master, clk_get_rate(aspeed->clk)); if (rc) goto err_regmap;