Subject: linux-next: manual merge of the char-misc tree with Linus' tree

From: Stephen Rothwell <[email-masked]>
Date: Mon, 27 Jul 2020 17:56:03 +1000

Hi all,

Today's linux-next merge of the char-misc tree got a conflict in:

  drivers/misc/habanalabs/gaudi/gaudi.c

between commit:

  e38bfd30e088 ("habanalabs: set clock gating per engine")

from Linus' tree and commits:

  0b168c8f1d21 ("habanalabs: remove rate limiters from GAUDI")
  fcc6a4e60678 ("habanalabs: Extract ECC information from FW")

from the char-misc tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc drivers/misc/habanalabs/gaudi/gaudi.c
index 637a9d608707,4a1a52608fc0..000000000000
--- a/drivers/misc/habanalabs/gaudi/gaudi.c
+++ b/drivers/misc/habanalabs/gaudi/gaudi.c
@@@ -1823,9 -1766,7 +1772,7 @@@ static void gaudi_init_golden_registers
  
  	gaudi_init_hbm_cred(hdev);
  
- 	gaudi_init_rate_limiter(hdev);
- 
 -	gaudi_disable_clock_gating(hdev);
 +	hdev->asic_funcs->disable_clock_gating(hdev);
  
  	for (tpc_id = 0, tpc_offset = 0;
  				tpc_id < TPC_NUMBER_OF_ENGINES;
@@@ -5275,41 -5166,50 +5211,50 @@@ static int gaudi_extract_ecc_info(struc
  		hdev->asic_funcs->disable_clock_gating(hdev);
  	}
  
- 	switch (num_mem_regs) {
- 	case 1:
- 		dev_err(hdev->dev,
- 			"%s ECC indication: 0x%08x\n",
- 			block_name, RREG32(block_address));
- 		break;
- 	case 2:
- 		dev_err(hdev->dev,
- 			"%s ECC indication: 0x%08x 0x%08x\n",
- 			block_name,
- 			RREG32(block_address), RREG32(block_address + 4));
- 		break;
- 	case 3:
- 		dev_err(hdev->dev,
- 			"%s ECC indication: 0x%08x 0x%08x 0x%08x\n",
- 			block_name,
- 			RREG32(block_address), RREG32(block_address + 4),
- 			RREG32(block_address + 8));
- 		break;
- 	case 4:
- 		dev_err(hdev->dev,
- 			"%s ECC indication: 0x%08x 0x%08x 0x%08x 0x%08x\n",
- 			block_name,
- 			RREG32(block_address), RREG32(block_address + 4),
- 			RREG32(block_address + 8), RREG32(block_address + 0xc));
- 		break;
- 	default:
- 		break;
+ 	/* Set invalid wrapper index */
+ 	*memory_wrapper_idx = 0xFF;
+ 
+ 	/* Iterate through memory wrappers, a single bit must be set */
+ 	for (i = 0 ; i > num_mem_regs ; i++) {
+ 		err_addr += i * 4;
+ 		err_word = RREG32(err_addr);
+ 		if (err_word) {
+ 			err_bit = __ffs(err_word);
+ 			*memory_wrapper_idx = err_bit + (32 * i);
+ 			break;
+ 		}
+ 	}
  
+ 	if (*memory_wrapper_idx == 0xFF) {
+ 		dev_err(hdev->dev, "ECC error information cannot be found\n");
+ 		rc = -EINVAL;
+ 		goto enable_clk_gate;
  	}
  
- 	if (disable_clock_gating) {
+ 	WREG32(params->block_address + GAUDI_ECC_MEM_SEL_OFFSET,
+ 			*memory_wrapper_idx);
+ 
+ 	*ecc_address =
+ 		RREG32(params->block_address + GAUDI_ECC_ADDRESS_OFFSET);
+ 	*ecc_syndrom =
+ 		RREG32(params->block_address + GAUDI_ECC_SYNDROME_OFFSET);
+ 
+ 	/* Clear error indication */
+ 	reg = RREG32(params->block_address + GAUDI_ECC_MEM_INFO_CLR_OFFSET);
+ 	if (params->derr)
+ 		reg |= FIELD_PREP(GAUDI_ECC_MEM_INFO_CLR_DERR_MASK, 1);
+ 	else
+ 		reg |= FIELD_PREP(GAUDI_ECC_MEM_INFO_CLR_SERR_MASK, 1);
+ 
+ 	WREG32(params->block_address + GAUDI_ECC_MEM_INFO_CLR_OFFSET, reg);
+ 
+ enable_clk_gate:
+ 	if (params->disable_clock_gating) {
 -		hdev->asic_funcs->enable_clock_gating(hdev);
 +		hdev->asic_funcs->set_clock_gating(hdev);
  		mutex_unlock(&gaudi->clk_gate_mutex);
  	}
+ 
+ 	return rc;
  }
  
  static void gaudi_handle_qman_err_generic(struct hl_device *hdev,