Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3180690pxj; Mon, 7 Jun 2021 04:32:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzZmV8PhHOqZzoGR+vGRAHSUqxxu0vFTijMdCVGRmyzGh+FmkurDS9O1PklKzp9H8vT57NZ X-Received: by 2002:a17:906:6712:: with SMTP id a18mr15026841ejp.334.1623065541433; Mon, 07 Jun 2021 04:32:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623065541; cv=none; d=google.com; s=arc-20160816; b=xE29PDh5kk8fx0Glr3ik/SllRMpDW7n46L3Hqn88myH6niIVeZ0vOdjZfcKKZY0pN7 YjzQicrQNj3baklPetsawC4cJICT01OXkjP3/7V0/tjFBMDQcXrAboMhCISS0xhS/Ezp JhJW0Q+i1VIMSTcRLIbu/vWrbkGDcJE+hXEBqSWonZcwoiJl80YRuXee6k/Yl0SqpIgE pxK9BSNtZ/g/cvRgN7k9Hs9JyZ4ifRdHm1mjzJfM3JnjyQjJer7456423aUBQzXSJ0d8 9wtDozRl3nlTex0lO/FqG7zKnX6oktjXF8XxDj7LYiP/Hi5aoUpz/6CXaAJ3ebAX4IBN Kgew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Rvzb4qtGRQUWi/ckS9nOcXRKxlM0Wnl5P5x853tHbFI=; b=RiKb/bIms9si4zzvueHMXI5G1/VZnoMDgu9qLZCmItSvcmacIVN3X20lqCOFUFcHCY 45Owh/jG3ZBXHZr+lHR+4kSZHGyCPsiEGlfeCHEVuEh4F8xka2RBz1TP3w7YpynYRPjL O+0HvpIFgWdKA0Dz6pCn+NXaFr08BE+zE1CKy8APVISCil6u+Tjslu1dLOTaEgUkpXo0 gGGF1cr29Bqwbzxt+yehJ8VyxbmPGcNE1Y/GZOz21tGkSVF17mAHmDX3flSBN6mW5S1+ iiNj4lR/IB9piQqGtAI/4RvsJYGPWM7hQFK2K1fuTzVbbhf7k7l5F8G27p5YErO2gZvm 6PuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=WVWBYvsx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 6si6125496ejm.411.2021.06.07.04.31.57; Mon, 07 Jun 2021 04:32:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=WVWBYvsx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231497AbhFGLbL (ORCPT + 99 others); Mon, 7 Jun 2021 07:31:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230314AbhFGLbK (ORCPT ); Mon, 7 Jun 2021 07:31:10 -0400 Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CCE46C061766; Mon, 7 Jun 2021 04:29:19 -0700 (PDT) Received: by mail-pj1-x1031.google.com with SMTP id g24so9618304pji.4; Mon, 07 Jun 2021 04:29:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Rvzb4qtGRQUWi/ckS9nOcXRKxlM0Wnl5P5x853tHbFI=; b=WVWBYvsx5qebQs4uhxeWPTzu+987IycgSJNvyTphaVZrETj044Iw58W6NbDZyHgxse r5AwKefCsExOVbY3OQaHaijWhGJm8Bnd3b5eNIibKARMPxmBXDeW4f5d5cyyg9z5I8ZF FDXjSJKyFIJRfk/JsSNyibt2LYfBdRNPDxyH9PqyZF7pIrTwge0x9S0P/r9cgwHkA6oQ 3d6DKAIwRz1+GjxMzI7diW4cIGU7BEajxdieRXURAaE+C5ROu6UCtr3WjkCKLMMEG6FP OTOdGOndNHpnmHg8xUpabWofMjMoq1m+VrGTY4DAqSx7dRBD6hqm6PB58wsTlNMIlUVx exKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Rvzb4qtGRQUWi/ckS9nOcXRKxlM0Wnl5P5x853tHbFI=; b=opmalnwmCmsohDuuELLdqtocopjMQyzRUb31DzwRgZxrM4IIz8efgX+exrFKXCDnCJ oXUrkWtJBxzOzy+EjXguUg4ZDFCKwmiyq+lz3zWMPfKfQHI7bl08AKE4CA/020qWAYb0 e3Q1iOG1evNWq28f93/89tVu7IxGU8IX/PWil9IwVE/v8/4u4VoekxOU96HefFyv4c7M MbNdSmtTzb7N+z4w4kbP8b1XWuLf+IHWSCH3hbdyy1JttsvXHvSK0IoQYdkX1SIqXi/4 AnZyHXy+LXGXXbcW9B7Yo1hQTqFvon1Lz1vX1NQ0lYrBjge26XgYUwdErPWZgZLU/pd0 MvZg== X-Gm-Message-State: AOAM531g0Ut6uzWMgHxjC4vIxUSZtdoE/MrnU/CX64AtFRZmpe1tZNvN 8ErAdvFqrlotbWcSOazuiXE= X-Received: by 2002:a17:90a:7e84:: with SMTP id j4mr32325306pjl.101.1623065359403; Mon, 07 Jun 2021 04:29:19 -0700 (PDT) Received: from localhost (122x211x248x161.ap122.ftth.ucom.ne.jp. [122.211.248.161]) by smtp.gmail.com with ESMTPSA id d23sm1725619pjz.15.2021.06.07.04.29.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Jun 2021 04:29:18 -0700 (PDT) From: Punit Agrawal To: helgaas@kernel.org, robh+dt@kernel.org Cc: Punit Agrawal , linux-rockchip@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, alexandru.elisei@arm.com, wqu@suse.com, robin.murphy@arm.com, pgwipeout@gmail.com, ardb@kernel.org, briannorris@chromium.org, shawn.lin@rock-chips.com, Vidya Sagar Subject: [PATCH v3 3/4] PCI: of: Refactor the check for non-prefetchable 32-bit window Date: Mon, 7 Jun 2021 20:28:55 +0900 Message-Id: <20210607112856.3499682-4-punitagrawal@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210607112856.3499682-1-punitagrawal@gmail.com> References: <20210607112856.3499682-1-punitagrawal@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Recently, an override was added for non-prefetchable host bridge windows below 4GB that have the 64-bit address attribute set. As many of the conditions for the check overlap with the check for non-prefetchable window size, refactor the code to unify the ranges validation into devm_of_pci_get_host_bridge_resources(). As an added benefit, the warning message is now printed right after the range mapping giving the user a better indication of where the issue is. Signed-off-by: Punit Agrawal Tested-by: Alexandru Elisei Cc: Vidya Sagar --- drivers/pci/of.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/pci/of.c b/drivers/pci/of.c index 38fe2589beb0..0580c654127e 100644 --- a/drivers/pci/of.c +++ b/drivers/pci/of.c @@ -355,11 +355,15 @@ static int devm_of_pci_get_host_bridge_resources(struct device *dev, *io_base = range.cpu_addr; } else if (resource_type(res) == IORESOURCE_MEM) { if (!(res->flags & IORESOURCE_PREFETCH)) { - if (res->flags & IORESOURCE_MEM_64) + if (res->flags & IORESOURCE_MEM_64) { if (!upper_32_bits(range.pci_addr + range.size - 1)) { dev_warn(dev, "Clearing 64-bit flag for non-prefetchable memory below 4GB\n"); res->flags &= ~IORESOURCE_MEM_64; } + } else { + if (upper_32_bits(resource_size(res))) + dev_warn(dev, "Memory resource size exceeds max for 32 bits\n"); + } } } @@ -579,12 +583,6 @@ static int pci_parse_request_of_pci_ranges(struct device *dev, break; case IORESOURCE_MEM: res_valid |= !(res->flags & IORESOURCE_PREFETCH); - - if (!(res->flags & IORESOURCE_PREFETCH)) - if (!(res->flags & IORESOURCE_MEM_64) && - upper_32_bits(resource_size(res))) - dev_warn(dev, "Memory resource size exceeds max for 32 bits\n"); - break; } } -- 2.30.2