From patchwork Fri Dec 18 14:20:28 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 7886171 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id AA62E9F387 for ; Fri, 18 Dec 2015 15:01:47 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A076020416 for ; Fri, 18 Dec 2015 15:01:46 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 82039204AB for ; Fri, 18 Dec 2015 15:01:41 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1a9wVu-0007mn-SJ; Fri, 18 Dec 2015 15:00:10 +0000 Received: from mailout3.w1.samsung.com ([210.118.77.13]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1a9vtv-0000vw-8y for linux-arm-kernel@lists.infradead.org; Fri, 18 Dec 2015 14:21:02 +0000 Received: from eucpsbgm2.samsung.com (unknown [203.254.199.245]) by mailout3.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0NZK00FP3566FK70@mailout3.w1.samsung.com> for linux-arm-kernel@lists.infradead.org; Fri, 18 Dec 2015 14:20:30 +0000 (GMT) X-AuditID: cbfec7f5-f79b16d000005389-54-5674162e8a3c Received: from eusync3.samsung.com ( [203.254.199.213]) by eucpsbgm2.samsung.com (EUCPMTA) with SMTP id D4.44.21385.E2614765; Fri, 18 Dec 2015 14:20:30 +0000 (GMT) Received: from [106.116.147.30] by eusync3.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0NZK00CIC5651CA0@eusync3.samsung.com>; Fri, 18 Dec 2015 14:20:30 +0000 (GMT) Subject: Re: -next regression: "driver cohandle -EPROBE_DEFER from bus_type.match()" To: Russell King - ARM Linux , Dan Williams References: <20151217184641.GI8644@n2100.arm.linux.org.uk> From: Marek Szyprowski Message-id: <5674162C.6050801@samsung.com> Date: Fri, 18 Dec 2015 15:20:28 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.4.0 MIME-version: 1.0 In-reply-to: <20151217184641.GI8644@n2100.arm.linux.org.uk> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrHLMWRmVeSWpSXmKPExsVy+t/xq7p6YiVhBitXKVhsnLGe1WL61AuM FpseX2O1uLxrDpvF9DMv2S1uX+a12Lr3KrtF39pLbA4cHi3NPWwejTdusHnsuLuE0WPxnpdM HpuX1HtMuvCY2aNvyypGj8+b5AI4orhsUlJzMstSi/TtErgytr7oYy/YKFcx/etepgbGFxJd jJwcEgImErubljFD2GISF+6tZ+ti5OIQEljKKLFq1w1WCOc5o8SmY5vYQaqEBcIk/tyaxwJi iwgkSCxbtIQZoqiZUaJx/1xWkASzwFkmibMPI0FsNgFDia63XUBjOTh4BbQk3ryRAwmzCKhK 9J/7wgZiiwrESDxevBWslVdAUOLH5Htg8zkFrCVmv/nBBDHSTOLLy8NQ4+UlNq95yzyBUWAW kpZZSMpmISlbwMi8ilE0tTS5oDgpPddIrzgxt7g0L10vOT93EyMkFr7uYFx6zOoQowAHoxIP 7w3m4jAh1sSy4srcQ4wSHMxKIrybhErChHhTEiurUovy44tKc1KLDzFKc7AoifPO3PU+REgg PbEkNTs1tSC1CCbLxMEp1cBoFnntnJffrv0Cqn2ZEtzLS3Zkv920c/4N3axTW949Lp8vK7xV pep2++X09gs5Oy+pNUn0cLEvPbTF4FdQ82l/m5l97SeCV25M7nSYqXXfv3nees2tAR/7fl3z XG+fpHXh4vo9q77dnRJZt31pAAfH6flXtDbN6n9gd0+c/VPwC6vKdqW3U76lKrEUZyQaajEX FScCAOCc3amBAgAA X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151218_062055_864767_179F00A0 X-CRM114-Status: GOOD ( 24.60 ) X-Spam-Score: -6.9 (------) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Stephen Rothwell , tomeu.vizoso@collabora.com, Bartlomiej Zolnierkiewicz , "linux-nvdimm@lists.01.org" , "linux-kernel@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Hello, On 2015-12-17 19:46, Russell King - ARM Linux wrote: > On Thu, Dec 17, 2015 at 07:51:14AM -0800, Dan Williams wrote: >> The commit below causes the libnvdimm sub-system to stop loading. >> This is due to the fact that nvdimm_bus_match() returns the result of >> test_bit() which may be negative. If there are any other bus match >> functions using test_bit they may be similarly impacted. >> >> Can we queue a fixup like the following to libnvdimm, and maybe >> others, ahead of this driver core change? > This is rather annoying. Have we uncovered a latent bug in other > architectures? Well, looking through the test_bit() implementations, > it looks like it. > > I'll drop the patch set for the time being, we can't go around breaking > stuff like this. However, I think the test_bit() result should be > regularised across different architectures - it _looks_ to me like most > implementations return 0/1 values, but there may be some that don't > (maybe the assembly versions?) I've checked all the functions assigned to match entry of struct bus_type objects and found that there are only 4 such functions that don't return 0/1 values: 1. arch/arm/common/sa1111.c: sa1111_match -> result of bitwise & 2. drivers/nvdimm/bus.c: nvdimm_bus_match -> result of test_bit() 3. drivers/sh/superhyway/superhyway.c: superhyway_bus_match -> error codes (this is really funny case, all errors are resolved to 'matched' case) 4. drivers/staging/unisys/visorbus/visorbus_main.c: visorbus_match -> 0 and some positive integer values, safe for now The list of functions that I've examined has been generated by following command: $ git grep -Pp "\.match\s" | grep -A1 bus_type | grep "\.match\s" | tr -s "\t;&,=:" " " | cut -d" " -f1,3 Only the first two functions require potential fixing to ensure that correct match will not result in negative return value, so the following extension to the patch proposed by Dan Williams fixes all of them: From: Marek Szyprowski Date: Fri, 18 Dec 2015 15:17:12 +0100 Subject: [PATCH] drivers: ensure no negative value gets returned on positive match Commit 09a14906a26e454cad7ff0ad96af40fc4cd90eb0 "ARM: 8472/1: driver cohandle -EPROBE_DEFER from bus_type.match()") added support for returning error values from bus_match callback. This patch ensures that all existing match callbacks don't return negative values (potential errors) in case of positive match. Suggested-by: Dan Williams Signed-off-by: Marek Szyprowski --- arch/arm/common/sa1111.c | 2 +- drivers/nvdimm/bus.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) static struct module *to_bus_provider(struct device *dev) -- 1.9.2 Best regards diff --git a/arch/arm/common/sa1111.c b/arch/arm/common/sa1111.c index 3d22494..fb0a0a4 100644 --- a/arch/arm/common/sa1111.c +++ b/arch/arm/common/sa1111.c @@ -1290,7 +1290,7 @@ static int sa1111_match(struct device *_dev, struct device_driver *_drv) struct sa1111_dev *dev = SA1111_DEV(_dev); struct sa1111_driver *drv = SA1111_DRV(_drv); - return dev->devid & drv->devid; + return !!(dev->devid & drv->devid); } static int sa1111_bus_suspend(struct device *dev, pm_message_t state) diff --git a/drivers/nvdimm/bus.c b/drivers/nvdimm/bus.c index 7e2c43f..2b2181c 100644 --- a/drivers/nvdimm/bus.c +++ b/drivers/nvdimm/bus.c @@ -62,7 +62,7 @@ static int nvdimm_bus_match(struct device *dev, struct device_driver *drv) { struct nd_device_driver *nd_drv = to_nd_device_driver(drv); - return test_bit(to_nd_device_type(dev), &nd_drv->type); + return !!test_bit(to_nd_device_type(dev), &nd_drv->type); }