Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp4920936ybv; Wed, 26 Feb 2020 05:21:50 -0800 (PST) X-Google-Smtp-Source: APXvYqw4nlD/ZCkcqXDdciGUeZCigjk257MWn3HjV9AYE1v7aNAszXWhHA+2fl7mijBDlheqVgyt X-Received: by 2002:aca:c256:: with SMTP id s83mr3151111oif.57.1582723309956; Wed, 26 Feb 2020 05:21:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582723309; cv=none; d=google.com; s=arc-20160816; b=P8KWkRzyHtA8OvzW6bqjAXd+/PqBSORRR+yrlPgBUKfy1/JlOVRmi4Mdh9dAxlHFgT CO7I8on59Zq9V0ugtXNgLVeHjJ3/13tw14yyM/8H0Fr6VAef5gglLBaDqsFUvmJBbGYD SkTbc9q0QY169LToK/autkNVioB8a6y8gpXGigFE7Is5JnEW67n46bodZkcYGd+chc/S JalQDXz5G6GRcO3lfOiijXdyZU8pck3/n2KdBSBNrxw2RDQ/FROTQ5DJTUpKddoI7yc3 0fbpwZuR++8UKcFCIfxIgbby5iNeP6Qc1z9cEqwNLJPXUd/OCxdzngiKwlr4gnDrpHI5 H6Eg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=Fy52SQINJzSPO6qyI5wghT7d3mupE8hGQ8oLBB47Vjs=; b=XI1GeiY/UoNBqfsrxITQdZgDXr5Ch7r907WR6HQyllh1soELRVAxPFYQ068xtQN59P 4eEohvXehgbwOXnPelMsmTausVrO55z4xN1ubdGktA2XWLm4R9SZ8s5Sj8YKKOUBLSDc eOK9eWeORQ5G/5jTT1Cp0Jrj50EnmnWKrG0+K9z0eXYz43HnqtTL3nS9Uk1j4QTLkiOR C0CMpdJxUsQBcN+ICUpyv5CNALQSzzCJPtO77RzIA3Gi3XIEp9UUn4zZlZndBOLhhwld 1/8xaQrffx9+zSykeSzgRfOCmqKqfUxpdOtOel4kBss//ch/xjw8Vk1GpWc7UJgN5aAe m56A== ARC-Authentication-Results: i=1; mx.google.com; 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=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o1si1268868otk.154.2020.02.26.05.21.37; Wed, 26 Feb 2020 05:21:49 -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; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727047AbgBZNV3 (ORCPT + 99 others); Wed, 26 Feb 2020 08:21:29 -0500 Received: from mga02.intel.com ([134.134.136.20]:17462 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726277AbgBZNV2 (ORCPT ); Wed, 26 Feb 2020 08:21:28 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Feb 2020 05:21:27 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,488,1574150400"; d="scan'208";a="410603466" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga005.jf.intel.com with ESMTP; 26 Feb 2020 05:21:23 -0800 Received: by black.fi.intel.com (Postfix, from userid 1001) id BA74044B; Wed, 26 Feb 2020 15:21:22 +0200 (EET) From: Mika Westerberg To: Guenter Roeck , Jean Delvare , Wim Van Sebroeck , Wolfram Sang Cc: Martin Volf , Andy Shevchenko , Jarkko Nikula , Mika Westerberg , linux-i2c@vger.kernel.org, linux-hwmon@vger.kernel.org, linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 3/3] i2c: i801: Do not add ICH_RES_IO_SMI for the iTCO_wdt device Date: Wed, 26 Feb 2020 16:21:22 +0300 Message-Id: <20200226132122.62805-4-mika.westerberg@linux.intel.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200226132122.62805-1-mika.westerberg@linux.intel.com> References: <20200226132122.62805-1-mika.westerberg@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Martin noticed that nct6775 driver does not load properly on his system in v5.4+ kernels. The issue was bisected to commit b84398d6d7f9 ("i2c: i801: Use iTCO version 6 in Cannon Lake PCH and beyond") but it is likely not the culprit because the faulty code has been in the driver already since commit 9424693035a5 ("i2c: i801: Create iTCO device on newer Intel PCHs"). So more likely some commit that added PCI IDs of recent chipsets made the driver to create the iTCO_wdt device on Martins system. The issue was debugged to be PCI configuration access to the PMC device that is not present. This returns all 1's when read and this caused the iTCO_wdt driver to accidentally request resourses used by nct6775. It turns out that the SMI resource is only required for some ancient systems, not the ones supported by this driver. For this reason do not populate the SMI resource at all and drop all the related code. The driver now always populates the main I/O resource and only in case of SPT (Intel Sunrisepoint) compatible devices it adds another resource for the NO_REBOOT bit. These two resources are of different types so platform_get_resource() used by the iTCO_wdt driver continues to find the both resources at index 0. Link: https://lore.kernel.org/linux-hwmon/CAM1AHpQ4196tyD=HhBu-2donSsuogabkfP03v1YF26Q7_BgvgA@mail.gmail.com/ Fixes: 9424693035a5 ("i2c: i801: Create iTCO device on newer Intel PCHs") Reported-by: Martin Volf Signed-off-by: Mika Westerberg --- drivers/i2c/busses/i2c-i801.c | 45 ++++++++++------------------------- 1 file changed, 12 insertions(+), 33 deletions(-) diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c index ca4f096fef74..a9c03f5c3482 100644 --- a/drivers/i2c/busses/i2c-i801.c +++ b/drivers/i2c/busses/i2c-i801.c @@ -132,11 +132,6 @@ #define TCOBASE 0x050 #define TCOCTL 0x054 -#define ACPIBASE 0x040 -#define ACPIBASE_SMI_OFF 0x030 -#define ACPICTRL 0x044 -#define ACPICTRL_EN 0x080 - #define SBREG_BAR 0x10 #define SBREG_SMBCTRL 0xc6000c #define SBREG_SMBCTRL_DNV 0xcf000c @@ -1553,7 +1548,7 @@ i801_add_tco_spt(struct i801_priv *priv, struct pci_dev *pci_dev, pci_bus_write_config_byte(pci_dev->bus, devfn, 0xe1, hidden); spin_unlock(&p2sb_spinlock); - res = &tco_res[ICH_RES_MEM_OFF]; + res = &tco_res[1]; if (pci_dev->device == PCI_DEVICE_ID_INTEL_DNV_SMBUS) res->start = (resource_size_t)base64_addr + SBREG_SMBCTRL_DNV; else @@ -1563,7 +1558,7 @@ i801_add_tco_spt(struct i801_priv *priv, struct pci_dev *pci_dev, res->flags = IORESOURCE_MEM; return platform_device_register_resndata(&pci_dev->dev, "iTCO_wdt", -1, - tco_res, 3, &spt_tco_platform_data, + tco_res, 2, &spt_tco_platform_data, sizeof(spt_tco_platform_data)); } @@ -1576,17 +1571,16 @@ static struct platform_device * i801_add_tco_cnl(struct i801_priv *priv, struct pci_dev *pci_dev, struct resource *tco_res) { - return platform_device_register_resndata(&pci_dev->dev, "iTCO_wdt", -1, - tco_res, 2, &cnl_tco_platform_data, - sizeof(cnl_tco_platform_data)); + return platform_device_register_resndata(&pci_dev->dev, + "iTCO_wdt", -1, tco_res, 1, &cnl_tco_platform_data, + sizeof(cnl_tco_platform_data)); } static void i801_add_tco(struct i801_priv *priv) { - u32 base_addr, tco_base, tco_ctl, ctrl_val; struct pci_dev *pci_dev = priv->pci_dev; - struct resource tco_res[3], *res; - unsigned int devfn; + struct resource tco_res[2], *res; + u32 tco_base, tco_ctl; /* If we have ACPI based watchdog use that instead */ if (acpi_has_watchdog()) @@ -1601,30 +1595,15 @@ static void i801_add_tco(struct i801_priv *priv) return; memset(tco_res, 0, sizeof(tco_res)); - - res = &tco_res[ICH_RES_IO_TCO]; - res->start = tco_base & ~1; - res->end = res->start + 32 - 1; - res->flags = IORESOURCE_IO; - /* - * Power Management registers. + * Always populate the main iTCO IO resource here. The second entry + * for NO_REBOOT MMIO is filled by the SPT specific function. */ - devfn = PCI_DEVFN(PCI_SLOT(pci_dev->devfn), 2); - pci_bus_read_config_dword(pci_dev->bus, devfn, ACPIBASE, &base_addr); - - res = &tco_res[ICH_RES_IO_SMI]; - res->start = (base_addr & ~1) + ACPIBASE_SMI_OFF; - res->end = res->start + 3; + res = &tco_res[0]; + res->start = tco_base & ~1; + res->end = res->start + 32 - 1; res->flags = IORESOURCE_IO; - /* - * Enable the ACPI I/O space. - */ - pci_bus_read_config_dword(pci_dev->bus, devfn, ACPICTRL, &ctrl_val); - ctrl_val |= ACPICTRL_EN; - pci_bus_write_config_dword(pci_dev->bus, devfn, ACPICTRL, ctrl_val); - if (priv->features & FEATURE_TCO_CNL) priv->tco_pdev = i801_add_tco_cnl(priv, pci_dev, tco_res); else -- 2.25.0