From patchwork Tue Dec 19 09:55:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kishon Vijay Abraham I X-Patchwork-Id: 122359 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp3932230qgn; Tue, 19 Dec 2017 01:55:59 -0800 (PST) X-Google-Smtp-Source: ACJfBovCZmirN9rfRYiSvLNiSNWbItnE/2FDvS/ecpuhbKdbYpuXZhYQCM9gEmaXCp50lz/a+QzJ X-Received: by 10.101.68.65 with SMTP id e1mr2414041pgq.282.1513677359419; Tue, 19 Dec 2017 01:55:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513677359; cv=none; d=google.com; s=arc-20160816; b=LFtBc51adHxZcSG4oGnKEB+fK6pkawovofTrlvb2gTi2L+Y3Q7ivCtbtSuXk0SK9Qs doEqA+SX1xY18J8oyNoFg0MtP3KpniVPFTw0tAUyY0tCnrsWqA5bUgOyXR0zVycoFpJ7 5Xim84M5cUpi60hJ8TAiMj9QhEdd1mgk6lYc86bN7hlOOxw/x/Ecgf7J3VyGd3iDtI+6 1ijwbFN+3PFCZhR+ayNJXowinl8M7qq4Sz6tfOSbya1KoFVT+0TVENy5d4zGrC4VbDPf N4BgbSvywE2khizE7BdCADcAsur31dTVHt6UnK/XYFRDltSETzlJtwmh68mmuNsB4g2z +Eig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from:dkim-signature:arc-authentication-results; bh=85EWZ0+NoXM94+fJRBF1Taf7OIRClVAFQXTMOfOHPmw=; b=0vQgfi3yjSVMwAOM073//uDOJFwYg/0a23Y4xdWXq/LwqKDq8a/ltxkoH7lTD44XK0 RUqgM3Q3W+EiNb1nl/eihdj7tb3V89R/itEGTatnQ88yoTacO3gItLo+SyP9PEsQpo34 aCOHrDoqrNs+MSNnITSD8TPmveZaPFgpS6Dm4Z4wVSUrVCxWZHCDfKguYEwAgHogcC1+ GXsifhngJxZEpw3gyknDFxoZaZEr0kVjbx+1i/tEHOcvE7WbhjZuTzvyZa78sAVs/Ing 8y3vcZNjwfFKV+ifa+Hh7OXGRrKFwThPboz1rP48wqz1cp69otzzHjTc2vX61DQ7RbCT L2yw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=Jvtft4yC; 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=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a13si9940604pgd.155.2017.12.19.01.55.59; Tue, 19 Dec 2017 01:55: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=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=Jvtft4yC; 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=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1761662AbdLSJzz (ORCPT + 28 others); Tue, 19 Dec 2017 04:55:55 -0500 Received: from lelnx194.ext.ti.com ([198.47.27.80]:18553 "EHLO lelnx194.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760653AbdLSJzv (ORCPT ); Tue, 19 Dec 2017 04:55:51 -0500 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by lelnx194.ext.ti.com (8.15.1/8.15.1) with ESMTP id vBJ9tkrP029263; Tue, 19 Dec 2017 03:55:46 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1513677346; bh=1hMI0iyDFvCUI/e8oq4hKYMT04FT0rZIeBTbN4S5/7E=; h=From:To:CC:Subject:Date; b=Jvtft4yCowCeUJMsIkQn25GHTidSafeuPrJ+1YVFyt9TlW5KGgiWnuXNXn5+Km/1x zKOX/XWMcNkInW+4KQFOtF3pjRI9RTtw9ponKNOrMOqrppArlafl94cDapobf+4WPx Fv28AVFzDX7wg2etsJf81pMHVnAmDU9DXk12TZCU= Received: from DFLE103.ent.ti.com (dfle103.ent.ti.com [10.64.6.24]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id vBJ9tkXe019599; Tue, 19 Dec 2017 03:55:46 -0600 Received: from DFLE100.ent.ti.com (10.64.6.21) by DFLE103.ent.ti.com (10.64.6.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1261.35; Tue, 19 Dec 2017 03:55:46 -0600 Received: from dlep32.itg.ti.com (157.170.170.100) by DFLE100.ent.ti.com (10.64.6.21) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1261.35 via Frontend Transport; Tue, 19 Dec 2017 03:55:46 -0600 Received: from a0393678ub.india.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep32.itg.ti.com (8.14.3/8.13.8) with ESMTP id vBJ9thKL019515; Tue, 19 Dec 2017 03:55:44 -0600 From: Kishon Vijay Abraham I To: Jingoo Han , Joao Pinto , Lorenzo Pieralisi , Bjorn Helgaas , CC: , , Subject: [PATCH v2] PCI: designware-ep: Fix ->get_msi() to check MSI_EN bit Date: Tue, 19 Dec 2017 15:25:41 +0530 Message-ID: <20171219095541.18838-1-kishon@ti.com> X-Mailer: git-send-email 2.11.0 MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ->get_msi() now checks MSI_EN bit in the MSI CAPABILITY register to find whether the host supports MSI instead of using the MSI ADDRESS in the MSI CAPABILITY register. This fixes the issue with the following sequence 'modprobe pci_endpoint_test' enables MSI 'rmmod pci_endpoint_test' disables MSI but MSI address (in EP's capability register) has a valid value 'modprobe pci_endpoint_test no_msi=1' - Since MSI address (in EP's capability register) has a valid value (set during the previous insertion of the module), EP thinks host supports MSI. Fixes: f8aed6ec624fb436 ("PCI: dwc: designware: Add EP mode support") Signed-off-by: Kishon Vijay Abraham I --- changes from v1: Added a Fixes tag and mentioned MSI address to be set in EP's capability register in the commit log. drivers/pci/dwc/pcie-designware-ep.c | 12 +++--------- drivers/pci/dwc/pcie-designware.h | 1 + 2 files changed, 4 insertions(+), 9 deletions(-) -- 2.11.0 diff --git a/drivers/pci/dwc/pcie-designware-ep.c b/drivers/pci/dwc/pcie-designware-ep.c index d53d5f168363..7c621877a939 100644 --- a/drivers/pci/dwc/pcie-designware-ep.c +++ b/drivers/pci/dwc/pcie-designware-ep.c @@ -197,20 +197,14 @@ static int dw_pcie_ep_map_addr(struct pci_epc *epc, phys_addr_t addr, static int dw_pcie_ep_get_msi(struct pci_epc *epc) { int val; - u32 lower_addr; - u32 upper_addr; struct dw_pcie_ep *ep = epc_get_drvdata(epc); struct dw_pcie *pci = to_dw_pcie_from_ep(ep); - val = dw_pcie_readb_dbi(pci, MSI_MESSAGE_CONTROL); - val = (val & MSI_CAP_MME_MASK) >> MSI_CAP_MME_SHIFT; - - lower_addr = dw_pcie_readl_dbi(pci, MSI_MESSAGE_ADDR_L32); - upper_addr = dw_pcie_readl_dbi(pci, MSI_MESSAGE_ADDR_U32); - - if (!(lower_addr || upper_addr)) + val = dw_pcie_readw_dbi(pci, MSI_MESSAGE_CONTROL); + if (!(val & MSI_CAP_MSI_EN_MASK)) return -EINVAL; + val = (val & MSI_CAP_MME_MASK) >> MSI_CAP_MME_SHIFT; return val; } diff --git a/drivers/pci/dwc/pcie-designware.h b/drivers/pci/dwc/pcie-designware.h index e5d9d77b778e..cb493bcae8b4 100644 --- a/drivers/pci/dwc/pcie-designware.h +++ b/drivers/pci/dwc/pcie-designware.h @@ -101,6 +101,7 @@ #define MSI_MESSAGE_CONTROL 0x52 #define MSI_CAP_MMC_SHIFT 1 #define MSI_CAP_MME_SHIFT 4 +#define MSI_CAP_MSI_EN_MASK 0x1 #define MSI_CAP_MME_MASK (7 << MSI_CAP_MME_SHIFT) #define MSI_MESSAGE_ADDR_L32 0x54 #define MSI_MESSAGE_ADDR_U32 0x58