From patchwork Fri Oct 2 13:24:36 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 54423 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f72.google.com (mail-la0-f72.google.com [209.85.215.72]) by patches.linaro.org (Postfix) with ESMTPS id 1D24C218EF for ; Fri, 2 Oct 2015 13:29:17 +0000 (UTC) Received: by labjk1 with SMTP id jk1sf48485416lab.0 for ; Fri, 02 Oct 2015 06:29:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:in-reply-to:references :sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=yxJhG+FJa+Lt/E2+lQIxF/dDOAXaAbeasnPr2v2l5dM=; b=ZCEpoAb5gZCdkKeshZfvSsOblfzGWdFjhArcZLEh6pUzaikUV71RXFQX02k6cMMJD0 +WFQsnNcpnk7re7aGVzA0PgPq3w9oGkLeh2qfV/n+RK1J78/ZnPSRbi/jlRKUIWydL/6 pJzmbhJK1Xp9qkY3BWRfLuP5ur5CUOMERvrPSZRyHbXB5tAYhXbNJAsJO8ldcRUbS9Bd By6MFVfQ0xMsI6SWxSVFT+GDEnZfPf69wdlyaUbmsqN6kK/Q6mbHyRUIibTwZFZn7oL+ Yi8ZiCFFj7+9di9yDArjGAsEa+mlaPVCDUOwnr91WNJlp6ixNmLGbcJqZRbm4MHHTuYN eq/Q== X-Gm-Message-State: ALoCoQnQnf/a4W6ok8Jxw+c4fwwYJtz8nSHqcGgNexlKUEyfoVw62srEneg5wYRmAVG9w3h+ZW4u X-Received: by 10.194.156.193 with SMTP id wg1mr2605696wjb.3.1443792555663; Fri, 02 Oct 2015 06:29:15 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.25.163.73 with SMTP id m70ls237982lfe.39.gmail; Fri, 02 Oct 2015 06:29:15 -0700 (PDT) X-Received: by 10.112.147.232 with SMTP id tn8mr3674686lbb.84.1443792555509; Fri, 02 Oct 2015 06:29:15 -0700 (PDT) Received: from mail-lb0-f180.google.com (mail-lb0-f180.google.com. [209.85.217.180]) by mx.google.com with ESMTPS id s5si6236299lbo.86.2015.10.02.06.29.15 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 02 Oct 2015 06:29:15 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.180 as permitted sender) client-ip=209.85.217.180; Received: by lbwr8 with SMTP id r8so26369587lbw.2 for ; Fri, 02 Oct 2015 06:29:15 -0700 (PDT) X-Received: by 10.25.82.10 with SMTP id g10mr3752591lfb.56.1443792555339; Fri, 02 Oct 2015 06:29:15 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.59.35 with SMTP id w3csp1245159lbq; Fri, 2 Oct 2015 06:29:14 -0700 (PDT) X-Received: by 10.66.216.1 with SMTP id om1mr20186123pac.51.1443792554041; Fri, 02 Oct 2015 06:29:14 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g7si16756374pat.209.2015.10.02.06.29.13; Fri, 02 Oct 2015 06:29:14 -0700 (PDT) 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; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753191AbbJBNZt (ORCPT + 30 others); Fri, 2 Oct 2015 09:25:49 -0400 Received: from mx2.suse.de ([195.135.220.15]:39572 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752837AbbJBNZm (ORCPT ); Fri, 2 Oct 2015 09:25:42 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 78B98ACB8; Fri, 2 Oct 2015 13:25:40 +0000 (UTC) From: Jiri Slaby To: stable@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Grant Likely , Pantelis Antoniou , Wolfram Sang , Rob Herring , Greg Kroah-Hartman , Ricardo Ribalda Delgado , Jiri Slaby Subject: [PATCH 3.12 31/84] drivercore: Fix unregistration path of platform devices Date: Fri, 2 Oct 2015 15:24:36 +0200 Message-Id: <65181120e266d3b1bf04d1020774c3510d2f8b82.1443792303.git.jslaby@suse.cz> X-Mailer: git-send-email 2.6.0 In-Reply-To: <4386f737d429451d61358f771e315ed47e2f451f.1443792303.git.jslaby@suse.cz> References: <4386f737d429451d61358f771e315ed47e2f451f.1443792303.git.jslaby@suse.cz> In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: linux-kernel-owner@vger.kernel.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.180 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Grant Likely 3.12-stable review patch. If anyone has any objections, please let me know. =============== commit 7f5dcaf1fdf289767a126a0a5cc3ef39b5254b06 upstream. The unregister path of platform_device is broken. On registration, it will register all resources with either a parent already set, or type==IORESOURCE_{IO,MEM}. However, on unregister it will release everything with type==IORESOURCE_{IO,MEM}, but ignore the others. There are also cases where resources don't get registered in the first place, like with devices created by of_platform_populate()*. Fix the unregister path to be symmetrical with the register path by checking the parent pointer instead of the type field to decide which resources to unregister. This is safe because the upshot of the registration path algorithm is that registered resources have a parent pointer, and non-registered resources do not. * It can be argued that of_platform_populate() should be registering it's resources, and they argument has some merit. However, there are quite a few platforms that end up broken if we try to do that due to overlapping resources in the device tree. Until that is fixed, we need to solve the immediate problem. Cc: Pantelis Antoniou Cc: Wolfram Sang Cc: Rob Herring Cc: Greg Kroah-Hartman Cc: Ricardo Ribalda Delgado Signed-off-by: Grant Likely Tested-by: Ricardo Ribalda Delgado Tested-by: Wolfram Sang Signed-off-by: Rob Herring Signed-off-by: Jiri Slaby --- drivers/base/platform.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/base/platform.c b/drivers/base/platform.c index 4f8bef3eb5a8..413441a2ad4a 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c @@ -344,9 +344,7 @@ int platform_device_add(struct platform_device *pdev) while (--i >= 0) { struct resource *r = &pdev->resource[i]; - unsigned long type = resource_type(r); - - if (type == IORESOURCE_MEM || type == IORESOURCE_IO) + if (r->parent) release_resource(r); } @@ -377,9 +375,7 @@ void platform_device_del(struct platform_device *pdev) for (i = 0; i < pdev->num_resources; i++) { struct resource *r = &pdev->resource[i]; - unsigned long type = resource_type(r); - - if (type == IORESOURCE_MEM || type == IORESOURCE_IO) + if (r->parent) release_resource(r); } }