From patchwork Tue Aug 20 14:36:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea della Porta X-Patchwork-Id: 13770297 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DA113C3DA4A for ; Tue, 20 Aug 2024 14:45:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:To:From:Reply-To: Cc:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=ME6qWihrqgDhoFw7rnf+emxGVj4+uhQv8Lp27J8mM3c=; b=hdCqYUrGVF5+dYqVzzJGr/wt0U ioRFV/i33ScCvYnnVWW4OjEVSGuNqwtV9OlVkSKqKzNPLk+BG4Ne/sEqz2T+/ChTjaQbuV1VtUZMo 7esOk3B9ez31wuMcYxE5Yv0N9utfDhiNTu80bmwjHMEULORKMgvlCeVwB5Spn7tp5wAF3MFlgWzT4 3mqKxaQVO3DtmtJgcUOtbuKAPEfMuAua/1hwjTL9r2MAvqC9D/fx3+v7GKEBMmdygj6lw9CPFMPNi 1y82pQQU0U7om2pqyhk/DAcA0JloZmbHfr75EJxuWTOg92rQHh397k+6gTc1sForvnp2/xCKq4IPl aJcxCu5Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sgQ6t-00000005clE-32KW; Tue, 20 Aug 2024 14:45:23 +0000 Received: from mail-ej1-x635.google.com ([2a00:1450:4864:20::635]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sgPy5-00000005ZwU-3thv for linux-arm-kernel@lists.infradead.org; Tue, 20 Aug 2024 14:36:21 +0000 Received: by mail-ej1-x635.google.com with SMTP id a640c23a62f3a-a80eab3945eso568689866b.1 for ; Tue, 20 Aug 2024 07:36:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1724164576; x=1724769376; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=ME6qWihrqgDhoFw7rnf+emxGVj4+uhQv8Lp27J8mM3c=; b=eI7HCQJR+2m1oTdIl+y8PakPZhDUlmEfVOQrQqsClKQEjkpLHehtuLjQ/T41bOYYUl 84GR0fDrVKrFd0CIPv7cp7BbHw9G5gGoyAbO8T07lVrbR1nwhmgEYGy5JkYMMx1px9vE arTByNdkWZ457dVFhbbto2IFjYysAxVzQzuDAIlw3y/tjb0Q2gLqijSdKpoleodK34oW JA6l4WdNxsr6+fsq3T5UHJjl34vctDxehSIRDKXED8Bafuvdd+Vz7S49sKpdfwatfjxJ UE3YUJb3xFVvtRL8IjBkUcev5aaEp999+LsA6bRSXUn81oA0lN0om6cISALZt7CB+LQ/ ntTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724164576; x=1724769376; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ME6qWihrqgDhoFw7rnf+emxGVj4+uhQv8Lp27J8mM3c=; b=LiwhtaQGhxeIR/L8o0IWztcqeMwfctW1SP59Mbe5R753TPbnau3dheQMxQ9IqJFmJR 2/ys3A80KDPktogr77ll159WNT5Ima4WdTbrYMeX5ibQCLu1MMEiP2mrJ66LbRQpvTaJ 5uTNCLFYkAs/w4EEhlKoZ1tpXZ+yjfHkeVzpGaInQTJWM1CK3574NAVU0FWByspEu7FN h2owCljCwmudqM2ekfWKPl3h0Uw+FH7/srrZpEZ3xjOMnyQ7IgqzmvEqFcbgXSa7FkHj Pjtc1EXUnqiLbwc3hgW6jMXieHJZzeAQ4XSBPhoKyMduhetpn8gJ5MKi1AU840CWnR3B 5wCA== X-Forwarded-Encrypted: i=1; AJvYcCUFJVN4McL8Y3vqjlk4fnK3EdVCrTlS1p8iSnZbNy/XaxmA2PB2tXPFOpDaBpzLinoGLJM9DULM736zgLQTZp4i@lists.infradead.org X-Gm-Message-State: AOJu0YwQDcyvTUKu8F+bb8AUq/X3wvLlncMuJovK4CfpjlQfc1fU7z6+ 8hy44TWgWEPhi7qbWRQKJjPCnRfZ6LGIy/lr/jvQcjItDT3CUIQoPINaxq/Uawo= X-Google-Smtp-Source: AGHT+IF2qH4dP28P5IO8gpA7s40UNOYyhDmMrqE5VSKZ2OTtvuPVd4Y6Vq1UjJSJsr78+uOKo4LfAw== X-Received: by 2002:a17:907:6d0b:b0:a7d:3ce8:131c with SMTP id a640c23a62f3a-a8392a49776mr1063754666b.62.1724164575530; Tue, 20 Aug 2024 07:36:15 -0700 (PDT) Received: from localhost ([87.13.33.30]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a83838cfd5esm768068266b.78.2024.08.20.07.36.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Aug 2024 07:36:15 -0700 (PDT) From: Andrea della Porta To: Andrea della Porta , Michael Turquette , Stephen Boyd , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Florian Fainelli , Broadcom internal kernel review list , Linus Walleij , Catalin Marinas , Will Deacon , Derek Kiernan , Dragan Cvetic , Arnd Bergmann , Greg Kroah-Hartman , Nicolas Ferre , Claudiu Beznea , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Saravana Kannan , Bjorn Helgaas , linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, netdev@vger.kernel.org, linux-pci@vger.kernel.org, linux-arch@vger.kernel.org, Lee Jones , Andrew Lunn , Stefan Wahren Subject: [PATCH 04/11] of: address: Preserve the flags portion on 1:1 dma-ranges mapping Date: Tue, 20 Aug 2024 16:36:06 +0200 Message-ID: <5ca13a5b01c6c737f07416be53eb05b32811da21.1724159867.git.andrea.porta@suse.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240820_073618_135566_E1AC347A X-CRM114-Status: GOOD ( 15.90 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org A missing or empty dma-ranges in a DT node implies a 1:1 mapping for dma translations. In this specific case, rhe current behaviour is to zero out the entire specifier so that the translation could be carried on as an offset from zero. This includes address specifier that has flags (e.g. PCI ranges). Once the flags portion has been zeroed, the translation chain is broken since the mapping functions will check the upcoming address specifier against mismatching flags, always failing the 1:1 mapping and its entire purpose of always succeeding. Set to zero only the address portion while passing the flags through. Signed-off-by: Andrea della Porta --- drivers/of/address.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/of/address.c b/drivers/of/address.c index d669ce25b5f9..5a6d55a67aa8 100644 --- a/drivers/of/address.c +++ b/drivers/of/address.c @@ -443,7 +443,8 @@ static int of_translate_one(struct device_node *parent, struct of_bus *bus, } if (ranges == NULL || rlen == 0) { offset = of_read_number(addr, na); - memset(addr, 0, pna * 4); + /* copy the address while preserving the flags */ + memset(addr + pbus->flag_cells, 0, (pna - pbus->flag_cells) * 4); pr_debug("empty ranges; 1:1 translation\n"); goto finish; }