Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from shelob.surriel.com (shelob.surriel.com [96.67.55.147]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D2C17C433EF for ; Mon, 11 Apr 2022 14:26:23 +0000 (UTC) Received: from localhost ([::1] helo=shelob.surriel.com) by shelob.surriel.com with esmtp (Exim 4.94.2) (envelope-from ) id 1nduzg-0006bB-Ex; Mon, 11 Apr 2022 10:26:16 -0400 Received: from wout5-smtp.messagingengine.com ([64.147.123.21]) by shelob.surriel.com with esmtps (TLS1.2) tls TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1nduzc-0006aO-TP for kernelnewbies@kernelnewbies.org; Mon, 11 Apr 2022 10:26:13 -0400 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id 09A9C3201FEF; Mon, 11 Apr 2022 10:26:08 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Mon, 11 Apr 2022 10:26:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kroah.com; h=cc :cc:content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to; s=fm1; t=1649687168; x=1649773568; bh=mCbLXh/0jJ +kFZX9oaGmG6nibuEt9/MWpwt7mnqFdsI=; b=SE+oPPm5xtkyaFkE9e14DytKZb Igi9V7EnYTX8/N4xAaijYzrZDqKVUnkmZYETFNpF/Z96xQUqaAHBMHppkWQuBFNj hYUgF1s3Z/FKPYav2x2xiC1UXA98/O751e/PJKVvhFlYgOMHMmCxWS5AGGMmpRM6 jwfIG35XexjOGiNiUs65gRHNANzlUb9ZSe3M80Gx6y90GgdPODmKoElnndDMGytZ uEnquHsvb/TC2Oca4w8uKuS+gpXidwfUMxRk9rGpAlfz5O49AGnX/yQiZTfE0iaA su+UDU6L25krBkizF6CEn86pRJP+OE208WKapavhFlkGKtTYhuREDyi7lRvw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1649687168; x= 1649773568; bh=mCbLXh/0jJ+kFZX9oaGmG6nibuEt9/MWpwt7mnqFdsI=; b=X 2KWTWmlxwtX2g3etsrGD7ztUWIsf1DwurWRC1YewDSs1jVTjyPjCjjQcwNUT3Sbc kVqEK30STobACFkMucVOk57bdsB2EdBi8j+sPjhDEezw6y8xtU4H29fg4XhmKth/ hb8uMATXjtEONidqWB9G5Q0O663TLH6VG9tJSB7oa6g7AS4qA3Wq3RdZvnHevQS2 TlpyppBCfICR3lYax3F3LLavCMUHNPwJKGv/frIUC8QjYb0bEnHDGyuAl7uX8TJb X127mNh7XQOEDcxHh3QVplAxlTkJQ32Ne/hpS3xQ5z3CC7bEnFZmpE442UZho5q/ M7or4emo/lwixMCplwRDA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvvddrudekiedgjeeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvffukfhfgggtuggjsehttdertddttddvnecuhfhrohhmpedkifhrvghg ucfmjfdkuceoghhrvghgsehkrhhorghhrdgtohhmqeenucggtffrrghtthgvrhhnpeeihf eghefghfevveekueeiieeghedvhfeludevgfeujedvleeufeegtdduleeufeenucevlhhu shhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehgrhgvgheskhhroh grhhdrtghomh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 11 Apr 2022 10:26:08 -0400 (EDT) Date: Mon, 11 Apr 2022 16:26:05 +0200 From: 'Greg KH' To: Chan Kim Subject: Re: Can't understand /proc/interrupts output for GICv3 case Message-ID: References: <049201d84b04$951cbab0$bf563010$@etri.re.kr> <06c401d84da0$bc1a5ca0$344f15e0$@etri.re.kr> <06cf01d84da5$f7a1fa80$e6e5ef80$@etri.re.kr> <06fc01d84dae$a9e4ebf0$fdaec3d0$@etri.re.kr> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <06fc01d84dae$a9e4ebf0$fdaec3d0$@etri.re.kr> Cc: kernelnewbies@kernelnewbies.org, 'qemu-discuss' X-BeenThere: kernelnewbies@kernelnewbies.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Learn about the Linux kernel List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: kernelnewbies-bounces@kernelnewbies.org On Mon, Apr 11, 2022 at 11:15:57PM +0900, Chan Kim wrote: > > > > > What bus type is your driver written for? > > > > > > > That sounds very logical. In my case I added it to system bus. > > > > What exactly do you mean by "system bus"? > > > I meant 'sysbus' in qemu code that I showed in the qemu code. > And I think it's the CPU bus. > > > > > Where is your kernel code? > > > This is the init function of my char driver. I thought if the struct cdev > contains struct device, maybe I could use the struct device's of_node to > call of_irq_get but it doesn't. > And I remember I've seen the cdev in usually contained in the driver data of > platform driver(?). Can I implement platform driver in kernel module form? > Below is the char driver init code. Currently it's request_irq(6, ... ) but > I want to know out the number 6 using program. If you have any advice, > please tell me. > > static int __init chr_driver_init(void) > { > int ret; > /* Allocating Major number */ > if ((alloc_chrdev_region(&dev, 0, 1, "axpu_Dev")) < 0) { > printk(KERN_INFO"Cannot allocate the major number..\n"); > return -1; > } > > printk(KERN_INFO"Major = %d Minor = %d..\n",MAJOR(dev),MINOR(dev)); > > /* creating cdev structure */ > cdev_init(&axpu_cdev, &fops); > axpu_cdev.owner = THIS_MODULE; > > /* Adding character device to the system */ > if ((cdev_add(&axpu_cdev,dev,1)) < 0) { > printk(KERN_INFO "Cannot add the device to the > system...\n"); > goto r_class; > } > > /* creating struct class */ > if ((dev_class = class_create(THIS_MODULE, "axpu_class")) == NULL) { > printk(KERN_INFO "cannot create the struct class...\n"); > goto r_class; > } > > /* for interrupt test !! */ > /* for vanilla work-around.. already made by mkdev */ > if ((device_create(dev_class, NULL, dev, NULL, "axpu_device")) == > NULL) { > printk(KERN_INFO "cannot create the device ..\n"); > goto r_device; > } > else { printk(KERN_INFO "axpu_device created..\n"); } > /**/ You can replace all of the above code by just using the miscdevice interface instead. Please use that, it ensures that you do everything properly and simplifies it all. > > vaddr = ioremap(AXPU_BASE, 0x80000); Wait, where are you picking those random values from? That's not how drivers work in the kernel. You have to have a bus pass you a device. Please register your driver with the proper bus type and go from there. The probe callback should be the place you set things up based on the device and resources given to you by the bus. You can't just randomly pick memory locations and think things will work. > if(!vaddr) > { > printk(KERN_INFO"Failed to map the address.\n"); > release_mem_region(AXPU_BASE,AXPU_SIZE); > return 1; > } > printk("----- AXPU_BASE mapped at vaddr = %px\n", vaddr); > > ret = request_irq(6, axpu_irq_handler, IRQF_SHARED, "axpu_irq", > &axpu_cdev); Same for that, just picking 6 will not work, sorry. Perhaps take a look at the book, Linux Device Drivers, 3rd edition. It's free online and should help you out a lot. > printk("request_irq returned %d\n", ret); // -EINVAL > printk(KERN_INFO "Device driver inserted ..done properly..\n"); > return 0; > > r_device : > class_destroy(dev_class); > > r_class : > unregister_chrdev_region(dev,1); > return -1; One final comment, don't make up error values like this, use real ERROR codes. thanks, greg k-h _______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies