Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1170424ybl; Wed, 8 Jan 2020 12:16:15 -0800 (PST) X-Google-Smtp-Source: APXvYqyOl2vbkLazsYnPSbaXnVc2nT3AEcZ1R9htDmptYO5zuo7GbfElxTEFGbLEJWeI7ecYzXOh X-Received: by 2002:aca:c74e:: with SMTP id x75mr330646oif.140.1578514575267; Wed, 08 Jan 2020 12:16:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578514575; cv=none; d=google.com; s=arc-20160816; b=Q5sCYNUROyYnohf8qzL88PsQls013iUPeBICekcw12sVBTwNwbaCU2WkmTqi0HruO7 UZrRYFjkobPPQrOlS5Zm0DBqzdYBDn3RIyhJdym8lx0i2AEgncw39KKQiWj5BGqNpwcd wnibZIvFk4hGC6egxSo49E/g9+8ywrtQi+9/cSDrBPgHCuGxH+snwuiWkki4jzASWyMK 7w2oO/EwOS/VnZkfpVvicIWg4sEKYvDL9ffmKlrVjBXxU5sEUiI2FEryXKP/fCHOl/ru Yaqx++kWuIHsE1eFFk5AL2A6Bxg89pPEtQaRHO49Ugncmzz2e+LYnFDHQT4/XKUy1wcG gOIw== 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-transfer-encoding:content-disposition:mime-version :message-id:subject:cc:to:from:date:dkim-signature; bh=kErSshlCxSTCHPTZRA8BlJtvQLKvFYMjDyKtfcVGZgA=; b=ToMyETxV2r0xNyzxlLjHBjB7UZHLai5RwYpEilJfHps6sCM0ZcFdzRjKmLfoqFxXOA IbjUYZ0mlzXbkzJdjThbclUKnTAbpHZX0WBIW2fcTuYGaxqmZTCx+wd8xPw9tnhlEO6e pINlPi7gIybvCbAbjyf7cFQcoQTln/XeIfLgxrJGoSRk7MZmEbDts06SjXzhghR0DOHR QQX+JLD4Z38bIAChkz9C+kZ6QQkYvDootHPJGNQhjMvCfOUl2qqeYUZGwOyQzwBnM9Lc ptVnurVwI/W6sh0mMuduA5vjFnOisGWW3r1qv4hkcSrlWxpEtmg/7+XIfB+231QkwIOL u9OA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=JA9MYxg2; 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=pass (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 p20si2528186otk.73.2020.01.08.12.16.01; Wed, 08 Jan 2020 12:16:15 -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=pass header.i=@kernel.org header.s=default header.b=JA9MYxg2; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726340AbgAHUPO (ORCPT + 99 others); Wed, 8 Jan 2020 15:15:14 -0500 Received: from mail.kernel.org ([198.145.29.99]:46472 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725881AbgAHUPO (ORCPT ); Wed, 8 Jan 2020 15:15:14 -0500 Received: from localhost (mobile-166-170-223-177.mycingular.net [166.170.223.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 16EA320720; Wed, 8 Jan 2020 20:15:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1578514513; bh=tBezumwZiXfw+iJuCA5Lb1jx5XYFSgomgl+Q0fDWQEg=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=JA9MYxg2ki1Fe5w3z7DzwsYokFOH5foJzaqnzkIZNJwyAmJJlebcnJHLEPgqjqIHn 7l0uUFm5+S/T6rt62KSWWjkE7IFhcsN9HCSbYx63qstiC9qzJSgM/h0L5MmknoW0BQ 8rlaNSPjGMiBNmkUe2IXmAR9Wl84lUxL4bpuZCng= Date: Wed, 8 Jan 2020 14:15:11 -0600 From: Bjorn Helgaas To: Muni Sekhar Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: pcie: xilinx: kernel hang - ISR readl() Message-ID: <20200108201511.GA195980@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: 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 On Tue, Jan 07, 2020 at 09:45:13PM +0530, Muni Sekhar wrote: > Hi, > > I have module with Xilinx FPGA. It implements UART(s), SPI(s), > parallel I/O and interfaces them to the Host CPU via PCI Express bus. > I see that my system freezes without capturing the crash dump for > certain tests. I debugged this issue and it was tracked down to the > below mentioned interrupt handler code. > > > In ISR, first reads the Interrupt Status register using ‘readl()’ as > given below. > status = readl(ctrl->reg + INT_STATUS); > > > And then clears the pending interrupts using ‘writel()’ as given blow. > writel(status, ctrl->reg + INT_STATUS); > > > I've noticed a kernel hang if INT_STATUS register read again after > clearing the pending interrupts. > > Can someone clarify me why the kernel hangs without crash dump incase > if I read the INT_STATUS register using readl() after clearing the > pending bits? > > Can readl() block? readl() should not block in software. Obviously at the hardware CPU instruction level, the read instruction has to wait for the result of the read. Since that data is provided by the device, i.e., your FPGA, it's possible there's a problem there. Can you tell whether the FPGA has received the Memory Read for INT_STATUS and sent the completion? On the architectures I'm familiar with, if a device doesn't respond, something would eventually time out so the CPU doesn't wait forever. > Snippet of the ISR code is given blow: > > https://pastebin.com/WdnZJZF5 > > > > static irqreturn_t pcie_isr(int irq, void *dev_id) > > { > > struct test_device *ctrl = data; > > u32 status; > > … > > > > status = readl(ctrl->reg + INT_STATUS); > > /* > > * Check to see if it was our interrupt > > */ > > if (!(status & 0x000C)) > > return IRQ_NONE; > > > > /* Clear the interrupt */ > > writel(status, ctrl->reg + INT_STATUS); > > > > if (status & 0x0004) { > > /* > > * Tx interrupt pending. > > */ > > .... > > } > > > > if (status & 0x0008) { > > /* Rx interrupt Pending */ > > /* The system freezes if I read again the INT_STATUS > register as given below */ > > status = readl(ctrl->reg + INT_STATUS); > > .... > > } > > .. > > return IRQ_HANDLED; > } > > > > -- > Thanks, > Sekhar