Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 8 Dec 2002 11:08:52 +0100 (CET)
From:      Michal Mertl <mime@traveller.cz>
To:        roger@freebsd.org, <current@freebsd.org>
Subject:   bktr(4) bufs plus patch
Message-ID:  <Pine.BSF.4.41.0212081046090.73179-200000@prg.traveller.cz>

next in thread | raw e-mail | index | archive | help
  This message is in MIME format.  The first part should be readable text,
  while the remaining parts are likely unreadable without MIME-aware tools.
  Send mail to mime@docserver.cac.washington.edu for more info.

--0-1784969169-1039342132=:73179
Content-Type: TEXT/PLAIN; charset=US-ASCII

I found 2 bugs and some potential problems in bktr(4) code.

Bug 1:
Compilation with options BKTR_USE_FREEBSD_SMBUS failes. Error is
that code tries to use iicbus which isn't defined where it looks for
it. I added it there and the compilation and detection goes fine. I don't
know how to actually test it though.

Bug 2:
On module unload destroy_dev(9) is called on dev_alias which leads to
panic. According to MAKE_DEV(9) it's forbidden. The patch removes the code
to remove aliases. All seems to work fine.


Problem 1:
When using bktr(4) in a module, there's a helper module
bktr_mem, which allocates memory for bktr(4) devices. There is fixed limit
(#define BKTR_MEM_MAX_DEVICES 8 in bktr_mem.h) on number of devices
supported - it should at least be mentioned somewhere and possibly raised
- I have 16 devices and soon will be using more.

Problem 2:
There's another limit on number of bktr(4) devices in device creation
on lines 443-448 in bktr_os.c.
        bktr->bktrdev = make_dev(&bktr_cdevsw, unit,
                                0, 0, 0444, "bktr%d",  unit);
        bktr->tunerdev= make_dev(&bktr_cdevsw, unit+16,
                                0, 0, 0444, "tuner%d", unit);
        bktr->vbidev  = make_dev(&bktr_cdevsw, unit+32,
                                0, 0, 0444, "vbi%d"  , unit);

If I read the code right it seems to limit the maximum number of devices
to 16. I don't see why it can't be much more here - say 256 (so change +16
to +256 and +32 to +512. In DEVFS world users should care about
majors/minors but with normal /dev it could be problem.

Problem 3: (affacting mainly STABLE)
In MAKEDEV there's only one char allowed so one can create only 10
devices. Patch could look like this:

*** MAKEDEV.ori	Sun Dec  8 11:02:38 2002
--- MAKEDEV	Sun Dec  8 11:07:01 2002
***************
*** 1552,1559 ****
  	chmod 444 meteor$unit
  	;;

! bktr?)
  	unit=`expr $i : 'bktr\(.*\)'`
  	mknod bktr$unit c 92 `unit2minor $unit`
  	mknod tuner$unit c 92 `unit2minor $((16 + $unit))`
  	mknod vbi$unit c 92 `unit2minor $((32 + $unit))`
--- 1552,1562 ----
  	chmod 444 meteor$unit
  	;;

! bktr*)
  	unit=`expr $i : 'bktr\(.*\)'`
+ 	if [ ${unit} -lt 0 -o ${unit} -gt 15 ]; then
+ 		die 3 "bktr(4) unit limited to 0-15"
+ 	fi
  	mknod bktr$unit c 92 `unit2minor $unit`
  	mknod tuner$unit c 92 `unit2minor $((16 + $unit))`
  	mknod vbi$unit c 92 `unit2minor $((32 + $unit))`

-- 
Michal Mertl
mime@traveller.cz


--0-1784969169-1039342132=:73179
Content-Type: TEXT/PLAIN; charset=US-ASCII; name="bktr.patch"
Content-Transfer-Encoding: BASE64
Content-ID: <Pine.BSF.4.41.0212081108520.73179@prg.traveller.cz>
Content-Description: 
Content-Disposition: attachment; filename="bktr.patch"

KioqIGRldi9ia3RyL2JrdHJfcmVnLmgub3JpCVN1biBEZWMgIDggMTA6NDA6
MTQgMjAwMg0KLS0tIGRldi9ia3RyL2JrdHJfcmVnLmgJU3VuIERlYyAgOCAx
MDo0MDozOCAyMDAyDQoqKioqKioqKioqKioqKioNCioqKiA0NDgsNDUzICoq
KioNCi0tLSA0NDgsNDU0IC0tLS0NCiAgc3RydWN0IGJrdHJfaTJjX3NvZnRj
IHsNCiAgCWludCBidXNfb3duZWQ7DQogIA0KKyAJZGV2aWNlX3QgaWljYnVz
Ow0KICAJZGV2aWNlX3QgaWljYmI7DQogIAlkZXZpY2VfdCBzbWJ1czsNCiAg
fTsNCioqKiBkZXYvYmt0ci9ia3RyX29zLmMub3JpCVN1biBEZWMgIDggMTA6
Mzk6MTMgMjAwMg0KLS0tIGRldi9ia3RyL2JrdHJfb3MuYwlTdW4gRGVjICA4
IDEwOjM5OjM1IDIwMDINCioqKioqKioqKioqKioqKg0KKioqIDQ5OSw1MTMg
KioqKg0KICAJZGVzdHJveV9kZXYoYmt0ci0+dHVuZXJkZXYpOw0KICAJZGVz
dHJveV9kZXYoYmt0ci0+Ymt0cmRldik7DQogIA0KLSAJLyogSWYgdGhpcyBp
cyB1bml0IDAsIHRoZW4gZGVzdHJveSB0aGUgYWxpYXMgZW50cmllcyB0b28g
Ki8NCi0gI2lmIChfX0ZyZWVCU0RfdmVyc2lvbiA+PTUwMDAwMCkNCi0gCWlm
ICh1bml0ID09IDApIHsNCi0gCSAgICBkZXN0cm95X2Rldihia3RyLT52Ymlk
ZXZfYWxpYXMpOw0KLSAJICAgIGRlc3Ryb3lfZGV2KGJrdHItPnR1bmVyZGV2
X2FsaWFzKTsNCi0gCSAgICBkZXN0cm95X2Rldihia3RyLT5ia3RyZGV2X2Fs
aWFzKTsNCi0gCX0NCi0gI2VuZGlmDQotIA0KICAJLyoNCiAgCSAqIERlYWxs
b2NhdGUgcmVzb3VyY2VzLg0KICAJICovDQotLS0gNDk5LDUwNCAtLS0tDQo=
--0-1784969169-1039342132=:73179--

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.41.0212081046090.73179-200000>