All of lore.kernel.org
 help / color / mirror / Atom feed
* arch/powerpc/kernel/entry_32.S:450: Error: unsupported relocation against thread
From: kbuild test robot @ 2020-05-29 16:41 UTC (permalink / raw)
  To: Christophe, Leroy,; +Cc: kbuild-all, linux-kernel, Michael Ellerman

[-- Attachment #1: Type: text/plain, Size: 12052 bytes --]

Hi Christophe,

First bad commit (maybe != root cause):

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   75caf310d16cc5e2f851c048cd597f5437013368
commit: 4833ce06e6855d526234618b746ffb71d6612c9a powerpc/32s: Fix build failure with CONFIG_PPC_KUAP_DEBUG
date:   3 weeks ago
config: powerpc-randconfig-r035-20200529 (attached as .config)
compiler: powerpc-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        git checkout 4833ce06e6855d526234618b746ffb71d6612c9a
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=powerpc 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kbuild test robot <lkp@intel.com>

All errors (new ones prefixed by >>, old ones prefixed by <<):

arch/powerpc/kernel/entry_32.S: Assembler messages:
arch/powerpc/kernel/entry_32.S:450: Error: invalid operands (*UND* and *UND* sections) for `|'
arch/powerpc/kernel/entry_32.S:735: Error: invalid operands (*UND* and *UND* sections) for `|'
>> arch/powerpc/kernel/entry_32.S:450: Error: unsupported relocation against thread
arch/powerpc/kernel/entry_32.S:735: Error: unsupported relocation against thread

vim +450 arch/powerpc/kernel/entry_32.S

b86fb88855ea78 Christophe Leroy       2019-04-30  344  
9994a33865f4d5 Paul Mackerras         2005-10-10  345  /*
9994a33865f4d5 Paul Mackerras         2005-10-10  346   * Handle a system call.
9994a33865f4d5 Paul Mackerras         2005-10-10  347   */
9994a33865f4d5 Paul Mackerras         2005-10-10  348  	.stabs	"arch/powerpc/kernel/",N_SO,0,0,0f
9994a33865f4d5 Paul Mackerras         2005-10-10  349  	.stabs	"entry_32.S",N_SO,0,0,0f
9994a33865f4d5 Paul Mackerras         2005-10-10  350  0:
9994a33865f4d5 Paul Mackerras         2005-10-10  351  
9994a33865f4d5 Paul Mackerras         2005-10-10  352  _GLOBAL(DoSyscall)
9994a33865f4d5 Paul Mackerras         2005-10-10  353  	stw	r3,ORIG_GPR3(r1)
9994a33865f4d5 Paul Mackerras         2005-10-10  354  	li	r12,0
9994a33865f4d5 Paul Mackerras         2005-10-10  355  	stw	r12,RESULT(r1)
5d38902c483881 Benjamin Herrenschmidt 2009-06-17  356  #ifdef CONFIG_TRACE_IRQFLAGS
40530db7c65611 Christophe Leroy       2019-04-30  357  	/* Make sure interrupts are enabled */
5d38902c483881 Benjamin Herrenschmidt 2009-06-17  358  	mfmsr	r11
5d38902c483881 Benjamin Herrenschmidt 2009-06-17  359  	andi.	r12,r11,MSR_EE
40530db7c65611 Christophe Leroy       2019-04-30  360  	/* We came in with interrupts disabled, we WARN and mark them enabled
40530db7c65611 Christophe Leroy       2019-04-30  361  	 * for lockdep now */
40530db7c65611 Christophe Leroy       2019-04-30  362  0:	tweqi	r12, 0
40530db7c65611 Christophe Leroy       2019-04-30  363  	EMIT_BUG_ENTRY 0b,__FILE__,__LINE__, BUGFLAG_WARNING
5d38902c483881 Benjamin Herrenschmidt 2009-06-17  364  #endif /* CONFIG_TRACE_IRQFLAGS */
f7354ccac844da Christophe Leroy       2019-01-31  365  	lwz	r11,TI_FLAGS(r2)
10ea834364c867 Michael Ellerman       2015-01-15  366  	andi.	r11,r11,_TIF_SYSCALL_DOTRACE
9994a33865f4d5 Paul Mackerras         2005-10-10  367  	bne-	syscall_dotrace
9994a33865f4d5 Paul Mackerras         2005-10-10  368  syscall_dotrace_cont:
9994a33865f4d5 Paul Mackerras         2005-10-10  369  	cmplwi	0,r0,NR_syscalls
9994a33865f4d5 Paul Mackerras         2005-10-10  370  	lis	r10,sys_call_table@h
9994a33865f4d5 Paul Mackerras         2005-10-10  371  	ori	r10,r10,sys_call_table@l
9994a33865f4d5 Paul Mackerras         2005-10-10  372  	slwi	r0,r0,2
9994a33865f4d5 Paul Mackerras         2005-10-10  373  	bge-	66f
c28218d4abbf4f Diana Craciun          2018-07-28  374  
c28218d4abbf4f Diana Craciun          2018-07-28  375  	barrier_nospec_asm
c28218d4abbf4f Diana Craciun          2018-07-28  376  	/*
c28218d4abbf4f Diana Craciun          2018-07-28  377  	 * Prevent the load of the handler below (based on the user-passed
c28218d4abbf4f Diana Craciun          2018-07-28  378  	 * system call number) being speculatively executed until the test
c28218d4abbf4f Diana Craciun          2018-07-28  379  	 * against NR_syscalls and branch to .66f above has
c28218d4abbf4f Diana Craciun          2018-07-28  380  	 * committed.
c28218d4abbf4f Diana Craciun          2018-07-28  381  	 */
c28218d4abbf4f Diana Craciun          2018-07-28  382  
9994a33865f4d5 Paul Mackerras         2005-10-10  383  	lwzx	r10,r10,r0	/* Fetch system call handler [ptr] */
9994a33865f4d5 Paul Mackerras         2005-10-10  384  	mtlr	r10
9994a33865f4d5 Paul Mackerras         2005-10-10  385  	addi	r9,r1,STACK_FRAME_OVERHEAD
9994a33865f4d5 Paul Mackerras         2005-10-10  386  	PPC440EP_ERR42
9994a33865f4d5 Paul Mackerras         2005-10-10  387  	blrl			/* Call handler */
9994a33865f4d5 Paul Mackerras         2005-10-10  388  	.globl	ret_from_syscall
9994a33865f4d5 Paul Mackerras         2005-10-10  389  ret_from_syscall:
6f37be4b1364ee Boqun Feng             2018-06-02  390  #ifdef CONFIG_DEBUG_RSEQ
6f37be4b1364ee Boqun Feng             2018-06-02  391  	/* Check whether the syscall is issued inside a restartable sequence */
6f37be4b1364ee Boqun Feng             2018-06-02  392  	stw	r3,GPR3(r1)
6f37be4b1364ee Boqun Feng             2018-06-02  393  	addi    r3,r1,STACK_FRAME_OVERHEAD
6f37be4b1364ee Boqun Feng             2018-06-02  394  	bl      rseq_syscall
6f37be4b1364ee Boqun Feng             2018-06-02  395  	lwz	r3,GPR3(r1)
6f37be4b1364ee Boqun Feng             2018-06-02  396  #endif
9994a33865f4d5 Paul Mackerras         2005-10-10  397  	mr	r6,r3
9994a33865f4d5 Paul Mackerras         2005-10-10  398  	/* disable interrupts so current_thread_info()->flags can't change */
ba18025fb03306 Christophe Leroy       2019-08-20  399  	LOAD_REG_IMMEDIATE(r10,MSR_KERNEL)	/* doesn't include MSR_EE */
5d38902c483881 Benjamin Herrenschmidt 2009-06-17  400  	/* Note: We don't bother telling lockdep about it */
9994a33865f4d5 Paul Mackerras         2005-10-10  401  	SYNC
39bccfd1649705 Christophe Leroy       2019-12-21  402  	mtmsr	r10
f7354ccac844da Christophe Leroy       2019-01-31  403  	lwz	r9,TI_FLAGS(r2)
c3525940cca53c Michael Ellerman       2015-07-23  404  	li	r8,-MAX_ERRNO
10ea834364c867 Michael Ellerman       2015-01-15  405  	andi.	r0,r9,(_TIF_SYSCALL_DOTRACE|_TIF_SINGLESTEP|_TIF_USER_WORK_MASK|_TIF_PERSYSCALL_MASK)
9994a33865f4d5 Paul Mackerras         2005-10-10  406  	bne-	syscall_exit_work
401d1f029bebb7 David Woodhouse        2005-11-15  407  	cmplw	0,r3,r8
401d1f029bebb7 David Woodhouse        2005-11-15  408  	blt+	syscall_exit_cont
401d1f029bebb7 David Woodhouse        2005-11-15  409  	lwz	r11,_CCR(r1)			/* Load CR */
401d1f029bebb7 David Woodhouse        2005-11-15  410  	neg	r3,r3
401d1f029bebb7 David Woodhouse        2005-11-15  411  	oris	r11,r11,0x1000	/* Set SO bit in CR */
401d1f029bebb7 David Woodhouse        2005-11-15  412  	stw	r11,_CCR(r1)
9994a33865f4d5 Paul Mackerras         2005-10-10  413  syscall_exit_cont:
5d38902c483881 Benjamin Herrenschmidt 2009-06-17  414  	lwz	r8,_MSR(r1)
5d38902c483881 Benjamin Herrenschmidt 2009-06-17  415  #ifdef CONFIG_TRACE_IRQFLAGS
5d38902c483881 Benjamin Herrenschmidt 2009-06-17  416  	/* If we are going to return from the syscall with interrupts
40530db7c65611 Christophe Leroy       2019-04-30  417  	 * off, we trace that here. It shouldn't normally happen.
5d38902c483881 Benjamin Herrenschmidt 2009-06-17  418  	 */
5d38902c483881 Benjamin Herrenschmidt 2009-06-17  419  	andi.	r10,r8,MSR_EE
5d38902c483881 Benjamin Herrenschmidt 2009-06-17  420  	bne+	1f
5d38902c483881 Benjamin Herrenschmidt 2009-06-17  421  	stw	r3,GPR3(r1)
5d38902c483881 Benjamin Herrenschmidt 2009-06-17  422  	bl      trace_hardirqs_off
5d38902c483881 Benjamin Herrenschmidt 2009-06-17  423  	lwz	r3,GPR3(r1)
5d38902c483881 Benjamin Herrenschmidt 2009-06-17  424  1:
5d38902c483881 Benjamin Herrenschmidt 2009-06-17  425  #endif /* CONFIG_TRACE_IRQFLAGS */
9994a33865f4d5 Paul Mackerras         2005-10-10  426  #if defined(CONFIG_4xx) || defined(CONFIG_BOOKE)
4eaddb4d7ec380 Kumar Gala             2008-04-09  427  	/* If the process has its own DBCR0 value, load it up.  The internal
4eaddb4d7ec380 Kumar Gala             2008-04-09  428  	   debug mode bit tells us that dbcr0 should be loaded. */
9994a33865f4d5 Paul Mackerras         2005-10-10  429  	lwz	r0,THREAD+THREAD_DBCR0(r2)
2325f0a0c3d76b Kumar Gala             2008-07-26  430  	andis.	r10,r0,DBCR0_IDM@h
9994a33865f4d5 Paul Mackerras         2005-10-10  431  	bnel-	load_dbcr0
9994a33865f4d5 Paul Mackerras         2005-10-10  432  #endif
b98ac05d5e4603 Benjamin Herrenschmidt 2007-10-31  433  #ifdef CONFIG_44x
e7f75ad01d5902 Dave Kleikamp          2010-03-05  434  BEGIN_MMU_FTR_SECTION
b98ac05d5e4603 Benjamin Herrenschmidt 2007-10-31  435  	lis	r4,icache_44x_need_flush@ha
b98ac05d5e4603 Benjamin Herrenschmidt 2007-10-31  436  	lwz	r5,icache_44x_need_flush@l(r4)
b98ac05d5e4603 Benjamin Herrenschmidt 2007-10-31  437  	cmplwi	cr0,r5,0
b98ac05d5e4603 Benjamin Herrenschmidt 2007-10-31  438  	bne-	2f
b98ac05d5e4603 Benjamin Herrenschmidt 2007-10-31  439  1:
e7f75ad01d5902 Dave Kleikamp          2010-03-05  440  END_MMU_FTR_SECTION_IFCLR(MMU_FTR_TYPE_47x)
b98ac05d5e4603 Benjamin Herrenschmidt 2007-10-31  441  #endif /* CONFIG_44x */
b64f87c16f3c00 Becky Bruce            2007-11-10  442  BEGIN_FTR_SECTION
b64f87c16f3c00 Becky Bruce            2007-11-10  443  	lwarx	r7,0,r1
b64f87c16f3c00 Becky Bruce            2007-11-10  444  END_FTR_SECTION_IFSET(CPU_FTR_NEED_PAIRED_STWCX)
9994a33865f4d5 Paul Mackerras         2005-10-10  445  	stwcx.	r0,0,r1			/* to clear the reservation */
f7354ccac844da Christophe Leroy       2019-01-31  446  	ACCOUNT_CPU_USER_EXIT(r2, r5, r7)
31ed2b13c48d77 Christophe Leroy       2019-03-11  447  #ifdef CONFIG_PPC_BOOK3S_32
31ed2b13c48d77 Christophe Leroy       2019-03-11  448  	kuep_unlock r5, r7
31ed2b13c48d77 Christophe Leroy       2019-03-11  449  #endif
e2fb9f5444312f Christophe Leroy       2019-03-11 @450  	kuap_check r2, r4
9994a33865f4d5 Paul Mackerras         2005-10-10  451  	lwz	r4,_LINK(r1)
9994a33865f4d5 Paul Mackerras         2005-10-10  452  	lwz	r5,_CCR(r1)
9994a33865f4d5 Paul Mackerras         2005-10-10  453  	mtlr	r4
9994a33865f4d5 Paul Mackerras         2005-10-10  454  	mtcr	r5
9994a33865f4d5 Paul Mackerras         2005-10-10  455  	lwz	r7,_NIP(r1)
9994a33865f4d5 Paul Mackerras         2005-10-10  456  	lwz	r2,GPR2(r1)
9994a33865f4d5 Paul Mackerras         2005-10-10  457  	lwz	r1,GPR1(r1)
cd99ddbea250ee Christophe Leroy       2018-01-12  458  #if defined(CONFIG_PPC_8xx) && defined(CONFIG_PERF_EVENTS)
75b824727680a9 Christophe Leroy       2016-12-15  459  	mtspr	SPRN_NRI, r0
75b824727680a9 Christophe Leroy       2016-12-15  460  #endif
9994a33865f4d5 Paul Mackerras         2005-10-10  461  	mtspr	SPRN_SRR0,r7
9994a33865f4d5 Paul Mackerras         2005-10-10  462  	mtspr	SPRN_SRR1,r8
9994a33865f4d5 Paul Mackerras         2005-10-10  463  	SYNC
9994a33865f4d5 Paul Mackerras         2005-10-10  464  	RFI
b98ac05d5e4603 Benjamin Herrenschmidt 2007-10-31  465  #ifdef CONFIG_44x
b98ac05d5e4603 Benjamin Herrenschmidt 2007-10-31  466  2:	li	r7,0
b98ac05d5e4603 Benjamin Herrenschmidt 2007-10-31  467  	iccci	r0,r0
b98ac05d5e4603 Benjamin Herrenschmidt 2007-10-31  468  	stw	r7,icache_44x_need_flush@l(r4)
b98ac05d5e4603 Benjamin Herrenschmidt 2007-10-31  469  	b	1b
b98ac05d5e4603 Benjamin Herrenschmidt 2007-10-31  470  #endif  /* CONFIG_44x */
9994a33865f4d5 Paul Mackerras         2005-10-10  471  

:::::: The code at line 450 was first introduced by commit
:::::: e2fb9f5444312fd01627c84a3e018c1fe8ac6ebb powerpc/32: Prepare for Kernel Userspace Access Protection

:::::: TO: Christophe Leroy <christophe.leroy@c-s.fr>
:::::: CC: Michael Ellerman <mpe@ellerman.id.au>

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 32037 bytes --]

^ permalink raw reply

* [PATCH v4 4/4] scsi: ufs: add compatibility with 3.1 UFS unit descriptor length
From: Bean Huo @ 2020-05-29 16:40 UTC (permalink / raw)
  To: alim.akhtar, avri.altman, asutoshd, jejb, martin.petersen,
	stanley.chu, beanhuo, bvanassche, tomas.winkler, cang
  Cc: linux-scsi, linux-kernel
In-Reply-To: <20200529164054.27552-1-huobean@gmail.com>

From: Bean Huo <beanhuo@micron.com>

For UFS 3.1, the normal unit descriptor is 10 bytes larger
than the RPMB unit, however, both descriptors share the same
desc_idn, to cover both unit descriptors with one length, we
choose the normal unit descriptor length by desc_index.

Signed-off-by: Bean Huo <beanhuo@micron.com>
---
 drivers/scsi/ufs/ufs.h    |  1 +
 drivers/scsi/ufs/ufshcd.c | 11 ++++++++---
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/ufs/ufs.h b/drivers/scsi/ufs/ufs.h
index 6548ef102eb9..332ae09e6238 100644
--- a/drivers/scsi/ufs/ufs.h
+++ b/drivers/scsi/ufs/ufs.h
@@ -63,6 +63,7 @@
 #define UFS_UPIU_MAX_UNIT_NUM_ID	0x7F
 #define UFS_MAX_LUNS		(SCSI_W_LUN_BASE + UFS_UPIU_MAX_UNIT_NUM_ID)
 #define UFS_UPIU_WLUN_ID	(1 << 7)
+#define UFS_RPMB_UNIT		0xC4
 
 /* WriteBooster buffer is available only for the logical unit from 0 to 7 */
 #define UFS_UPIU_MAX_WB_LUN_ID	8
diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 951e52babf65..3cdc585d0095 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -3070,11 +3070,16 @@ void ufshcd_map_desc_id_to_length(struct ufs_hba *hba, enum desc_idn desc_id,
 EXPORT_SYMBOL(ufshcd_map_desc_id_to_length);
 
 static void ufshcd_update_desc_length(struct ufs_hba *hba,
-				      enum desc_idn desc_id,
+				      enum desc_idn desc_id, int desc_index,
 				      unsigned char desc_len)
 {
 	if (hba->desc_size[desc_id] == QUERY_DESC_MAX_SIZE &&
-	    desc_id != QUERY_DESC_IDN_STRING)
+	    desc_id != QUERY_DESC_IDN_STRING && desc_index != UFS_RPMB_UNIT)
+		/* For UFS 3.1, the normal unit descriptor is 10 bytes larger
+		 * than the RPMB unit, however, both descriptors share the same
+		 * desc_idn, to cover both unit descriptors with one length, we
+		 * choose the normal unit descriptor length by desc_index.
+		 */
 		hba->desc_size[desc_id] = desc_len;
 }
 
@@ -3141,7 +3146,7 @@ int ufshcd_read_desc_param(struct ufs_hba *hba,
 		goto out;
 	}
 
-	ufshcd_update_desc_length(hba, desc_id,
+	ufshcd_update_desc_length(hba, desc_id, desc_index,
 				  desc_buf[QUERY_DESC_LENGTH_OFFSET]);
 
 	/* Check wherher we will not copy more data, than available */
-- 
2.17.1


^ permalink raw reply related

* [PATCH v4 3/4] scsi: ufs: cleanup ufs initialization path
From: Bean Huo @ 2020-05-29 16:40 UTC (permalink / raw)
  To: alim.akhtar, avri.altman, asutoshd, jejb, martin.petersen,
	stanley.chu, beanhuo, bvanassche, tomas.winkler, cang
  Cc: linux-scsi, linux-kernel
In-Reply-To: <20200529164054.27552-1-huobean@gmail.com>

From: Bean Huo <beanhuo@micron.com>

At UFS initialization stage, to get the length of the descriptor,
ufshcd_read_desc_length() being called 6 times. Instead, we will
capture the descriptor size the first time  we'll read it.

Delete unnecessary redundant code, remove ufshcd_read_desc_length(),
ufshcd_init_desc_sizes(), and boost UFS initialization.

Signed-off-by: Bean Huo <beanhuo@micron.com>
Reviewed-by: Bart van Assche <bvanassche@acm.org>
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
---
 drivers/scsi/ufs/ufs.h     |  10 ---
 drivers/scsi/ufs/ufs_bsg.c |   5 +-
 drivers/scsi/ufs/ufshcd.c  | 165 +++++++------------------------------
 drivers/scsi/ufs/ufshcd.h  |  16 +---
 4 files changed, 36 insertions(+), 160 deletions(-)

diff --git a/drivers/scsi/ufs/ufs.h b/drivers/scsi/ufs/ufs.h
index fadba3a3bbcd..6548ef102eb9 100644
--- a/drivers/scsi/ufs/ufs.h
+++ b/drivers/scsi/ufs/ufs.h
@@ -200,16 +200,6 @@ enum desc_header_offset {
 	QUERY_DESC_DESC_TYPE_OFFSET	= 0x01,
 };
 
-enum ufs_desc_def_size {
-	QUERY_DESC_DEVICE_DEF_SIZE		= 0x59,
-	QUERY_DESC_CONFIGURATION_DEF_SIZE	= 0x90,
-	QUERY_DESC_UNIT_DEF_SIZE		= 0x2D,
-	QUERY_DESC_INTERCONNECT_DEF_SIZE	= 0x06,
-	QUERY_DESC_GEOMETRY_DEF_SIZE		= 0x48,
-	QUERY_DESC_POWER_DEF_SIZE		= 0x62,
-	QUERY_DESC_HEALTH_DEF_SIZE		= 0x25,
-};
-
 /* Unit descriptor parameters offsets in bytes*/
 enum unit_desc_param {
 	UNIT_DESC_PARAM_LEN			= 0x0,
diff --git a/drivers/scsi/ufs/ufs_bsg.c b/drivers/scsi/ufs/ufs_bsg.c
index 53dd87628cbe..27f54615ee84 100644
--- a/drivers/scsi/ufs/ufs_bsg.c
+++ b/drivers/scsi/ufs/ufs_bsg.c
@@ -11,13 +11,12 @@ static int ufs_bsg_get_query_desc_size(struct ufs_hba *hba, int *desc_len,
 {
 	int desc_size = be16_to_cpu(qr->length);
 	int desc_id = qr->idn;
-	int ret;
 
 	if (desc_size <= 0)
 		return -EINVAL;
 
-	ret = ufshcd_map_desc_id_to_length(hba, desc_id, desc_len);
-	if (ret || !*desc_len)
+	ufshcd_map_desc_id_to_length(hba, desc_id, desc_len);
+	if (!*desc_len)
 		return -EINVAL;
 
 	*desc_len = min_t(int, *desc_len, desc_size);
diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index f7e8bfefe3d4..951e52babf65 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -3052,95 +3052,32 @@ int ufshcd_query_descriptor_retry(struct ufs_hba *hba,
 	return err;
 }
 
-/**
- * ufshcd_read_desc_length - read the specified descriptor length from header
- * @hba: Pointer to adapter instance
- * @desc_id: descriptor idn value
- * @desc_index: descriptor index
- * @desc_length: pointer to variable to read the length of descriptor
- *
- * Return 0 in case of success, non-zero otherwise
- */
-static int ufshcd_read_desc_length(struct ufs_hba *hba,
-	enum desc_idn desc_id,
-	int desc_index,
-	int *desc_length)
-{
-	int ret;
-	u8 header[QUERY_DESC_HDR_SIZE];
-	int header_len = QUERY_DESC_HDR_SIZE;
-
-	if (desc_id >= QUERY_DESC_IDN_MAX)
-		return -EINVAL;
-
-	ret = ufshcd_query_descriptor_retry(hba, UPIU_QUERY_OPCODE_READ_DESC,
-					desc_id, desc_index, 0, header,
-					&header_len);
-
-	if (ret) {
-		dev_err(hba->dev, "%s: Failed to get descriptor header id %d",
-			__func__, desc_id);
-		return ret;
-	} else if (desc_id != header[QUERY_DESC_DESC_TYPE_OFFSET]) {
-		dev_warn(hba->dev, "%s: descriptor header id %d and desc_id %d mismatch",
-			__func__, header[QUERY_DESC_DESC_TYPE_OFFSET],
-			desc_id);
-		ret = -EINVAL;
-	}
-
-	*desc_length = header[QUERY_DESC_LENGTH_OFFSET];
-	return ret;
-
-}
-
 /**
  * ufshcd_map_desc_id_to_length - map descriptor IDN to its length
  * @hba: Pointer to adapter instance
  * @desc_id: descriptor idn value
  * @desc_len: mapped desc length (out)
  *
- * Return 0 in case of success, non-zero otherwise
  */
-int ufshcd_map_desc_id_to_length(struct ufs_hba *hba,
-	enum desc_idn desc_id, int *desc_len)
+void ufshcd_map_desc_id_to_length(struct ufs_hba *hba, enum desc_idn desc_id,
+				  int *desc_len)
 {
-	switch (desc_id) {
-	case QUERY_DESC_IDN_DEVICE:
-		*desc_len = hba->desc_size.dev_desc;
-		break;
-	case QUERY_DESC_IDN_POWER:
-		*desc_len = hba->desc_size.pwr_desc;
-		break;
-	case QUERY_DESC_IDN_GEOMETRY:
-		*desc_len = hba->desc_size.geom_desc;
-		break;
-	case QUERY_DESC_IDN_CONFIGURATION:
-		*desc_len = hba->desc_size.conf_desc;
-		break;
-	case QUERY_DESC_IDN_UNIT:
-		*desc_len = hba->desc_size.unit_desc;
-		break;
-	case QUERY_DESC_IDN_INTERCONNECT:
-		*desc_len = hba->desc_size.interc_desc;
-		break;
-	case QUERY_DESC_IDN_STRING:
-		*desc_len = QUERY_DESC_MAX_SIZE;
-		break;
-	case QUERY_DESC_IDN_HEALTH:
-		*desc_len = hba->desc_size.hlth_desc;
-		break;
-	case QUERY_DESC_IDN_RFU_0:
-	case QUERY_DESC_IDN_RFU_1:
+	if (desc_id == QUERY_DESC_IDN_RFU_0 || desc_id == QUERY_DESC_IDN_RFU_1)
 		*desc_len = 0;
-		break;
-	default:
-		*desc_len = 0;
-		return -EINVAL;
-	}
-	return 0;
+	else
+		*desc_len = hba->desc_size[desc_id];
 }
 EXPORT_SYMBOL(ufshcd_map_desc_id_to_length);
 
+static void ufshcd_update_desc_length(struct ufs_hba *hba,
+				      enum desc_idn desc_id,
+				      unsigned char desc_len)
+{
+	if (hba->desc_size[desc_id] == QUERY_DESC_MAX_SIZE &&
+	    desc_id != QUERY_DESC_IDN_STRING)
+		hba->desc_size[desc_id] = desc_len;
+}
+
 /**
  * ufshcd_read_desc_param - read the specified descriptor parameter
  * @hba: Pointer to adapter instance
@@ -3168,16 +3105,11 @@ int ufshcd_read_desc_param(struct ufs_hba *hba,
 	if (desc_id >= QUERY_DESC_IDN_MAX || !param_size)
 		return -EINVAL;
 
-	/* Get the max length of descriptor from structure filled up at probe
-	 * time.
-	 */
-	ret = ufshcd_map_desc_id_to_length(hba, desc_id, &buff_len);
-
-	/* Sanity checks */
-	if (ret || !buff_len) {
-		dev_err(hba->dev, "%s: Failed to get full descriptor length",
-			__func__);
-		return ret;
+	/* Get the length of descriptor */
+	ufshcd_map_desc_id_to_length(hba, desc_id, &buff_len);
+	if (!buff_len) {
+		dev_err(hba->dev, "%s: Failed to get desc length", __func__);
+		return -EINVAL;
 	}
 
 	/* Check whether we need temp memory */
@@ -3209,6 +3141,9 @@ int ufshcd_read_desc_param(struct ufs_hba *hba,
 		goto out;
 	}
 
+	ufshcd_update_desc_length(hba, desc_id,
+				  desc_buf[QUERY_DESC_LENGTH_OFFSET]);
+
 	/* Check wherher we will not copy more data, than available */
 	if (is_kmalloc && param_size > buff_len)
 		param_size = buff_len;
@@ -6665,7 +6600,7 @@ static u32 ufshcd_find_max_sup_active_icc_level(struct ufs_hba *hba,
 static void ufshcd_set_active_icc_lvl(struct ufs_hba *hba)
 {
 	int ret;
-	int buff_len = hba->desc_size.pwr_desc;
+	int buff_len = hba->desc_size[QUERY_DESC_IDN_POWER];
 	u8 *desc_buf;
 	u32 icc_level;
 
@@ -6783,7 +6718,8 @@ static void ufshcd_wb_probe(struct ufs_hba *hba, u8 *desc_buf)
 	if (!ufshcd_is_wb_allowed(hba))
 		return;
 
-	if (hba->desc_size.dev_desc < DEVICE_DESC_PARAM_EXT_UFS_FEATURE_SUP + 4)
+	if (hba->desc_size[QUERY_DESC_IDN_DEVICE] <
+	    DEVICE_DESC_PARAM_EXT_UFS_FEATURE_SUP + 4)
 		goto wb_disabled;
 
 	hba->dev_info.d_ext_ufs_feature_sup =
@@ -6876,7 +6812,7 @@ static int ufs_get_device_desc(struct ufs_hba *hba)
 	}
 
 	err = ufshcd_read_desc_param(hba, QUERY_DESC_IDN_DEVICE, 0, 0, desc_buf,
-				     hba->desc_size.dev_desc);
+				     hba->desc_size[QUERY_DESC_IDN_DEVICE]);
 	if (err) {
 		dev_err(hba->dev, "%s: Failed reading Device Desc. err = %d\n",
 			__func__, err);
@@ -7104,53 +7040,13 @@ static void ufshcd_clear_dbg_ufs_stats(struct ufs_hba *hba)
 	hba->req_abort_count = 0;
 }
 
-static void ufshcd_init_desc_sizes(struct ufs_hba *hba)
-{
-	int err;
-
-	err = ufshcd_read_desc_length(hba, QUERY_DESC_IDN_DEVICE, 0,
-		&hba->desc_size.dev_desc);
-	if (err)
-		hba->desc_size.dev_desc = QUERY_DESC_DEVICE_DEF_SIZE;
-
-	err = ufshcd_read_desc_length(hba, QUERY_DESC_IDN_POWER, 0,
-		&hba->desc_size.pwr_desc);
-	if (err)
-		hba->desc_size.pwr_desc = QUERY_DESC_POWER_DEF_SIZE;
-
-	err = ufshcd_read_desc_length(hba, QUERY_DESC_IDN_INTERCONNECT, 0,
-		&hba->desc_size.interc_desc);
-	if (err)
-		hba->desc_size.interc_desc = QUERY_DESC_INTERCONNECT_DEF_SIZE;
-
-	err = ufshcd_read_desc_length(hba, QUERY_DESC_IDN_CONFIGURATION, 0,
-		&hba->desc_size.conf_desc);
-	if (err)
-		hba->desc_size.conf_desc = QUERY_DESC_CONFIGURATION_DEF_SIZE;
-
-	err = ufshcd_read_desc_length(hba, QUERY_DESC_IDN_UNIT, 0,
-		&hba->desc_size.unit_desc);
-	if (err)
-		hba->desc_size.unit_desc = QUERY_DESC_UNIT_DEF_SIZE;
-
-	err = ufshcd_read_desc_length(hba, QUERY_DESC_IDN_GEOMETRY, 0,
-		&hba->desc_size.geom_desc);
-	if (err)
-		hba->desc_size.geom_desc = QUERY_DESC_GEOMETRY_DEF_SIZE;
-
-	err = ufshcd_read_desc_length(hba, QUERY_DESC_IDN_HEALTH, 0,
-		&hba->desc_size.hlth_desc);
-	if (err)
-		hba->desc_size.hlth_desc = QUERY_DESC_HEALTH_DEF_SIZE;
-}
-
 static int ufshcd_device_geo_params_init(struct ufs_hba *hba)
 {
 	int err;
 	size_t buff_len;
 	u8 *desc_buf;
 
-	buff_len = hba->desc_size.geom_desc;
+	buff_len = hba->desc_size[QUERY_DESC_IDN_GEOMETRY];
 	desc_buf = kmalloc(buff_len, GFP_KERNEL);
 	if (!desc_buf) {
 		err = -ENOMEM;
@@ -7246,13 +7142,14 @@ static int ufshcd_set_dev_ref_clk(struct ufs_hba *hba)
 static int ufshcd_device_params_init(struct ufs_hba *hba)
 {
 	bool flag;
-	int ret;
+	int ret, i;
 
 	/* Clear any previous UFS device information */
 	memset(&hba->dev_info, 0, sizeof(hba->dev_info));
 
-	/* Init check for device descriptor sizes */
-	ufshcd_init_desc_sizes(hba);
+	/* Init device descriptor sizes */
+	for (i = 0; i < QUERY_DESC_IDN_MAX; i++)
+		hba->desc_size[i] = QUERY_DESC_MAX_SIZE;
 
 	/* Init UFS geometry descriptor related parameters */
 	ret = ufshcd_device_geo_params_init(hba);
diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h
index e3dfb48e669e..5ea090d82ddc 100644
--- a/drivers/scsi/ufs/ufshcd.h
+++ b/drivers/scsi/ufs/ufshcd.h
@@ -236,16 +236,6 @@ struct ufs_dev_cmd {
 	struct ufs_query query;
 };
 
-struct ufs_desc_size {
-	int dev_desc;
-	int pwr_desc;
-	int geom_desc;
-	int interc_desc;
-	int unit_desc;
-	int conf_desc;
-	int hlth_desc;
-};
-
 /**
  * struct ufs_clk_info - UFS clock related info
  * @list: list headed by hba->clk_list_head
@@ -738,7 +728,7 @@ struct ufs_hba {
 	bool is_urgent_bkops_lvl_checked;
 
 	struct rw_semaphore clk_scaling_lock;
-	struct ufs_desc_size desc_size;
+	unsigned char desc_size[QUERY_DESC_IDN_MAX];
 	atomic_t scsi_block_reqs_cnt;
 
 	struct device		bsg_dev;
@@ -975,8 +965,8 @@ int ufshcd_read_string_desc(struct ufs_hba *hba, u8 desc_index,
 int ufshcd_hold(struct ufs_hba *hba, bool async);
 void ufshcd_release(struct ufs_hba *hba);
 
-int ufshcd_map_desc_id_to_length(struct ufs_hba *hba, enum desc_idn desc_id,
-	int *desc_length);
+void ufshcd_map_desc_id_to_length(struct ufs_hba *hba, enum desc_idn desc_id,
+				  int *desc_length);
 
 u32 ufshcd_get_local_unipro_ver(struct ufs_hba *hba);
 
-- 
2.17.1


^ permalink raw reply related

* [PATCH v4 2/4] scsi: ufs: delete ufshcd_read_desc()
From: Bean Huo @ 2020-05-29 16:40 UTC (permalink / raw)
  To: alim.akhtar, avri.altman, asutoshd, jejb, martin.petersen,
	stanley.chu, beanhuo, bvanassche, tomas.winkler, cang
  Cc: linux-scsi, linux-kernel
In-Reply-To: <20200529164054.27552-1-huobean@gmail.com>

From: Bean Huo <beanhuo@micron.com>

Delete ufshcd_read_desc(). Instead, let caller directly call
ufshcd_read_desc_param().

Signed-off-by: Bean Huo <beanhuo@micron.com>
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Reviewed-by: Bart van Assche <bvanassche@acm.org>
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
---
 drivers/scsi/ufs/ufshcd.c | 27 ++++++++-------------------
 1 file changed, 8 insertions(+), 19 deletions(-)

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index f57acfbf9d60..f7e8bfefe3d4 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -3221,16 +3221,6 @@ int ufshcd_read_desc_param(struct ufs_hba *hba,
 	return ret;
 }
 
-static inline int ufshcd_read_desc(struct ufs_hba *hba,
-				   enum desc_idn desc_id,
-				   int desc_index,
-				   void *buf,
-				   u32 size)
-{
-	return ufshcd_read_desc_param(hba, desc_id, desc_index, 0, buf, size);
-}
-
-
 /**
  * struct uc_string_id - unicode string
  *
@@ -3278,9 +3268,8 @@ int ufshcd_read_string_desc(struct ufs_hba *hba, u8 desc_index,
 	if (!uc_str)
 		return -ENOMEM;
 
-	ret = ufshcd_read_desc(hba, QUERY_DESC_IDN_STRING,
-			       desc_index, uc_str,
-			       QUERY_DESC_MAX_SIZE);
+	ret = ufshcd_read_desc_param(hba, QUERY_DESC_IDN_STRING, desc_index, 0,
+				     (u8 *)uc_str, QUERY_DESC_MAX_SIZE);
 	if (ret < 0) {
 		dev_err(hba->dev, "Reading String Desc failed after %d retries. err = %d\n",
 			QUERY_REQ_RETRIES, ret);
@@ -6684,8 +6673,8 @@ static void ufshcd_set_active_icc_lvl(struct ufs_hba *hba)
 	if (!desc_buf)
 		return;
 
-	ret = ufshcd_read_desc(hba, QUERY_DESC_IDN_POWER, 0,
-			desc_buf, buff_len);
+	ret = ufshcd_read_desc_param(hba, QUERY_DESC_IDN_POWER, 0, 0,
+				     desc_buf, buff_len);
 	if (ret) {
 		dev_err(hba->dev,
 			"%s: Failed reading power descriptor.len = %d ret = %d",
@@ -6886,8 +6875,8 @@ static int ufs_get_device_desc(struct ufs_hba *hba)
 		goto out;
 	}
 
-	err = ufshcd_read_desc(hba, QUERY_DESC_IDN_DEVICE, 0, desc_buf,
-			hba->desc_size.dev_desc);
+	err = ufshcd_read_desc_param(hba, QUERY_DESC_IDN_DEVICE, 0, 0, desc_buf,
+				     hba->desc_size.dev_desc);
 	if (err) {
 		dev_err(hba->dev, "%s: Failed reading Device Desc. err = %d\n",
 			__func__, err);
@@ -7168,8 +7157,8 @@ static int ufshcd_device_geo_params_init(struct ufs_hba *hba)
 		goto out;
 	}
 
-	err = ufshcd_read_desc(hba, QUERY_DESC_IDN_GEOMETRY, 0,
-			desc_buf, buff_len);
+	err = ufshcd_read_desc_param(hba, QUERY_DESC_IDN_GEOMETRY, 0, 0,
+				     desc_buf, buff_len);
 	if (err) {
 		dev_err(hba->dev, "%s: Failed reading Geometry Desc. err = %d\n",
 				__func__, err);
-- 
2.17.1


^ permalink raw reply related

* [PATCH v4 1/4] scsi: ufs: remove max_t in ufs_get_device_desc
From: Bean Huo @ 2020-05-29 16:40 UTC (permalink / raw)
  To: alim.akhtar, avri.altman, asutoshd, jejb, martin.petersen,
	stanley.chu, beanhuo, bvanassche, tomas.winkler, cang
  Cc: linux-scsi, linux-kernel
In-Reply-To: <20200529164054.27552-1-huobean@gmail.com>

From: Bean Huo <beanhuo@micron.com>

For the UFS device, the maximum descriptor size is 255, max_t called
in ufs_get_device_desc() is useless.

Signed-off-by: Bart van Assche <bvanassche@acm.org>
Signed-off-by: Bean Huo <beanhuo@micron.com>
Acked-by: Avri Altman <avri.altman@wdc.com>
---
 drivers/scsi/ufs/ufshcd.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index aca50ed39844..f57acfbf9d60 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -6876,14 +6876,11 @@ static void ufs_fixup_device_setup(struct ufs_hba *hba)
 static int ufs_get_device_desc(struct ufs_hba *hba)
 {
 	int err;
-	size_t buff_len;
 	u8 model_index;
 	u8 *desc_buf;
 	struct ufs_dev_info *dev_info = &hba->dev_info;
 
-	buff_len = max_t(size_t, hba->desc_size.dev_desc,
-			 QUERY_DESC_MAX_SIZE + 1);
-	desc_buf = kmalloc(buff_len, GFP_KERNEL);
+	desc_buf = kmalloc(QUERY_DESC_MAX_SIZE, GFP_KERNEL);
 	if (!desc_buf) {
 		err = -ENOMEM;
 		goto out;
-- 
2.17.1


^ permalink raw reply related

* arch/powerpc/kernel/entry_32.S:450: Error: unsupported relocation against thread
From: kbuild test robot @ 2020-05-29 16:41 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 12234 bytes --]

Hi Christophe,

First bad commit (maybe != root cause):

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   75caf310d16cc5e2f851c048cd597f5437013368
commit: 4833ce06e6855d526234618b746ffb71d6612c9a powerpc/32s: Fix build failure with CONFIG_PPC_KUAP_DEBUG
date:   3 weeks ago
config: powerpc-randconfig-r035-20200529 (attached as .config)
compiler: powerpc-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        git checkout 4833ce06e6855d526234618b746ffb71d6612c9a
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=powerpc 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kbuild test robot <lkp@intel.com>

All errors (new ones prefixed by >>, old ones prefixed by <<):

arch/powerpc/kernel/entry_32.S: Assembler messages:
arch/powerpc/kernel/entry_32.S:450: Error: invalid operands (*UND* and *UND* sections) for `|'
arch/powerpc/kernel/entry_32.S:735: Error: invalid operands (*UND* and *UND* sections) for `|'
>> arch/powerpc/kernel/entry_32.S:450: Error: unsupported relocation against thread
arch/powerpc/kernel/entry_32.S:735: Error: unsupported relocation against thread

vim +450 arch/powerpc/kernel/entry_32.S

b86fb88855ea78 Christophe Leroy       2019-04-30  344  
9994a33865f4d5 Paul Mackerras         2005-10-10  345  /*
9994a33865f4d5 Paul Mackerras         2005-10-10  346   * Handle a system call.
9994a33865f4d5 Paul Mackerras         2005-10-10  347   */
9994a33865f4d5 Paul Mackerras         2005-10-10  348  	.stabs	"arch/powerpc/kernel/",N_SO,0,0,0f
9994a33865f4d5 Paul Mackerras         2005-10-10  349  	.stabs	"entry_32.S",N_SO,0,0,0f
9994a33865f4d5 Paul Mackerras         2005-10-10  350  0:
9994a33865f4d5 Paul Mackerras         2005-10-10  351  
9994a33865f4d5 Paul Mackerras         2005-10-10  352  _GLOBAL(DoSyscall)
9994a33865f4d5 Paul Mackerras         2005-10-10  353  	stw	r3,ORIG_GPR3(r1)
9994a33865f4d5 Paul Mackerras         2005-10-10  354  	li	r12,0
9994a33865f4d5 Paul Mackerras         2005-10-10  355  	stw	r12,RESULT(r1)
5d38902c483881 Benjamin Herrenschmidt 2009-06-17  356  #ifdef CONFIG_TRACE_IRQFLAGS
40530db7c65611 Christophe Leroy       2019-04-30  357  	/* Make sure interrupts are enabled */
5d38902c483881 Benjamin Herrenschmidt 2009-06-17  358  	mfmsr	r11
5d38902c483881 Benjamin Herrenschmidt 2009-06-17  359  	andi.	r12,r11,MSR_EE
40530db7c65611 Christophe Leroy       2019-04-30  360  	/* We came in with interrupts disabled, we WARN and mark them enabled
40530db7c65611 Christophe Leroy       2019-04-30  361  	 * for lockdep now */
40530db7c65611 Christophe Leroy       2019-04-30  362  0:	tweqi	r12, 0
40530db7c65611 Christophe Leroy       2019-04-30  363  	EMIT_BUG_ENTRY 0b,__FILE__,__LINE__, BUGFLAG_WARNING
5d38902c483881 Benjamin Herrenschmidt 2009-06-17  364  #endif /* CONFIG_TRACE_IRQFLAGS */
f7354ccac844da Christophe Leroy       2019-01-31  365  	lwz	r11,TI_FLAGS(r2)
10ea834364c867 Michael Ellerman       2015-01-15  366  	andi.	r11,r11,_TIF_SYSCALL_DOTRACE
9994a33865f4d5 Paul Mackerras         2005-10-10  367  	bne-	syscall_dotrace
9994a33865f4d5 Paul Mackerras         2005-10-10  368  syscall_dotrace_cont:
9994a33865f4d5 Paul Mackerras         2005-10-10  369  	cmplwi	0,r0,NR_syscalls
9994a33865f4d5 Paul Mackerras         2005-10-10  370  	lis	r10,sys_call_table(a)h
9994a33865f4d5 Paul Mackerras         2005-10-10  371  	ori	r10,r10,sys_call_table(a)l
9994a33865f4d5 Paul Mackerras         2005-10-10  372  	slwi	r0,r0,2
9994a33865f4d5 Paul Mackerras         2005-10-10  373  	bge-	66f
c28218d4abbf4f Diana Craciun          2018-07-28  374  
c28218d4abbf4f Diana Craciun          2018-07-28  375  	barrier_nospec_asm
c28218d4abbf4f Diana Craciun          2018-07-28  376  	/*
c28218d4abbf4f Diana Craciun          2018-07-28  377  	 * Prevent the load of the handler below (based on the user-passed
c28218d4abbf4f Diana Craciun          2018-07-28  378  	 * system call number) being speculatively executed until the test
c28218d4abbf4f Diana Craciun          2018-07-28  379  	 * against NR_syscalls and branch to .66f above has
c28218d4abbf4f Diana Craciun          2018-07-28  380  	 * committed.
c28218d4abbf4f Diana Craciun          2018-07-28  381  	 */
c28218d4abbf4f Diana Craciun          2018-07-28  382  
9994a33865f4d5 Paul Mackerras         2005-10-10  383  	lwzx	r10,r10,r0	/* Fetch system call handler [ptr] */
9994a33865f4d5 Paul Mackerras         2005-10-10  384  	mtlr	r10
9994a33865f4d5 Paul Mackerras         2005-10-10  385  	addi	r9,r1,STACK_FRAME_OVERHEAD
9994a33865f4d5 Paul Mackerras         2005-10-10  386  	PPC440EP_ERR42
9994a33865f4d5 Paul Mackerras         2005-10-10  387  	blrl			/* Call handler */
9994a33865f4d5 Paul Mackerras         2005-10-10  388  	.globl	ret_from_syscall
9994a33865f4d5 Paul Mackerras         2005-10-10  389  ret_from_syscall:
6f37be4b1364ee Boqun Feng             2018-06-02  390  #ifdef CONFIG_DEBUG_RSEQ
6f37be4b1364ee Boqun Feng             2018-06-02  391  	/* Check whether the syscall is issued inside a restartable sequence */
6f37be4b1364ee Boqun Feng             2018-06-02  392  	stw	r3,GPR3(r1)
6f37be4b1364ee Boqun Feng             2018-06-02  393  	addi    r3,r1,STACK_FRAME_OVERHEAD
6f37be4b1364ee Boqun Feng             2018-06-02  394  	bl      rseq_syscall
6f37be4b1364ee Boqun Feng             2018-06-02  395  	lwz	r3,GPR3(r1)
6f37be4b1364ee Boqun Feng             2018-06-02  396  #endif
9994a33865f4d5 Paul Mackerras         2005-10-10  397  	mr	r6,r3
9994a33865f4d5 Paul Mackerras         2005-10-10  398  	/* disable interrupts so current_thread_info()->flags can't change */
ba18025fb03306 Christophe Leroy       2019-08-20  399  	LOAD_REG_IMMEDIATE(r10,MSR_KERNEL)	/* doesn't include MSR_EE */
5d38902c483881 Benjamin Herrenschmidt 2009-06-17  400  	/* Note: We don't bother telling lockdep about it */
9994a33865f4d5 Paul Mackerras         2005-10-10  401  	SYNC
39bccfd1649705 Christophe Leroy       2019-12-21  402  	mtmsr	r10
f7354ccac844da Christophe Leroy       2019-01-31  403  	lwz	r9,TI_FLAGS(r2)
c3525940cca53c Michael Ellerman       2015-07-23  404  	li	r8,-MAX_ERRNO
10ea834364c867 Michael Ellerman       2015-01-15  405  	andi.	r0,r9,(_TIF_SYSCALL_DOTRACE|_TIF_SINGLESTEP|_TIF_USER_WORK_MASK|_TIF_PERSYSCALL_MASK)
9994a33865f4d5 Paul Mackerras         2005-10-10  406  	bne-	syscall_exit_work
401d1f029bebb7 David Woodhouse        2005-11-15  407  	cmplw	0,r3,r8
401d1f029bebb7 David Woodhouse        2005-11-15  408  	blt+	syscall_exit_cont
401d1f029bebb7 David Woodhouse        2005-11-15  409  	lwz	r11,_CCR(r1)			/* Load CR */
401d1f029bebb7 David Woodhouse        2005-11-15  410  	neg	r3,r3
401d1f029bebb7 David Woodhouse        2005-11-15  411  	oris	r11,r11,0x1000	/* Set SO bit in CR */
401d1f029bebb7 David Woodhouse        2005-11-15  412  	stw	r11,_CCR(r1)
9994a33865f4d5 Paul Mackerras         2005-10-10  413  syscall_exit_cont:
5d38902c483881 Benjamin Herrenschmidt 2009-06-17  414  	lwz	r8,_MSR(r1)
5d38902c483881 Benjamin Herrenschmidt 2009-06-17  415  #ifdef CONFIG_TRACE_IRQFLAGS
5d38902c483881 Benjamin Herrenschmidt 2009-06-17  416  	/* If we are going to return from the syscall with interrupts
40530db7c65611 Christophe Leroy       2019-04-30  417  	 * off, we trace that here. It shouldn't normally happen.
5d38902c483881 Benjamin Herrenschmidt 2009-06-17  418  	 */
5d38902c483881 Benjamin Herrenschmidt 2009-06-17  419  	andi.	r10,r8,MSR_EE
5d38902c483881 Benjamin Herrenschmidt 2009-06-17  420  	bne+	1f
5d38902c483881 Benjamin Herrenschmidt 2009-06-17  421  	stw	r3,GPR3(r1)
5d38902c483881 Benjamin Herrenschmidt 2009-06-17  422  	bl      trace_hardirqs_off
5d38902c483881 Benjamin Herrenschmidt 2009-06-17  423  	lwz	r3,GPR3(r1)
5d38902c483881 Benjamin Herrenschmidt 2009-06-17  424  1:
5d38902c483881 Benjamin Herrenschmidt 2009-06-17  425  #endif /* CONFIG_TRACE_IRQFLAGS */
9994a33865f4d5 Paul Mackerras         2005-10-10  426  #if defined(CONFIG_4xx) || defined(CONFIG_BOOKE)
4eaddb4d7ec380 Kumar Gala             2008-04-09  427  	/* If the process has its own DBCR0 value, load it up.  The internal
4eaddb4d7ec380 Kumar Gala             2008-04-09  428  	   debug mode bit tells us that dbcr0 should be loaded. */
9994a33865f4d5 Paul Mackerras         2005-10-10  429  	lwz	r0,THREAD+THREAD_DBCR0(r2)
2325f0a0c3d76b Kumar Gala             2008-07-26  430  	andis.	r10,r0,DBCR0_IDM(a)h
9994a33865f4d5 Paul Mackerras         2005-10-10  431  	bnel-	load_dbcr0
9994a33865f4d5 Paul Mackerras         2005-10-10  432  #endif
b98ac05d5e4603 Benjamin Herrenschmidt 2007-10-31  433  #ifdef CONFIG_44x
e7f75ad01d5902 Dave Kleikamp          2010-03-05  434  BEGIN_MMU_FTR_SECTION
b98ac05d5e4603 Benjamin Herrenschmidt 2007-10-31  435  	lis	r4,icache_44x_need_flush(a)ha
b98ac05d5e4603 Benjamin Herrenschmidt 2007-10-31  436  	lwz	r5,icache_44x_need_flush(a)l(r4)
b98ac05d5e4603 Benjamin Herrenschmidt 2007-10-31  437  	cmplwi	cr0,r5,0
b98ac05d5e4603 Benjamin Herrenschmidt 2007-10-31  438  	bne-	2f
b98ac05d5e4603 Benjamin Herrenschmidt 2007-10-31  439  1:
e7f75ad01d5902 Dave Kleikamp          2010-03-05  440  END_MMU_FTR_SECTION_IFCLR(MMU_FTR_TYPE_47x)
b98ac05d5e4603 Benjamin Herrenschmidt 2007-10-31  441  #endif /* CONFIG_44x */
b64f87c16f3c00 Becky Bruce            2007-11-10  442  BEGIN_FTR_SECTION
b64f87c16f3c00 Becky Bruce            2007-11-10  443  	lwarx	r7,0,r1
b64f87c16f3c00 Becky Bruce            2007-11-10  444  END_FTR_SECTION_IFSET(CPU_FTR_NEED_PAIRED_STWCX)
9994a33865f4d5 Paul Mackerras         2005-10-10  445  	stwcx.	r0,0,r1			/* to clear the reservation */
f7354ccac844da Christophe Leroy       2019-01-31  446  	ACCOUNT_CPU_USER_EXIT(r2, r5, r7)
31ed2b13c48d77 Christophe Leroy       2019-03-11  447  #ifdef CONFIG_PPC_BOOK3S_32
31ed2b13c48d77 Christophe Leroy       2019-03-11  448  	kuep_unlock r5, r7
31ed2b13c48d77 Christophe Leroy       2019-03-11  449  #endif
e2fb9f5444312f Christophe Leroy       2019-03-11 @450  	kuap_check r2, r4
9994a33865f4d5 Paul Mackerras         2005-10-10  451  	lwz	r4,_LINK(r1)
9994a33865f4d5 Paul Mackerras         2005-10-10  452  	lwz	r5,_CCR(r1)
9994a33865f4d5 Paul Mackerras         2005-10-10  453  	mtlr	r4
9994a33865f4d5 Paul Mackerras         2005-10-10  454  	mtcr	r5
9994a33865f4d5 Paul Mackerras         2005-10-10  455  	lwz	r7,_NIP(r1)
9994a33865f4d5 Paul Mackerras         2005-10-10  456  	lwz	r2,GPR2(r1)
9994a33865f4d5 Paul Mackerras         2005-10-10  457  	lwz	r1,GPR1(r1)
cd99ddbea250ee Christophe Leroy       2018-01-12  458  #if defined(CONFIG_PPC_8xx) && defined(CONFIG_PERF_EVENTS)
75b824727680a9 Christophe Leroy       2016-12-15  459  	mtspr	SPRN_NRI, r0
75b824727680a9 Christophe Leroy       2016-12-15  460  #endif
9994a33865f4d5 Paul Mackerras         2005-10-10  461  	mtspr	SPRN_SRR0,r7
9994a33865f4d5 Paul Mackerras         2005-10-10  462  	mtspr	SPRN_SRR1,r8
9994a33865f4d5 Paul Mackerras         2005-10-10  463  	SYNC
9994a33865f4d5 Paul Mackerras         2005-10-10  464  	RFI
b98ac05d5e4603 Benjamin Herrenschmidt 2007-10-31  465  #ifdef CONFIG_44x
b98ac05d5e4603 Benjamin Herrenschmidt 2007-10-31  466  2:	li	r7,0
b98ac05d5e4603 Benjamin Herrenschmidt 2007-10-31  467  	iccci	r0,r0
b98ac05d5e4603 Benjamin Herrenschmidt 2007-10-31  468  	stw	r7,icache_44x_need_flush(a)l(r4)
b98ac05d5e4603 Benjamin Herrenschmidt 2007-10-31  469  	b	1b
b98ac05d5e4603 Benjamin Herrenschmidt 2007-10-31  470  #endif  /* CONFIG_44x */
9994a33865f4d5 Paul Mackerras         2005-10-10  471  

:::::: The code at line 450 was first introduced by commit
:::::: e2fb9f5444312fd01627c84a3e018c1fe8ac6ebb powerpc/32: Prepare for Kernel Userspace Access Protection

:::::: TO: Christophe Leroy <christophe.leroy@c-s.fr>
:::::: CC: Michael Ellerman <mpe@ellerman.id.au>

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 32037 bytes --]

^ permalink raw reply

* Re: [PATCH] or1k: Fix compilation hiccup
From: Peter Maydell @ 2020-05-29 16:40 UTC (permalink / raw)
  To: Christophe de Dinechin
  Cc: QEMU Trivial, Stafford Horne, Jia Liu, QEMU Developers
In-Reply-To: <m1d06msod9.fsf@redhat.com>

On Fri, 29 May 2020 at 17:23, Christophe de Dinechin
<dinechin@redhat.com> wrote:
> On 2020-05-26 at 20:51 CEST, Eric Blake wrote...
> > diff --git a/hw/openrisc/openrisc_sim.c b/hw/openrisc/openrisc_sim.c
> > index d08ce6181199..95011a8015b4 100644
> > --- a/hw/openrisc/openrisc_sim.c
> > +++ b/hw/openrisc/openrisc_sim.c
> > @@ -129,7 +129,7 @@ static void openrisc_sim_init(MachineState *machine)
> >      const char *kernel_filename = machine->kernel_filename;
> >      OpenRISCCPU *cpu = NULL;
> >      MemoryRegion *ram;
> > -    qemu_irq *cpu_irqs[2];
> > +    qemu_irq *cpu_irqs[2] = {};
>
> Why is the value [2] correct here? The loop that initializes loops over
> machine->smp.cpus. Is it always less than 2 on this machine?

Yes: openrisc_sim_machine_init() sets mc->max_cpus = 2.
My suggestion of adding an assert() is essentially telling the
compiler that indeed smp_cpus must always be in the range [1,2],
which we can tell but it can't.

thanks
-- PMM


^ permalink raw reply

* [PATCH v4 0/4] scsi: ufs: cleanup ufs initialization
From: Bean Huo @ 2020-05-29 16:40 UTC (permalink / raw)
  To: alim.akhtar, avri.altman, asutoshd, jejb, martin.petersen,
	stanley.chu, beanhuo, bvanassche, tomas.winkler, cang
  Cc: linux-scsi, linux-kernel

From: Bean Huo <beanhuo@micron.com>

Cleanup UFS descriptor length initialization, and delete unnecessary code.

Changelog:

v2 - v3:
    1. Fix typo in the commit message (Avri Altman & Bart van Assche)
    2. Delete ufshcd_init_desc_sizes() in patch 3/4 (Stanley Chu)
    3. Remove max_t() and buff_len in patch 1/4 (Bart van Assche)
    4. Add patch 4/4

v1 - v2:
    1. Split patch
    2. Fix one compiling WARNING (Reported-by: kbuild test robot <lkp@intel.com>)

Bean Huo (4):
  scsi: ufs: remove max_t in ufs_get_device_desc
  scsi: ufs: delete ufshcd_read_desc()
  scsi: ufs: cleanup ufs initialization path
  scsi: ufs: add compatibility with 3.1 UFS unit descriptor length

 drivers/scsi/ufs/ufs.h     |  11 +-
 drivers/scsi/ufs/ufs_bsg.c |   5 +-
 drivers/scsi/ufs/ufshcd.c  | 200 ++++++++-----------------------------
 drivers/scsi/ufs/ufshcd.h  |  16 +--
 4 files changed, 50 insertions(+), 182 deletions(-)

-- 
2.17.1


^ permalink raw reply

* [ANNOUNCE] unionmount-testsuite: master branch updated to 9c60a9c
From: Amir Goldstein @ 2020-05-29 16:40 UTC (permalink / raw)
  To: linux-unionfs; +Cc: Vivek Goyal, Miklos Szeredi

Hi All,

The master branch on the unionmount-testsuite tree [1] has been updated.

Changes in this update:
- Support user configurable underlying filesystem

So far, unionmount-testsuite used hardcoded paths for layers and
mount point.  Using underlying filesystem other than tmpfs was possible,
but not very easy to setup.

This update brings the ability for user to configure custom paths
with a custom filesystem for the underlying layers.
This is intended to be used for integration with xfstests [2].

Here is an excerpt from the README:
---
  The following environment variables are supported:

  UNIONMOUNT_BASEDIR  - parent dir of all samefs layers (default: /base)
  UNIONMOUNT_LOWERDIR - lower layer path for non samefs (default: /lower)
  UNIONMOUNT_MNTPOINT - mount point for executing tests (default: /mnt)

  When user provides UNIONMOUNT_LOWERDIR:

  1) Path should be an existing directory whose content will be deleted.
  2) Path is assumed to be on a different filesystem than base dir, so
     --samefs setup is not supported.

  When user provides UNIONMOUNT_BASEDIR:

  1) Path should be an existing directory whose content will be deleted.
  2) Upper layer and middle layers will be created under base dir.
  3) If UNIONMOUNT_MNTPOINT is not provided, the overlay mount point will
     be created under base dir.
  4) If UNIONMOUNT_LOWERDIR is not provided, the lower layer dir will be
     created under base dir.
  5) If UNIONMOUNT_LOWERDIR is not provided, the test setup defaults to
     --samefs (i.e. lower and upper layers are on the same base fs).
     However, if --maxfs=<M> is specified, a tmpfs instance will be
     mounted on the lower layer dir that was created under base dir.
---

Many thanks to Vivek for review and testing.

Thanks,
Amir.

[1] https://github.com/amir73il/unionmount-testsuite
[2] https://github.com/amir73il/xfstests/commits/unionmount

The head of the master branch is commit:

9c60a9c Configure custom layers via environment variables

New commits:

Amir Goldstein (3):
  Add command run --clean-up to cleanup old test mounts
  Stop using bind mounts for --samefs
  Configure custom layers via environment variables

 README           |  26 ++++++++++
 mount_union.py   |  13 +----
 run              |  32 +++++-------
 set_up.py        | 127 +++++++++++++++++++++++++----------------------
 settings.py      |  85 +++++++++++++++++++++++++------
 unmount_union.py |  15 +++---
 6 files changed, 187 insertions(+), 111 deletions(-)

-- 
2.17.1


^ permalink raw reply

* Re: CFLAGS overridden by distribution build system
From: Stephen Smalley @ 2020-05-29 16:40 UTC (permalink / raw)
  To: William Roberts; +Cc: Laurent Bigonville, SElinux list
In-Reply-To: <CAFftDdovpeFWnmKGDnTOY4AmwzSW0sCZoRwePX-q=NW1HV2c8w@mail.gmail.com>

On Fri, May 29, 2020 at 12:05 PM William Roberts
<bill.c.roberts@gmail.com> wrote:
>
> On Fri, May 29, 2020 at 8:31 AM Stephen Smalley
> <stephen.smalley.work@gmail.com> wrote:
> >
> > On Sat, May 23, 2020 at 11:59 AM William Roberts
> > <bill.c.roberts@gmail.com> wrote:
> > >
> > > On Sat, May 23, 2020 at 5:57 AM Laurent Bigonville <bigon@debian.org> wrote:
> > > >
> > > > Hello,
> > > >
> > > > The current build system of the userspace is setting a lot of CFLAGS,
> > > > but most of these are overridden by the distributions when building.
> > > >
> > > > Today I received a bug report[0] from Christian Göttsche asking me to
> > > > set -fno-semantic-interposition again in libsepol. I see also the same
> > > > flag and also a lot of others set in libselinux and libsemanage build
> > > > system.
> > >
> > > Why would it be again? The old DSO design made that option impotent.
> > > Clang does it by default.
> > >
> > > >
> > > > For what I understand some of these are just needed for code quality
> > > > (-W) and could be controlled by distributions but others might actually
> > > > need to be always set (-f?).
> > >
> > > If you look at the Makefiles overall in all the projects, you'll see hardening
> > > flags, etc. Libsepol has a pretty minimal set compared to say libselinux, but
> > > they all get overridden by build time CFLAGS if you want.
> > >
> > > >
> > > > Shouldn't the flags that always need to be set (which ones?) be moved to
> > > > a "override CFLAGS" directive to avoid these to be unset by distributions?
> > >
> > > If you we're cleaver with CFLAGS before, you could acually circumvent
> > > the buildtime
> > > DSO stuff. While i'm not opposed to adding it to immutable flag, if
> > > you're setting
> > > CFLAGS, you're on your own. At least with the current design.
> > >
> > > I have no issues with adding it to override, but we would have to
> > > overhaul a bunch
> > > of them and make them consistent.
> >
> > I'm inclined to agree with Laurent here - we should always set this
> > flag in order to preserve the same behavior prior to the patches that
> > removed hidden_def/hidden_proto and switched to relying on this
> > instead.
>
> Theirs a lot of features that rely on particular cflags, consider hardening
> options. A lot of the warnings/error stuff is not just a code hygiene, but also
> spotting potential issues that could arise as security issues. If one starts
> tinkering with cflags, you can really change the code quite a bit. This is why
> some places only approve sanctioned builds of crypto libraries.

I think the difference here is that we made a change in the source
code (hidden_def/hidden_proto removal) that requires use of
-fno-semantic-interposition to preserve existing behavior.

> But one of the things to consider is that for clang builds, clang
> doesn't support
> this option, so we would need to move the compiler checking code into each
> projects root makefile and ensure any consuming subordinate leafs add a
> default, or move it to the global makefile and make sure each leaf that needs it
> has a default.

I think clang does support it now? https://reviews.llvm.org/D72724

^ permalink raw reply

* Re: [RFC][PATCH V3] btrfs: ssd_metadata: storing metadata on SSD
From: Goffredo Baroncelli @ 2020-05-29 16:40 UTC (permalink / raw)
  To: Hans van Kranenburg, linux-btrfs
  Cc: Michael, Hugo Mills, Martin Svec, Wang Yugui
In-Reply-To: <a84d7342-47ed-e162-3047-f7ccdc77fdf1@knorrie.org>

On 5/29/20 6:06 PM, Hans van Kranenburg wrote:
> Hi Goffredo,
> 
> On 4/5/20 10:26 AM, Goffredo Baroncelli wrote:
>>
>> This is an RFC; I wrote this patch because I find the idea interesting
>> even though it adds more complication to the chunk allocator.
>>
>> The core idea is to store the metadata on the ssd and to leave the data
>> on the rotational disks. BTRFS looks at the rotational flags to
>> understand the kind of disks.
> 
> Like I said yesterday, thanks for working on these kind of proof of
> concepts. :)
> 
> Even while this can't be a final solution, it's still very useful in the
> meantime for users for which this is sufficient right now.
> 
> I simply did not realize before that it was possible to just set that
> rotational flag myself using an udev rule... How convenient.
> 
> -# cat /etc/udev/rules.d/99-yolo.rules
> ACTION=="add|change",
> ENV{ID_FS_UUID_SUB_ENC}=="4139fb4c-e7c4-49c7-a4ce-5c86f683ffdc",
> ATTR{queue/rotational}="1"
> ACTION=="add|change",
> ENV{ID_FS_UUID_SUB_ENC}=="192139f4-1618-4089-95fd-4a863db9416b",
> ATTR{queue/rotational}="0"

Yes but of course this should be an exception than the default

> 
>> This new mode is enabled passing the option ssd_metadata at mount time.
>> This policy of allocation is the "preferred" one. If this doesn't permit
>> a chunk allocation, the "classic" one is used.
>>
>> Some examples: (/dev/sd[abc] are ssd, and /dev/sd[ef] are rotational)
>>
>> Non striped profile: metadata->raid1, data->raid1
>> The data is stored on /dev/sd[ef], metadata is stored on /dev/sd[abc].
>> When /dev/sd[ef] are full, then the data chunk is allocated also on
>> /dev/sd[abc].
>>
>> Striped profile: metadata->raid6, data->raid6
>> raid6 requires 3 disks at minimum, so /dev/sd[ef] are not enough for a
>> data profile raid6. To allow a data chunk allocation, the data profile raid6
>> will be stored on all the disks /dev/sd[abcdef].
>> Instead the metadata profile raid6 will be allocated on /dev/sd[abc],
>> because these are enough to host this chunk.
> 
> Yes, and while the explanation above focuses on multi-disk profiles, it
> might be useful (for the similar section in later versions) to
> explicitly mention that for single profile, the same algorithm will just
> cause it to overflow to a less preferred disk if the preferred one is
> completely full. Neat!
> 
> I've been testing this change on top of my 4.19 kernel, and also tried
> to come up with some edge cases, doing ridiculous things to generate
> metadata usage en do stuff like btrfs fi resize to push metadata away
> from the prefered device etc... No weird things happened.
> 
> I guess there will be no further work on this V3, the only comment I
> would have now is that an Opt_no_ssd_metadata would be nice for testing,
> but I can hack that in myself.

Because ssd_metadata is not a default, what would be the purpouse of
Opt_no_ssd_metadata ?

> 
> Thanks,
> Hans
> 


-- 
gpg @keyserver.linux.it: Goffredo Baroncelli <kreijackATinwind.it>
Key fingerprint BBF5 1610 0B64 DAC6 5F7D  17B2 0EDA 9B37 8B82 E0B5

^ permalink raw reply

* Re: [PATCH] or1k: Fix compilation hiccup
From: Peter Maydell @ 2020-05-29 16:40 UTC (permalink / raw)
  To: Christophe de Dinechin
  Cc: Eric Blake, QEMU Trivial, Stafford Horne, Jia Liu,
	QEMU Developers
In-Reply-To: <m1d06msod9.fsf@redhat.com>

On Fri, 29 May 2020 at 17:23, Christophe de Dinechin
<dinechin@redhat.com> wrote:
> On 2020-05-26 at 20:51 CEST, Eric Blake wrote...
> > diff --git a/hw/openrisc/openrisc_sim.c b/hw/openrisc/openrisc_sim.c
> > index d08ce6181199..95011a8015b4 100644
> > --- a/hw/openrisc/openrisc_sim.c
> > +++ b/hw/openrisc/openrisc_sim.c
> > @@ -129,7 +129,7 @@ static void openrisc_sim_init(MachineState *machine)
> >      const char *kernel_filename = machine->kernel_filename;
> >      OpenRISCCPU *cpu = NULL;
> >      MemoryRegion *ram;
> > -    qemu_irq *cpu_irqs[2];
> > +    qemu_irq *cpu_irqs[2] = {};
>
> Why is the value [2] correct here? The loop that initializes loops over
> machine->smp.cpus. Is it always less than 2 on this machine?

Yes: openrisc_sim_machine_init() sets mc->max_cpus = 2.
My suggestion of adding an assert() is essentially telling the
compiler that indeed smp_cpus must always be in the range [1,2],
which we can tell but it can't.

thanks
-- PMM


^ permalink raw reply

* Re: [PATCH] Bluetooth: btmtkuart: Improve exception handling in btmtuart_probe()
From: Markus Elfring @ 2020-05-28 17:09 UTC (permalink / raw)
  To: Chuhong Yuan, linux-arm-kernel, linux-bluetooth, linux-mediatek
  Cc: Johan Hedberg, Marcel Holtmann, Sean Wang, kernel-janitors,
	linux-kernel, Matthias Brugger

> btmtuart_probe() misses several function calls in its error paths,
> including hci_free_dev() and clk_disable_unprepare().
> Refactor the code and call correct undo functions to fix the error
> paths.

How do you think about a wording variant like the following?

   Change description:
   Calls of the functions “clk_disable_unprepare” and “hci_free_dev”
   were missing for the exception handling.
   Thus add the missed function calls together with corresponding
   jump targets.


Would you like to add the tag “Fixes” to the commit message?

Regards,
Markus

_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

^ permalink raw reply

* Re: [PATCH bpf-next RFC 2/3] bpf: devmap dynamic map-value storage area based on BTF
From: Toke Høiland-Jørgensen @ 2020-05-29 16:39 UTC (permalink / raw)
  To: Jesper Dangaard Brouer, David Ahern, bpf, netdev
  Cc: Jesper Dangaard Brouer, Daniel Borkmann, Alexei Starovoitov,
	Andrii Nakryiko
In-Reply-To: <159076798566.1387573.8417040652693679408.stgit@firesoul>

Jesper Dangaard Brouer <brouer@redhat.com> writes:

> The devmap map-value can be read from BPF-prog side, and could be used for a
> storage area per device. This could e.g. contain info on headers that need
> to be added when packet egress this device.
>
> This patchset adds a dynamic storage member to struct bpf_devmap_val. More
> importantly the struct bpf_devmap_val is made dynamic via leveraging and
> requiring BTF for struct sizes above 4. The only mandatory struct member is
> 'ifindex' with a fixed offset of zero.
>
> Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
> ---
>  kernel/bpf/devmap.c |  216 ++++++++++++++++++++++++++++++++++++++++++++-------
>  1 file changed, 185 insertions(+), 31 deletions(-)
>
> diff --git a/kernel/bpf/devmap.c b/kernel/bpf/devmap.c
> index 4ab67b2d8159..9cf2dadcc0fe 100644
> --- a/kernel/bpf/devmap.c
> +++ b/kernel/bpf/devmap.c
> @@ -48,6 +48,7 @@
>  #include <net/xdp.h>
>  #include <linux/filter.h>
>  #include <trace/events/xdp.h>
> +#include <linux/btf.h>
>  
>  #define DEV_CREATE_FLAG_MASK \
>  	(BPF_F_NUMA_NODE | BPF_F_RDONLY | BPF_F_WRONLY)
> @@ -60,13 +61,30 @@ struct xdp_dev_bulk_queue {
>  	unsigned int count;
>  };
>  
> -/* DEVMAP values */
> +/* DEVMAP map-value layout.
> + *
> + * The struct data-layout of map-value is a configuration interface.
> + * BPF-prog side have read-only access to this memory.
> + *
> + * The layout might be different than below, because some struct members are
> + * optional.  This is made dynamic by requiring userspace provides an BTF
> + * description of the struct layout, when creating the BPF-map. Struct names
> + * are important and part of API, as BTF use these names to identify members.
> + */
>  struct bpf_devmap_val {
> -	__u32 ifindex;   /* device index */
> +	__u32 ifindex;   /* device index - mandatory */
>  	union {
>  		int   fd;  /* prog fd on map write */
>  		__u32 id;  /* prog id on map read */
>  	} bpf_prog;
> +	struct {
> +		/* This 'storage' member is meant as a dynamically sized area,
> +		 * that BPF developer can redefine.  As other members are added
> +		 * overtime, this area can shrink, as size can be regained by
> +		 * not using members above. Add new members above this struct.
> +		 */
> +		unsigned char data[24];
> +	} storage;

Why is this needed? Userspace already passes in the value_size, so why
can't the kernel just use the BTF to pick out the values it cares about
and let the rest be up to userspace?

>  };
>  
>  struct bpf_dtab_netdev {
> @@ -79,10 +97,18 @@ struct bpf_dtab_netdev {
>  	struct bpf_devmap_val val;
>  };
>  
> +struct bpf_devmap_val_cfg {
> +	struct {
> +		int ifindex;
> +		int bpf_prog;
> +	} btf_offset;
> +};
> +
>  struct bpf_dtab {
>  	struct bpf_map map;
>  	struct bpf_dtab_netdev **netdev_map; /* DEVMAP type only */
>  	struct list_head list;
> +	struct bpf_devmap_val_cfg cfg;
>  
>  	/* these are only used for DEVMAP_HASH type maps */
>  	struct hlist_head *dev_index_head;
> @@ -116,20 +142,24 @@ static inline struct hlist_head *dev_map_index_hash(struct bpf_dtab *dtab,
>  
>  static int dev_map_init_map(struct bpf_dtab *dtab, union bpf_attr *attr)
>  {
> -	__u32 valsize = attr->value_size;
>  	u64 cost = 0;
>  	int err;
>  
> -	/* check sanity of attributes. 2 value sizes supported:
> -	 * 4 bytes: ifindex
> -	 * 8 bytes: ifindex + prog fd
> -	 */
> +	/* Value contents validated in dev_map_check_btf */
>  	if (attr->max_entries == 0 || attr->key_size != 4 ||
> -	    (valsize != offsetofend(struct bpf_devmap_val, ifindex) &&
> -	     valsize != offsetofend(struct bpf_devmap_val, bpf_prog.fd)) ||
> +	    attr->value_size > sizeof(struct bpf_devmap_val) ||
>  	    attr->map_flags & ~DEV_CREATE_FLAG_MASK)
>  		return -EINVAL;
>  
> +	/* Enforce BTF for userspace, unless dealing with legacy kABI */
> +	if (attr->value_size != 4 &&
> +	    (!attr->btf_key_type_id || !attr->btf_value_type_id))
> +		return -EOPNOTSUPP;
> +
> +	/* Mark BTF offset's as invalid */
> +	dtab->cfg.btf_offset.ifindex  = -1;
> +	dtab->cfg.btf_offset.bpf_prog = -1;
> +
>  	/* Lookup returns a pointer straight to dev->ifindex, so make sure the
>  	 * verifier prevents writes from the BPF side
>  	 */
> @@ -199,6 +229,119 @@ static struct bpf_map *dev_map_alloc(union bpf_attr *attr)
>  	return &dtab->map;
>  }
>  
> +struct expect {
> +	u8 btf_kind;
> +	bool mandatory;
> +	int bit_offset;
> +	int size;
> +	const char *name;
> +};
> +
> +static int btf_find_expect_layout_offset(const struct btf *btf,
> +					 const struct btf_type *value_type,
> +					 const struct expect *layout)
> +{
> +	const struct btf_member *member;
> +	u32 i, off = -ENOENT;
> +
> +	for_each_member(i, value_type, member) {
> +		const struct btf_type *member_type;
> +		const char *member_name;
> +
> +		member_type = btf_type_skip_modifiers(btf, member->type, NULL);
> +		if (BTF_INFO_KIND(member_type->info) != layout->btf_kind) {
> +			continue;
> +		}
> +
> +		member_name = btf_name_by_offset(btf, member->name_off);
> +		if (!member_name)
> +			return -EINVAL;
> +
> +		if (strcmp(layout->name, member_name))
> +			continue;
> +
> +		if (layout->size > 0 &&  // btf_type_has_size(member_type) &&
> +		    member_type->size != layout->size)
> +			continue;
> +
> +		off = btf_member_bit_offset(value_type, member);
> +		if (layout->bit_offset > 0 &&
> +		    layout->bit_offset != off) {
> +			off = -ENOENT;
> +			continue;
> +		}

Won't this enforced offset cause problems for extensibility? Say we
introduce a third struct member that the kernel understands, e.g.
another u32 with expect->bit_offset=64. That would mean you can no
longer skip members, since that would make any subsequent offset tests
fail? Or am I misunderstanding how this is supposed to work?

> +
> +		return off;
> +	}
> +	return off;
> +}
> +
> +/* Expected BTF layout that match struct bpf_devmap_val */
> +static const struct expect layout[] = {
> +	{BTF_KIND_INT,		true,	 0,	 4,	"ifindex"},
> +	{BTF_KIND_UNION,	false,	32,	 4,	"bpf_prog"},
> +	{BTF_KIND_STRUCT,	false,	-1,	-1,	"storage"}
> +};
> +
> +static int dev_map_check_btf(const struct bpf_map *map,
> +			     const struct btf *btf,
> +			     const struct btf_type *key_type,
> +			     const struct btf_type *value_type)
> +{
> +	struct bpf_dtab *dtab = container_of(map, struct bpf_dtab, map);
> +	u32 found_members_cnt = 0;
> +	u32 int_data;
> +	int off;
> +	u32 i;
> +
> +	/* Validate KEY type and size */
> +	if (BTF_INFO_KIND(key_type->info) != BTF_KIND_INT)
> +		return -EOPNOTSUPP;
> +
> +	int_data = *(u32 *)(key_type + 1);
> +	if (BTF_INT_BITS(int_data) != 32 || BTF_INT_OFFSET(int_data) != 0)
> +		return -EOPNOTSUPP;
> +
> +	/* Validate VALUE have layout that match/map-to struct bpf_devmap_val
> +	 * - With a flexible size of member 'storage'.
> +	 */
> +
> +	if (BTF_INFO_KIND(value_type->info) != BTF_KIND_STRUCT)
> +		return -EOPNOTSUPP;
> +
> +	/* Struct/union members in BTF must not exceed (max) expected members */
> +	if (btf_type_vlen(value_type) > ARRAY_SIZE(layout))
> +			return -E2BIG;
> +
> +	for (i = 0; i < ARRAY_SIZE(layout); i++) {
> +		off = btf_find_expect_layout_offset(btf, value_type, &layout[i]);
> +
> +		if (off < 0 && layout[i].mandatory)
> +			return -EUCLEAN;
> +
> +		if (off >= 0)
> +			found_members_cnt++;
> +
> +		/* Transfer layout config to map */
> +		switch (i) {
> +		case 0:
> +			dtab->cfg.btf_offset.ifindex = off;
> +			break;
> +		case 1:
> +			dtab->cfg.btf_offset.bpf_prog = off;
> +			break;
> +		default:
> +			break;
> +		}
> +	}
> +
> +	/* Detect if BTF/vlen have members that were not found */
> +	if (btf_type_vlen(value_type) > found_members_cnt)
> +		return -E2BIG;
> +
> +	return 0;
> +}
> +
>  static void dev_map_free(struct bpf_map *map)
>  {
>  	struct bpf_dtab *dtab = container_of(map, struct bpf_dtab, map);
> @@ -601,42 +744,53 @@ static int dev_map_hash_delete_elem(struct bpf_map *map, void *key)
>  	return ret;
>  }
>  
> +static inline bool map_value_has_bpf_prog(const struct bpf_dtab *dtab)
> +{
> +	return dtab->cfg.btf_offset.bpf_prog >= 0;
> +}
> +
>  static struct bpf_dtab_netdev *__dev_map_alloc_node(struct net *net,
> -						    struct bpf_dtab *dtab,
> +						    struct bpf_map *map,
>  						    struct bpf_devmap_val *val,
>  						    unsigned int idx)
>  {
> +	struct bpf_dtab *dtab = container_of(map, struct bpf_dtab, map);
>  	struct bpf_prog *prog = NULL;
>  	struct bpf_dtab_netdev *dev;
>  
> -	dev = kmalloc_node(sizeof(*dev), GFP_ATOMIC | __GFP_NOWARN,
> +	dev = kzalloc_node(sizeof(*dev), GFP_ATOMIC | __GFP_NOWARN,
>  			   dtab->map.numa_node);
>  	if (!dev)
>  		return ERR_PTR(-ENOMEM);
>  
> +	/* Member: ifindex is mandatory, both BTF and kABI */
>  	dev->dev = dev_get_by_index(net, val->ifindex);
>  	if (!dev->dev)
>  		goto err_out;
>  
> -	if (val->bpf_prog.fd >= 0) {
> -		prog = bpf_prog_get_type_dev(val->bpf_prog.fd,
> -					     BPF_PROG_TYPE_XDP, false);
> -		if (IS_ERR(prog))
> -			goto err_put_dev;
> -		if (prog->expected_attach_type != BPF_XDP_DEVMAP)
> -			goto err_put_prog;
> +	/* Member: bpf_prog union is optional, but have fixed offset if exist */
> +	if (map_value_has_bpf_prog(dtab)) {
> +		if (val->bpf_prog.fd >= 0) {
> +			prog = bpf_prog_get_type_dev(val->bpf_prog.fd,
> +						     BPF_PROG_TYPE_XDP, false);
> +			if (IS_ERR(prog))
> +				goto err_put_dev;
> +			if (prog->expected_attach_type != BPF_XDP_DEVMAP)
> +				goto err_put_prog;
> +		}
> +		if (prog) {
> +			dev->xdp_prog = prog;
> +			val->bpf_prog.id = prog->aux->id;
> +		} else {
> +			dev->xdp_prog = NULL;
> +			val->bpf_prog.id = 0;
> +		}
>  	}
> -
>  	dev->idx = idx;
>  	dev->dtab = dtab;
> -	if (prog) {
> -		dev->xdp_prog = prog;
> -		dev->val.bpf_prog.id = prog->aux->id;
> -	} else {
> -		dev->xdp_prog = NULL;
> -		dev->val.bpf_prog.id = 0;
> -	}
> -	dev->val.ifindex = val->ifindex;
> +
> +	/* After adjustment copy map value to get storage area */
> +	memcpy(&dev->val, val, map->value_size);
>  
>  	return dev;
>  err_put_prog:
> @@ -672,7 +826,7 @@ static int __dev_map_update_elem(struct net *net, struct bpf_map *map,
>  		if (val.bpf_prog.fd != -1)
>  			return -EINVAL;
>  	} else {
> -		dev = __dev_map_alloc_node(net, dtab, &val, i);
> +		dev = __dev_map_alloc_node(net, map, &val, i);
>  		if (IS_ERR(dev))
>  			return PTR_ERR(dev);
>  	}
> @@ -717,7 +871,7 @@ static int __dev_map_hash_update_elem(struct net *net, struct bpf_map *map,
>  	if (old_dev && (map_flags & BPF_NOEXIST))
>  		goto out_err;
>  
> -	dev = __dev_map_alloc_node(net, dtab, &val, idx);
> +	dev = __dev_map_alloc_node(net, map, &val, idx);
>  	if (IS_ERR(dev)) {
>  		err = PTR_ERR(dev);
>  		goto out_err;
> @@ -762,7 +916,7 @@ const struct bpf_map_ops dev_map_ops = {
>  	.map_lookup_elem = dev_map_lookup_elem,
>  	.map_update_elem = dev_map_update_elem,
>  	.map_delete_elem = dev_map_delete_elem,
> -	.map_check_btf = map_check_no_btf,
> +	.map_check_btf = dev_map_check_btf,
>  };
>  
>  const struct bpf_map_ops dev_map_hash_ops = {
> @@ -772,7 +926,7 @@ const struct bpf_map_ops dev_map_hash_ops = {
>  	.map_lookup_elem = dev_map_hash_lookup_elem,
>  	.map_update_elem = dev_map_hash_update_elem,
>  	.map_delete_elem = dev_map_hash_delete_elem,
> -	.map_check_btf = map_check_no_btf,
> +	.map_check_btf = dev_map_check_btf,
>  };
>  
>  static void dev_map_hash_remove_netdev(struct bpf_dtab *dtab,


^ permalink raw reply

* Re: [PULL 00/21] Vga 20200528 patches
From: Peter Maydell @ 2020-05-29 16:36 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Igor Mitsyanko, Alistair Francis, Mark Cave-Ayland,
	QEMU Developers, qemu-arm, qemu-ppc, Gerd Hoffmann
In-Reply-To: <bf43132b-71c2-d411-7cf3-e9a00066ccdc@amsat.org>

On Fri, 29 May 2020 at 17:15, Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
> On 5/29/20 12:29 PM, Peter Maydell wrote:
> > Could somebody send a followup patch to fix the indentation
> > error checkpatch notices, please?
>
> If this is part of your scripts, this is a nice feature :)

No, I just noticed the patchew email.

> >
> > 5/21 Checking commit 97f369f2479d (hw/display/cirrus_vga: Use
> > qemu_log_mask(ERROR) instead of debug printf)
> > ERROR: suspect code indent for conditional statements (16, 12)
> > #34: FILE: hw/display/cirrus_vga.c:1038:
> >                 if (s->cirrus_blt_pixelwidth > 2) {
> > +            qemu_log_mask(LOG_GUEST_ERROR,
>
> I explained on the patches:
>
>   False positive.

The code is
            if (s->cirrus_blt_mode & CIRRUS_BLTMODE_TRANSPARENTCOMP) {
                if (s->cirrus_blt_pixelwidth > 2) {
            qemu_log_mask(LOG_GUEST_ERROR,
                          "cirrus: src transparent without colorexpand "
                          "must be 8bpp or 16bpp\n");
                    goto bitblt_ignore;
                }

checkpatch seems correct; the qemu_log_mask line is misindented,
and looking at the commit this is a misindent introduced in
commit 2b55f4d3504a9f34 "hw/display/cirrus_vga: Use
qemu_log_mask(ERROR) instead of debug printf". The old
fprintf() line was using indent of tab+tab+4 spaces, but
the new qemu_log_mask line is indented by 12 spaces, not 20.
(Tabs are always 8 spaces equivalent.)

Some days I wonder whether we should just do a bulk detabify
of the QEMU sources.

thanks
-- PMM


^ permalink raw reply

* [android-common:android-4.19 1/4] fs/incfs/format.c:616:3: note: in expansion of macro 'pr_warn'
From: kbuild test robot @ 2020-05-29 16:38 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 7079 bytes --]

tree:   https://android.googlesource.com/kernel/common android-4.19
head:   7bab03039e64ed6c26be90530e08978eab3be578
commit: 040942fc50b20325bb56737c32b303268bb6f35c [1/4] ANDROID: Initial commit of Incremental FS
config: i386-randconfig-m021-20200529 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-13) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kbuild test robot <lkp@intel.com>

All warnings (new ones prefixed by >>, old ones prefixed by <<):

In file included from include/linux/printk.h:7,
from include/linux/kernel.h:14,
from include/linux/list.h:9,
from include/linux/wait.h:7,
from include/linux/wait_bit.h:8,
from include/linux/fs.h:6,
from fs/incfs/format.c:5:
fs/incfs/format.c: In function 'incfs_read_next_metadata_record':
include/linux/kern_levels.h:5:18: warning: format '%ld' expects argument of type 'long int', but argument 2 has type 'size_t' {aka 'unsigned int'} [-Wformat=]
5 | #define KERN_SOH "001"  /* ASCII Start Of Header */
|                  ^~~~~~
include/linux/kern_levels.h:12:22: note: in expansion of macro 'KERN_SOH'
12 | #define KERN_WARNING KERN_SOH "4" /* warning conditions */
|                      ^~~~~~~~
include/linux/printk.h:310:9: note: in expansion of macro 'KERN_WARNING'
310 |  printk(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
|         ^~~~~~~~~~~~
include/linux/printk.h:311:17: note: in expansion of macro 'pr_warning'
311 | #define pr_warn pr_warning
|                 ^~~~~~~~~~
>> fs/incfs/format.c:616:3: note: in expansion of macro 'pr_warn'
616 |   pr_warn("incfs: The record is too large. Size: %ld",
|   ^~~~~~~
fs/incfs/format.c:616:52: note: format string is defined here
616 |   pr_warn("incfs: The record is too large. Size: %ld",
|                                                  ~~^
|                                                    |
|                                                    long int
|                                                  %d
--
In file included from fs/incfs/vfs.c:22:
fs/incfs/data_mgmt.h: In function 'get_incfs_node':
fs/incfs/data_mgmt.h:263:27: warning: comparison is always true due to limited range of data type [-Wtype-limits]
263 |  if (inode->i_sb->s_magic != INCFS_MAGIC_NUMBER) {
|                           ^~
fs/incfs/vfs.c: In function 'ioctl_create_file':
fs/incfs/vfs.c:1323:4: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
1323 |    (struct incfs_file_signature_info __user *)
|    ^
fs/incfs/vfs.c: At top level:
fs/incfs/vfs.c:2057:16: warning: no previous prototype for 'incfs_mount_fs' [-Wmissing-prototypes]
2057 | struct dentry *incfs_mount_fs(struct file_system_type *type, int flags,
|                ^~~~~~~~~~~~~~
In file included from fs/incfs/vfs.c:19:
fs/incfs/vfs.c: In function 'incfs_mount_fs':
>> include/uapi/linux/incrementalfs.h:21:28: warning: conversion from 'long long unsigned int' to 'long unsigned int' changes value from '357661101641' to '1178816073' [-Woverflow]
21 | #define INCFS_MAGIC_NUMBER (0x5346434e49ul)
|                            ^
>> fs/incfs/vfs.c:2075:16: note: in expansion of macro 'INCFS_MAGIC_NUMBER'
2075 |  sb->s_magic = INCFS_MAGIC_NUMBER;
|                ^~~~~~~~~~~~~~~~~~
fs/incfs/vfs.c: At top level:
fs/incfs/vfs.c:2176:6: warning: no previous prototype for 'incfs_kill_sb' [-Wmissing-prototypes]
2176 | void incfs_kill_sb(struct super_block *sb)
|      ^~~~~~~~~~~~~

vim +/pr_warn +616 fs/incfs/format.c

   578	
   579	/*
   580	 * Read through metadata records from the backing file one by one
   581	 * and call provided metadata handlers.
   582	 */
   583	int incfs_read_next_metadata_record(struct backing_file_context *bfc,
   584				      struct metadata_handler *handler)
   585	{
   586		const ssize_t max_md_size = INCFS_MAX_METADATA_RECORD_SIZE;
   587		ssize_t bytes_read = 0;
   588		size_t md_record_size = 0;
   589		loff_t next_record = 0;
   590		loff_t prev_record = 0;
   591		int res = 0;
   592		struct incfs_md_header *md_hdr = NULL;
   593	
   594		if (!bfc || !handler)
   595			return -EFAULT;
   596	
   597		LOCK_REQUIRED(bfc->bc_mutex);
   598	
   599		if (handler->md_record_offset == 0)
   600			return -EPERM;
   601	
   602		memset(&handler->md_buffer, 0, max_md_size);
   603		bytes_read = incfs_kread(bfc->bc_file, &handler->md_buffer,
   604					 max_md_size, handler->md_record_offset);
   605		if (bytes_read < 0)
   606			return bytes_read;
   607		if (bytes_read < sizeof(*md_hdr))
   608			return -EBADMSG;
   609	
   610		md_hdr = &handler->md_buffer.md_header;
   611		next_record = le64_to_cpu(md_hdr->h_next_md_offset);
   612		prev_record = le64_to_cpu(md_hdr->h_prev_md_offset);
   613		md_record_size = le16_to_cpu(md_hdr->h_record_size);
   614	
   615		if (md_record_size > max_md_size) {
 > 616			pr_warn("incfs: The record is too large. Size: %ld",
   617					md_record_size);
   618			return -EBADMSG;
   619		}
   620	
   621		if (bytes_read < md_record_size) {
   622			pr_warn("incfs: The record hasn't been fully read.");
   623			return -EBADMSG;
   624		}
   625	
   626		if (next_record <= handler->md_record_offset && next_record != 0) {
   627			pr_warn("incfs: Next record (%lld) points back in file.",
   628				next_record);
   629			return -EBADMSG;
   630		}
   631	
   632		if (prev_record != handler->md_prev_record_offset) {
   633			pr_warn("incfs: Metadata chain has been corrupted.");
   634			return -EBADMSG;
   635		}
   636	
   637		if (le32_to_cpu(md_hdr->h_record_crc) != calc_md_crc(md_hdr)) {
   638			pr_warn("incfs: Metadata CRC mismatch.");
   639			return -EBADMSG;
   640		}
   641	
   642		switch (md_hdr->h_md_entry_type) {
   643		case INCFS_MD_NONE:
   644			break;
   645		case INCFS_MD_BLOCK_MAP:
   646			if (handler->handle_blockmap)
   647				res = handler->handle_blockmap(
   648					&handler->md_buffer.blockmap, handler);
   649			break;
   650		case INCFS_MD_FILE_ATTR:
   651			if (handler->handle_file_attr)
   652				res = handler->handle_file_attr(
   653					&handler->md_buffer.file_attr, handler);
   654			break;
   655		case INCFS_MD_SIGNATURE:
   656			if (handler->handle_signature)
   657				res = handler->handle_signature(
   658					&handler->md_buffer.signature, handler);
   659			break;
   660		default:
   661			res = -ENOTSUPP;
   662			break;
   663		}
   664	
   665		if (!res) {
   666			if (next_record == 0) {
   667				/*
   668				 * Zero offset for the next record means that the last
   669				 * metadata record has just been processed.
   670				 */
   671				bfc->bc_last_md_record_offset =
   672					handler->md_record_offset;
   673			}
   674			handler->md_prev_record_offset = handler->md_record_offset;
   675			handler->md_record_offset = next_record;
   676		}
   677		return res;
   678	}
   679	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 35732 bytes --]

^ permalink raw reply

* [RFC PATCH v5 1/6] dt-bindings: exynos-bus: Add documentation for interconnect properties
From: Sylwester Nawrocki @ 2020-05-29 16:31 UTC (permalink / raw)
  To: georgi.djakov, cw00.choi, krzk
  Cc: linux-samsung-soc, b.zolnierkie, sw0312.kim, a.swigon, dri-devel,
	linux-kernel, myungjoo.ham, s.nawrocki, linux-arm-kernel,
	m.szyprowski
In-Reply-To: <20200529163200.18031-1-s.nawrocki@samsung.com>

Add documentation for new optional properties in the exynos bus nodes:
samsung,interconnect-parent, #interconnect-cells.
These properties allow to specify the SoC interconnect structure which
then allows the interconnect consumer devices to request specific
bandwidth requirements.

Signed-off-by: Artur Świgoń <a.swigon@samsung.com>
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
---
Changes for v5:
 - exynos,interconnect-parent-node renamed to samsung,interconnect-parent
---
 Documentation/devicetree/bindings/devfreq/exynos-bus.txt | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/devfreq/exynos-bus.txt b/Documentation/devicetree/bindings/devfreq/exynos-bus.txt
index e71f752..e0d2daa 100644
--- a/Documentation/devicetree/bindings/devfreq/exynos-bus.txt
+++ b/Documentation/devicetree/bindings/devfreq/exynos-bus.txt
@@ -51,6 +51,11 @@ Optional properties only for parent bus device:
 - exynos,saturation-ratio: the percentage value which is used to calibrate
 			the performance count against total cycle count.

+Optional properties for interconnect functionality (QoS frequency constraints):
+- samsung,interconnect-parent: phandle to the parent interconnect node; for
+  passive devices should point to same node as the exynos,parent-bus property.
+- #interconnect-cells: should be 0
+
 Detailed correlation between sub-blocks and power line according to Exynos SoC:
 - In case of Exynos3250, there are two power line as following:
 	VDD_MIF |--- DMC
@@ -185,8 +190,9 @@ Example1:
 	----------------------------------------------------------

 Example2 :
-	The bus of DMC (Dynamic Memory Controller) block in exynos3250.dtsi
-	is listed below:
+	The bus of DMC (Dynamic Memory Controller) block in exynos3250.dtsi is
+	listed below. An interconnect path "bus_lcd0 -- bus_leftbus -- bus_dmc"
+	is defined for demonstration purposes.

 	bus_dmc: bus_dmc {
 		compatible = "samsung,exynos-bus";
@@ -376,12 +382,15 @@ Example2 :
 	&bus_dmc {
 		devfreq-events = <&ppmu_dmc0_3>, <&ppmu_dmc1_3>;
 		vdd-supply = <&buck1_reg>;	/* VDD_MIF */
+		#interconnect-cells = <0>;
 		status = "okay";
 	};

 	&bus_leftbus {
 		devfreq-events = <&ppmu_leftbus_3>, <&ppmu_rightbus_3>;
 		vdd-supply = <&buck3_reg>;
+		samsung,interconnect-parent = <&bus_dmc>;
+		#interconnect-cells = <0>;
 		status = "okay";
 	};

@@ -392,6 +401,8 @@ Example2 :

 	&bus_lcd0 {
 		devfreq = <&bus_leftbus>;
+		samsung,interconnect-parent = <&bus_leftbus>;
+		#interconnect-cells = <0>;
 		status = "okay";
 	};

--
2.7.4

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related

* [RFC PATCH v5 2/6] interconnect: Add generic interconnect driver for Exynos SoCs
From: Sylwester Nawrocki @ 2020-05-29 16:31 UTC (permalink / raw)
  To: georgi.djakov, cw00.choi, krzk
  Cc: linux-samsung-soc, b.zolnierkie, sw0312.kim, a.swigon, dri-devel,
	linux-kernel, myungjoo.ham, s.nawrocki, linux-arm-kernel,
	m.szyprowski
In-Reply-To: <20200529163200.18031-1-s.nawrocki@samsung.com>

This patch adds a generic interconnect driver for Exynos SoCs in order
to provide interconnect functionality for each "samsung,exynos-bus"
compatible device.

The SoC topology is a graph (or more specifically, a tree) and its
edges are specified using the 'samsung,interconnect-parent' in the
DT. Due to unspecified relative probing order, -EPROBE_DEFER may be
propagated to ensure that the parent is probed before its children.

Each bus is now an interconnect provider and an interconnect node as
well (cf. Documentation/interconnect/interconnect.rst), i.e. every bus
registers itself as a node. Node IDs are not hardcoded but rather
assigned dynamically at runtime. This approach allows for using this
driver with various Exynos SoCs.

Frequencies requested via the interconnect API for a given node are
propagated to devfreq using dev_pm_qos_update_request(). Please note
that it is not an error when CONFIG_INTERCONNECT is 'n', in which
case all interconnect API functions are no-op.

Signed-off-by: Artur Świgoń <a.swigon@samsung.com>
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>

Changes for v5:
 - adjust to renamed exynos,interconnect-parent-node property,
 - use automatically generated platform device id as the interconect
   node id instead of a now unavailable devfreq->id field,
 - add icc_ prefix to some variables to make the code more self-commenting,
 - use icc_nodes_remove() instead of icc_node_del() + icc_node_destroy(),
 - adjust to exynos,interconnect-parent-node property rename to
   samsung,interconnect-parent,
 - converted to a separate platform driver in drivers/interconnect.
---
 drivers/interconnect/Kconfig         |   1 +
 drivers/interconnect/Makefile        |   1 +
 drivers/interconnect/exynos/Kconfig  |   6 ++
 drivers/interconnect/exynos/Makefile |   4 +
 drivers/interconnect/exynos/exynos.c | 185 +++++++++++++++++++++++++++++++++++
 5 files changed, 197 insertions(+)
 create mode 100644 drivers/interconnect/exynos/Kconfig
 create mode 100644 drivers/interconnect/exynos/Makefile
 create mode 100644 drivers/interconnect/exynos/exynos.c

diff --git a/drivers/interconnect/Kconfig b/drivers/interconnect/Kconfig
index 5b7204e..eca6eda 100644
--- a/drivers/interconnect/Kconfig
+++ b/drivers/interconnect/Kconfig
@@ -11,6 +11,7 @@ menuconfig INTERCONNECT
 
 if INTERCONNECT
 
+source "drivers/interconnect/exynos/Kconfig"
 source "drivers/interconnect/imx/Kconfig"
 source "drivers/interconnect/qcom/Kconfig"
 
diff --git a/drivers/interconnect/Makefile b/drivers/interconnect/Makefile
index 4825c28..2ba1de6 100644
--- a/drivers/interconnect/Makefile
+++ b/drivers/interconnect/Makefile
@@ -4,5 +4,6 @@ CFLAGS_core.o				:= -I$(src)
 icc-core-objs				:= core.o
 
 obj-$(CONFIG_INTERCONNECT)		+= icc-core.o
+obj-$(CONFIG_INTERCONNECT_EXYNOS)	+= exynos/
 obj-$(CONFIG_INTERCONNECT_IMX)		+= imx/
 obj-$(CONFIG_INTERCONNECT_QCOM)		+= qcom/
diff --git a/drivers/interconnect/exynos/Kconfig b/drivers/interconnect/exynos/Kconfig
new file mode 100644
index 0000000..e51e52e
--- /dev/null
+++ b/drivers/interconnect/exynos/Kconfig
@@ -0,0 +1,6 @@
+# SPDX-License-Identifier: GPL-2.0-only
+config INTERCONNECT_EXYNOS
+	tristate "Exynos generic interconnect driver"
+	depends on ARCH_EXYNOS || COMPILE_TEST
+	help
+	  Generic interconnect driver for Exynos SoCs.
diff --git a/drivers/interconnect/exynos/Makefile b/drivers/interconnect/exynos/Makefile
new file mode 100644
index 0000000..e19d1df
--- /dev/null
+++ b/drivers/interconnect/exynos/Makefile
@@ -0,0 +1,4 @@
+# SPDX-License-Identifier: GPL-2.0
+exynos-interconnect-objs		:= exynos.o
+
+obj-$(CONFIG_INTERCONNECT_EXYNOS)	+= exynos-interconnect.o
diff --git a/drivers/interconnect/exynos/exynos.c b/drivers/interconnect/exynos/exynos.c
new file mode 100644
index 0000000..8278194
--- /dev/null
+++ b/drivers/interconnect/exynos/exynos.c
@@ -0,0 +1,185 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Exynos generic interconnect provider driver
+ *
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ *
+ * Authors: Artur Świgoń <a.swigon@samsung.com>
+ *          Sylwester Nawrocki <s.nawrocki@samsung.com>
+ */
+#include <linux/device.h>
+#include <linux/interconnect-provider.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
+#include <linux/pm_qos.h>
+
+#define kbps_to_khz(x) ((x) / 8)
+
+struct exynos_icc_priv {
+	struct device *dev;
+
+	/* One interconnect node per provider */
+	struct icc_provider provider;
+	struct icc_node *node;
+
+	struct dev_pm_qos_request qos_req;
+};
+
+static struct icc_node *exynos_icc_get_parent(struct device_node *np)
+{
+	struct of_phandle_args args;
+	int num, ret;
+
+	num = of_count_phandle_with_args(np, "samsung,interconnect-parent",
+					"#interconnect-cells");
+	if (num != 1)
+		return NULL; /* parent nodes are optional */
+
+	ret = of_parse_phandle_with_args(np, "samsung,interconnect-parent",
+					"#interconnect-cells", 0, &args);
+	if (ret < 0)
+		return ERR_PTR(ret);
+
+	of_node_put(args.np);
+
+	return of_icc_get_from_provider(&args);
+}
+
+
+static int exynos_generic_icc_set(struct icc_node *src, struct icc_node *dst)
+{
+	struct exynos_icc_priv *src_priv = src->data, *dst_priv = dst->data;
+	s32 src_freq = kbps_to_khz(max(src->avg_bw, src->peak_bw));
+	s32 dst_freq = kbps_to_khz(max(dst->avg_bw, dst->peak_bw));
+	int ret;
+
+	ret = dev_pm_qos_update_request(&src_priv->qos_req, src_freq);
+	if (ret < 0) {
+		dev_err(src_priv->dev, "failed to update PM QoS of %s\n",
+			src->name);
+		return ret;
+	}
+
+	ret = dev_pm_qos_update_request(&dst_priv->qos_req, dst_freq);
+	if (ret < 0) {
+		dev_err(dst_priv->dev, "failed to update PM QoS of %s\n",
+			dst->name);
+		return ret;
+	}
+
+	return 0;
+}
+
+static struct icc_node *exynos_generic_icc_xlate(struct of_phandle_args *spec,
+						 void *data)
+{
+	struct exynos_icc_priv *priv = data;
+
+	if (spec->np != priv->dev->parent->of_node)
+		return ERR_PTR(-EINVAL);
+
+	return priv->node;
+}
+
+static int exynos_generic_icc_remove(struct platform_device *pdev)
+{
+	struct exynos_icc_priv *priv = platform_get_drvdata(pdev);
+	struct icc_node *parent_node, *node = priv->node;
+
+	parent_node = exynos_icc_get_parent(priv->dev->parent->of_node);
+	if (parent_node && !IS_ERR(parent_node))
+		icc_link_destroy(node, parent_node);
+
+	icc_nodes_remove(&priv->provider);
+	icc_provider_del(&priv->provider);
+
+	return 0;
+}
+
+static int exynos_generic_icc_probe(struct platform_device *pdev)
+{
+	struct device *bus_dev = pdev->dev.parent;
+	struct exynos_icc_priv *priv;
+	struct icc_provider *provider;
+	struct icc_node *icc_node, *icc_parent_node;
+	int ret;
+
+	priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
+	if (!priv)
+		return -ENOMEM;
+
+	priv->dev = &pdev->dev;
+	platform_set_drvdata(pdev, priv);
+
+	provider = &priv->provider;
+
+	provider->set = exynos_generic_icc_set;
+	provider->aggregate = icc_std_aggregate;
+	provider->xlate = exynos_generic_icc_xlate;
+	provider->dev = bus_dev;
+	provider->inter_set = true;
+	provider->data = priv;
+
+	ret = icc_provider_add(provider);
+	if (ret < 0)
+		return ret;
+
+	icc_node = icc_node_create(pdev->id);
+	if (IS_ERR(icc_node)) {
+		ret = PTR_ERR(icc_node);
+		goto err_prov_del;
+	}
+
+	priv->node = icc_node;
+	icc_node->name = bus_dev->of_node->name;
+	icc_node->data = priv;
+	icc_node_add(icc_node, provider);
+
+	icc_parent_node = exynos_icc_get_parent(bus_dev->of_node);
+	if (IS_ERR(icc_parent_node)) {
+		ret = PTR_ERR(icc_parent_node);
+		goto err_node_del;
+	}
+	if (icc_parent_node) {
+		ret = icc_link_create(icc_node, icc_parent_node->id);
+		if (ret < 0)
+			goto err_node_del;
+	}
+
+	/*
+	 * Register a PM QoS request for the bus device for which also devfreq
+	 * functionality is registered.
+	 */
+	ret = dev_pm_qos_add_request(bus_dev, &priv->qos_req,
+				     DEV_PM_QOS_MIN_FREQUENCY, 0);
+	if (ret < 0)
+		goto err_link_destroy;
+
+	return 0;
+
+err_link_destroy:
+	if (icc_parent_node)
+		icc_link_destroy(icc_node, icc_parent_node);
+err_node_del:
+	icc_nodes_remove(provider);
+err_prov_del:
+	icc_provider_del(provider);
+
+	return ret;
+}
+
+static struct platform_driver exynos_generic_icc_driver = {
+	.driver = {
+		.name = "exynos-generic-icc",
+	},
+	.probe = exynos_generic_icc_probe,
+	.remove = exynos_generic_icc_remove,
+};
+module_platform_driver(exynos_generic_icc_driver);
+
+MODULE_DESCRIPTION("Exynos generic interconnect driver");
+MODULE_AUTHOR("Artur Świgoń <a.swigon@samsung.com>");
+MODULE_AUTHOR("Sylwester Nawrocki <s.nawrocki@samsung.com>");
+MODULE_LICENSE("GPL v2");
+MODULE_ALIAS("platform:exynos-generic-icc");
-- 
2.7.4

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related

* [RFC PATCH v5 4/6] ARM: dts: exynos: Add interconnect properties to Exynos4412 bus nodes
From: Sylwester Nawrocki @ 2020-05-29 16:31 UTC (permalink / raw)
  To: georgi.djakov, cw00.choi, krzk
  Cc: linux-samsung-soc, b.zolnierkie, sw0312.kim, a.swigon, dri-devel,
	linux-kernel, myungjoo.ham, s.nawrocki, linux-arm-kernel,
	m.szyprowski
In-Reply-To: <20200529163200.18031-1-s.nawrocki@samsung.com>

This patch adds the following properties for Exynos4412 interconnect
bus nodes:
 - samsung,interconnect-parent: to declare connections between
   nodes in order to guarantee PM QoS requirements between nodes;
 - #interconnect-cells: required by the interconnect framework.

Note that #interconnect-cells is always zero and node IDs are not
hardcoded anywhere.

Signed-off-by: Artur Świgoń <a.swigon@samsung.com>
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
---
Changes for v5:
 - adjust to renamed exynos,interconnect-parent-node property,
 - add properties in common exynos4412.dtsi file rather than
   in Odroid specific odroid4412-odroid-common.dtsi.
---
 arch/arm/boot/dts/exynos4412.dtsi | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/arch/arm/boot/dts/exynos4412.dtsi b/arch/arm/boot/dts/exynos4412.dtsi
index 4886894..a7496d3 100644
--- a/arch/arm/boot/dts/exynos4412.dtsi
+++ b/arch/arm/boot/dts/exynos4412.dtsi
@@ -381,6 +381,7 @@
 			clocks = <&clock CLK_DIV_DMC>;
 			clock-names = "bus";
 			operating-points-v2 = <&bus_dmc_opp_table>;
+			#interconnect-cells = <0>;
 			status = "disabled";
 		};
 
@@ -450,6 +451,8 @@
 			clocks = <&clock CLK_DIV_GDL>;
 			clock-names = "bus";
 			operating-points-v2 = <&bus_leftbus_opp_table>;
+			samsung,interconnect-parent = <&bus_dmc>;
+			#interconnect-cells = <0>;
 			status = "disabled";
 		};
 
@@ -466,6 +469,8 @@
 			clocks = <&clock CLK_ACLK160>;
 			clock-names = "bus";
 			operating-points-v2 = <&bus_display_opp_table>;
+			samsung,interconnect-parent = <&bus_leftbus>;
+			#interconnect-cells = <0>;
 			status = "disabled";
 		};
 
-- 
2.7.4

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related

* [RFC PATCH v5 5/6] ARM: dts: exynos: Add interconnects to Exynos4412 mixer
From: Sylwester Nawrocki @ 2020-05-29 16:31 UTC (permalink / raw)
  To: georgi.djakov, cw00.choi, krzk
  Cc: linux-samsung-soc, b.zolnierkie, sw0312.kim, a.swigon, dri-devel,
	linux-kernel, myungjoo.ham, s.nawrocki, linux-arm-kernel,
	m.szyprowski
In-Reply-To: <20200529163200.18031-1-s.nawrocki@samsung.com>

From: Artur Świgoń <a.swigon@samsung.com>

This patch adds an 'interconnects' property to Exynos4412 DTS in order to
declare the interconnect path used by the mixer. Please note that the
'interconnect-names' property is not needed when there is only one path in
'interconnects', in which case calling of_icc_get() with a NULL name simply
returns the right path.

Signed-off-by: Artur Świgoń <a.swigon@samsung.com>
Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com>
---
Changes for v5:
 - none.
---
 arch/arm/boot/dts/exynos4412.dtsi | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/boot/dts/exynos4412.dtsi b/arch/arm/boot/dts/exynos4412.dtsi
index a7496d3..eee86d2 100644
--- a/arch/arm/boot/dts/exynos4412.dtsi
+++ b/arch/arm/boot/dts/exynos4412.dtsi
@@ -776,6 +776,7 @@
 	clock-names = "mixer", "hdmi", "sclk_hdmi", "vp";
 	clocks = <&clock CLK_MIXER>, <&clock CLK_HDMI>,
 		 <&clock CLK_SCLK_HDMI>, <&clock CLK_VP>;
+	interconnects = <&bus_display &bus_dmc>;
 };
 
 &pmu {
-- 
2.7.4

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related

* [RFC PATCH v5 3/6] PM / devfreq: exynos-bus: Add registration of interconnect child device
From: Sylwester Nawrocki @ 2020-05-29 16:31 UTC (permalink / raw)
  To: georgi.djakov, cw00.choi, krzk
  Cc: linux-samsung-soc, b.zolnierkie, sw0312.kim, a.swigon, dri-devel,
	linux-kernel, myungjoo.ham, s.nawrocki, linux-arm-kernel,
	m.szyprowski
In-Reply-To: <20200529163200.18031-1-s.nawrocki@samsung.com>

This patch adds registration of a child platform device for the exynos
interconnect driver. It is assumed that the interconnect provider will
only be needed when #interconnect-cells property is present in the bus
DT node, hence the child device will be created only when such a property
is present.

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>

Changes for v5:
 - new patch.
---
 drivers/devfreq/exynos-bus.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/drivers/devfreq/exynos-bus.c b/drivers/devfreq/exynos-bus.c
index 8fa8eb5..856e37d 100644
--- a/drivers/devfreq/exynos-bus.c
+++ b/drivers/devfreq/exynos-bus.c
@@ -24,6 +24,7 @@
 
 struct exynos_bus {
 	struct device *dev;
+	struct platform_device *icc_pdev;
 
 	struct devfreq *devfreq;
 	struct devfreq_event_dev **edev;
@@ -156,6 +157,8 @@ static void exynos_bus_exit(struct device *dev)
 	if (ret < 0)
 		dev_warn(dev, "failed to disable the devfreq-event devices\n");
 
+	platform_device_unregister(bus->icc_pdev);
+
 	dev_pm_opp_of_remove_table(dev);
 	clk_disable_unprepare(bus->clk);
 	if (bus->opp_table) {
@@ -168,6 +171,8 @@ static void exynos_bus_passive_exit(struct device *dev)
 {
 	struct exynos_bus *bus = dev_get_drvdata(dev);
 
+	platform_device_unregister(bus->icc_pdev);
+
 	dev_pm_opp_of_remove_table(dev);
 	clk_disable_unprepare(bus->clk);
 }
@@ -431,6 +436,18 @@ static int exynos_bus_probe(struct platform_device *pdev)
 	if (ret < 0)
 		goto err;
 
+	/* Create child platform device for the interconnect provider */
+	if (of_get_property(dev->of_node, "#interconnect-cells", NULL)) {
+		    bus->icc_pdev = platform_device_register_data(
+						dev, "exynos-generic-icc",
+						PLATFORM_DEVID_AUTO, NULL, 0);
+
+		    if (IS_ERR(bus->icc_pdev)) {
+			    ret = PTR_ERR(bus->icc_pdev);
+			    goto err;
+		    }
+	}
+
 	max_state = bus->devfreq->profile->max_state;
 	min_freq = (bus->devfreq->profile->freq_table[0] / 1000);
 	max_freq = (bus->devfreq->profile->freq_table[max_state - 1] / 1000);
-- 
2.7.4

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related

* Re: [PATCH] usb: dwc2: Fix shutdown callback in platform
From: Doug Anderson @ 2020-05-29 16:37 UTC (permalink / raw)
  To: Minas Harutyunyan
  Cc: John Youn, Felipe Balbi, Greg Kroah-Hartman,
	linux-usb@vger.kernel.org, Felipe Balbi, Heiko Stübner,
	# 4.0+, Frank Mori Hess
In-Reply-To: <0f6b1580-41d8-b7e7-206b-64cda87abfd5@synopsys.com>

Hi,


On Fri, May 29, 2020 at 9:30 AM Minas Harutyunyan
<Minas.Harutyunyan@synopsys.com> wrote:
>
> Hi Doug,
>
> On 5/29/2020 6:49 PM, Doug Anderson wrote:
> > Hi,
> >
> > On Fri, May 29, 2020 at 4:51 AM Minas Harutyunyan
> > <Minas.Harutyunyan@synopsys.com> wrote:
> >>
> >> To avoid lot of interrupts from dwc2 core, which can be asserted in
> >> specific conditions need to disable interrupts on HW level instead of
> >> disable IRQs on Kernel level, because of IRQ can be shared between
> >> drivers.
> >>
> >> Cc: stable@vger.kernel.org
> >> Fixes: a40a00318c7fc ("usb: dwc2: add shutdown callback to platform variant")
> >> Tested-by: Frank Mori Hess <fmh6jj@gmail.com>
> >> Signed-off-by: Minas Harutyunyan <hminas@synopsys.com>
> >> ---
> >>   drivers/usb/dwc2/platform.c | 2 +-
> >>   1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >> diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c
> >> index e571c8ae65ec..ada5b66b948e 100644
> >> --- a/drivers/usb/dwc2/platform.c
> >> +++ b/drivers/usb/dwc2/platform.c
> >> @@ -342,7 +342,7 @@ static void dwc2_driver_shutdown(struct platform_device *dev)
> >>   {
> >>          struct dwc2_hsotg *hsotg = platform_get_drvdata(dev);
> >>
> >> -       disable_irq(hsotg->irq);
> >> +       dwc2_disable_global_interrupts(hsotg);
> >>   }
> >
> > I could be wrong, but I think it would be better to instead end up
> > with both calls, like:
> >
> > dwc2_disable_global_interrupts(hsotg);
> > disable_irq(hsotg->irq);
> >
> > To some extent it's slightly overkill, but the disable_irq() function
> > has the nice "and wait for completion" bit.  Your new call doesn't do
> > this.
> >
> If dwc2 currently handling some interrupt then below patch can allow to
> wait until interrupt will be handled:
>
> spin_lock(&hsotg->lock);
> dwc2_disable_global_interrupts(hsotg);
> spin_unlock(&hsotg->lock);

Would that really work?  If you've got a two core system and the
interrupt is just firing on a different core but hasn't acquired the
spinlock then your code might get the spinlock, disable the
interrupts, and then release the spinlock.  The interrupt handler will
still be running on the other CPU and now will get the spinlock.


> but on other hand dwc2 have 3 subsequent interrupt handlers - core,
> gadget, host and not clear which of handler completed.
>
> > That being said, though, you still won't wait for the completion of
> > the IRQ handler for the "other drivers" you reference, right.  Maybe a
> > better fix would be to add a shutdown callback for those other drivers
> > and just keep relying on disable_irq()?
> >
> I have look to other drivers where used disable_irq() - no any driver
> care about SHARED irq's. In that case your suggestion to use both
> disabling is looks Ok.

I'm not sure I understand.  Are you saying that you'll just add
shutdown callbacks to all the drivers using this IRQ and call
disable_irq() there?  That seems like the best solution to me.

-Doug

^ permalink raw reply

* Re: [PATCH v2 3/5] automation/archlinux: Add 32-bit glibc headers
From: Anthony PERARD @ 2020-05-29 16:37 UTC (permalink / raw)
  To: George Dunlap; +Cc: xen-devel@lists.xenproject.org, Doug Goldstein, Wei Liu
In-Reply-To: <CF50B50F-BDC0-4290-A606-33927CE86FE9@citrix.com>

On Thu, May 28, 2020 at 12:32:02PM +0100, George Dunlap wrote:
> On May 27, 2020, at 12:29 PM, Wei Liu <wl@xen.org> wrote:
> > All automation patches:
> > 
> > Acked-by: Wei Liu <wl@xen.org>
> > 
> > Anthony, can you generate and push the new images? Thanks.
> 
> These are checked in now.
> 
> BTW it looks like there may be some other compilation issues updating the archlinux image.  I tested the minimum configuration required to get the golang bindings to build; but a full build fails with other errors I haven’t had time to diagnose yet.

The only issue seems to be that ipxe doesn't build. A simple -Wno-error
would make it works.

-- 
Anthony PERARD


^ permalink raw reply

* Re: [RFC][PATCH V4] btrfs: preferred_metadata: preferred device for metadata
From: Goffredo Baroncelli @ 2020-05-29 16:37 UTC (permalink / raw)
  To: Hans van Kranenburg, linux-btrfs
  Cc: Michael, Hugo Mills, Martin Svec, Wang Yugui, Paul Jones,
	Adam Borowski, Zygo Blaxell
In-Reply-To: <8f85f920-b0d0-3c11-3fd2-2f831efb37f4@knorrie.org>

On 5/28/20 11:59 PM, Hans van Kranenburg wrote:
> Hi!
> 
> On 5/28/20 8:34 PM, Goffredo Baroncelli wrote:
>>
>> [the previous patches sets called this mode ssd_metadata]
>>
>> Hi all,
>>
>> This is an RFC; I wrote this patch because I find the idea interesting
>> even though it adds more complication to the chunk allocator.
> 
> Thanks for working on this. This is an often discussed feature request.
> So, taking it to the next level by actually writing PoC code helps a lot
> I guess.
> 
>> The initial idea was to store the metadata on the ssd and to leave the data
>> on the rotational disks. The kind of disk was determined from the rotational
>> flag. However looking only at the rotational flags is not flexible enough. So
>> I added a device property called "preferred_metadata" to mark a device
>> as preferred for metadata.
>>
>> A separate patches set is sent to extend the "btrfs property" command
>> for supporting the preferred_metadata device flag. The basic usage is:
>>
>>      $ # set a new value
>>      $ sudo btrfs property set /dev/vde preferred_metadata 1
>>      
>>      $ # get the current value
>>      $ sudo btrfs property get /dev/vde preferred_metadata
>>      devid=4, path=/dev/vde: dedicated_metadata=1
>>
>> This new mode is enabled passing the option "preferred_metadata" at mount time.
>> This policy of allocation is the default one. However if this doesn't permit
>> a chunk allocation, the "classic" one is used.
>>
>> Some examples: (/dev/sd[abc] are marked as preferred_metadata,
>> and /dev/sd[ef] are not)
>>
>> Non striped profile: metadata->raid1, data->raid1
>> The data is stored on /dev/sd[ef], metadata is stored on /dev/sd[abc].
>> When /dev/sd[ef] are full, then the data chunk is allocated also on
>> /dev/sd[abc].
>>
>> Striped profile: metadata->raid6, data->raid6
>> raid6 requires 3 disks at minimum, so /dev/sd[ef] are not enough for a
>> data profile raid6. To allow a data chunk allocation, the data profile raid6
>> will be stored on all the disks /dev/sd[abcdef].
>> Instead the metadata profile raid6 will be allocated on /dev/sd[abc],
>> because these are enough to host this chunk.
>>
>> The patches set is composed by four patches:
>>
>> - The first patch adds the ioctl to update the btrfs_dev_item.type field.
>> The ioctl is generic to handle more fields, however now only the "type"
>> field is supported.
> 
> What are your thoughts about the chicken/egg situation of changing these
> properties only when the filesystem is mounted?

The logic is related only to a chunk allocation. I.e. if you have a not
empty filesystem, after enabling the preferred_metadata "mode", in order
to get the benefit a full balance is required.

> 
> E.g. mkfs puts metadata on the wrong disk, and then only after actually
> mounting, I have to find out how to find out where metadata is actually
> placed, and then play around with btrfs balance options until I get
> everything moved to my preferred disks. Do you have any ideas about
> improving the out of the box usability of this?

In order to figure out where the (meta)data are placed, "btrfs fi us"
is your friend.
Of course setting this at mkfs.btrfs time is a good suggestion.

> 
>> - The second patch adds the flag BTRFS_DEV_PREFERRED_METADATA which is
>> used to mark a device as "preferred_metadata"
>>
>> - The third patch exports the btrfs_dev_item.type field via sysfs files
>> /sys/fs/btrfs/<UUID>/devinfo/<devid>/type
>>
>> It is possible only to read the value. It is not implemented the updated
>> of the value because in btrfs/stsfs.c there is a comment that states:
>> "We don't want to do full transaction commit from inside sysfs".
>>
>> - The fourth patch implements this new mode
>>
>> Changelog:
>> v4: - renamed ssd_metadata to preferred_metadata
>>      - add the device property "preferred_metadata"
>>      - add the ioctl BTRFS_IOC_DEV_PROPERTIES
>>      - export the btrfs_dev_item.type values via sysfs
>> v3: - correct the collision between BTRFS_MOUNT_DISCARD_ASYNC and
>>        BTRFS_MOUNT_SSD_METADATA.
>> v2: - rebased to v5.6.2
>>      - correct the comparison about the rotational disks (>= instead of >)
>>      - add the flag rotational to the struct btrfs_device_info to
>>        simplify the comparison function (btrfs_cmp_device_info*() )
>> v1: - first issue
>>
>> [...]
> Another question: what is your opinion about device replace? Should it
> leave properties of the destination device alone, or should it copy the
> bit over?
>
> If I'm replacing my ssd with metadata with a larger one, then what
> should I expect to happen by default as user (already having forgotten
> about that property command that I had to use to actually make it work
> months ago)?

In the previous attempt I rtried  to detect automatically which disk is faster
looking at the rotation flag. However someone pointed me that even from
a sata ssd and a pci nvme there is an huge speed differences (even tough
the latency is more important).
This to say that an automatic logic is not the best possible choice for all
the cases .
Then the next step was to add a flag to mark explicitly the devices for
metadata.

I think that "replacing" and "adding" doesn't have a "sane" default. There will
be always a case where an user replace an ssd with an mechanical hdd or
a case where an ssd is added where there is already an pci nvme.

What would make sense is an additional option to btrfs add/replace
that allows to specify if the disk should be preferred for metadata or not.
> 
> Thanks,
> Hans
> 


-- 
gpg @keyserver.linux.it: Goffredo Baroncelli <kreijackATinwind.it>
Key fingerprint BBF5 1610 0B64 DAC6 5F7D  17B2 0EDA 9B37 8B82 E0B5

^ permalink raw reply

* Re: Kernel crash due to memory corruption with v5.4.26-rt17 and PowerPC e500
From: Sebastian Andrzej Siewior @ 2020-05-29 16:37 UTC (permalink / raw)
  To: Mark Marshall
  Cc: linux-rt-users, Mark Marshall, thomas.graziadei, Thomas Gleixner,
	linux-kernel, rostedt
In-Reply-To: <20200529161518.svpxhkeljafbtdz2@linutronix.de>

On 2020-05-29 18:15:18 [+0200], To Mark Marshall wrote:
> In order to get it back into the RT queue I need to understand why it is
> required. What exactly is it fixing. Let me stare at for a little…

it used to be local_irq_disable() which then became preempt_disable()
local_irq_disable() due to ARM's limitation.

> > Best regards,
> > Mark
> 
Sebastian

^ permalink raw reply


This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.