Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1703935

Re: [PATCH v9 06/13] iommu/amd: copy old trans table from old kernel

From Joerg Roedel <jroedel@suse.de>
Newsgroups linux.kernel
Subject Re: [PATCH v9 06/13] iommu/amd: copy old trans table from old kernel
Date 2017-08-04 14:30 +0200
Message-ID <uaJTQ-6TP-17@gated-at.bofh.it> (permalink)
References <u9DGO-3pR-9@gated-at.bofh.it> <u9DGP-3pR-35@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Tue, Aug 01, 2017 at 07:37:22PM +0800, Baoquan He wrote:
>  static void init_device_table_dma(void)
>  {
> @@ -2137,9 +2140,49 @@ static void early_enable_iommu(struct amd_iommu *iommu)
>  static void early_enable_iommus(void)
>  {
>  	struct amd_iommu *iommu;
> +	bool is_pre_disabled = false;
>  
> -	for_each_iommu(iommu)
> -		early_enable_iommu(iommu);
> +	for_each_iommu(iommu) {
> +		if (!translation_pre_enabled(iommu)) {
> +			is_pre_disabled = true;
> +			break;
> +		}
> +	}

I think this could be easier if you make 'is_pre_disabled' a global state
bool variable with reversed meaning and initialize it with 'true'.
Basically

	static bool __init amd_iommu_pre_enabled = true;

And set this variable to 'false' when you find a already disabled IOMMU
during initialization. Then you can remove the code above.

> +
> +	if (is_pre_disabled) {
> +		for_each_iommu(iommu)
> +			early_enable_iommu(iommu);

		return
	}

> +	} else {

And remove this to get rid of one indendation level for the code below.

> +		pr_warn("Translation is already enabled - trying to copy translation structures\n");
> +		if (copy_device_table()) {

Seeing how the return value of copy_device_table() is used, it makes
sense to change its return-type to bool. This way it is also easier to
see which one is the sucess and which one the failure case.

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v9 06/13] iommu/amd: copy old trans table from old kernel Baoquan He <bhe@redhat.com> - 2017-08-01 13:40 +0200
  Re: [PATCH v9 06/13] iommu/amd: copy old trans table from old kernel Joerg Roedel <jroedel@suse.de> - 2017-08-04 14:30 +0200
    Re: [PATCH v9 06/13] iommu/amd: copy old trans table from old kernel Baoquan He <bhe@redhat.com> - 2017-08-04 15:10 +0200

csiph-web