Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4999078imu; Tue, 15 Jan 2019 09:24:00 -0800 (PST) X-Google-Smtp-Source: ALg8bN7aafj5CrgHO/FmW9YgV4VV4+hW1ArlqUhtRZ/77I453xliTgKfXkhDUtEqVcabD+c2Ceu7 X-Received: by 2002:a17:902:d68c:: with SMTP id v12mr5183972ply.4.1547573039965; Tue, 15 Jan 2019 09:23:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547573039; cv=none; d=google.com; s=arc-20160816; b=miawsrKI6hnEjRhnB2oblDvzr5Gi6epaYy7StRJeOH15r6EE2VawMIhfMRqYHhQzbK o+xBMAnliaupreCRG3D6uHqiuAcgTxzyndgsTze+Y3IOAmJItYd8omlTFPnSsrABwKpV 2zfcS8inuoLe9WeGJIH2UcaUYE5FxiwQBbnQkIM5KWpx2qXNu+Kk8smxbk611qAY4p/0 MyNDnWlfy1WmGCSv/teNM/vX52H3lzozqBw/3RWfzKo5HF5e+QFvXXz04PAEHmuimHPK WD5uerMCwyf4mSNBjdaDT9MAirO94XgsXTFWtuIsLpeo89rTJwzjYiPHN2iGIbBoNb4v hDdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=DrWM2TYp01Hb/9SMq6G1LGGAVaQ0o4kL5/Rut7tJG4o=; b=VqywQ0GpMYN60ST7wKI8dehfRHfsIlYqoTs6oBvae7Aae//V4HyXZbL/nM4vglohG+ xNc3D/KUgKCTnSf/qrZ2rkSyi4XMtRrim9Yk/RW1La2S9e4WyBiuhrSpogPOq0VW3+my RW7usLsd/XPsldMTpIXGYBM8VWntsVspr5E/mJxI4St0LnLtXlHp7TwKknT1cLRxGuZt UUGOFld7vVHE0vxZWKSBL7lciCOKKx+owsqHDfpYpu3tGAIScqOfTGQoDDH6kpksO82s 0jYWjgmWin2jPR7QK6C427hcQ2F1owIlsVZhbe6f9lJQsFtKgN8tDkL6F0QRvRgNqSm4 Oa9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@sirena.org.uk header.s=20170815-heliosphere header.b=eD5Cqffc; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y10si3612402plt.406.2019.01.15.09.23.40; Tue, 15 Jan 2019 09:23:59 -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; dkim=fail header.i=@sirena.org.uk header.s=20170815-heliosphere header.b=eD5Cqffc; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730339AbfAOOZF (ORCPT + 99 others); Tue, 15 Jan 2019 09:25:05 -0500 Received: from heliosphere.sirena.org.uk ([172.104.155.198]:32846 "EHLO heliosphere.sirena.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727574AbfAOOZD (ORCPT ); Tue, 15 Jan 2019 09:25:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sirena.org.uk; s=20170815-heliosphere; h=In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=DrWM2TYp01Hb/9SMq6G1LGGAVaQ0o4kL5/Rut7tJG4o=; b=eD5CqffcHSv5SK1z6qOtRE8cn ttmd8oNu8FcVjCw3fieaBapIp0n4eUC8rhh7ydUGFJrdqVSa3eN8DxNDpvmliPkGqMobn1XLZ+9yi 8T4VHpSRxQDSoLGzcZMOr0A5QiZtdxhHzzi1rwXv+OzjFOpf4Kf2oDY0vZrK0suzYPWvs=; Received: from cpc102320-sgyl38-2-0-cust46.18-2.cable.virginm.net ([82.37.168.47] helo=debutante.sirena.org.uk) by heliosphere.sirena.org.uk with esmtpa (Exim 4.89) (envelope-from ) id 1gjPe8-000843-Se; Tue, 15 Jan 2019 14:24:52 +0000 Received: by debutante.sirena.org.uk (Postfix, from userid 1000) id 44B9A1127848; Tue, 15 Jan 2019 14:24:52 +0000 (GMT) Date: Tue, 15 Jan 2019 14:24:52 +0000 From: Mark Brown To: Baolin Wang Cc: robh+dt@kernel.org, mark.rutland@arm.com, orsonzhai@gmail.com, zhang.lyra@gmail.com, lanqing.liu@unisoc.com, linux-spi@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/4] spi: sprd: Add the SPI irq function for the SPI DMA mode Message-ID: <20190115142452.GA5522@sirena.org.uk> References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="oyUTqETQ0mS9luUI" Content-Disposition: inline In-Reply-To: X-Cookie: Violence is molding. User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --oyUTqETQ0mS9luUI Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Tue, Jan 15, 2019 at 09:46:51PM +0800, Baolin Wang wrote: This looks good, just one small issue and a thing to check: > +static irqreturn_t sprd_spi_handle_irq(int irq, void *data) > +{ > + struct sprd_spi *ss = (struct sprd_spi *)data; > + u32 val = readl_relaxed(ss->base + SPRD_SPI_INT_MASK_STS); > + > + if (val & SPRD_SPI_MASK_TX_END) { > + writel_relaxed(SPRD_SPI_TX_END_CLR, ss->base + SPRD_SPI_INT_CLR); > + if (!(ss->trans_mode & SPRD_SPI_RX_MODE)) > + complete(&ss->xfer_completion); > + return IRQ_HANDLED; > + } > + > + if (val & SPRD_SPI_MASK_RX_END) { > + writel_relaxed(SPRD_SPI_RX_END_CLR, ss->base + SPRD_SPI_INT_CLR); > + complete(&ss->xfer_completion); > + } > + > + return IRQ_HANDLED; > +} This will return IRQ_HANDLED no matter if there was an interrupt actually handled. That means that if something goes wrong due to some bug or a hardware change (eg, a new version of the IP) and there's another interrupt fired we won't clear it and the interrupt core won't be able to detect that it's a spurious interrupt and use its own error handling. It's better to return IRQ_NONE in that case. > + ret = devm_request_irq(&pdev->dev, ss->irq, sprd_spi_handle_irq, > + 0, pdev->name, ss); > + if (ret) > + dev_err(&pdev->dev, "failed to request spi irq %d, ret = %d\n", > + ss->irq, ret); Are you sure it's safe to use devm_request_irq(), especially when unloading the driver? Using it means that we will only disable the interrupt after the driver's remove function has finished so there's a danger of an interrupt firing when some of the resources the hander has used are still in use. I didn't spot any issues, just something to check especially with the later patches building on top of this. --oyUTqETQ0mS9luUI Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEreZoqmdXGLWf4p/qJNaLcl1Uh9AFAlw97TMACgkQJNaLcl1U h9BFNwf9HP3Z+bpkgsUNL5XdG5PvKTnwIdDpVQSXq4JNtppq2ITkJ7VxbDbJ3+1l 8dK4dnT6wX3+/dib9ky626PIovD+WkchDpQYKud/tb4ZsKwmhJ5OhfxLd/2rQOOF eeYdFPiKHai0NzIdZpOga6orkDvjgM860VSh7Ylfl2iJ13cZGoR8Jnxo+Sa+huPg lxphZAUJWUjFVeU0fetbyVb8iY89ovgBUMtzJ5xcWzdLXiLi3yT2s8NGrTtDxS2u QVhJulPTxjxJ694mGH2mPz8hda+7uw/IT8sjk8bd3MmK/efl6CEZ5B1frzIm85Jg pDm8Fno1/aJOZ339cLVOo5pjwxtJ2g== =cuso -----END PGP SIGNATURE----- --oyUTqETQ0mS9luUI--