From patchwork Wed Nov 22 09:04:27 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: 119439 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp6430868qgn; Wed, 22 Nov 2017 01:06:52 -0800 (PST) X-Google-Smtp-Source: AGs4zMbHlBKv9YJu+yDvioV/qA+u1xWaK2qv65S3e7lDXUqGUkBpr0C/kDOzMNRglmOLBXxSeBHQ X-Received: by 10.101.80.197 with SMTP id s5mr61782pgp.399.1511341612883; Wed, 22 Nov 2017 01:06:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511341612; cv=none; d=google.com; s=arc-20160816; b=H8kq8Gj5Eim8L9uPk4dSfaiBLJ13n5BafzCun0JvqnwFHb/tRpbJjrVa75uHLiEIj/ QMGgBLJ649up3iDje8SiVeE8hZ/UBVpXP4lMzbXZdNYIqAPj2wnvOs/FRQqmDGczf22i BN85XrU0sG8cW3qbetBYxdgkzAO79mykOJJPmpg1F4VkDLH7PyX3Jz9SYGVOZt9zN+lt 9IQhEaqS5JXDGWS/V5MLBtESDAtgJcMMxPCEGARl/CwZCQNuKJ1EASDxe5zVmg9M2Lvq zTpaA3Av0HgYaJUEQcHViiGLlzCoBs9WDQTD2qKoa/TSE4dsor58ajAUMsJ2msBkHY1H 6uhQ== 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=MH0EUsqsM+el5sgl4XFbOP+MU5v+Swp75go0Cr0Svxg=; b=L7/zPqybn/h/tH6ynGn4HcgtS7FztbBqH3XLcxyzLRq4cFujMhNo+LlfFXDAQeG1AB l2iHH3FknGJBaYcexshVRpLWR7lx97zZ1W2DgLmyJG5r2VKeeGUBUkt/vQ13A6u7cCBr de3SgtOIc7e41lJtvkYVrDBRCSSCnvGHPo4ZBD9CFRqKZlCycvKzDXQOkr7jRFmYqGk/ kLgaUN8eX/OXTF0tyGAf4PdQzBbWXGlUMMwtj7sQQnVbSIc5MjJS6X8Y19TTtQ+K6mgl nY0eAp02T8HvKmhYdSYaNJLbP5u9W3ayCkVw7HOzd/plGN1tBMHGpFAx98zCi9dSBwW4 +jRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=AlZYDQPG; 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 b60si8818952plc.391.2017.11.22.01.06.52; Wed, 22 Nov 2017 01:06:52 -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=AlZYDQPG; 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 S1751883AbdKVJGu (ORCPT + 28 others); Wed, 22 Nov 2017 04:06:50 -0500 Received: from lelnx193.ext.ti.com ([198.47.27.77]:31560 "EHLO lelnx193.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751777AbdKVJEp (ORCPT ); Wed, 22 Nov 2017 04:04:45 -0500 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by lelnx193.ext.ti.com (8.15.1/8.15.1) with ESMTP id vAM94W5P023094; Wed, 22 Nov 2017 03:04:32 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1511341472; bh=Wviyy7K/GVPVb7sNPy8m3C2UyOiiQwOjG1yveSAdqWI=; h=From:To:CC:Subject:Date; b=AlZYDQPGHePPMChvi/Csmx30hm4eb34IyQdEr3RY1AEakyAvkdatmfbTbzV6sYN65 r+nlbHQpHu426ubQDkQfTIfmhhNXOhOBpwM1+TTLj+BEm/dKShqj4fpQz60a9mIXO5 bEQEk9CvwYcbMU0RM3amCtlxmtPfs1kxRU3dcv0U= Received: from DFLE100.ent.ti.com (dfle100.ent.ti.com [10.64.6.21]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id vAM94WPi000476; Wed, 22 Nov 2017 03:04:32 -0600 Received: from DFLE101.ent.ti.com (10.64.6.22) by DFLE100.ent.ti.com (10.64.6.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.845.34; Wed, 22 Nov 2017 03:04:32 -0600 Received: from dflp32.itg.ti.com (10.64.6.15) by DFLE101.ent.ti.com (10.64.6.22) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.845.34 via Frontend Transport; Wed, 22 Nov 2017 03:04:32 -0600 Received: from a0393678ub.india.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id vAM94SVg011635; Wed, 22 Nov 2017 03:04:29 -0600 From: Kishon Vijay Abraham I To: Jingoo Han , Joao Pinto , Kishon Vijay Abraham I , Lorenzo Pieralisi , Bjorn Helgaas CC: , , , Xiaowei Bao , Niklas Cassel Subject: [PATCH] PCI: designware-ep: Fix ->get_msi() to check MSI_EN bit Date: Wed, 22 Nov 2017 14:34:27 +0530 Message-ID: <20171122090427.12371-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 has a valid value 'modprobe pci_endpoint_test no_msi=1' - Since MSI address has a valid value (set during the previous insertion of the module), EP thinks host supports MSI. Signed-off-by: Kishon Vijay Abraham I --- 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