From patchwork Sun Nov 24 10:05:37 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: 845450 Received: from mail-ej1-f48.google.com (mail-ej1-f48.google.com [209.85.218.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 89AB21885B3 for ; Sun, 24 Nov 2024 10:05:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732442715; cv=none; b=DJRcB9UbbWOsmwpoBFlcl6Na7W3bCRRvdP6TKX5ivM9DR0vdK3cWcSZcZwNqmkh1EnuInRrcF/dspC2s19HQ6J5a9+l53+mctSPijZiHWPO68Bnk3zUOQ3xo2hNtEPQx0qNn2SR02X7cBVoYhgeCtM/NMNMwvEqgchonCgsG97k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732442715; c=relaxed/simple; bh=00GKzIkIov7sWC7YYf/fsmzjuTtHwftcYafHQRVNIQM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=I0nRCCYSf53o0IcXHWfbkcjWKxUTOeDgaJcR6AtRxuhmHNxJ1KT8X2mwiN0MAzddbeAAFzeO3PBd5usyqvdTSiH2TcDMLo4zNnUvc4Y3qkbAfkMgP2qi6rD/oDUCSN1PyhmX/AoVdZVlvACHJMpBe+cSm/2CF4ihfb3DbTQC8jk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=A0CZfEhQ; arc=none smtp.client-ip=209.85.218.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="A0CZfEhQ" Received: by mail-ej1-f48.google.com with SMTP id a640c23a62f3a-aa549f2f9d2so37373366b.3 for ; Sun, 24 Nov 2024 02:05:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1732442712; x=1733047512; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=lk2GE1arbul51a1ynLU7Q9xhqGMt1ZdTPnPwO47t9KY=; b=A0CZfEhQgZuNQ8XUXPzjnRT3zv6xBUgrbIEApsB8YDOs+8YIt6aLdgPxacHdQ6fGrE 4rbfMu2q8qqYnuLIAR1xVGQ9TpkMSD0a2KZh3sQp6U8s85NT1p6PzRiDkCkcxacIPULI PpyvC6I2LjBos1zcw2mVC3LUUUKHC7J65nGvJZfOsfIeULRJyQyWZxMRcDKWVhB8hCG3 jyJM+Ee0ouYLEjtxx49p3j3PxwwUv75dSK0CSD725e4iBtgnBuarA8bLlmM/ZWv+uNTR FiJGb/+P4PLKzu9MD7zgH900QuuWIWC04chcWChMeq5TUNYpN6x14sCDQiQf1UNgirm2 JSrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732442712; x=1733047512; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lk2GE1arbul51a1ynLU7Q9xhqGMt1ZdTPnPwO47t9KY=; b=SiLlT2hUs7RaHUoSZ3gH+NWdfVTSTm/v2x9emschqjLlKzR98hy04uL2DTa88gCuQp quOwxVVj9KOKyiqpp936FWQYoxVk88XJ75xNTkhJLGa6rDhHoB9VtjwkiSIENULrqEY0 zXT0+B6iUXbAEO6x3KGSq3MupLXWOVSQ0AJhoznp8i+dcbtuMDzUYEYx5V8/hI3OgwG1 FgFHHOKFxtbj4BeFjF3OBfFyi6gl+5x4BPi8oGmLvDzrl4qLiMDUpb/Kf0LM9LQiCwI7 nNTyDX2lmJCdh0wmgB+j0AFzKGclOromMPHDEbbKDuGz/BSFYx2DF2aC2DXscF3HyO2T TSRw== X-Forwarded-Encrypted: i=1; AJvYcCWS/xg7MMDtJyAli6B69pyM6+tjTVXhELz1ylf1pp7DigKPurY6kid2V9Eu/1TrdD4pvcQ1VdG4VOS3@vger.kernel.org X-Gm-Message-State: AOJu0Yz4m6i2N69l5bz/g7lZbMA2DFdXpqBTUrDCgfn6VpFJc/ejfZlN ZAccAE8YXRw0I5/Y6ju6n6xEbbeDKUDErjLRYnhUo8rBpGwMeA6X2zU0+7PPT5o= X-Gm-Gg: ASbGncuO1VEoVuflE4uxe2PAFNN7C/9NVV2VQ1DZKebqUwQwgMgbPXqRjFAePDfLkJI XhSAu6wAWiM/VGZlkDaZlLo08oComb9UBAqdJNTmqzCxrw7Y2k+WmZ9qG7QF1RkvrUT58cNFikn v5CBZ3tNHp3dwsZz/seMspNhL9u4nZ681p08UEYkrAbN9GzU2HKO9ojKybEudsg7nOcINEX8yMp FwgFgVFkQ/hEmX3PMnfVnpioqfc76imIBLNvhkLU9u7fBchyhjZgWetgft/tMN8xJyYtusJUV5l YDRBS/AiLDtjJQ1kA/8a X-Google-Smtp-Source: AGHT+IHzhjRJgC4zyn46rADf4coPj01YWTVyf6AHNKqiCSQA366o1m7GZGOpC6OvPXD6QZ4IdkHEbQ== X-Received: by 2002:a17:907:770d:b0:aa5:29ef:3aa6 with SMTP id a640c23a62f3a-aa529ef3b9fmr468828366b.23.1732442711875; Sun, 24 Nov 2024 02:05:11 -0800 (PST) Received: from localhost (host-79-49-220-127.retail.telecomitalia.it. [79.49.220.127]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-aa50b57bda2sm325822466b.146.2024.11.24.02.05.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Nov 2024 02:05:11 -0800 (PST) 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 , Lorenzo Pieralisi , Krzysztof Wilczynski , Manivannan Sadhasivam , Bjorn Helgaas , Linus Walleij , Catalin Marinas , Will Deacon , Bartosz Golaszewski , Derek Kiernan , Dragan Cvetic , Arnd Bergmann , Greg Kroah-Hartman , Saravana Kannan , 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-pci@vger.kernel.org, linux-gpio@vger.kernel.org, Masahiro Yamada , Stefan Wahren , Herve Codina , Luca Ceresoli , Thomas Petazzoni , Andrew Lunn Cc: stable@vger.kernel.org Subject: [PATCH v2 2/2] of: address: Preserve the flags portion on 1:1 dma-ranges mapping Date: Sun, 24 Nov 2024 11:05:37 +0100 Message-ID: X-Mailer: git-send-email 2.44.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-gpio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 A missing or empty dma-ranges in a DT node implies a 1:1 mapping for dma translations. In this specific case, the 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. Fixes: dbbdee94734b ("of/address: Merge all of the bus translation code") Cc: stable@vger.kernel.org Signed-off-by: Andrea della Porta Tested-by: Herve Codina --- 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 286f0c161e33..b3479586bd4d 100644 --- a/drivers/of/address.c +++ b/drivers/of/address.c @@ -455,7 +455,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); + /* set address to zero, pass flags through */ + memset(addr + pbus->flag_cells, 0, (pna - pbus->flag_cells) * 4); pr_debug("empty ranges; 1:1 translation\n"); goto finish; }