Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753233AbdFVNV5 (ORCPT ); Thu, 22 Jun 2017 09:21:57 -0400 Received: from mail7.pr.hu ([87.242.0.7]:36394 "EHLO mail7.pr.hu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751546AbdFVNVx (ORCPT ); Thu, 22 Jun 2017 09:21:53 -0400 From: =?UTF-8?q?Zolt=C3=A1n=20B=C3=B6sz=C3=B6rm=C3=A9nyi?= To: linux-kernel@vger.kernel.org Cc: linux-usb@vger.kernel.org, linux-watchdog@vger.kernel.org, linux-i2c@vger.kernel.org, Paul Menzel , Christian Fetzer , Jean Delvare , Nehal Shah , Tim Small , Guenter Roeck , kernel@ekass.net, wim@iguana.be, jlayton@poochiereds.net, marc.2377@gmail.com, cshorler@googlemail.com, wsa@the-dreams.de, regressions@leemhuis.info, =?UTF-8?q?Zolt=C3=A1n=20B=C3=B6sz=C3=B6rm=C3=A9nyi?= Subject: [PATCH 0/5 v4] Fix sp5100_tco watchdog driver regression Date: Thu, 22 Jun 2017 15:21:29 +0200 Message-Id: <20170622132134.7200-1-zboszor@pr.hu> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170621035349.4125-1-zboszor@pr.hu> References: <20170621035349.4125-1-zboszor@pr.hu> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: 2.2 (++) X-Spam-Report: Spam detection software, running on the system "prspamd3.pr.hu", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: This patch series fixes a regression introduced by: commit 2fee61d22e606fc99ade9079fda15fdee83ec33e Author: Christian Fetzer Date: Thu Nov 19 20:13:48 2015 +0100 i2c: piix4: Add support for multiplexed main adapter in SB800 [...] Content analysis details: (2.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.2 ALL_TRUSTED Passed through trusted hosts only via SMTP 3.5 BAYES_99 BODY: Bayes spam probability is 99 to 100% [score: 1.0000] 0.2 BAYES_999 BODY: Bayes spam probability is 99.9 to 100% [score: 1.0000] -1.3 AWL AWL: Adjusted score from AWL reputation of From: address X-Scan-Signature: b4e7b9a57eb5e69049d20469c203f96a X-Spam-Tracer: backend.mail.pr.hu 2.2 20170622132146Z Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3354 Lines: 73 This patch series fixes a regression introduced by: commit 2fee61d22e606fc99ade9079fda15fdee83ec33e Author: Christian Fetzer Date: Thu Nov 19 20:13:48 2015 +0100 i2c: piix4: Add support for multiplexed main adapter in SB800 The regression caused sp5100_tco fail to load: sp5100_tco: SP5100/SB800 TCO WatchDog Timer Driver v0.05 sp5100_tco: PCI Vendor ID: 0x1002, Device ID: 0x4385, Revision ID: 0x42 sp5100_tco: I/O address 0x0cd6 already in use Notable bugzilla links about this issue: https://bugzilla.kernel.org/show_bug.cgi?id=170741 https://bugzilla.redhat.com/show_bug.cgi?id=1369269 https://bugzilla.redhat.com/show_bug.cgi?id=1406844 The previous two versions of this patch series introduced a common mutex to synchronize access to the I/O port pair 0xcd6 / 0xcd7 used by the AMD SB800 USB PCI quirk code and the i2c-piix and sp5100_tco drivers. The common mutex was criticized because it introduces an inter-dependency between drivers. This approach modifies the request_muxed_region() semantics and modifies the possible use cases. The first patch in the series adds a new IORESOURCE_ALLOCATED flag that alloc_resource() sets and free_resource() considers. The core of __request_region() is factored out into a new function that doesn't allocate. With this change, drivers can use the pre-existing DEFINE_RES_IO_NAMED() static initialized macro to declare struct resource statically (e.g. on the stack) and pass the address of it to the new __request_declared_region() function. A new macro called request_declared_muxed_region() was added to exploit this functionality. Because of the new IORESOURCE_ALLOCATED resource flag, release_region() can still be called with the old interface (the port region start and end values) and it won't attempt to free a non-allocated resource. This eliminated one failure case that can come from allocation errors. The second patch modifies the behaviour of IORESOURCE_MUXED, a.k.a. the request_*muxed_region() macros. When these macros are called, the caller goes to sleep when there is any conflicting regions, even if the conflicting region did not use the IORESOURCE_MUXED flag. The kernel logs this inconsistent flag usage with KERN_ERR. This change eliminates the second failure case for IORESOURCE_MUXED and request_muxed_region() can be used like mutex_lock(), i.e. it returns only in case it could successfully request the region. The last three patches adds proper synchronization between the USB PCI quirks code and the i2c-piix and sp5100_tco drivers. The result is that the sp5100_tco driver can load and works again: sp5100_tco: SP5100/SB800 TCO WatchDog Timer Driver v0.05 sp5100_tco: PCI Vendor ID: 0x1002, Device ID: 0x4385, Revision ID: 0x42 sp5100_tco: Using 0xfed80b00 for watchdog MMIO address sp5100_tco: Last reboot was not triggered by watchdog. sp5100_tco: initialized (0xffffba2f4192db00). heartbeat=60 sec (nowayout=0) Signed-off-by: Zoltán Böszörményi --- drivers/i2c/busses/i2c-piix4.c | 41 ++++++++++++------------------------- drivers/usb/host/pci-quirks.c | 4 ++++ drivers/watchdog/sp5100_tco.c | 28 +++++++++++++------------ include/linux/ioport.h | 14 +++++++++++++ kernel/resource.c | 46 ++++++++++++++++++++++++++++++++++++++---- 5 files changed, 88 insertions(+), 45 deletions(-)