Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp479119lqo; Thu, 16 May 2024 11:34:18 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUty2wBPwawl57V1Cy/LkIQnCaRgbP8w24PkDbgElq2fErTy1tHYDcnACam88trAGQdjQ7NaobcxvIrfoMtA/IC4Tk0178X+HOam19xCw== X-Google-Smtp-Source: AGHT+IFSuCYuj6nby78ECY39skaREb0RdW6XxkFQO5iYlQNd/C/kJ9HLs0jW4sX+oNv5UYLro7sI X-Received: by 2002:a05:6359:4593:b0:18f:81e1:e557 with SMTP id e5c5f4694b2df-193bb401c02mr2162935955d.1.1715884458026; Thu, 16 May 2024 11:34:18 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715884457; cv=pass; d=google.com; s=arc-20160816; b=recMbZaWxhZAivV5CEKk2maKLsJJeSaWX9p3dw3TGuV6SebG8ITpOaO4JTurgGZZ4t TGhe6noFPEKLJhkpfvtipjnIrKnUIGU++ZCT+6Kkvbww97DqJAQbNfqXyYjSeGN2ZVfU Fwl337KXmp9bQ7jpGDfiud0qex5tE2gB1pjjltmucmi/MVFpDYE7/q6+vdpC7+Jmg8rv Lut8jo58+bXATtSAE0vjdo3NJNWl0mfcPyzevGfrpvRzK3wVXCRS1/eM0FOQ7f/y5oV5 wR4EIUvKrR1pnA47v0KB3+3ONMx9g02tuQKFmXa6ge3B5qEKjDv+uhXBAMlTCni8akVo r1ug== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=7144/LG2eNgprd/415eaf17snNBOk8+YXJ4liDEExS4=; fh=r7jucx4EDwcx4QmKdJY/B/BWs7eG+xdxvoZ3FO/I2uA=; b=cIUR7TwisIvxP28XcyvSYerj6AWslgFPE+KP/jQYhi9tPVSSiT5V75bD+PZL7bEjr1 KhWKIftlBsXi9JUsRQFJs1WeOLEcg8Y7IOiNVoq2H3v/cISuT74FuCYasVK4zDSQgfUr hSgml7gtSVaeDpXefgOAZQwwTkmNauNEj6noeMKLLgwmuH/0ilMPx5xazQRTqRy3Dfoc KOT6bVfqqN9HkzpQrQvSmPjg9ai/SrHV5VyKSbEi/4HMVwjcXQgf8a4KJ092cFeBTIlM V/uvYEVaCYyksQ5vOrjSYU0LWeXIE58H3pC/5UinvQW2rQOMB93n9Z8CiAvJd9Y0bVic NcWg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=JfUkLGqR; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-181465-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-181465-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id 41be03b00d2f7-65e0d9e8ccasi261579a12.565.2024.05.16.11.34.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 May 2024 11:34:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-181465-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=JfUkLGqR; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-181465-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-181465-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 479D0B236E3 for ; Thu, 16 May 2024 18:28:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9054915FA96; Thu, 16 May 2024 18:19:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="JfUkLGqR" 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 smtp.subspace.kernel.org (Postfix) with ESMTPS id 281D815F417; Thu, 16 May 2024 18:19:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715883592; cv=none; b=H8sEvw+Zzly2YFqIBAXlLtF/qZW1zHdFondCcTgcfty5y6Rl47blnM/69MS2EAQqV03k1KVb552/k3/lK+6TRF960Rh3k94dF3ktvZjU9FgYphJZk1quOzGk+V/iaFzogp6Opb2IJSjOlVSHU4hFZYZmCcChtOO/cWej/6JqDIk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715883592; c=relaxed/simple; bh=qaKSN57DFhgzUoIJwygcbsMbYI7rqB3nhHlVwwQrD0s=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=pVQoVVzChrp1fFXCX1a/etaN3tEv40jP/PyN/uWyPnjNzNAKI91iDGCfqRtmuZTdWuGLLwH5iCKC3I8fSte0vjX+Z2Qthcec5Z8asxgbJrZpPZ7kFuhsoyOuJ9r2l+CDsjU+lPCOAJ0UswaItCSYCDsbmRgT5elwm8CnVEEL5/I= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=JfUkLGqR; arc=none smtp.client-ip=148.163.158.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Received: from pps.filterd (m0356516.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 44GHgglc003311; Thu, 16 May 2024 18:19:19 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=7144/LG2eNgprd/415eaf17snNBOk8+YXJ4liDEExS4=; b=JfUkLGqR0w44sdi7TCORDZY4JSPiNwMHvZTFE1EhV6dmOnkT+PxQ8pweSdJYxXQMTibb h7hgdnmb2GiyLOsWMsFBziAO6Qmy2MsnoY1/+/bp8dCJ6u5N6CDe/cr0MXd7C+dH7sBh 1IXs6/9GtUAqgy88VxNy+ORTN7xjWTPZlIvNlDrkJgR4SaA0/Y7UYg7tVS4voAYKlWaP gXdOxg8zQt1BqqTlyEu/cbpQlVnlAqXfE3R3ttaWQKbBX6k2wkNFpMGx0KYM6Cu5ei36 NGnnjNZCPQbriycKsVc6vKGaU/jCOsZuUrXJlbd/11zgwwiqJ/lNyEeHW8kHVHC8l22s Kw== Received: from ppma21.wdc07v.mail.ibm.com (5b.69.3da9.ip4.static.sl-reverse.com [169.61.105.91]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3y5pse82hv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 16 May 2024 18:19:18 +0000 Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 44GIAFtW002257; Thu, 16 May 2024 18:19:18 GMT Received: from smtprelay06.wdc07v.mail.ibm.com ([172.16.1.73]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3y2m0pkfun-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 16 May 2024 18:19:18 +0000 Received: from smtpav05.dal12v.mail.ibm.com (smtpav05.dal12v.mail.ibm.com [10.241.53.104]) by smtprelay06.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 44GIJF9D4391626 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 16 May 2024 18:19:17 GMT Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8CF9A58052; Thu, 16 May 2024 18:19:13 +0000 (GMT) Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4E88858087; Thu, 16 May 2024 18:19:13 +0000 (GMT) Received: from slate16.aus.stglabs.ibm.com (unknown [9.61.107.19]) by smtpav05.dal12v.mail.ibm.com (Postfix) with ESMTP; Thu, 16 May 2024 18:19:13 +0000 (GMT) From: Eddie James To: linux-fsi@lists.ozlabs.org Cc: linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, linux-spi@vger.kernel.org, broonie@kernel.org, andi.shyti@kernel.org, joel@jms.id.au, alistair@popple.id.au, jk@ozlabs.org, andrew@codeconstruct.com.au, linux-aspeed@lists.ozlabs.org, eajames@linux.ibm.com Subject: [PATCH v3 20/40] fsi: aspeed: Switch to spinlock Date: Thu, 16 May 2024 13:18:47 -0500 Message-Id: <20240516181907.3468796-21-eajames@linux.ibm.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240516181907.3468796-1-eajames@linux.ibm.com> References: <20240516181907.3468796-1-eajames@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: eKL6peb-uWDAiGtkcxoarInplCb8X2xR X-Proofpoint-GUID: eKL6peb-uWDAiGtkcxoarInplCb8X2xR X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.650,FMLib:17.11.176.26 definitions=2024-05-16_07,2024-05-15_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 adultscore=0 suspectscore=0 lowpriorityscore=0 mlxscore=0 priorityscore=1501 spamscore=0 impostorscore=0 phishscore=0 mlxlogscore=990 clxscore=1015 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2405010000 definitions=main-2405160132 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 10ca23cf58c2e..176e596b4391b 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; void __iomem *ctrl; @@ -251,6 +251,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) @@ -259,7 +260,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: @@ -278,7 +279,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; } @@ -286,6 +287,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) @@ -294,7 +296,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: @@ -313,7 +315,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; } @@ -396,15 +398,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); regmap_write(aspeed->master.map, FSI_MRESP0, FSI_MRESP_RST_ALL_MASTER); - mutex_unlock(&aspeed->lock); + spin_unlock_irqrestore(&aspeed->lock, flags); trace_fsi_master_aspeed_cfam_reset(false); return count; @@ -498,6 +501,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)) { @@ -583,7 +587,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; -- 2.39.3