Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp663098ybl; Tue, 28 Jan 2020 09:41:55 -0800 (PST) X-Google-Smtp-Source: APXvYqxyL1/AdghkW6KSrzxD6M7C2C+GiEBzYA2GLsMLOddch+jUMaOw62e+Pwdr+NetpnkBuUTX X-Received: by 2002:aca:55cc:: with SMTP id j195mr3749431oib.22.1580233314948; Tue, 28 Jan 2020 09:41:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580233314; cv=none; d=google.com; s=arc-20160816; b=CepL72HpM0antKiQKHcZ9yk7YGvo631tJHvk5roaAWUkBsOfZqma8oHr635mz4K+s7 zWT9aT2Pk5PYololjzT5xq8xIDAZyN9/HPKV8320AECYPR6OjPXdO3mlGMayLh6ULWdf wBHFJuC18QYm/YU5uEGYlIAP13L+oruNKep00bpCUw3h5P1Q4i+3KIAm0Hkrf1qCVJiX l3KahqAqBt6G645L0Ts5jhGOW78loUkXxBm6u4jHjMZVDDjtBBsVMEhDUGdtLBcJ7Pfm 8hL1PneiFhVd8MEgvqT54wBcOZVUPKQjwVBMkRWb0ujo2/x7Lb+cEyJKo99Ccyjxi+Pd ZIHA== 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=qwvSZNuEQOT9+K6ZwZOBqf27s0+fUPy209ClSTY1hyM=; b=xIVQmaLPJV0qoHIAxt512bq1NoswsGqxt6lmtn47hS4tLm4palIZDLj6EiyK9b1BPd TDuhjZmaWSYGjjZH6NmprkfLXesw/8Kp6LgUPhbvPdPH7GvwzI84wQwBU8rPNT//0NxU YLOQ0Q1InXl9mxNoJ+CAsQ5HVM5hbdh/PdHN1e6tTUSQ4ZPm5JgNeb5XL//Sxy/2nDma j7X3KQ9rf3r13zCShZvPObldQN6Omm1gqAENWQDP0gSA12CyHVfP4CUeDTimsmoIsFnX 3KpoNVxg6n5jJGVuR/17kEBqCN7IQJFSEfz8WJ9mL67qrOx9tEQp9p2HtkRY7amNfd8y 8hWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Z8Xfe+OR; 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 l4si2819001oib.170.2020.01.28.09.41.42; Tue, 28 Jan 2020 09:41:54 -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=Z8Xfe+OR; 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 S1726318AbgA1Rkv (ORCPT + 99 others); Tue, 28 Jan 2020 12:40:51 -0500 Received: from mail.kernel.org ([198.145.29.99]:39818 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726066AbgA1Rku (ORCPT ); Tue, 28 Jan 2020 12:40:50 -0500 Received: from localhost (mobile-166-175-186-165.mycingular.net [166.175.186.165]) (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 9F8872465B; Tue, 28 Jan 2020 17:40:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580233250; bh=xvhgfQQ5L9TDXPMISXTC3Sh2WZWsStbYQGl8G7pS4r8=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=Z8Xfe+ORuHL9ioZ5kXpem+/RFpCCtHqRtviOviDKDoaZvD+VfUjnIDGERZxa4zI3M mYO+oB/LvIezXMP/fbvV9ZtA0mgKvLgINK/eg0gZRL8KlYcnoBszzTIPzr4AtHNPwA h4fQ+s6Mpm9Mga/4+8MwrI9ucCkFeTqyH7b0iEgU= Date: Tue, 28 Jan 2020 11:40:47 -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: <20200128174047.GA181400@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 Sat, Jan 18, 2020 at 07:16:14AM +0530, Muni Sekhar wrote: > On Thu, Jan 9, 2020 at 10:05 AM Bjorn Helgaas wrote: > > > > On Thu, Jan 09, 2020 at 08:47:51AM +0530, Muni Sekhar wrote: > > > On Thu, Jan 9, 2020 at 1:45 AM Bjorn Helgaas wrote: > > > > 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. > > > > > > Thank you very much for your reply. > > > Where can I find the details about what is protocol for reading the > > > ‘memory mapped IO’? Can you point me to any useful links.. > > > I tried locate the exact point of the kernel code where CPU waits for > > > read instruction as given below. > > > readl() -> __raw_readl() -> return *(const volatile u32 __force *)add > > > Do I need to check for the assembly instructions, here? > > > > The C pointer dereference, e.g., "*address", will be some sort of a > > "load" instruction in assembly. The CPU wait isn't explicit; it's > > just that when you load a value, the CPU waits for the value. > > > > > > Can you tell whether the FPGA has received the Memory Read for > > > > INT_STATUS and sent the completion? > I have not seen any ‘missing’ completions on the logic analyser. Is > there any other ways to debug this one? If you see the Memory Read and the associated Completion, and you still see a hang in the kernel, then mostly likely the problem is not in PCIe. I would start by trying to prove that the instruction after the readl() is or is not executed. Bjorn