Skip to contentSkip to conversation

s390: export ipl device parameters

PATCH In review Heiko Carstens 2 participants 4 messages Sep 23, 2005 – Sep 26, 2005 s390

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 s390: export ipl device parameters

Hi,

this is the new "export ipl device parameters" patch with the changes integrated as proposed by Greg KH. Now this interface resides in /sys/firmware/ipl and all files contain only a single value.

This patch is aimed for 2.6.15 and should replace s390-ipl-device.patch in the -mm tree.

Thanks,
Heiko

From: Heiko Carstens <[email protected]>

Sysfs interface to export ipl device parameters. Dependent on the ipl type the interface will look like this:

- ccw ipl:

/sys/firmware/ipl/device
/ipl_type

- fcp ipl:

/sys/firmware/ipl/binary_parameter

		 /bootprog
		 /br_lba
		 /device
		 /ipl_type
		 /lun
		 /scp_data
		 /wwpn

- otherwise (unknown that is):

/sys/firmware/ipl/ipl_type

diffstat:

 arch/s390/kernel/head.S   |   72 ++++++++++++++++-
 arch/s390/kernel/head64.S |   66 +++++++++++++++
 arch/s390/kernel/setup.c  |  192 ++++++++++++++++++++++++++++++++++++++++++++++
 include/asm-s390/setup.h  |   50 +++++++++++
 4 files changed, 373 insertions(+), 7 deletions(-)
arch/s390/kernel/head.S +67 -5
@@ -485,7 +485,9 @@ start:
 #
         .org  0x10000
 startup:basr  %r13,0                     # get base
-.LPG1:  lctl  %c0,%c15,.Lctl-.LPG1(%r13) # load control registers
+.LPG1:	l     %r1, .Lget_ipl_device_addr-.LPG1(%r13)
+	basr  %r14, %r1
+	lctl  %c0,%c15,.Lctl-.LPG1(%r13) # load control registers
 	la    %r12,_pstart-.LPG1(%r13)   # pointer to parameter area
 					 # move IPL device to lowcore
         mvc   __LC_IPLDEV(4),IPL_DEVICE-PARMAREA(%r12)
@@ -560,6 +562,9 @@ startup:basr  %r13,0                    
 	mr    %r2,%r1			# mem size in bytes in %r3
 	b     .Lfchunk-.LPG1(%r13)
 
+	.align 4
+.Lget_ipl_device_addr:
+	.long .Lget_ipl_device
 .Lpmask:
 	.byte 0
 .align 8
@@ -755,6 +760,63 @@ _pstart:	
 	.global _pend
 _pend:	
 
+.Lget_ipl_device:
+	basr  %r12,0
+.LPG2:	l     %r1,0xb8			# get sid
+	sll   %r1,15			# test if subchannel is enabled
+	srl   %r1,31
+	ltr   %r1,%r1
+	bz    0(%r14)			# subchannel disabled
+	l     %r1,0xb8
+	la    %r5,.Lipl_schib-.LPG2(%r12)
+	stsch 0(%r5)		        # get schib of subchannel
+	bnz   0(%r14)			# schib not available
+	tm    5(%r5),0x01		# devno valid?
+	bno   0(%r14)
+	la    %r6,ipl_parameter_flags-.LPG2(%r12)
+	oi    3(%r6),0x01		# set flag
+	la    %r2,ipl_devno-.LPG2(%r12)
+	mvc   0(2,%r2),6(%r5)		# store devno
+	tm    4(%r5),0x80		# qdio capable device?
+	bno   0(%r14)
+	oi    3(%r6),0x02		# set flag
+
+	# copy ipl parameters
+
+	lhi   %r0,4096
+	l     %r2,20(%r0)		# get address of parameter list
+	lhi   %r3,IPL_PARMBLOCK_ORIGIN
+	st    %r3,20(%r0)
+	lhi   %r4,1
+	cr    %r2,%r3			# start parameters < destination ?
+	jl    0f
+	lhi   %r1,1			# copy direction is upwards
+	j     1f
+0:	lhi   %r1,-1			# copy direction is downwards
+	ar    %r2,%r0
+	ar    %r3,%r0
+	ar    %r2,%r1
+	ar    %r3,%r1
+1:	mvc   0(1,%r3),0(%r2)		# finally copy ipl parameters
+	ar    %r3,%r1
+	ar    %r2,%r1
+	sr    %r0,%r4
+	jne   1b
+	b     0(%r14)
+
+	.align 4
+.Lipl_schib:
+	.rept 13
+	.long 0
+	.endr
+
+	.globl ipl_parameter_flags
+ipl_parameter_flags:
+	.long 0
+	.globl ipl_devno
+ipl_devno:
+	.word 0
+
 #ifdef CONFIG_SHARED_KERNEL
 	.org   0x100000
 #endif
@@ -764,11 +826,11 @@ _pend:	
 #
         .globl _stext
 _stext:	basr  %r13,0                    # get base
-.LPG2:
+.LPG3:
 #
 # Setup stack
 #
-        l     %r15,.Linittu-.LPG2(%r13)
+        l     %r15,.Linittu-.LPG3(%r13)
 	mvc   __LC_CURRENT(4),__TI_task(%r15)
         ahi   %r15,1<<(PAGE_SHIFT+THREAD_ORDER) # init_task_union + THREAD_SIZE
         st    %r15,__LC_KERNEL_STACK    # set end of kernel stack
@@ -782,8 +844,8 @@ _stext:	basr  %r13,0                    
         lctl   %c0,%c15,0(%r15)
 
 #
-        lam    0,15,.Laregs-.LPG2(%r13) # load access regs needed by uaccess
-        l      %r14,.Lstart-.LPG2(%r13)
+        lam    0,15,.Laregs-.LPG3(%r13) # load access regs needed by uaccess
+        l      %r14,.Lstart-.LPG3(%r13)
         basr   %r14,%r14                # call start_kernel
 #
 # We returned from start_kernel ?!? PANIK
arch/s390/kernel/head64.S +64 -2

96 lines not on this page · raw message

arch/s390/kernel/setup.c +192 -0

201 lines not on this page · raw message

include/asm-s390/setup.h +50 -0

67 lines not on this page · raw message

#1 lore raw
Quoted 6 lines · Heiko Carstens

Hi,

this is the new "export ipl device parameters" patch with the changes integrated as proposed by Greg KH. Now this interface resides in /sys/firmware/ipl and all files contain only a single value.

Hi, I have a few minor comments on the patch. It looks much better than the last one.

Quoted 19 lines

Sysfs interface to export ipl device parameters. Dependent on the ipl type the interface will look like this:

- ccw ipl:

/sys/firmware/ipl/device
/ipl_type

- fcp ipl:

/sys/firmware/ipl/binary_parameter

		 /bootprog
		 /br_lba
		 /device
		 /ipl_type
		 /lun
		 /scp_data
		 /wwpn
Quoted 3 lines

- otherwise (unknown that is):

/sys/firmware/ipl/ipl_type

Nice interface.

Quoted 2 lines

+#ifdef CONFIG_SYSFS

Does anyone build a s390 kernel without sysfs? You can probably just drop this ifdef.

Quoted 7 lines
arch/s390/kernel/setup.c +7 -0
+#define DEFINE_IPL_ATTR(_name, _format, _value)			\
+static ssize_t ipl_##_name##_show(struct subsystem *subsys,	\
+		char *page)					\
+{								\
+	return sprintf(page, _format, _value);			\
+}								\
+static struct subsys_attribute ipl_##_name##_attr =		\

arch/s390/kernel/setup.c struct seq_operations cpuinfo_op = { · line 707

Quoted 10 lines
arch/s390/kernel/setup.c +10 -0
+	__ATTR(_name, S_IRUGO, ipl_##_name##_show, NULL);
+
+DEFINE_IPL_ATTR(wwpn, "0x%016llx\n", (unsigned long long)
+		IPL_PARMBLOCK_START->fcp.wwpn);
+DEFINE_IPL_ATTR(lun, "0x%016llx\n", (unsigned long long)
+		IPL_PARMBLOCK_START->fcp.lun);
+DEFINE_IPL_ATTR(bootprog, "%lld\n", (unsigned long long)
+		IPL_PARMBLOCK_START->fcp.bootprog);
+DEFINE_IPL_ATTR(br_lba, "%lld\n", (unsigned long long)
+		IPL_PARMBLOCK_START->fcp.br_lba);

Why have a format field, if you only use the same format?

Quoted 9 lines
arch/s390/kernel/setup.c +9 -0
+static struct subsys_attribute ipl_type_attr = __ATTR_RO(ipl_type);
+
+static ssize_t
+ipl_device_show(struct subsystem *subsys, char *page)
+{
+	struct ipl_parameter_block *ipl = IPL_PARMBLOCK_START;
+
+	switch (get_ipl_type()) {
+	case ipl_type_ccw:

arch/s390/kernel/setup.c struct seq_operations cpuinfo_op = { · line 762

Quoted 10 lines
arch/s390/kernel/setup.c +10 -0
+		return sprintf(page, "0.0.%04x\n", ipl_devno);
+	case ipl_type_fcp:
+		return sprintf(page, "0.0.%04x\n", ipl->fcp.devno);
+	default:
+		return 0;
+	}
+}
+
+static struct subsys_attribute ipl_device_attr =
+	__ATTR(device, S_IRUGO, ipl_device_show, NULL);

Why not use __ATTR_RO() like you did above?

Quoted 1 line

+#define IPL_PARMBLOCK_ORIGIN 0x2000

You are just directly addressing memory with this address, right? Shouldn't you iomap it or something first?

thanks,

greg k-h

#2 lore raw

Hi,

Quoted 3 lines
Quoted 1 line

+#ifdef CONFIG_SYSFS

Does anyone build a s390 kernel without sysfs? You can probably just drop this ifdef.

Yes, you're right.

Quoted 3 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+DEFINE_IPL_ATTR(lun, "0x%016llx\n", (unsigned long long)
+DEFINE_IPL_ATTR(bootprog, "%lld\n", (unsigned long long)

Why have a format field, if you only use the same format?

I use two different formats (hexadecimal and decimal).

Quoted 2 lines

Review

Quoted 1 line
(quoted diff) +1 -0
+	__ATTR(device, S_IRUGO, ipl_device_show, NULL);

Why not use __ATTR_RO() like you did above?

The name of the attribute is supposed to be 'device'. If I would use __ATTR_RO it stringifies the first parameter and the result would be 'ipl_device' because of the function name I use. Otherwise I would have to rename my function, which is something I don't want to do. Somehow __ATTR_RO doesn't fit.

Quoted 2 lines
Quoted 1 line

+#define IPL_PARMBLOCK_ORIGIN 0x2000

You are just directly addressing memory with this address, right?

Yes.

Quoted 1 line

Shouldn't you iomap it or something first?

No, we don't have memory mapped IO on S390.

How about this:

From: Heiko Carstens <[email protected]>

Remove unnecessary ifdef + unused variable.

diffstat:

 arch/s390/kernel/setup.c |    6 ------
 1 file changed, 6 deletions(-)
arch/s390/kernel/setup.c +0 -6
diff -urN a/arch/s390/kernel/setup.c b/arch/s390/kernel/setup.c
@@ -686,8 +686,6 @@
 	.show	= show_cpuinfo,
 };
 
-#ifdef CONFIG_SYSFS
-
 #define DEFINE_IPL_ATTR(_name, _format, _value)			\
 static ssize_t ipl_##_name##_show(struct subsystem *subsys,	\
 		char *page)					\
@@ -847,7 +845,6 @@
 
 static int __init
 ipl_device_sysfs_register(void) {
-	struct attribute_group *attr_group;
 	int rc;
 
 	rc = firmware_register(&ipl_subsys);
@@ -868,12 +865,9 @@
 	default:
 		sysfs_create_group(&ipl_subsys.kset.kobj,
 				   &ipl_unknown_attr_group);
-		attr_group = &ipl_unknown_attr_group;
 		break;
 	}
 	return 0;
 }
 
 __initcall(ipl_device_sysfs_register);
-
-#endif /* CONFIG_SYSFS */
#3 lore raw
Quoted 6 lines · Heiko Carstens

Hi,

Quoted 3 lines
Quoted 1 line

+#ifdef CONFIG_SYSFS

Does anyone build a s390 kernel without sysfs? You can probably just drop this ifdef.

Quoted 7 lines

Yes, you're right.

Quoted 3 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+DEFINE_IPL_ATTR(lun, "0x%016llx\n", (unsigned long long)
+DEFINE_IPL_ATTR(bootprog, "%lld\n", (unsigned long long)

Why have a format field, if you only use the same format?

I use two different formats (hexadecimal and decimal).

Sorry, I was referring to the (unsigned long long) duplication there, not the format field.

Quoted 8 lines
Quoted 2 lines

Review

Quoted 1 line
(quoted diff) +1 -0
+	__ATTR(device, S_IRUGO, ipl_device_show, NULL);

Why not use __ATTR_RO() like you did above?

The name of the attribute is supposed to be 'device'. If I would use __ATTR_RO it stringifies the first parameter and the result would be 'ipl_device' because of the function name I use. Otherwise I would have to rename my function, which is something I don't want to do. Somehow __ATTR_RO doesn't fit.

Ok, fair enough.

Quoted 8 lines
Quoted 2 lines
Quoted 1 line

+#define IPL_PARMBLOCK_ORIGIN 0x2000

You are just directly addressing memory with this address, right?

Yes.

Quoted 1 line

Shouldn't you iomap it or something first?

No, we don't have memory mapped IO on S390.

Neither do we on x86, yet we force everyone to use the proper function calls, for when that code is then ported to other arches. No reason s390 should be alone with getting away from that :)

Quoted 5 lines

How about this:

From: Heiko Carstens <[email protected]>

Remove unnecessary ifdef + unused variable.

<snip>

Looks fine to me.

thanks,

greg k-h