[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2 5/9] IOMMU: add common API for device reserved memory


  • To: Marek Marczykowski-Górecki <marmarek@xxxxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Thu, 14 Jul 2022 12:17:53 +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=j03mID6bl8/6lDw0QEjHD4R/1oGOPe96nOda6mrupuE=; b=FjunMJUG/SwllBqhSYtp9DK0r+CJitRIXPADwM9plcwHhhvUPtE1V95wl72dMISt2Wh26Y+DjlNK0I7A/ZXlqccW2lXGBWKqyy2zT1oG232nymekqM6jb8cVbvsRLJu42lwa7Ys09ztlQ/q57EWE+u60UjLWZ5+f4B4dK96R3D8JNN/6DPJ+X6Vniy7xvPdNadJuqjQozgzsdFvlgRL8qlgpgJapn1iTvmYp1cWojmlG2KJvoBsY0PEYW7DMciwRjQ3beSph2SSebiiyDmfrfFD5wJ/g651xuks6i9gligUN9Sw0MobcuIRcDEZ65qywtbiJF1t3WkhBRea1JrsweQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IeJIulJ56Nb2dkf7rqk5rSd7PQHHLsemaHpwr1Md+PczuAdlOFldmH95SjTe1qwX02IUNEgfCXzAqijKm9oMPS0tEY62+c/SqwKDwBJCRr6VcvqlbQEi12NBIGg8TuoLNkNG6MFVv+6KPOBnFYGXDEDOH1Ca4Rg+eddIxw9nOpUGL5QUoLfbihI5vv8szVoyaHpx6c+DfNMVzIRxArhp8makvdhqapGXn3QUjLV6HaxBqPptZWMMOQYu+pNmwnIhUyRsehpT0W2EOcnITpEodOCLwD/Lkpop3RX1udKZDPH/R0F68980mheIjUncqWVwYuMnIegkQL5h5Z2fIoxLVA==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Paul Durrant <paul@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Thu, 14 Jul 2022 10:18:01 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 06.07.2022 17:32, Marek Marczykowski-Górecki wrote:
> Add API similar to rmrr= and ivmd= arguments, but in a common code. This
> will allow drivers to register reserved memory regardless of the IOMMU
> vendor.
> The direct reason for this API is xhci-dbc console driver (aka xue),
> that needs to use DMA. But future change may unify command line
> arguments for user-supplied reserved memory, and it may be useful for
> other drivers in the future too.

I take it that I'll understand the purpose of this when making it to
later patches.

> --- a/xen/drivers/passthrough/iommu.c
> +++ b/xen/drivers/passthrough/iommu.c
> @@ -651,6 +651,46 @@ bool_t iommu_has_feature(struct domain *d, enum 
> iommu_feature feature)
>      return is_iommu_enabled(d) && test_bit(feature, dom_iommu(d)->features);
>  }
>  
> +#define MAX_EXTRA_RESERVED_RANGES 20
> +struct extra_reserved_range {
> +    xen_pfn_t start;

Why not unsigned long?

> +    xen_ulong_t nr;

Why not unsigned int or unsigned long?

> +    u32 sbdf;

uint32_t please.

All these type related remarks apply elsewhere as well; others
below also apply wherever else applicable.

> +};
> +static unsigned int __initdata nr_extra_reserved_ranges;
> +static struct extra_reserved_range __initdata 
> extra_reserved_ranges[MAX_EXTRA_RESERVED_RANGES];

Overly long line.

> +int iommu_add_extra_reserved_device_memory(xen_pfn_t start, xen_ulong_t nr, 
> u32 sbdf)
> +{
> +    unsigned int idx;
> +
> +    if ( nr_extra_reserved_ranges >= MAX_EXTRA_RESERVED_RANGES )
> +        return -ENOMEM;
> +
> +    idx = nr_extra_reserved_ranges++;
> +    extra_reserved_ranges[idx].start = start;
> +    extra_reserved_ranges[idx].nr = nr;
> +    extra_reserved_ranges[idx].sbdf = sbdf;
> +    return 0;
> +}

Blank line please before final return statement.

Jan



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.