From patchwork Mon Oct 7 12:39:49 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: 13824643 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 95310CFB43F for ; Mon, 7 Oct 2024 13:03:09 +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=wmMJCoFVCCoMSDMdNDybyaBIx5hGSa7lQNj9sEKg2KA=; b=lBx0vGvH/n0DvXjFOg1I/xkFsR ns7T07y+wtbxqRtr9jPgDSupHAv103/slX1/1oQXEx/umhSRyQmaDHaybFFr6mO+CnsuD4Ur3X6Z5 GXsiRhb5eb6895wtvZSgbOvceKTL6HHzsABPHx2udjzckh5g3otNQ+IcYVdduXJ8pLh++FCIQQaKZ l9lqRblwhC7qg/N7SAJlh9WyMn2GuoG/k/P18uw9tpXMX+T62z9dy8lm++Bh9l114SBUlOHEUFPI3 2vELlhK12lhNH7BxLVoYR4896oUzVIAOfm6rWM+hOvRylUdtqR9PrD/YsGenZgBeg4u4qyrnMDtXZ /3a65U/Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1sxnO6-00000002R0u-1Eas; Mon, 07 Oct 2024 13:02:58 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1sxn1r-00000002Mcs-2mMp for linux-arm-kernel@bombadil.infradead.org; Mon, 07 Oct 2024 12:39:59 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-ID:Date:Subject:To:From:Sender:Reply-To:Cc: Content-Type:Content-ID:Content-Description; bh=wmMJCoFVCCoMSDMdNDybyaBIx5hGSa7lQNj9sEKg2KA=; b=MOn7uRaw+08HwipyABmI3n6jAr EeknMZtdCjkJTcE+xmv0v0oLB+SHjgW0PNL17zAxDLAzN3WA4RsqsqGIHuOxCoB2nhZ1TwC97Hp7t dSF7fOOZUS7ta38kSNlLMnVSppLsx5w5nY1iXxa8KkvK1JSRmSracn6CsBLhkbzDBocso4N1ubTVj q1NuGfPWOBC86udRrkXJqDoLIoH01W65dKGMHG8lLld4J09beYz2lejF1Wj25z8fNAne6JPq11kmQ AlG7k/91seGmtZW9eeIQvIEVW+k49so/xV9NDJfb2iqVa7CNqaWyJxFAttHc+UGtizmdPP0lRSbej fM8ZwKAA==; Received: from mail-ej1-x633.google.com ([2a00:1450:4864:20::633]) by desiato.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1sxn1m-00000004PyY-2JOI for linux-arm-kernel@lists.infradead.org; Mon, 07 Oct 2024 12:39:58 +0000 Received: by mail-ej1-x633.google.com with SMTP id a640c23a62f3a-a8d446adf6eso740299666b.2 for ; Mon, 07 Oct 2024 05:39:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1728304792; x=1728909592; 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=wmMJCoFVCCoMSDMdNDybyaBIx5hGSa7lQNj9sEKg2KA=; b=QGJmEE2JlPjc3qPzMXGMeNd1vN59Yb6uHY4V2kepzfo01cuC/23hBdXobEoJzwG31a LnxIXb9tKODfVjSWRBSpbfBaJm4S+C9yu9bB1uwIs3sd35VqssSlk/J3u+Mun6rHSecz B4nVulSxWlStxttu7/yMcTfZknfA6lnqVTSSZhRgny3sfi/MlfS8R4MxPw3LTrgJHpok PtqlHBetil2YNggrvAdxOe8gLbgiz2A8EHs9IH/rG3x88RCoCM8VqyAXDZJAFa5irJVH ngSNCTZA2OstXPrZ2T8slmtafaja+DmAVveg8+T8cjqTrRgk1TqxTJ5FDkqUp5L6AmPn zGfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728304792; x=1728909592; 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=wmMJCoFVCCoMSDMdNDybyaBIx5hGSa7lQNj9sEKg2KA=; b=TC+m1KHG6CMqSAelIh8itSB3zQBR3h2MUKwaI971uDQVkTbU1stVYo2MLtLOPKEGA/ gv1icS3lrs3nX1yzLbtAOGzj8aE5girJzdy6zO7JX0uhlUWYiazUtErLkMcK6WP9NDnk vGq+6QoBG//hR0QHySJLxfCDmV5cCErfZcAVQ18kflmDsjvMflaSUUZYSdJLogU6ls/P WZ2bvqqtP3bFVjYecsHlH5GeOCQaaFpKxaJFN9iymmzp5GE7CXS3gH/3pHzSkrhSproI KbG9GAGpGWuem0mzhycGZC4cDFF07fKM9o5pw4vM+lrWzs0oSyx74EzhEmTQtH92cB3l cDag== X-Forwarded-Encrypted: i=1; AJvYcCUsp9NdpMGq+ZFXGXN9qrxgFyaloXUvg7yh6VZa5Ps9Hqfp5i6HZtDzUSxXglqF/4XpmSa9zmFaBh9YovownYEo@lists.infradead.org X-Gm-Message-State: AOJu0YypTjKO+Hkp4m5kMhBndCV1t+AEolcOKYTD49YiqUoSTULhPASv ytx6dlgPdtR0UVh0A8q04eDadnn6p8Eu6QL7xt3RKsLFbN6fyu9mFJe/rvadsUs= X-Google-Smtp-Source: AGHT+IHTBvg5M5ry0Kp6n2llss528AG1tMlkKm6Eq4xV0RUgVViw5ZHoodaCTq7bcUKV0kUcKhVe+w== X-Received: by 2002:a17:907:7da7:b0:a99:4a8f:c83f with SMTP id a640c23a62f3a-a994a8fca5amr566416566b.5.1728304792074; Mon, 07 Oct 2024 05:39:52 -0700 (PDT) Received: from localhost (host-87-21-212-62.retail.telecomitalia.it. [87.21.212.62]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a992e664fb9sm377591066b.88.2024.10.07.05.39.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Oct 2024 05:39:51 -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 , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84?= =?utf-8?q?ski?= , 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 Subject: [PATCH v2 06/14] of: address: Preserve the flags portion on 1:1 dma-ranges mapping Date: Mon, 7 Oct 2024 14:39:49 +0200 Message-ID: <3bda3b90df5a36cc902213383287e79b34195485.1728300189.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-20241007_133954_789350_F20EAAA2 X-CRM114-Status: GOOD ( 15.86 ) 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, 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. Signed-off-by: Andrea della Porta --- This patch still lacks an entry in the DT unittest. 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..72b6accff21c 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); + /* 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; }