Message ID | 20211013185812.590931-5-clabbe@baylibre.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | staging: media: zoran: fusion in one module | expand |
On Wed, Oct 13, 2021 at 06:58:06PM +0000, Corentin Labbe wrote: > +config VIDEO_ZORAN_DEBUG > + bool "Enable zoran debugfs" > + depends on VIDEO_ZORAN > + depends on DEBUG_FS > + help > + Say y to enable zoran debug file. > + This will create /sys/kernel/debug/CARD_NAME/debug for displaying > + stats and debug information. Why bother with a CONFIG? Just make it always on? > @@ -1286,6 +1321,12 @@ static int zoran_probe(struct pci_dev *pdev, const struct pci_device_id *ent) > > zr->map_mode = ZORAN_MAP_MODE_RAW; > > +#ifdef CONFIG_VIDEO_ZORAN_DEBUG > + zr->dbgfs_dir = debugfs_create_dir(ZR_DEVNAME(zr), NULL); > + debugfs_create_file("debug", 0444, > + zr->dbgfs_dir, zr, > + &zoran_debugfs_fops); This whitespace is weird. regards, dan carpenter
Hi Corentin,
I love your patch! Perhaps something to improve:
[auto build test WARNING on staging/staging-testing]
url: https://github.com/0day-ci/linux/commits/Corentin-Labbe/staging-media-zoran-fusion-in-one-module/20211014-025945
base: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git 6ac113f741a7674e4268eea3eb13972732d83571
config: x86_64-randconfig-a016-20211014 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 6c76d0101193aa4eb891a6954ff047eda2f9cf71)
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
# https://github.com/0day-ci/linux/commit/74fc116256f23b2c65d0c813f1d90b617ce9c97d
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Corentin-Labbe/staging-media-zoran-fusion-in-one-module/20211014-025945
git checkout 74fc116256f23b2c65d0c813f1d90b617ce9c97d
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 ARCH=x86_64
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
All warnings (new ones prefixed by >>):
drivers/staging/media/zoran/zoran_card.c:948:31: error: no member named 'dbgfs_dir' in 'struct zoran'
debugfs_remove_recursive(zr->dbgfs_dir);
~~ ^
>> drivers/staging/media/zoran/zoran_card.c:1141:46: warning: implicit conversion from 'unsigned long long' to 'unsigned int' changes value from 18446744073709551615 to 4294967295 [-Wconstant-conversion]
vb2_dma_contig_set_max_seg_size(&pdev->dev, DMA_BIT_MASK(32));
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~
include/linux/dma-mapping.h:76:40: note: expanded from macro 'DMA_BIT_MASK'
#define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
^~~~~
1 warning and 1 error generated.
vim +1141 drivers/staging/media/zoran/zoran_card.c
74fc116256f23b Corentin Labbe 2021-10-13 1088
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1089 /*
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1090 * Scan for a Buz card (actually for the PCI controller ZR36057),
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1091 * request the irq and map the io memory
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1092 */
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1093 static int zoran_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1094 {
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1095 unsigned char latency, need_latency;
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1096 struct zoran *zr;
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1097 int result;
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1098 struct videocodec_master *master_vfe = NULL;
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1099 struct videocodec_master *master_codec = NULL;
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1100 int card_num;
d61c7451fcb712 Corentin Labbe 2020-09-25 1101 const char *codec_name, *vfe_name;
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1102 unsigned int nr;
d4ae3689226e56 Corentin Labbe 2020-09-25 1103 int err;
d4ae3689226e56 Corentin Labbe 2020-09-25 1104
26edeeecea59d6 Corentin Labbe 2021-10-13 1105 pci_info(pdev, "Zoran MJPEG board driver version %s\n", ZORAN_VERSION);
26edeeecea59d6 Corentin Labbe 2021-10-13 1106
26edeeecea59d6 Corentin Labbe 2021-10-13 1107 /* check the parameters we have been given, adjust if necessary */
26edeeecea59d6 Corentin Labbe 2021-10-13 1108 if (v4l_nbufs < 2)
26edeeecea59d6 Corentin Labbe 2021-10-13 1109 v4l_nbufs = 2;
26edeeecea59d6 Corentin Labbe 2021-10-13 1110 if (v4l_nbufs > VIDEO_MAX_FRAME)
26edeeecea59d6 Corentin Labbe 2021-10-13 1111 v4l_nbufs = VIDEO_MAX_FRAME;
26edeeecea59d6 Corentin Labbe 2021-10-13 1112 /* The user specifies the in KB, we want them in byte (and page aligned) */
26edeeecea59d6 Corentin Labbe 2021-10-13 1113 v4l_bufsize = PAGE_ALIGN(v4l_bufsize * 1024);
26edeeecea59d6 Corentin Labbe 2021-10-13 1114 if (v4l_bufsize < 32768)
26edeeecea59d6 Corentin Labbe 2021-10-13 1115 v4l_bufsize = 32768;
26edeeecea59d6 Corentin Labbe 2021-10-13 1116 /* 2 MB is arbitrary but sufficient for the maximum possible images */
26edeeecea59d6 Corentin Labbe 2021-10-13 1117 if (v4l_bufsize > 2048 * 1024)
26edeeecea59d6 Corentin Labbe 2021-10-13 1118 v4l_bufsize = 2048 * 1024;
26edeeecea59d6 Corentin Labbe 2021-10-13 1119 if (jpg_nbufs < 4)
26edeeecea59d6 Corentin Labbe 2021-10-13 1120 jpg_nbufs = 4;
26edeeecea59d6 Corentin Labbe 2021-10-13 1121 if (jpg_nbufs > BUZ_MAX_FRAME)
26edeeecea59d6 Corentin Labbe 2021-10-13 1122 jpg_nbufs = BUZ_MAX_FRAME;
26edeeecea59d6 Corentin Labbe 2021-10-13 1123 jpg_bufsize = PAGE_ALIGN(jpg_bufsize * 1024);
26edeeecea59d6 Corentin Labbe 2021-10-13 1124 if (jpg_bufsize < 8192)
26edeeecea59d6 Corentin Labbe 2021-10-13 1125 jpg_bufsize = 8192;
26edeeecea59d6 Corentin Labbe 2021-10-13 1126 if (jpg_bufsize > (512 * 1024))
26edeeecea59d6 Corentin Labbe 2021-10-13 1127 jpg_bufsize = 512 * 1024;
26edeeecea59d6 Corentin Labbe 2021-10-13 1128 /* Use parameter for vidmem or try to find a video card */
26edeeecea59d6 Corentin Labbe 2021-10-13 1129 if (vidmem)
26edeeecea59d6 Corentin Labbe 2021-10-13 1130 pci_info(pdev, "%s: Using supplied video memory base address @ 0x%lx\n",
26edeeecea59d6 Corentin Labbe 2021-10-13 1131 ZORAN_NAME, vidmem);
26edeeecea59d6 Corentin Labbe 2021-10-13 1132
26edeeecea59d6 Corentin Labbe 2021-10-13 1133 /* some mainboards might not do PCI-PCI data transfer well */
26edeeecea59d6 Corentin Labbe 2021-10-13 1134 if (pci_pci_problems & (PCIPCI_FAIL | PCIAGP_FAIL | PCIPCI_ALIMAGIK))
26edeeecea59d6 Corentin Labbe 2021-10-13 1135 pci_warn(pdev, "%s: chipset does not support reliable PCI-PCI DMA\n",
26edeeecea59d6 Corentin Labbe 2021-10-13 1136 ZORAN_NAME);
26edeeecea59d6 Corentin Labbe 2021-10-13 1137
d4ae3689226e56 Corentin Labbe 2020-09-25 1138 err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
d4ae3689226e56 Corentin Labbe 2020-09-25 1139 if (err)
d4ae3689226e56 Corentin Labbe 2020-09-25 1140 return -ENODEV;
d4ae3689226e56 Corentin Labbe 2020-09-25 @1141 vb2_dma_contig_set_max_seg_size(&pdev->dev, DMA_BIT_MASK(32));
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1142
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1143 nr = zoran_num++;
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1144 if (nr >= BUZ_MAX) {
b7c3b2bb9db412 Corentin Labbe 2020-09-25 1145 pci_err(pdev, "driver limited to %d card(s) maximum\n", BUZ_MAX);
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1146 return -ENOENT;
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1147 }
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1148
6d1d9ba2c4396f Corentin Labbe 2020-09-25 1149 zr = devm_kzalloc(&pdev->dev, sizeof(*zr), GFP_KERNEL);
5e195bbddabdd9 Corentin Labbe 2020-09-25 1150 if (!zr)
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1151 return -ENOMEM;
5e195bbddabdd9 Corentin Labbe 2020-09-25 1152
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1153 zr->v4l2_dev.notify = zoran_subdev_notify;
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1154 if (v4l2_device_register(&pdev->dev, &zr->v4l2_dev))
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1155 goto zr_free_mem;
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1156 zr->pci_dev = pdev;
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1157 zr->id = nr;
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1158 snprintf(ZR_DEVNAME(zr), sizeof(ZR_DEVNAME(zr)), "MJPEG[%u]", zr->id);
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1159 if (v4l2_ctrl_handler_init(&zr->hdl, 10))
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1160 goto zr_unreg;
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1161 zr->v4l2_dev.ctrl_handler = &zr->hdl;
8cb356d4eaae11 Corentin Labbe 2020-09-25 1162 v4l2_ctrl_new_std(&zr->hdl, &zoran_video_ctrl_ops,
8cb356d4eaae11 Corentin Labbe 2020-09-25 1163 V4L2_CID_JPEG_COMPRESSION_QUALITY, 0,
8cb356d4eaae11 Corentin Labbe 2020-09-25 1164 100, 1, 50);
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1165 spin_lock_init(&zr->spinlock);
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1166 mutex_init(&zr->lock);
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1167 if (pci_enable_device(pdev))
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1168 goto zr_unreg;
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1169 zr->revision = zr->pci_dev->revision;
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1170
9bb2720293a04f Corentin Labbe 2020-09-25 1171 pci_info(zr->pci_dev, "Zoran ZR360%c7 (rev %d), irq: %d, memory: 0x%08llx\n",
9bb2720293a04f Corentin Labbe 2020-09-25 1172 zr->revision < 2 ? '5' : '6', zr->revision,
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1173 zr->pci_dev->irq, (uint64_t)pci_resource_start(zr->pci_dev, 0));
9bb2720293a04f Corentin Labbe 2020-09-25 1174 if (zr->revision >= 2)
9bb2720293a04f Corentin Labbe 2020-09-25 1175 pci_info(zr->pci_dev, "Subsystem vendor=0x%04x id=0x%04x\n",
9bb2720293a04f Corentin Labbe 2020-09-25 1176 zr->pci_dev->subsystem_vendor, zr->pci_dev->subsystem_device);
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1177
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1178 /* Use auto-detected card type? */
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1179 if (card[nr] == -1) {
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1180 if (zr->revision < 2) {
b7c3b2bb9db412 Corentin Labbe 2020-09-25 1181 pci_err(pdev, "No card type specified, please use the card=X module parameter\n");
b7c3b2bb9db412 Corentin Labbe 2020-09-25 1182 pci_err(pdev, "It is not possible to auto-detect ZR36057 based cards\n");
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1183 goto zr_unreg;
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1184 }
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1185
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1186 card_num = ent->driver_data;
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1187 if (card_num >= NUM_CARDS) {
b7c3b2bb9db412 Corentin Labbe 2020-09-25 1188 pci_err(pdev, "Unknown card, try specifying card=X module parameter\n");
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1189 goto zr_unreg;
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1190 }
daae1da762c1e3 Corentin Labbe 2020-09-25 1191 pci_info(zr->pci_dev, "%s() - card %s detected\n", __func__, zoran_cards[card_num].name);
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1192 } else {
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1193 card_num = card[nr];
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1194 if (card_num >= NUM_CARDS || card_num < 0) {
b7c3b2bb9db412 Corentin Labbe 2020-09-25 1195 pci_err(pdev, "User specified card type %d out of range (0 .. %d)\n",
b7c3b2bb9db412 Corentin Labbe 2020-09-25 1196 card_num, NUM_CARDS - 1);
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1197 goto zr_unreg;
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1198 }
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1199 }
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1200
5e195bbddabdd9 Corentin Labbe 2020-09-25 1201 /*
5e195bbddabdd9 Corentin Labbe 2020-09-25 1202 * even though we make this a non pointer and thus
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1203 * theoretically allow for making changes to this struct
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1204 * on a per-individual card basis at runtime, this is
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1205 * strongly discouraged. This structure is intended to
5e195bbddabdd9 Corentin Labbe 2020-09-25 1206 * keep general card information, no settings or anything
5e195bbddabdd9 Corentin Labbe 2020-09-25 1207 */
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1208 zr->card = zoran_cards[card_num];
5e195bbddabdd9 Corentin Labbe 2020-09-25 1209 snprintf(ZR_DEVNAME(zr), sizeof(ZR_DEVNAME(zr)), "%s[%u]",
5e195bbddabdd9 Corentin Labbe 2020-09-25 1210 zr->card.name, zr->id);
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1211
845556fd8027b8 Corentin Labbe 2020-09-25 1212 err = pci_request_regions(pdev, ZR_DEVNAME(zr));
845556fd8027b8 Corentin Labbe 2020-09-25 1213 if (err)
845556fd8027b8 Corentin Labbe 2020-09-25 1214 goto zr_unreg;
845556fd8027b8 Corentin Labbe 2020-09-25 1215
e83bf68b5827e0 Corentin Labbe 2020-09-25 1216 zr->zr36057_mem = devm_ioremap(&pdev->dev, pci_resource_start(pdev, 0), pci_resource_len(pdev, 0));
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1217 if (!zr->zr36057_mem) {
b7c3b2bb9db412 Corentin Labbe 2020-09-25 1218 pci_err(pdev, "%s() - ioremap failed\n", __func__);
845556fd8027b8 Corentin Labbe 2020-09-25 1219 goto zr_pci_release;
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1220 }
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1221
ce72671d5d2d93 Corentin Labbe 2020-09-25 1222 result = pci_request_irq(pdev, 0, zoran_irq, NULL, zr, ZR_DEVNAME(zr));
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1223 if (result < 0) {
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1224 if (result == -EINVAL) {
b7c3b2bb9db412 Corentin Labbe 2020-09-25 1225 pci_err(pdev, "%s - bad IRQ number or handler\n", __func__);
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1226 } else if (result == -EBUSY) {
b7c3b2bb9db412 Corentin Labbe 2020-09-25 1227 pci_err(pdev, "%s - IRQ %d busy, change your PnP config in BIOS\n",
b7c3b2bb9db412 Corentin Labbe 2020-09-25 1228 __func__, zr->pci_dev->irq);
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1229 } else {
b7c3b2bb9db412 Corentin Labbe 2020-09-25 1230 pci_err(pdev, "%s - cannot assign IRQ, error code %d\n", __func__, result);
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1231 }
e83bf68b5827e0 Corentin Labbe 2020-09-25 1232 goto zr_pci_release;
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1233 }
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1234
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1235 /* set PCI latency timer */
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1236 pci_read_config_byte(zr->pci_dev, PCI_LATENCY_TIMER,
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1237 &latency);
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1238 need_latency = zr->revision > 1 ? 32 : 48;
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1239 if (latency != need_latency) {
9bb2720293a04f Corentin Labbe 2020-09-25 1240 pci_info(zr->pci_dev, "Changing PCI latency from %d to %d\n", latency, need_latency);
5e195bbddabdd9 Corentin Labbe 2020-09-25 1241 pci_write_config_byte(zr->pci_dev, PCI_LATENCY_TIMER, need_latency);
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1242 }
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1243
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1244 zr36057_restart(zr);
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1245 /* i2c */
9bb2720293a04f Corentin Labbe 2020-09-25 1246 pci_info(zr->pci_dev, "Initializing i2c bus...\n");
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1247
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1248 if (zoran_register_i2c(zr) < 0) {
b7c3b2bb9db412 Corentin Labbe 2020-09-25 1249 pci_err(pdev, "%s - can't initialize i2c bus\n", __func__);
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1250 goto zr_free_irq;
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1251 }
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1252
5e195bbddabdd9 Corentin Labbe 2020-09-25 1253 zr->decoder = v4l2_i2c_new_subdev(&zr->v4l2_dev, &zr->i2c_adapter,
5e195bbddabdd9 Corentin Labbe 2020-09-25 1254 zr->card.i2c_decoder, 0,
5e195bbddabdd9 Corentin Labbe 2020-09-25 1255 zr->card.addrs_decoder);
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1256
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1257 if (zr->card.i2c_encoder)
5e195bbddabdd9 Corentin Labbe 2020-09-25 1258 zr->encoder = v4l2_i2c_new_subdev(&zr->v4l2_dev, &zr->i2c_adapter,
5e195bbddabdd9 Corentin Labbe 2020-09-25 1259 zr->card.i2c_encoder, 0,
5e195bbddabdd9 Corentin Labbe 2020-09-25 1260 zr->card.addrs_encoder);
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1261
9bb2720293a04f Corentin Labbe 2020-09-25 1262 pci_info(zr->pci_dev, "Initializing videocodec bus...\n");
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1263
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1264 if (zr->card.video_codec) {
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1265 codec_name = codecid_to_modulename(zr->card.video_codec);
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1266 if (codec_name) {
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1267 result = request_module(codec_name);
b7c3b2bb9db412 Corentin Labbe 2020-09-25 1268 if (result)
b7c3b2bb9db412 Corentin Labbe 2020-09-25 1269 pci_err(pdev, "failed to load modules %s: %d\n", codec_name, result);
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1270 }
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1271 }
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1272 if (zr->card.video_vfe) {
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1273 vfe_name = codecid_to_modulename(zr->card.video_vfe);
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1274 if (vfe_name) {
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1275 result = request_module(vfe_name);
b7c3b2bb9db412 Corentin Labbe 2020-09-25 1276 if (result < 0)
b7c3b2bb9db412 Corentin Labbe 2020-09-25 1277 pci_err(pdev, "failed to load modules %s: %d\n", vfe_name, result);
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1278 }
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1279 }
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1280
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1281 /* reset JPEG codec */
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1282 jpeg_codec_sleep(zr, 1);
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1283 jpeg_codec_reset(zr);
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1284 /* video bus enabled */
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1285 /* display codec revision */
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1286 if (zr->card.video_codec != 0) {
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1287 master_codec = zoran_setup_videocodec(zr, zr->card.video_codec);
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1288 if (!master_codec)
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1289 goto zr_unreg_i2c;
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1290 zr->codec = videocodec_attach(master_codec);
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1291 if (!zr->codec) {
b7c3b2bb9db412 Corentin Labbe 2020-09-25 1292 pci_err(pdev, "%s - no codec found\n", __func__);
4bae5db2f28d64 Corentin Labbe 2020-09-25 1293 goto zr_unreg_i2c;
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1294 }
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1295 if (zr->codec->type != zr->card.video_codec) {
b7c3b2bb9db412 Corentin Labbe 2020-09-25 1296 pci_err(pdev, "%s - wrong codec\n", __func__);
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1297 goto zr_detach_codec;
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1298 }
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1299 }
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1300 if (zr->card.video_vfe != 0) {
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1301 master_vfe = zoran_setup_videocodec(zr, zr->card.video_vfe);
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1302 if (!master_vfe)
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1303 goto zr_detach_codec;
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1304 zr->vfe = videocodec_attach(master_vfe);
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1305 if (!zr->vfe) {
b7c3b2bb9db412 Corentin Labbe 2020-09-25 1306 pci_err(pdev, "%s - no VFE found\n", __func__);
4bae5db2f28d64 Corentin Labbe 2020-09-25 1307 goto zr_detach_codec;
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1308 }
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1309 if (zr->vfe->type != zr->card.video_vfe) {
b7c3b2bb9db412 Corentin Labbe 2020-09-25 1310 pci_err(pdev, "%s = wrong VFE\n", __func__);
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1311 goto zr_detach_vfe;
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1312 }
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1313 }
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1314
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1315 /* take care of Natoma chipset and a revision 1 zr36057 */
83f89a8bcbc3c5 Corentin Labbe 2020-09-25 1316 if ((pci_pci_problems & PCIPCI_NATOMA) && zr->revision <= 1)
9bb2720293a04f Corentin Labbe 2020-09-25 1317 pci_info(zr->pci_dev, "ZR36057/Natoma bug, max. buffer size is 128K\n");
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1318
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1319 if (zr36057_init(zr) < 0)
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1320 goto zr_detach_vfe;
61c3b19f7b9eb7 Corentin Labbe 2020-09-25 1321
b564cb6e0bd587 Corentin Labbe 2020-09-25 1322 zr->map_mode = ZORAN_MAP_MODE_RAW;
b564cb6e0bd587 Corentin Labbe 2020-09-25 1323
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
Le Thu, Oct 14, 2021 at 10:37:52AM +0300, Dan Carpenter a écrit : > On Wed, Oct 13, 2021 at 06:58:06PM +0000, Corentin Labbe wrote: > > +config VIDEO_ZORAN_DEBUG > > + bool "Enable zoran debugfs" > > + depends on VIDEO_ZORAN > > + depends on DEBUG_FS > > + help > > + Say y to enable zoran debug file. > > + This will create /sys/kernel/debug/CARD_NAME/debug for displaying > > + stats and debug information. > > Why bother with a CONFIG? Just make it always on? > Hello I love to provides choice to user (and so avoid a dep on DEBUG_FS), even if I think I am the only one remaining user. > > @@ -1286,6 +1321,12 @@ static int zoran_probe(struct pci_dev *pdev, const struct pci_device_id *ent) > > > > zr->map_mode = ZORAN_MAP_MODE_RAW; > > > > +#ifdef CONFIG_VIDEO_ZORAN_DEBUG > > + zr->dbgfs_dir = debugfs_create_dir(ZR_DEVNAME(zr), NULL); > > + debugfs_create_file("debug", 0444, > > + zr->dbgfs_dir, zr, > > + &zoran_debugfs_fops); > > This whitespace is weird. Definitively Yes, fixed! Thanks Regards
On Sun, Oct 17, 2021 at 10:05:06PM +0200, LABBE Corentin wrote: > Le Thu, Oct 14, 2021 at 10:37:52AM +0300, Dan Carpenter a écrit : > > On Wed, Oct 13, 2021 at 06:58:06PM +0000, Corentin Labbe wrote: > > > +config VIDEO_ZORAN_DEBUG > > > + bool "Enable zoran debugfs" > > > + depends on VIDEO_ZORAN > > > + depends on DEBUG_FS > > > + help > > > + Say y to enable zoran debug file. > > > + This will create /sys/kernel/debug/CARD_NAME/debug for displaying > > > + stats and debug information. > > > > Why bother with a CONFIG? Just make it always on? > > > > Hello > > I love to provides choice to user (and so avoid a dep on DEBUG_FS), even if I think I am the only one remaining user. Sorry, for the delay, I was on vacation. No, there is no depends on DEBUG_FS in the method that I am describing. How that works is when DEBUG_FS is turned on then it's on for everything, but when it's disabled it's disabled for everything. You do not need the "depends on DEBUG_FS" and if you make this an option the it feels like it should be a selects DEBUG_FS instead. How this normally works is that when you have debugfs disabled, there are dummy files in the debugfs .h files. I bet the compiler can tell most of those are empty and removes them. So if you have DEBUG_FS then it doesn't use that much more memory than when VIDEO_ZORAN_DEBUG is disabled. I don't know if I'm being clear at all #jetlag. It should be easy to check. Just remove the "depends on DEBUG_FS" and enable VIDEO_ZORAN_DEBUG. Disable DEBUG_FS. It should still build fine because of the dummy functions. That's build 1. Then disable VIDEO_ZORAN_DEBUG and that's build 2. See how much memory difference there is between 1 and 2. regards, dan carpenter
Le Tue, Nov 02, 2021 at 08:40:28PM +0300, Dan Carpenter a écrit : > On Sun, Oct 17, 2021 at 10:05:06PM +0200, LABBE Corentin wrote: > > Le Thu, Oct 14, 2021 at 10:37:52AM +0300, Dan Carpenter a écrit : > > > On Wed, Oct 13, 2021 at 06:58:06PM +0000, Corentin Labbe wrote: > > > > +config VIDEO_ZORAN_DEBUG > > > > + bool "Enable zoran debugfs" > > > > + depends on VIDEO_ZORAN > > > > + depends on DEBUG_FS > > > > + help > > > > + Say y to enable zoran debug file. > > > > + This will create /sys/kernel/debug/CARD_NAME/debug for displaying > > > > + stats and debug information. > > > > > > Why bother with a CONFIG? Just make it always on? > > > > > > > Hello > > > > I love to provides choice to user (and so avoid a dep on DEBUG_FS), even if I think I am the only one remaining user. > > Sorry, for the delay, I was on vacation. > > No, there is no depends on DEBUG_FS in the method that I am describing. > > How that works is when DEBUG_FS is turned on then it's on for everything, > but when it's disabled it's disabled for everything. You do not need > the "depends on DEBUG_FS" and if you make this an option the it feels > like it should be a selects DEBUG_FS instead. > > How this normally works is that when you have debugfs disabled, there > are dummy files in the debugfs .h files. I bet the compiler can tell > most of those are empty and removes them. So if you have DEBUG_FS then > it doesn't use that much more memory than when VIDEO_ZORAN_DEBUG is > disabled. > > I don't know if I'm being clear at all #jetlag. > > It should be easy to check. Just remove the "depends on DEBUG_FS" and > enable VIDEO_ZORAN_DEBUG. Disable DEBUG_FS. It should still build fine > because of the dummy functions. That's build 1. Then disable > VIDEO_ZORAN_DEBUG and that's build 2. See how much memory difference > there is between 1 and 2. > No worry for the delay. Anyway, I have removed VIDEO_ZORAN_DEBUG in v3 since Hans Verkuil also asked for its removing. Regards
diff --git a/drivers/staging/media/zoran/Kconfig b/drivers/staging/media/zoran/Kconfig index 7874842033ca..06f79b91cda7 100644 --- a/drivers/staging/media/zoran/Kconfig +++ b/drivers/staging/media/zoran/Kconfig @@ -74,3 +74,12 @@ config VIDEO_ZORAN_AVS6EYES select VIDEO_KS0127 if MEDIA_SUBDRV_AUTOSELECT help Support for the AverMedia 6 Eyes video surveillance card. + +config VIDEO_ZORAN_DEBUG + bool "Enable zoran debugfs" + depends on VIDEO_ZORAN + depends on DEBUG_FS + help + Say y to enable zoran debug file. + This will create /sys/kernel/debug/CARD_NAME/debug for displaying + stats and debug information. diff --git a/drivers/staging/media/zoran/zoran.h b/drivers/staging/media/zoran/zoran.h index b1ad2a2b914c..c37d064ff11d 100644 --- a/drivers/staging/media/zoran/zoran.h +++ b/drivers/staging/media/zoran/zoran.h @@ -18,6 +18,7 @@ #ifndef _BUZ_H_ #define _BUZ_H_ +#include <linux/debugfs.h> #include <media/v4l2-device.h> #include <media/v4l2-ctrls.h> #include <media/videobuf2-core.h> @@ -295,6 +296,9 @@ struct zoran { struct list_head queued_bufs; spinlock_t queued_bufs_lock; /* Protects queued_bufs */ struct zr_buffer *inuse[BUZ_NUM_STAT_COM * 2]; +#ifdef CONFIG_VIDEO_ZORAN_DEBUG + struct dentry *dbgfs_dir; +#endif }; static inline struct zoran *to_zoran(struct v4l2_device *v4l2_dev) diff --git a/drivers/staging/media/zoran/zoran_card.c b/drivers/staging/media/zoran/zoran_card.c index f1465fbf98af..6f29986a3fc2 100644 --- a/drivers/staging/media/zoran/zoran_card.c +++ b/drivers/staging/media/zoran/zoran_card.c @@ -945,6 +945,8 @@ static void zoran_remove(struct pci_dev *pdev) if (!zr->initialized) goto exit_free; + debugfs_remove_recursive(zr->dbgfs_dir); + zoran_queue_exit(zr); /* unregister videocodec bus */ @@ -1051,6 +1053,39 @@ static const struct v4l2_ctrl_ops zoran_video_ctrl_ops = { .s_ctrl = zoran_video_set_ctrl, }; +#ifdef CONFIG_VIDEO_ZORAN_DEBUG +static int zoran_debugfs_show(struct seq_file *seq, void *v) +{ + struct zoran *zr = seq->private; + + seq_printf(seq, "Running mode %x\n", zr->running); + seq_printf(seq, "Codec mode %x\n", zr->codec_mode); + seq_printf(seq, "Norm %llx\n", zr->norm); + seq_printf(seq, "Input %d\n", zr->input); + seq_printf(seq, "Buffersize %d\n", zr->buffer_size); + + seq_printf(seq, "V4L width %dx%d\n", zr->v4l_settings.width, zr->v4l_settings.height); + seq_printf(seq, "V4L bytesperline %d\n", zr->v4l_settings.bytesperline); + + seq_printf(seq, "JPG decimation %u\n", zr->jpg_settings.decimation); + seq_printf(seq, "JPG hor_dcm %u\n", zr->jpg_settings.hor_dcm); + seq_printf(seq, "JPG ver_dcm %u\n", zr->jpg_settings.ver_dcm); + seq_printf(seq, "JPG tmp_dcm %u\n", zr->jpg_settings.tmp_dcm); + seq_printf(seq, "JPG odd_even %u\n", zr->jpg_settings.odd_even); + seq_printf(seq, "JPG crop %dx%d %d %d\n", + zr->jpg_settings.img_x, + zr->jpg_settings.img_y, + zr->jpg_settings.img_width, + zr->jpg_settings.img_height); + + seq_printf(seq, "Prepared %u\n", zr->prepared); + seq_printf(seq, "Queued %u\n", zr->queued); + return 0; +} + +DEFINE_SHOW_ATTRIBUTE(zoran_debugfs); +#endif + /* * Scan for a Buz card (actually for the PCI controller ZR36057), * request the irq and map the io memory @@ -1286,6 +1321,12 @@ static int zoran_probe(struct pci_dev *pdev, const struct pci_device_id *ent) zr->map_mode = ZORAN_MAP_MODE_RAW; +#ifdef CONFIG_VIDEO_ZORAN_DEBUG + zr->dbgfs_dir = debugfs_create_dir(ZR_DEVNAME(zr), NULL); + debugfs_create_file("debug", 0444, + zr->dbgfs_dir, zr, + &zoran_debugfs_fops); +#endif return 0; zr_detach_vfe:
Add debugfs for displaying zoran debug and stats information. Signed-off-by: Corentin Labbe <clabbe@baylibre.com> --- drivers/staging/media/zoran/Kconfig | 9 ++++++ drivers/staging/media/zoran/zoran.h | 4 +++ drivers/staging/media/zoran/zoran_card.c | 41 ++++++++++++++++++++++++ 3 files changed, 54 insertions(+)