Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp287584rwi; Tue, 18 Oct 2022 17:54:35 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6lHj1IfXK1LQpIJKhkn+bYmcfDLcfESdwaqG3TwXHuZo9VrHRWpnEWBcWeSgIBPxH5+UOD X-Received: by 2002:a17:906:ee8e:b0:730:4a24:f311 with SMTP id wt14-20020a170906ee8e00b007304a24f311mr4694131ejb.420.1666140864569; Tue, 18 Oct 2022 17:54:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666140864; cv=none; d=google.com; s=arc-20160816; b=T+FHrX2zI7v2OOP02PYw7Zlbc8VbXxRtvscSwpaAfIFDr9a8AWh9opYPRBSEYJ1bmz oX9ynF+m9BL5yIszS9qmYKSFMG+plnn/X3uy5YfxqjiKpzuZ/Y1u5yZsODenfzM4XXRw TqJAzwGZpTZXvLs9fBXpY9vLBbLO1VYoC6HC4UCBmWSpkYNH7hboQGxTw1w+m0ey/UR6 1MgpC14JCqJ58QN5QAzPbetdR8AfvHKcgA1tG6kXqSZaigMjXjccg6WP5iRyCwNY6ikW TBzQKvnbYo84nkcxSSv5Yc1pEU/EGPjHp/touA+/iMZYawXK5upiAoTfoV8wh/886SZ6 KWDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=+cTVgJVg0IUxMAw+pQIdKwwykPYI/HH5oOQf3vgrQO4=; b=dL8Dwrr56guBzDmdB4lfgHWn9RzkvLuSmtBJJhjSacFR2CiszgTofu69UP+2fB+HnR KHgIloDfM7cU+hpTMVhTz+pzNtmJEio8ORBTwYyx2ryH7WNdzdkDVhVX0osgBUdPWynb o65qjSbt60ky/0vpaoQa+tSsyJOBOrNy9EDUfxGVOGtC1mY+oVtuhI+KgDGaERg3Ptwm 0EAx6h1ckBFc9QjHB/1qTkVuw0FaZDvGZPzxDpDi1/tSSMyOH+keAnwqf80/HGA6hRZg J42867hJC4mm8AX+Fw5Qt2hiWjGELW0ACfQzbOu3AzhYZiYhz/yBzvN+4wjPERjrMGv9 wfxQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x11-20020a05640226cb00b0045d46f28533si11862049edd.377.2022.10.18.17.53.58; Tue, 18 Oct 2022 17:54:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229727AbiJSAmq (ORCPT + 99 others); Tue, 18 Oct 2022 20:42:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56188 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229660AbiJSAmn (ORCPT ); Tue, 18 Oct 2022 20:42:43 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7F85B9AF9B; Tue, 18 Oct 2022 17:42:41 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 2CBEB1042; Tue, 18 Oct 2022 17:42:47 -0700 (PDT) Received: from [192.168.122.164] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 238213F792; Tue, 18 Oct 2022 17:42:40 -0700 (PDT) Message-ID: Date: Tue, 18 Oct 2022 19:41:44 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.0 Subject: Re: [PATCH] ACPI: scan: Fix DMA range assignment Content-Language: en-US To: Robin Murphy , rafael@kernel.org Cc: lvjianmin@loongson.cn, yangyicong@huawei.com, lpieralisi@kernel.org, chenhuacai@loongson.cn, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, lenb@kernel.org References: From: Jeremy Linton In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On 10/18/22 08:14, Robin Murphy wrote: > Assigning the device's dma_range_map from the iterator variable after > the loop means it always points to the empty terminator at the end of > the map, which is not what we want. Similarly, freeing the iterator on > error when it points to somwhere in the middle of the allocated array > won't work either. Fix this. This fixes the boot problem on both SoC generations of the rpi4+ACPI, Thanks, Tested-by: Jeremy Linton > > Fixes: bf2ee8d0c385 ("ACPI: scan: Support multiple DMA windows with different offsets") > Signed-off-by: Robin Murphy > --- > drivers/acpi/scan.c | 7 ++++--- > 1 file changed, 4 insertions(+), 3 deletions(-) > > diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c > index 558664d169fc..024cc373a197 100644 > --- a/drivers/acpi/scan.c > +++ b/drivers/acpi/scan.c > @@ -1509,9 +1509,12 @@ int acpi_dma_get_range(struct device *dev, const struct bus_dma_region **map) > goto out; > } > > + *map = r; > + > list_for_each_entry(rentry, &list, node) { > if (rentry->res->start >= rentry->res->end) { > - kfree(r); > + kfree(*map); > + *map = NULL; > ret = -EINVAL; > dev_dbg(dma_dev, "Invalid DMA regions configuration\n"); > goto out; > @@ -1523,8 +1526,6 @@ int acpi_dma_get_range(struct device *dev, const struct bus_dma_region **map) > r->offset = rentry->offset; > r++; > } > - > - *map = r; > } > out: > acpi_dev_free_resource_list(&list);