From patchwork Mon Sep 21 09:36:07 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 53958 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 BE37422B04 for ; Mon, 21 Sep 2015 09:36:21 +0000 (UTC) Received: by lagj9 with SMTP id j9sf40876101lag.0 for ; Mon, 21 Sep 2015 02:36:20 -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:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=KjGRNghzPNFgS+ITM1C3AqsRRJBR7EyfdcLvyWkqLoc=; b=WapAj4w7r8HEmroKNjqLSJqyaSWRKsXLHRfvV1Xd1crbjcHw6SSFRz4N+oSvEiEmhz Y81Xm5911DarqqMrQbalsgpAwUO7VDnQED7852tm48WdMczh9UtYIaioJ0Lm2VyI7BY7 7s8DKYKSdvjB2G5Sgxp+JQB2df7+K3B13/igf6HG2OTwcZxBePK7V5onsGuN4wPlMbmT 9rkmvuup9BFiP5OZK23le7lyiaWuyWgGWkt+GplXWtKvpVV+lkeFH8XeW+8eDzgSnLym Fkw3qQs/Y9+lmFpc9ttiQyGlTcExKNtkNDVZVNkQvoNXnhXCIOimRNZ+AnWnZoyh+X0o MZ0g== X-Gm-Message-State: ALoCoQlbxkf0J3cMfUptC3yRzmlMEcVismXvQ4sfS7e8lTdGE96YMPUfCwPqM04B4ennAPlPyt1k X-Received: by 10.152.4.136 with SMTP id k8mr2591458lak.2.1442828180753; Mon, 21 Sep 2015 02:36:20 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.3.194 with SMTP id e2ls505666lae.49.gmail; Mon, 21 Sep 2015 02:36:20 -0700 (PDT) X-Received: by 10.152.163.98 with SMTP id yh2mr7143944lab.5.1442828180513; Mon, 21 Sep 2015 02:36:20 -0700 (PDT) Received: from mail-lb0-f176.google.com (mail-lb0-f176.google.com. [209.85.217.176]) by mx.google.com with ESMTPS id rj9si15402760lbb.26.2015.09.21.02.36.20 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 Sep 2015 02:36:20 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.176 as permitted sender) client-ip=209.85.217.176; Received: by lbbvu2 with SMTP id vu2so47938503lbb.0 for ; Mon, 21 Sep 2015 02:36:20 -0700 (PDT) X-Received: by 10.152.219.34 with SMTP id pl2mr3013028lac.29.1442828180400; Mon, 21 Sep 2015 02:36:20 -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 w3csp1615905lbq; Mon, 21 Sep 2015 02:36:19 -0700 (PDT) X-Received: by 10.68.95.3 with SMTP id dg3mr24249466pbb.35.1442828177335; Mon, 21 Sep 2015 02:36:17 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id gy9si36428663pbc.83.2015.09.21.02.36.17; Mon, 21 Sep 2015 02:36:17 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-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 S1756586AbbIUJgP (ORCPT + 1 other); Mon, 21 Sep 2015 05:36:15 -0400 Received: from mx2.suse.de ([195.135.220.15]:35740 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756429AbbIUJgO (ORCPT ); Mon, 21 Sep 2015 05:36:14 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id D4335AB1A; Mon, 21 Sep 2015 09:36:12 +0000 (UTC) From: Jiri Slaby To: stable@vger.kernel.org Cc: Grant Likely , Pantelis Antoniou , Wolfram Sang , Rob Herring , Greg Kroah-Hartman , Ricardo Ribalda Delgado , Jiri Slaby Subject: [patch added to the 3.12 stable tree] drivercore: Fix unregistration path of platform devices Date: Mon, 21 Sep 2015 11:36:07 +0200 Message-Id: <1442828169-20794-7-git-send-email-jslaby@suse.cz> X-Mailer: git-send-email 2.5.3 In-Reply-To: <1442828169-20794-1-git-send-email-jslaby@suse.cz> References: <1442828169-20794-1-git-send-email-jslaby@suse.cz> Sender: stable-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: stable@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: patch@linaro.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.176 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 This patch has been added to the 3.12 stable tree. If you have any objections, please let us 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); } }