[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2 2/2] xen/pci: replace call to is_memory_hole to pci_check_bar
- To: Rahul Singh <rahul.singh@xxxxxxx>
- From: Jan Beulich <jbeulich@xxxxxxxx>
- Date: Wed, 17 Aug 2022 17:18:28 +0200
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=0H8B85pjagi9TloYkOc0XJgGulASfPaJF0sC9dO9eqc=; b=j0PN6/yi+AH48yEoBxHvednPFpc42ofWK27ipaH2sjfQULzsPTAA9EQCA6n7mkboWqrHxODr4UEdSX11pBV1lrlDPNvHSSvjfRq3CU6B6WUHMzNPPHo/ywt76tPb0YyLV5Ddke5u2klSpMrJqPNfAEuPUe6M9UWBHjPZTP4v+KxsrTObxoxt4GZYmf/5NRJC/R0My6Fg3uNbVUFLCpZvQOlCLoAnK01QgLuR3kzJrE/439YfcWChEAohDd0CdME9xc6RxOQ9bJEfipZo4dd5bdNkEwff4R4jHffUQmQwYKsre5UZdT0/0QoHSKISMPWcGAhHpK0AXY7OU7T9EuRVlg==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ImrocgJUzSIeFd4dlqzR43Hzp6OIbaPrwVDp6dqRJGJOEhSybr1TBiDaD4j4P6e9CRp8PKTUSdxcP8CQCdopSGzE2uE4JkgSonEWubo/5P+d+oE5CdO2rvqWHe9OvFjnqytmHg1919h72mFdAQFRA8JrAIPVBO5jnIxgXrTroAnW2XDNZc9Z5PDAxbeUUBtLbQP7DqH4bwqkljL0SE9s+T1Qq1Y88WitebJZT1gz9It/tdYrLUTpzCwdgCyRZxIje2MLWd2Nb9UYPhfoCS9J18FgUx4omVSr+C5+rnYIh4uFWIEnIGeIF9fGx/of2jWb9QajnbaJkaY2xJJeyH15zw==
- Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
- Cc: bertrand.marquis@xxxxxxx, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Paul Durrant <paul@xxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
- Delivery-date: Wed, 17 Aug 2022 15:18:52 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
On 17.08.2022 16:45, Rahul Singh wrote:
> @@ -363,6 +373,42 @@ int __init pci_host_bridge_mappings(struct domain *d)
> return 0;
> }
>
> +static int is_bar_valid(const struct dt_device_node *dev,
> + u64 addr, u64 len, void *data)
s/u64/uint64_t/g please.
> +{
> + struct pdev_bar *bar_data = data;
> + unsigned long s = mfn_x(bar_data->start);
> + unsigned long e = mfn_x(bar_data->end);
> +
> + if ( (s < e) && (s >= PFN_UP(addr)) && (e <= PFN_UP(addr + len - 1)) )
Doesn't this need to be s >= PFN_DOWN(addr)? Or else why is e checked
against PFN_UP()?
> + bar_data->is_valid = true;
> +
> + return 0;
> +}
> +
> +bool pci_check_bar(const struct pci_dev *pdev, mfn_t start, mfn_t end)
> +{
> + int ret;
> + const struct dt_device_node *dt_node;
> + struct pdev_bar bar_data = {
> + .start = start,
> + .end = end,
> + .is_valid = false
> + };
> +
> + dt_node = pci_find_host_bridge_node(pdev);
> + if ( !dt_node )
> + return false;
> +
> + ret = dt_for_each_range(dt_node, &is_bar_valid, &bar_data);
Just as a side note - I find such (the first instance here) uses of the
unary & operator odd. The same effect will be had without it. So all it
does (in my opinion) is make things harder to read (just very slightly,
of course).
> + if ( ret < 0 )
> + return false;
> +
> + if ( !bar_data.is_valid )
> + return false;
> +
> + return true;
Simply "return bar_data.is_valid;"?
Jan
|