From javierbrk at gmail.com Mon Sep 4 16:23:01 2023 From: javierbrk at gmail.com (Javier Jorge) Date: Mon, 4 Sep 2023 17:23:01 -0300 Subject: [Lkw] hello world Message-ID: Hi My name is Javier and I'm part of the organization of the event. Saludos Ing. Javier Alejandro Jorge -------------- next part -------------- An HTML attachment was scrubbed... URL: From javier.jorge at unc.edu.ar Fri Sep 8 22:41:16 2023 From: javier.jorge at unc.edu.ar (Javier Alejandro JORGE) Date: Fri, 8 Sep 2023 23:41:16 -0300 Subject: [Lkw] lectura recomendada Message-ID: *Recuerde que es necesario leer varios capítulos antes del taller. Esto nos permitirá a todos sacar el mayor provecho del mismo. * *https://lwn.net/Kernel/LDD3/ * *Los capítulos mas interesantes son * * Chapter 2: Building and Running Modules Chapter 9: Communicating with Hardware Chapter 10: Interrupt Handling Chapter 12: PCI Drivers* * and for anyone not bored yet* * Chapter 15: Memory Mapping and DMA* Saludos Javier -------------- next part -------------- An HTML attachment was scrubbed... URL: From javier.jorge at unc.edu.ar Sat Sep 9 15:30:13 2023 From: javier.jorge at unc.edu.ar (Javier Alejandro JORGE) Date: Sat, 9 Sep 2023 16:30:13 -0300 Subject: [Lkw] Bienvenidos al taller del kernel Message-ID: Les doy oficialmente la bienvenida al taller del kernel desde ahora las comunicaciones serán por la lista de correos. El taller será en inglés por lo que sería bueno que las comunicaciones en la lista sean en inglés también. LKW lkw at jrsl.org recuerden leer el material recomendado -------------- next part -------------- An HTML attachment was scrubbed... URL: From rodrigomelo9 at gmail.com Mon Sep 11 07:10:17 2023 From: rodrigomelo9 at gmail.com (Rodrigo Alejandro Melo) Date: Mon, 11 Sep 2023 08:10:17 -0300 Subject: [Lkw] Breaking the ice Message-ID: Hi everyone, Rodrigo Melo here, one of the attendants at the workshop. Somewhere, we were asked to introduce ourselves, but there are no threads for that yet (at least not in English), so let's start. I'm an Electronic Engineer, living in Buenos Aires but working remotely for a company located in Cordoba (indie Semiconductor). I started with GNU/Linux and FLOSS in general in 2005 (Debian Potato first, Debian Woody a few weeks later). I have my own FOSS projects and I contributed to some others, but mainly in the FPGA space, which is my area of expertise. Because embedded Linux is an option with those devices, I did a course about Kernel modules in 2015, so the idea is to refresh/update concepts and who knows, maybe finally start contributing to Linux ;-) Who's next? See you on Thursday! -------------- next part -------------- An HTML attachment was scrubbed... URL: From rodrigomelo9 at gmail.com Mon Sep 11 07:17:22 2023 From: rodrigomelo9 at gmail.com (Rodrigo Alejandro Melo) Date: Mon, 11 Sep 2023 08:17:22 -0300 Subject: [Lkw] lectura recomendada In-Reply-To: References: Message-ID: Already downloaded and I'm reading it, thanks! I have had this book in my TODO for a while, but concerned about the fact is based on Kernels 2.6. Is updated enough? Is the most updated alternative? Other chapters are not particularly useful for this workshop or are those not valid anymore with the current 6.5 Kernel? Regards, Rodrigo El vie, 8 sept 2023 a las 23:42, Javier Alejandro JORGE (< javier.jorge at unc.edu.ar>) escribió: > > *Recuerde que es necesario leer varios capítulos antes del taller. Esto > nos permitirá a todos sacar el mayor provecho del mismo. * > > > *https://lwn.net/Kernel/LDD3/ * > > *Los capítulos mas interesantes son * > > > > > * Chapter 2: Building and Running Modules Chapter 9: Communicating with > Hardware Chapter 10: Interrupt Handling Chapter 12: PCI Drivers* > * and for anyone not bored yet* > > * Chapter 15: Memory Mapping and DMA* > > Saludos > Javier > -------------- next part -------------- An HTML attachment was scrubbed... URL: From javierbrk at gmail.com Mon Sep 11 10:48:13 2023 From: javierbrk at gmail.com (Javier Jorge) Date: Mon, 11 Sep 2023 11:48:13 -0300 Subject: [Lkw] lectura recomendada In-Reply-To: References: Message-ID: The idea is to get the students a little more up to speed, so that we might be more productive. The book is fairly outdated (many interfaces changed) the best documentation is the kernel itself, but most of the concepts explained are still in use. Saludos Ing. Javier Alejandro Jorge On Mon, 11 Sept 2023 at 08:18, Rodrigo Alejandro Melo < rodrigomelo9 at gmail.com> wrote: > Already downloaded and I'm reading it, thanks! > > I have had this book in my TODO for a while, but concerned about the fact > is based on Kernels 2.6. Is updated enough? Is the most updated > alternative? Other chapters are not particularly useful for this workshop > or are those not valid anymore with the current 6.5 Kernel? > > Regards, > Rodrigo > > > El vie, 8 sept 2023 a las 23:42, Javier Alejandro JORGE (< > javier.jorge at unc.edu.ar>) escribió: > >> >> *Recuerde que es necesario leer varios capítulos antes del taller. Esto >> nos permitirá a todos sacar el mayor provecho del mismo. * >> >> >> *https://lwn.net/Kernel/LDD3/ * >> >> *Los capítulos mas interesantes son * >> >> >> >> >> * Chapter 2: Building and Running Modules Chapter 9: Communicating with >> Hardware Chapter 10: Interrupt Handling Chapter 12: PCI Drivers* >> * and for anyone not bored yet* >> >> * Chapter 15: Memory Mapping and DMA* >> >> Saludos >> Javier >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From javier.jorge at unc.edu.ar Mon Sep 11 11:28:29 2023 From: javier.jorge at unc.edu.ar (Javier Alejandro JORGE) Date: Mon, 11 Sep 2023 12:28:29 -0300 Subject: [Lkw] Breaking the ice In-Reply-To: References: Message-ID: Hi ! ¡Thanks Rodrigo ! My name is Javier Jorge, I work at INTI and I am also a professor at UNC. One of the topics I teach at unc is linux drivers. So this year I asked Christoph if he would like to give a small motivational talk to the students, but he replied that he could come and prepare a workshop. So ... Here we are ! He also asked about a conference in the region to give a talk and we found out that there were none. Somo of us have experience with flisol and we were looking for an excuse to make a more technical free software conference. So we also organized the conference on freedom software day (16/09). I feel so thankful with Christoph, because of him we all are here gathered and renewing the free software wave by remakin JRSL. Just as a side note, I took a workshop with him in 2009 https://www.vialibre.org.ar/agosto-hackaton-en-famaf-%C2%A1escribimos-un-driver-wifi/. Hope to see you soon ! Javier El lun, 11 sept 2023 a las 8:11, Rodrigo Alejandro Melo (< rodrigomelo9 at gmail.com>) escribió: > Hi everyone, Rodrigo Melo here, one of the attendants at the workshop. > Somewhere, we were asked to introduce ourselves, but there are no threads > for that yet (at least not in English), so let's start. > > I'm an Electronic Engineer, living in Buenos Aires but working remotely > for a company located in Cordoba (indie Semiconductor). I started with > GNU/Linux and FLOSS in general in 2005 (Debian Potato first, Debian Woody a > few weeks later). I have my own FOSS projects and I contributed to some > others, but mainly in the FPGA space, which is my area of expertise. > Because embedded Linux is an option with those devices, I did a course > about Kernel modules in 2015, so the idea is to refresh/update concepts and > who knows, maybe finally start contributing to Linux ;-) > > Who's next? See you on Thursday! > -- Esp. Ing. Javier A. Jorge Prof. Asistente Métodos Numéricos FCEFyN - UNC -------------- next part -------------- An HTML attachment was scrubbed... URL: From rodrigomelo9 at gmail.com Mon Sep 11 11:49:15 2023 From: rodrigomelo9 at gmail.com (Rodrigo Alejandro Melo) Date: Mon, 11 Sep 2023 12:49:15 -0300 Subject: [Lkw] lectura recomendada In-Reply-To: References: Message-ID: Ok, I got it. Thanks El lun, 11 sept 2023 a las 12:12, Javier Jorge () escribió: > The idea is to get the students a little more up to speed, so that we > might be more productive. The book is fairly outdated (many interfaces > changed) the best documentation is the kernel itself, but most of the > concepts explained are still in use. > > Saludos > Ing. Javier Alejandro Jorge > > > On Mon, 11 Sept 2023 at 08:18, Rodrigo Alejandro Melo < > rodrigomelo9 at gmail.com> wrote: > >> Already downloaded and I'm reading it, thanks! >> >> I have had this book in my TODO for a while, but concerned about the fact >> is based on Kernels 2.6. Is updated enough? Is the most updated >> alternative? Other chapters are not particularly useful for this workshop >> or are those not valid anymore with the current 6.5 Kernel? >> >> Regards, >> Rodrigo >> >> >> El vie, 8 sept 2023 a las 23:42, Javier Alejandro JORGE (< >> javier.jorge at unc.edu.ar>) escribió: >> >>> >>> *Recuerde que es necesario leer varios capítulos antes del taller. Esto >>> nos permitirá a todos sacar el mayor provecho del mismo. * >>> >>> >>> *https://lwn.net/Kernel/LDD3/ * >>> >>> *Los capítulos mas interesantes son * >>> >>> >>> >>> >>> * Chapter 2: Building and Running Modules Chapter 9: Communicating with >>> Hardware Chapter 10: Interrupt Handling Chapter 12: PCI Drivers* >>> * and for anyone not bored yet* >>> >>> * Chapter 15: Memory Mapping and DMA* >>> >>> Saludos >>> Javier >>> >> -------------- next part -------------- An HTML attachment was scrubbed... URL: From damian.gonzalez at mi.unc.edu.ar Mon Sep 11 12:21:39 2023 From: damian.gonzalez at mi.unc.edu.ar (=?UTF-8?Q?DAMI=C3=81N_MARCELO_GONZALEZ?=) Date: Mon, 11 Sep 2023 13:21:39 -0300 Subject: [Lkw] lectura recomendada In-Reply-To: References: Message-ID: Hi everyone, nice to e-meet for now, My name's Damian. I thaught myself to write code at around 2011. Prefered scripting language: Ruby. I've been working in the localization industry for about 6 years as a Software Developer. I'm currently a Computer Engineering student at the FCEFyN UNC, I'm in my 4th year. I grow bored of writing high level stuff and moved towards the low level stuff since a couple of years. Among my collabs in the open source world, I wrote in C a small library to read XLSX files, and made a port to Ruby through FFI bindings. Be free to check these and other projects I made: https://damian-m-g.github.io/portfolio/. My interest in the Linux world (and GNU) started pretty recently, at the start of this year. I read a couple of iconic books about the subject (the ones from Linus and Stallman included), and I'm making a slow transition from the unmentionable (the one that starts with W) to a linux distro. I've a low spec laptop running Puppy Linux x32, but I fear it's not going to be enough for creating virtual machines. I believe I'll run a linux distro from a pendrive on my newest laptop, or use the unmentionable for now. Please let me know if you have insight about what should be useful for the workshop. About the book, I'm going to have to rush on it since Wednesday night 'till the start of the workshop because I've a test on Wednesday. Fortunately for me, the test subject is about coding in C an LCP1769 microcontroller using ARM infrastructure, so it's somehow related I believe. Cheers, D. El lun, 11 sept 2023 a las 12:50, Rodrigo Alejandro Melo (< rodrigomelo9 at gmail.com>) escribió: > Ok, I got it. Thanks > > El lun, 11 sept 2023 a las 12:12, Javier Jorge () > escribió: > >> The idea is to get the students a little more up to speed, so that we >> might be more productive. The book is fairly outdated (many interfaces >> changed) the best documentation is the kernel itself, but most of the >> concepts explained are still in use. >> >> Saludos >> Ing. Javier Alejandro Jorge >> >> >> On Mon, 11 Sept 2023 at 08:18, Rodrigo Alejandro Melo < >> rodrigomelo9 at gmail.com> wrote: >> >>> Already downloaded and I'm reading it, thanks! >>> >>> I have had this book in my TODO for a while, but concerned about the >>> fact is based on Kernels 2.6. Is updated enough? Is the most updated >>> alternative? Other chapters are not particularly useful for this workshop >>> or are those not valid anymore with the current 6.5 Kernel? >>> >>> Regards, >>> Rodrigo >>> >>> >>> El vie, 8 sept 2023 a las 23:42, Javier Alejandro JORGE (< >>> javier.jorge at unc.edu.ar>) escribió: >>> >>>> >>>> *Recuerde que es necesario leer varios capítulos antes del taller. Esto >>>> nos permitirá a todos sacar el mayor provecho del mismo. * >>>> >>>> >>>> *https://lwn.net/Kernel/LDD3/ * >>>> >>>> *Los capítulos mas interesantes son * >>>> >>>> >>>> >>>> >>>> * Chapter 2: Building and Running Modules Chapter 9: Communicating with >>>> Hardware Chapter 10: Interrupt Handling Chapter 12: PCI Drivers* >>>> * and for anyone not bored yet* >>>> >>>> * Chapter 15: Memory Mapping and DMA* >>>> >>>> Saludos >>>> Javier >>>> >>> -------------- next part -------------- An HTML attachment was scrubbed... URL: From javier.jorge at unc.edu.ar Mon Sep 11 15:36:00 2023 From: javier.jorge at unc.edu.ar (Javier Alejandro JORGE) Date: Mon, 11 Sep 2023 16:36:00 -0300 Subject: [Lkw] =?utf-8?q?12=C2=BA_JRSL_C=C3=B3rdoba_2023?= Message-ID: The full event schedule is available on line https://eventol.flisol.org.ar/events/jrsl-cordoba-2023/schedule -------------- next part -------------- An HTML attachment was scrubbed... URL: From hch at lst.de Tue Sep 12 11:01:08 2023 From: hch at lst.de (Christoph Hellwig) Date: Tue, 12 Sep 2023 17:01:08 +0200 Subject: [Lkw] =?iso-8859-1?q?=A1Hola!?= Message-ID: <20230912150108.GA8644@lst.de> Hi, I'm Christoph and I will give the kernel programming workshop togther with the local teachers. My Spanish is not very good so I will usually talk English. Feel free to ask me any question you have in person or by email. From rodrigomelo9 at gmail.com Wed Sep 13 08:03:45 2023 From: rodrigomelo9 at gmail.com (Rodrigo Alejandro Melo) Date: Wed, 13 Sep 2023 09:03:45 -0300 Subject: [Lkw] lectura recomendada In-Reply-To: References: Message-ID: Four chapters in, one left! (and I'm particularly interested in DMA). I'm already in Cordoba, so see you tomorrow! El lun, 11 sept 2023 a las 13:21, DAMIÁN MARCELO GONZALEZ (< damian.gonzalez at mi.unc.edu.ar>) escribió: > Hi everyone, nice to e-meet for now, > > My name's Damian. I thaught myself to write code at around 2011. Prefered > scripting language: Ruby. I've been working in the localization industry > for about 6 years as a Software Developer. I'm currently a Computer > Engineering student at the FCEFyN UNC, I'm in my 4th year. I grow bored of > writing high level stuff and moved towards the low level stuff since a > couple of years. Among my collabs in the open source world, I wrote in C a > small library to read XLSX files, and made a port to Ruby through FFI > bindings. Be free to check these and other projects I made: > https://damian-m-g.github.io/portfolio/. > > My interest in the Linux world (and GNU) started pretty recently, at the > start of this year. I read a couple of iconic books about the subject (the > ones from Linus and Stallman included), and I'm making a slow transition > from the unmentionable (the one that starts with W) to a linux distro. I've > a low spec laptop running Puppy Linux x32, but I fear it's not going to be > enough for creating virtual machines. I believe I'll run a linux distro > from a pendrive on my newest laptop, or use the unmentionable for now. > Please let me know if you have insight about what should be useful for the > workshop. > > About the book, I'm going to have to rush on it since Wednesday night > 'till the start of the workshop because I've a test on Wednesday. > Fortunately for me, the test subject is about coding in C an LCP1769 > microcontroller using ARM infrastructure, so it's somehow related I believe. > > Cheers, > > D. > > El lun, 11 sept 2023 a las 12:50, Rodrigo Alejandro Melo (< > rodrigomelo9 at gmail.com>) escribió: > >> Ok, I got it. Thanks >> >> El lun, 11 sept 2023 a las 12:12, Javier Jorge () >> escribió: >> >>> The idea is to get the students a little more up to speed, so that we >>> might be more productive. The book is fairly outdated (many interfaces >>> changed) the best documentation is the kernel itself, but most of the >>> concepts explained are still in use. >>> >>> Saludos >>> Ing. Javier Alejandro Jorge >>> >>> >>> On Mon, 11 Sept 2023 at 08:18, Rodrigo Alejandro Melo < >>> rodrigomelo9 at gmail.com> wrote: >>> >>>> Already downloaded and I'm reading it, thanks! >>>> >>>> I have had this book in my TODO for a while, but concerned about the >>>> fact is based on Kernels 2.6. Is updated enough? Is the most updated >>>> alternative? Other chapters are not particularly useful for this workshop >>>> or are those not valid anymore with the current 6.5 Kernel? >>>> >>>> Regards, >>>> Rodrigo >>>> >>>> >>>> El vie, 8 sept 2023 a las 23:42, Javier Alejandro JORGE (< >>>> javier.jorge at unc.edu.ar>) escribió: >>>> >>>>> >>>>> *Recuerde que es necesario leer varios capítulos antes del taller. >>>>> Esto nos permitirá a todos sacar el mayor provecho del mismo. * >>>>> >>>>> >>>>> *https://lwn.net/Kernel/LDD3/ * >>>>> >>>>> *Los capítulos mas interesantes son * >>>>> >>>>> >>>>> >>>>> >>>>> * Chapter 2: Building and Running Modules Chapter 9: Communicating >>>>> with Hardware Chapter 10: Interrupt Handling Chapter 12: PCI Drivers* >>>>> * and for anyone not bored yet* >>>>> >>>>> * Chapter 15: Memory Mapping and DMA* >>>>> >>>>> Saludos >>>>> Javier >>>>> >>>> -------------- next part -------------- An HTML attachment was scrubbed... URL: From hch at lst.de Wed Sep 13 09:21:52 2023 From: hch at lst.de (Christoph Hellwig) Date: Wed, 13 Sep 2023 15:21:52 +0200 Subject: [Lkw] Getting started Message-ID: <20230913132152.GA9549@lst.de> Hello, Javier suggest that I send out the steps for creating the VM and the build environment before the start of the workshop so that we don't all hit the internet connection dowbloading things at the same time. Find a document describing the steps, and a shell script for starting the VM attached. If you have any questions just ask me, and if you don't have time to do the setup today we'll do it together tomorrow. -------------- next part -------------- A non-text attachment was scrubbed... Name: jrsl-lkw-0-setup.md Type: application/x-genesis-rom Size: 3037 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: kvm-jrsl.sh Type: application/x-shellscript Size: 375 bytes Desc: not available URL: From rodrigomelo9 at gmail.com Thu Sep 14 08:06:41 2023 From: rodrigomelo9 at gmail.com (Rodrigo Alejandro Melo) Date: Thu, 14 Sep 2023 09:06:41 -0300 Subject: [Lkw] Getting started In-Reply-To: <20230913132152.GA9549@lst.de> References: <20230913132152.GA9549@lst.de> Message-ID: Hi guys, I'm following your instructions. I already ran: qemu-img resize debian-12-nocloud-amd64.qcow2 8G The Debian image and your script are in the same directory: $ ls -l total 355540 -rw-rw-r-- 1 rodrigo rodrigo 364118144 sep 14 08:49 debian-12-nocloud-amd64.qcow2 -rwxrwxr-x 1 rodrigo rodrigo 375 sep 14 08:56 kvm-jrsl.sh But when I run the script: $ ./kvm-jrsl.sh qemu-system-x86_64: -device nvme,id=nvme0,serial=0123456789,cmb_size_mb=16: drive property not set drive looks properly set in the script. Any idea? Maybe something system dependant? I'm using a machine with Ubuntu 20.04. Thanks El mié, 13 sept 2023 a las 10:22, Christoph Hellwig () escribió: > Hello, > > Javier suggest that I send out the steps for creating the VM and > the build environment before the start of the workshop so that > we don't all hit the internet connection dowbloading things at > the same time. Find a document describing the steps, and a shell > script for starting the VM attached. If you have any questions > just ask me, and if you don't have time to do the setup today > we'll do it together tomorrow. > -------------- next part -------------- An HTML attachment was scrubbed... URL: From hch at lst.de Thu Sep 14 08:10:51 2023 From: hch at lst.de (Christoph Hellwig) Date: Thu, 14 Sep 2023 14:10:51 +0200 Subject: [Lkw] Getting started In-Reply-To: References: <20230913132152.GA9549@lst.de> Message-ID: <20230914121051.GA25664@lst.de> Hi Rodrigo, yes, unfortunately we already found out last night that the qemu in Ubuntu 20.04 is too old. This is the receipe to build a new qemu from the source tree: sudo apt-get install build-essential git clone https://github.com/qemu/qemu cd qemu mkdir build cd build ../configure --disable-werror --target-list=x86_64-softmmu --prefix=/opt/newqemu/ make After this the kvm-jrsl.sh scripts needs to be adjusted so that QEMU="qemu-system-x86_64" line instead says: QEMU="/opt/newqemu/bin/qemu-system-x86_64" From rodrigomelo9 at gmail.com Thu Sep 14 08:38:14 2023 From: rodrigomelo9 at gmail.com (Rodrigo Alejandro Melo) Date: Thu, 14 Sep 2023 09:38:14 -0300 Subject: [Lkw] Getting started In-Reply-To: <20230914121051.GA25664@lst.de> References: <20230913132152.GA9549@lst.de> <20230914121051.GA25664@lst.de> Message-ID: Hi Christoph, thanks! (it works, with a few tweaks) First of all, I strongly recommend other attendants to do that before the workshop! (at least, download things such as the Linux sources) If not, and with a probably saturated connection, we will spend a lot of time. This is the receipe to build a new qemu from the source tree: > At least on my system, to build qemu, I needed to install extra packages. TL;DR you can run: sudo apt install libglib2.0-dev libfdt-dev libpixman-1-dev zlib1g-dev libaio-dev libusb-1.0-0-dev libspice-server-dev libnfs-dev libiscsi-dev liblzo2-dev libseccomp-dev libattr1-dev libcap-ng-dev ninja-build > sudo apt-get install build-essential > git clone https://github.com/qemu/qemu > cd qemu > mkdir build > cd build > sudo apt install ninja-build meson > ../configure --disable-werror --target-list=x86_64-softmmu > --prefix=/opt/newqemu/ > make > > After this the kvm-jrsl.sh scripts needs to be adjusted so that > > QEMU="qemu-system-x86_64" > > line instead says: > > QEMU="/opt/newqemu/bin/qemu-system-x86_64" > And I needed to create shared (mkdir shared) to avoid an error. -------------- next part -------------- An HTML attachment was scrubbed... URL: From hch at lst.de Thu Sep 14 08:42:12 2023 From: hch at lst.de (Christoph Hellwig) Date: Thu, 14 Sep 2023 14:42:12 +0200 Subject: [Lkw] Getting started In-Reply-To: References: <20230913132152.GA9549@lst.de> <20230914121051.GA25664@lst.de> Message-ID: <20230914124212.GA27903@lst.de> Hi Rodrigo, thanks for the additional dependencies, and yes, we also need to create the shared directory. From rodrigomelo9 at gmail.com Thu Sep 14 08:54:48 2023 From: rodrigomelo9 at gmail.com (Rodrigo Alejandro Melo) Date: Thu, 14 Sep 2023 09:54:48 -0300 Subject: [Lkw] Getting started In-Reply-To: <20230914124212.GA27903@lst.de> References: <20230913132152.GA9549@lst.de> <20230914121051.GA25664@lst.de> <20230914124212.GA27903@lst.de> Message-ID: It seems that my VM has no internet (I can't install packages for building the kernel): root at localhost:~# ping deb.debian.org ping: deb.debian.org: Temporary failure in name resolution (but the same ping works in my host machine) El jue, 14 sept 2023 a las 9:42, Christoph Hellwig () escribió: > Hi Rodrigo, > > thanks for the additional dependencies, and yes, we also need to > create the shared directory. > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From emmanuelarias30 at gmail.com Thu Sep 14 08:58:44 2023 From: emmanuelarias30 at gmail.com (Emmanuel Arias) Date: Thu, 14 Sep 2023 09:58:44 -0300 Subject: [Lkw] Breaking the ice In-Reply-To: References: Message-ID: Hello everybody! I'm Emmanuel Arias from la Rioja Argentina. I started to use FOSS in 2013 during my University life :-). Then, In 2017 I started to contribute to some FOSS projects one of them being the Debian project. Happily in July I became a Debian Developer :-D. I am eager to learn a lot with this course. See you in a few hours! Cheers, Emmanuel El lun, 11 sept 2023 a la(s) 12:29, Javier Alejandro JORGE ( javier.jorge at unc.edu.ar) escribió: > Hi ! ¡Thanks Rodrigo ! > My name is Javier Jorge, I work at INTI and I am also a professor at UNC. > One of the topics I teach at unc is linux drivers. So this year I asked > Christoph if he would like to give a small motivational talk to the > students, but he replied that he could come and prepare a workshop. So ... > Here we are ! He also asked about a conference in the region to give a talk > and we found out that there were none. Somo of us have experience with > flisol and we were looking for an excuse to make a more technical free > software conference. So we also organized the conference on freedom > software day (16/09). > I feel so thankful with Christoph, because of him we all are here gathered > and renewing the free software wave by remakin JRSL. > Just as a side note, I took a workshop with him in 2009 > https://www.vialibre.org.ar/agosto-hackaton-en-famaf-%C2%A1escribimos-un-driver-wifi/. > > > Hope to see you soon ! > Javier > > > > > El lun, 11 sept 2023 a las 8:11, Rodrigo Alejandro Melo (< > rodrigomelo9 at gmail.com>) escribió: > >> Hi everyone, Rodrigo Melo here, one of the attendants at the workshop. >> Somewhere, we were asked to introduce ourselves, but there are no threads >> for that yet (at least not in English), so let's start. >> >> I'm an Electronic Engineer, living in Buenos Aires but working remotely >> for a company located in Cordoba (indie Semiconductor). I started with >> GNU/Linux and FLOSS in general in 2005 (Debian Potato first, Debian Woody a >> few weeks later). I have my own FOSS projects and I contributed to some >> others, but mainly in the FPGA space, which is my area of expertise. >> Because embedded Linux is an option with those devices, I did a course >> about Kernel modules in 2015, so the idea is to refresh/update concepts and >> who knows, maybe finally start contributing to Linux ;-) >> >> Who's next? See you on Thursday! >> > > > -- > Esp. Ing. Javier A. Jorge > Prof. Asistente > Métodos Numéricos > FCEFyN - UNC > -------------- next part -------------- An HTML attachment was scrubbed... URL: From hch at lst.de Thu Sep 14 09:23:41 2023 From: hch at lst.de (Christoph Hellwig) Date: Thu, 14 Sep 2023 15:23:41 +0200 Subject: [Lkw] Getting started In-Reply-To: References: <20230913132152.GA9549@lst.de> <20230914121051.GA25664@lst.de> <20230914124212.GA27903@lst.de> Message-ID: <20230914132341.GA30816@lst.de> This is probablt because libslirp-dev is missing. Do a: sudo apt-get install libslirp-dev and then from the qemu build dir, redo the ./configure --disable-werror --target-list=x86_64-softmmu --prefix=/opt/newqemu/ make sudo make install On Thu, Sep 14, 2023 at 09:54:48AM -0300, Rodrigo Alejandro Melo wrote: > It seems that my VM has no internet (I can't install packages for building > the kernel): > > root at localhost:~# ping deb.debian.org > ping: deb.debian.org: Temporary failure in name resolution > > (but the same ping works in my host machine) > > El jue, 14 sept 2023 a las 9:42, Christoph Hellwig () escribió: > > > Hi Rodrigo, > > > > thanks for the additional dependencies, and yes, we also need to > > create the shared directory. > > > > ---end quoted text--- From javier.jorge at unc.edu.ar Thu Sep 14 09:41:03 2023 From: javier.jorge at unc.edu.ar (Javier Alejandro JORGE) Date: Thu, 14 Sep 2023 10:41:03 -0300 Subject: [Lkw] Breaking the ice In-Reply-To: References: Message-ID: Thank you so much for sharing! See you soon ! El jue, 14 sept 2023 a las 9:58, Emmanuel Arias () escribió: > Hello everybody! > > I'm Emmanuel Arias from la Rioja Argentina. I started to use FOSS in 2013 > during > my University life :-). Then, In 2017 I started to contribute to some FOSS > projects > one of them being the Debian project. Happily in July I became a Debian > Developer :-D. > > I am eager to learn a lot with this course. > > See you in a few hours! > > Cheers, > Emmanuel > > El lun, 11 sept 2023 a la(s) 12:29, Javier Alejandro JORGE ( > javier.jorge at unc.edu.ar) escribió: > >> Hi ! ¡Thanks Rodrigo ! >> My name is Javier Jorge, I work at INTI and I am also a professor at UNC. >> One of the topics I teach at unc is linux drivers. So this year I asked >> Christoph if he would like to give a small motivational talk to the >> students, but he replied that he could come and prepare a workshop. So ... >> Here we are ! He also asked about a conference in the region to give a talk >> and we found out that there were none. Somo of us have experience with >> flisol and we were looking for an excuse to make a more technical free >> software conference. So we also organized the conference on freedom >> software day (16/09). >> I feel so thankful with Christoph, because of him we all are here >> gathered and renewing the free software wave by remakin JRSL. >> Just as a side note, I took a workshop with him in 2009 >> https://www.vialibre.org.ar/agosto-hackaton-en-famaf-%C2%A1escribimos-un-driver-wifi/. >> >> >> Hope to see you soon ! >> Javier >> >> >> >> >> El lun, 11 sept 2023 a las 8:11, Rodrigo Alejandro Melo (< >> rodrigomelo9 at gmail.com>) escribió: >> >>> Hi everyone, Rodrigo Melo here, one of the attendants at the workshop. >>> Somewhere, we were asked to introduce ourselves, but there are no threads >>> for that yet (at least not in English), so let's start. >>> >>> I'm an Electronic Engineer, living in Buenos Aires but working remotely >>> for a company located in Cordoba (indie Semiconductor). I started with >>> GNU/Linux and FLOSS in general in 2005 (Debian Potato first, Debian Woody a >>> few weeks later). I have my own FOSS projects and I contributed to some >>> others, but mainly in the FPGA space, which is my area of expertise. >>> Because embedded Linux is an option with those devices, I did a course >>> about Kernel modules in 2015, so the idea is to refresh/update concepts and >>> who knows, maybe finally start contributing to Linux ;-) >>> >>> Who's next? See you on Thursday! >>> >> >> >> -- >> Esp. Ing. Javier A. Jorge >> Prof. Asistente >> Métodos Numéricos >> FCEFyN - UNC >> > -- Esp. Ing. Javier A. Jorge Prof. Asistente Métodos Numéricos FCEFyN - UNC -------------- next part -------------- An HTML attachment was scrubbed... URL: From damian.gonzalez at mi.unc.edu.ar Thu Sep 14 10:40:18 2023 From: damian.gonzalez at mi.unc.edu.ar (=?UTF-8?Q?DAMI=C3=81N_MARCELO_GONZALEZ?=) Date: Thu, 14 Sep 2023 11:40:18 -0300 Subject: [Lkw] Getting started In-Reply-To: <20230914132341.GA30816@lst.de> References: <20230913132152.GA9549@lst.de> <20230914121051.GA25664@lst.de> <20230914124212.GA27903@lst.de> <20230914132341.GA30816@lst.de> Message-ID: Hi guys, This way it works, thanks for the insights. Cheers, D. El jue, 14 sept 2023 a las 10:24, Christoph Hellwig () escribió: > This is probablt because libslirp-dev is missing. > > Do a: > > sudo apt-get install libslirp-dev > > and then from the qemu build dir, redo the > > ./configure --disable-werror --target-list=x86_64-softmmu > --prefix=/opt/newqemu/ > make > sudo make install > > On Thu, Sep 14, 2023 at 09:54:48AM -0300, Rodrigo Alejandro Melo wrote: > > It seems that my VM has no internet (I can't install packages for > building > > the kernel): > > > > root at localhost:~# ping deb.debian.org > > ping: deb.debian.org: Temporary failure in name resolution > > > > (but the same ping works in my host machine) > > > > El jue, 14 sept 2023 a las 9:42, Christoph Hellwig () > escribió: > > > > > Hi Rodrigo, > > > > > > thanks for the additional dependencies, and yes, we also need to > > > create the shared directory. > > > > > > > ---end quoted text--- > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rodrigomelo9 at gmail.com Thu Sep 14 10:50:38 2023 From: rodrigomelo9 at gmail.com (Rodrigo Alejandro Melo) Date: Thu, 14 Sep 2023 11:50:38 -0300 Subject: [Lkw] Getting started In-Reply-To: References: <20230913132152.GA9549@lst.de> <20230914121051.GA25664@lst.de> <20230914124212.GA27903@lst.de> <20230914132341.GA30816@lst.de> Message-ID: Yep, I'm downloading Linux sources in the VM, thanks! El jue, 14 sept 2023 a las 11:40, DAMIÁN MARCELO GONZALEZ (< damian.gonzalez at mi.unc.edu.ar>) escribió: > Hi guys, > > This way it works, thanks for the insights. > > Cheers, > > D. > > > > > El jue, 14 sept 2023 a las 10:24, Christoph Hellwig () > escribió: > >> This is probablt because libslirp-dev is missing. >> >> Do a: >> >> sudo apt-get install libslirp-dev >> >> and then from the qemu build dir, redo the >> >> ./configure --disable-werror --target-list=x86_64-softmmu >> --prefix=/opt/newqemu/ >> make >> sudo make install >> >> On Thu, Sep 14, 2023 at 09:54:48AM -0300, Rodrigo Alejandro Melo wrote: >> > It seems that my VM has no internet (I can't install packages for >> building >> > the kernel): >> > >> > root at localhost:~# ping deb.debian.org >> > ping: deb.debian.org: Temporary failure in name resolution >> > >> > (but the same ping works in my host machine) >> > >> > El jue, 14 sept 2023 a las 9:42, Christoph Hellwig () >> escribió: >> > >> > > Hi Rodrigo, >> > > >> > > thanks for the additional dependencies, and yes, we also need to >> > > create the shared directory. >> > > >> > > >> ---end quoted text--- >> >> -------------- next part -------------- An HTML attachment was scrubbed... URL: From hch at lst.de Thu Sep 14 13:06:36 2023 From: hch at lst.de (Christoph Hellwig) Date: Thu, 14 Sep 2023 19:06:36 +0200 Subject: [Lkw] updates script to run the VM Message-ID: <20230914170636.GA14680@lst.de> As some people noticed, the kvm-jrsl.s script did not create th required shared folder. It also misses a qemu paramter, so here is a version with that fixed and a few improved comments. Please use the attached version going forward. -------------- next part -------------- A non-text attachment was scrubbed... Name: kvm-jrsl.sh Type: application/x-shellscript Size: 527 bytes Desc: not available URL: From hch at lst.de Thu Sep 14 13:24:52 2023 From: hch at lst.de (Christoph Hellwig) Date: Thu, 14 Sep 2023 19:24:52 +0200 Subject: [Lkw] kernel build and creating the shared folder Message-ID: <20230914172452.GB14680@lst.de> I got question on how to set up the shared folder. The instructions are at the end of this file which is the second lesson, use at your own risk if you want the shared folder now. -------------- next part -------------- A non-text attachment was scrubbed... Name: jrsl-lkw-1-build.md Type: application/x-genesis-rom Size: 1734 bytes Desc: not available URL: From hch at lst.de Thu Sep 14 13:51:47 2023 From: hch at lst.de (Christoph Hellwig) Date: Thu, 14 Sep 2023 19:51:47 +0200 Subject: [Lkw] git url Message-ID: <20230914175147.GA16221@lst.de> Hi all, as we just found out the git protocol does not work inside the university network. So replace the git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git url with https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git note that if you already cloned at home you can change it in the .git/config file in the linux directory as well. From hch at lst.de Thu Sep 14 13:54:46 2023 From: hch at lst.de (Christoph Hellwig) Date: Thu, 14 Sep 2023 19:54:46 +0200 Subject: [Lkw] how to build your own qemu Message-ID: <20230914175446.GB16221@lst.de> A few people had no working qemu, or a qemu where networking did not work at all (and not just git clone). It is very important that qemu has support for libslirp, as that is the default networking. On Debian/Ubuntu this done by: sudo apt-get install libslirp-dev for other distributions it might work a little different. There are some of the other required dependencies to build qemu on Ubuntu from Rodrigo: sudo apt install libglib2.0-dev libfdt-dev libpixman-1-dev zlib1g-dev libaio-dev libusb-1.0-0-dev libspice-server-dev libnfs-dev libiscsi-dev liblzo2-dev libseccomp-dev libattr1-dev libcap-ng-dev ninja-build then do: git clone https://github.com/qemu/qemu cd qemu mkdir build cd build ../configure --disable-werror --enable-slirp --target-list=x86_64-softmmu --prefix=/opt/newqemu/ make sudo make install and use the already existing commented out line for the newqemu in the kvm-jrsl.sh script. From sofia.amallo at mi.unc.edu.ar Thu Sep 14 14:05:14 2023 From: sofia.amallo at mi.unc.edu.ar (=?UTF-8?Q?Sof=C3=ADa_Amallo?=) Date: Thu, 14 Sep 2023 15:05:14 -0300 Subject: [Lkw] kernel build and creating the shared folder In-Reply-To: References: <20230914172452.GB14680@lst.de> Message-ID: On Thu, 14 Sep 2023 at 14:38 Sofía Amallo wrote: > Thanks! > If anyone is trying to set up the shared folder, just follow the last > steps on the jrsl-lkw-1-build.md file: > > edit the /etc/fstab file using your favorite > editor (I'm using vim here) > > vim /etc/fstab > > And add this line to the end of it: > > shared /mnt/shared 9p trans=virtio,version=9p2000.L > > And then mount this file system > > systemctl daemon-reload > mount /mnt/shared > > This file system will not also be available when you reboot. Test the > file system by e.g. storing all the kernel messages there: > > dmesg > /mnt/shared/dmesg > > and then check that you can read this text file on the host system. > > You can then use /mnt/shared by copying files to and from it in the host > and the guest. > > > > On Thu, 14 Sep 2023 at 14:25 Christoph Hellwig wrote: > >> I got question on how to set up the shared folder. The instructions >> are at the end of this file which is the second lesson, use at your >> own risk if you want the shared folder now. >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rodrigomelo9 at gmail.com Thu Sep 14 14:06:03 2023 From: rodrigomelo9 at gmail.com (Rodrigo Alejandro Melo) Date: Thu, 14 Sep 2023 15:06:03 -0300 Subject: [Lkw] git url In-Reply-To: <20230914175147.GA16221@lst.de> References: <20230914175147.GA16221@lst.de> Message-ID: Alternatively, if you downloaded the GIT repo at home, you can run the following to modify the remote: git remote set-url origin https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git El jue, 14 sept 2023 a las 14:53, Christoph Hellwig () escribió: > Hi all, > > as we just found out the git protocol does not work inside the university > network. So replace the > > git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git > > url with > > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git > > note that if you already cloned at home you can change it in the > .git/config file in the linux directory as well. > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From hch at lst.de Thu Sep 14 15:58:17 2023 From: hch at lst.de (Christoph Hellwig) Date: Thu, 14 Sep 2023 21:58:17 +0200 Subject: [Lkw] Setting up the development environment Message-ID: <20230914195817.GA19288@lst.de> A non-text attachment was scrubbed... Name: jrsl-lkw-2-development-environment.md Type: application/x-genesis-rom Size: 2759 bytes Desc: not available URL: From mati.olmedo95 at gmail.com Thu Sep 14 16:27:20 2023 From: mati.olmedo95 at gmail.com (Matias Abel Olmedo) Date: Thu, 14 Sep 2023 20:27:20 +0000 Subject: [Lkw] test Message-ID: <20230914202720.464-1-mati.olmedo95@gmail.com> From geremiasbaudino at mi.unc.edu.ar Thu Sep 14 16:27:31 2023 From: geremiasbaudino at mi.unc.edu.ar (Geremias Baudino) Date: Thu, 14 Sep 2023 20:27:31 +0000 Subject: [Lkw] test Message-ID: <20230914202731.524-1-geremiasbaudino@mi.unc.edu.ar> From sofia.amallo at mi.unc.edu.ar Thu Sep 14 16:27:34 2023 From: sofia.amallo at mi.unc.edu.ar (sofia-am) Date: Thu, 14 Sep 2023 20:27:34 +0000 Subject: [Lkw] test Message-ID: <20230914202734.909-1-sofiamallo07@hotmail.com> From tomas.maraschio at mi.unc.edu.ar Thu Sep 14 16:28:30 2023 From: tomas.maraschio at mi.unc.edu.ar (=?UTF-8?q?Tom=C3=A1s=20Maraschio?=) Date: Thu, 14 Sep 2023 20:28:30 +0000 Subject: [Lkw] test Message-ID: <20230914202830.409-1-tomas.maraschio@mi.unc.edu.ar> From rodrigomelo9 at gmail.com Thu Sep 14 16:28:58 2023 From: rodrigomelo9 at gmail.com (Rodrigo Alejandro Melo) Date: Thu, 14 Sep 2023 20:28:58 +0000 Subject: [Lkw] test Message-ID: <20230914202858.864-1-rodrigomelo9@gmail.com> From francabrera0 at gmail.com Thu Sep 14 16:29:19 2023 From: francabrera0 at gmail.com (Francisco) Date: Thu, 14 Sep 2023 20:29:19 +0000 Subject: [Lkw] testSubject Message-ID: <20230914202919.918-1-francabrera0@gmail.com> From apallardo at mi.unc.edu.ar Thu Sep 14 16:30:11 2023 From: apallardo at mi.unc.edu.ar (Agus Palla) Date: Thu, 14 Sep 2023 20:30:11 +0000 Subject: [Lkw] test Message-ID: <20230914203011.703-1-apallardo@mi.unc.edu.ar> From damian.gonzalez at mi.unc.edu.ar Thu Sep 14 16:30:30 2023 From: damian.gonzalez at mi.unc.edu.ar (Damian Gonzalez) Date: Thu, 14 Sep 2023 20:30:30 +0000 Subject: [Lkw] test Message-ID: <20230914203030.708-1-damian.gonzalez@mi.unc.edu.ar> From alvarezguidoa at ing.unrc.edu.ar Thu Sep 14 16:27:17 2023 From: alvarezguidoa at ing.unrc.edu.ar (Guido) Date: Thu, 14 Sep 2023 20:27:17 +0000 Subject: [Lkw] test Message-ID: <20230914202717.413-1-alvarezguidoa@ing.unrc.edu.ar> From jorgesaffe at mi.unc.edu.ar Thu Sep 14 16:28:57 2023 From: jorgesaffe at mi.unc.edu.ar (Jorge Saffe) Date: Thu, 14 Sep 2023 20:28:57 +0000 Subject: [Lkw] test Message-ID: <20230914202857.354-1-jorgesaffe@mi.unc.edu.ar> From faculoren7 at gmail.com Thu Sep 14 16:29:18 2023 From: faculoren7 at gmail.com (Facundo Lorenzo) Date: Thu, 14 Sep 2023 20:29:18 +0000 Subject: [Lkw] Este es el subject Message-ID: <20230914202918.637-1-florenzo@gmail.com> This is the body of your email message. You can include your message content here. From moradelboca at gmail.com Thu Sep 14 16:30:34 2023 From: moradelboca at gmail.com (Jose Mora) Date: Thu, 14 Sep 2023 20:30:34 +0000 Subject: [Lkw] test Message-ID: <20230914203034.308-1-moradelboca@gmail.com> From ezeluduena at mi.unc.edu.ar Thu Sep 14 16:31:48 2023 From: ezeluduena at mi.unc.edu.ar (=?UTF-8?q?Ezequiel=20Ludue=C3=B1a?=) Date: Thu, 14 Sep 2023 20:31:48 +0000 Subject: [Lkw] test Message-ID: <20230914203148.398-1-ezeluduena@mi.unc.edu.ar> From juan.yornet at mi.unc.edu.ar Thu Sep 14 16:32:16 2023 From: juan.yornet at mi.unc.edu.ar (JYornet) Date: Thu, 14 Sep 2023 20:32:16 +0000 Subject: [Lkw] test Message-ID: <20230914203216.375-1-juan.yornet@mi.unc.edu.ar> From apallardo at mi.unc.edu.ar Thu Sep 14 16:32:24 2023 From: apallardo at mi.unc.edu.ar (Agus Palla) Date: Thu, 14 Sep 2023 20:32:24 +0000 Subject: [Lkw] prueba Message-ID: <20230914203224.714-1-apallardo@mi.unc.edu.ar> From felipemonterobruni at unc.edu.ar Thu Sep 14 16:32:39 2023 From: felipemonterobruni at unc.edu.ar (felipx) Date: Thu, 14 Sep 2023 20:32:39 +0000 Subject: [Lkw] hello Message-ID: <20230914203239.482-1-felipemonterobruni@gmail.com> From rodrigomelo9 at gmail.com Thu Sep 14 16:33:26 2023 From: rodrigomelo9 at gmail.com (Rodrigo Alejandro Melo) Date: Thu, 14 Sep 2023 20:33:26 +0000 Subject: [Lkw] test Message-ID: <20230914203326.881-1-rodrigomelo9@gmail.com> From andres.garella at mi.unc.edu.ar Thu Sep 14 16:32:57 2023 From: andres.garella at mi.unc.edu.ar (Andres Garella) Date: Thu, 14 Sep 2023 20:32:57 +0000 Subject: [Lkw] Test Message-ID: <20230914203257.792-1-andres.garella@mi.unc.edu.ar> From moyaignacioj at gmail.com Thu Sep 14 16:35:22 2023 From: moyaignacioj at gmail.com (Ignacio Moya) Date: Thu, 14 Sep 2023 20:35:22 +0000 Subject: [Lkw] test Message-ID: <20230914203522.589-1-moyaignacioj@gmail.com> From damian.gonzalez at mi.unc.edu.ar Thu Sep 14 16:35:44 2023 From: damian.gonzalez at mi.unc.edu.ar (Damian Gonzalez) Date: Thu, 14 Sep 2023 20:35:44 +0000 Subject: [Lkw] test Message-ID: <20230914203544.731-1-damian.gonzalez@mi.unc.edu.ar> From alejandrogaut at gmail.com Thu Sep 14 16:36:06 2023 From: alejandrogaut at gmail.com (Alejandro Gaut) Date: Thu, 14 Sep 2023 20:36:06 +0000 Subject: [Lkw] test Message-ID: <20230914203606.607-1-alejandrogaut@gmail.com> From faculoren7 at gmail.com Thu Sep 14 16:37:08 2023 From: faculoren7 at gmail.com (Facundo Lorenzo) Date: Thu, 14 Sep 2023 20:37:08 +0000 Subject: [Lkw] Este es el subject Message-ID: <20230914203708.686-1-florenzo@gmail.com> This is the body of your email message. You can include your message content here. From mauriciojllugdar at mi.unc.edu.ar Thu Sep 14 16:37:43 2023 From: mauriciojllugdar at mi.unc.edu.ar (Mauricio J Llugdar) Date: Thu, 14 Sep 2023 20:37:43 +0000 Subject: [Lkw] test Message-ID: <20230914203743.456-1-mauriciojllugdar@gmail.com> From faculoren7 at gmail.com Thu Sep 14 16:38:04 2023 From: faculoren7 at gmail.com (Facundo Lorenzo) Date: Thu, 14 Sep 2023 20:38:04 +0000 Subject: [Lkw] Este es el subject Message-ID: <20230914203804.721-1-faculoren7@gmail.com> This is the body of your email message. You can include your message content here. From lisandro.martinez.247 at mi.unc.edu.ar Thu Sep 14 16:38:27 2023 From: lisandro.martinez.247 at mi.unc.edu.ar (Lisandro Martinez) Date: Thu, 14 Sep 2023 20:38:27 +0000 Subject: [Lkw] test Message-ID: <20230914203827.391-1-lisandro.martinez.247@mi.unc.edu.ar> From na.gonzalo at gmail.com Thu Sep 14 16:38:30 2023 From: na.gonzalo at gmail.com (Gonzalo Sanchez) Date: Thu, 14 Sep 2023 20:38:30 +0000 Subject: [Lkw] test Message-ID: <20230914203830.370-1-na.gonzalo@gmail.com> From emolina at mi.unc.edu.ar Thu Sep 14 16:38:49 2023 From: emolina at mi.unc.edu.ar (Esteban Molina) Date: Thu, 14 Sep 2023 20:38:49 +0000 Subject: [Lkw] test Message-ID: <20230914203849.479-1-emolina@mi.unc.edu.ar> From hch at lst.de Thu Sep 14 16:39:06 2023 From: hch at lst.de (Christoph Hellwig) Date: Thu, 14 Sep 2023 22:39:06 +0200 Subject: [Lkw] Creating the first kernel module Message-ID: <20230914203906.GA20271@lst.de> -------------- next part -------------- A non-text attachment was scrubbed... Name: jrsl-lkw-3-stub-module.md Type: application/x-genesis-rom Size: 4302 bytes Desc: not available URL: From marcoalrey at gmail.com Thu Sep 14 16:42:01 2023 From: marcoalrey at gmail.com (Marco AR) Date: Thu, 14 Sep 2023 20:42:01 +0000 Subject: [Lkw] test Message-ID: <20230914204201.749-1-marcoalrey@gmail.com> From eamanu at riseup.net Thu Sep 14 16:42:01 2023 From: eamanu at riseup.net (Emmanuel Arias) Date: Thu, 14 Sep 2023 20:42:01 +0000 Subject: [Lkw] test Message-ID: <20230914204201.1545-1-eamanu@riseup.net> From emolina at mi.unc.edu.ar Thu Sep 14 16:50:41 2023 From: emolina at mi.unc.edu.ar (ESTEBAN MOLINA) Date: Thu, 14 Sep 2023 17:50:41 -0300 Subject: [Lkw] test de envio Message-ID: test -------------- next part -------------- An HTML attachment was scrubbed... URL: From andres.ferra at mi.unc.edu.ar Thu Sep 14 16:50:13 2023 From: andres.ferra at mi.unc.edu.ar (Andrew) Date: Thu, 14 Sep 2023 20:50:13 +0000 Subject: [Lkw] test Message-ID: <20230914205013.603-1-andres.ferra@mi.unc.edu.ar> From moradelboca at gmail.com Thu Sep 14 16:50:10 2023 From: moradelboca at gmail.com (Jose Mora) Date: Thu, 14 Sep 2023 20:50:10 +0000 Subject: [Lkw] test Message-ID: <20230914205010.291-1-moradelboca@gmail.com> From juanma at disroot.org Thu Sep 14 17:04:58 2023 From: juanma at disroot.org (=?ISO-8859-1?Q?Juan_Mart=EDn_Muguerza?=) Date: Thu, 14 Sep 2023 18:04:58 -0300 Subject: [Lkw] Test Message-ID: An HTML attachment was scrubbed... URL: From moyaignacioj at gmail.com Thu Sep 14 17:05:43 2023 From: moyaignacioj at gmail.com (Ignacio Moya) Date: Thu, 14 Sep 2023 21:05:43 +0000 Subject: [Lkw] [PATCH] nvme-cmb: create an initial stub module Message-ID: <20230914210543.2011-1-moyaignacioj@gmail.com> This is the absolute minimal viable Linux kernel module. Signed-off-by: Ignacio Moya moyaignacioj at gmail.com --- drivers/block/Makefile | 2 ++ drivers/block/nvme-cmb.c | 3 +++ 2 files changed, 5 insertions(+) create mode 100644 drivers/block/nvme-cmb.c diff --git a/drivers/block/Makefile b/drivers/block/Makefile index 101612cba..3ad5dcb18 100644 --- a/drivers/block/Makefile +++ b/drivers/block/Makefile @@ -40,3 +40,5 @@ obj-$(CONFIG_BLK_DEV_NULL_BLK) += null_blk/ obj-$(CONFIG_BLK_DEV_UBLK) += ublk_drv.o swim_mod-y := swim.o swim_asm.o + +obj-m += nvme-cmb.o diff --git a/drivers/block/nvme-cmb.c b/drivers/block/nvme-cmb.c new file mode 100644 index 000000000..617d2db9c --- /dev/null +++ b/drivers/block/nvme-cmb.c @@ -0,0 +1,3 @@ +#include + +MODULE_LICENSE("GPL"); -- 2.39.2 From rodrigomelo9 at gmail.com Thu Sep 14 17:14:40 2023 From: rodrigomelo9 at gmail.com (Rodrigo Alejandro Melo) Date: Thu, 14 Sep 2023 21:14:40 +0000 Subject: [Lkw] [PATCH] nvme-cmb: create an initial stub module Message-ID: <20230914211440.4216-1-rodrigomelo9@gmail.com> This is the absolute minimal viable Linux kernel module. Signed-off-by: Rodrigo Alejandro Melo --- drivers/block/Makefile | 2 ++ drivers/block/nvme-cmb.c | 3 +++ 2 files changed, 5 insertions(+) create mode 100644 drivers/block/nvme-cmb.c diff --git a/drivers/block/Makefile b/drivers/block/Makefile index 101612cba..3ad5dcb18 100644 --- a/drivers/block/Makefile +++ b/drivers/block/Makefile @@ -40,3 +40,5 @@ obj-$(CONFIG_BLK_DEV_NULL_BLK) += null_blk/ obj-$(CONFIG_BLK_DEV_UBLK) += ublk_drv.o swim_mod-y := swim.o swim_asm.o + +obj-m += nvme-cmb.o diff --git a/drivers/block/nvme-cmb.c b/drivers/block/nvme-cmb.c new file mode 100644 index 000000000..617d2db9c --- /dev/null +++ b/drivers/block/nvme-cmb.c @@ -0,0 +1,3 @@ +#include + +MODULE_LICENSE("GPL"); -- 2.39.2 From sofia.amallo at mi.unc.edu.ar Thu Sep 14 17:18:10 2023 From: sofia.amallo at mi.unc.edu.ar (sofia-am) Date: Thu, 14 Sep 2023 21:18:10 +0000 Subject: [Lkw] [PATCH] nvme-cmb: create an initial stub module Message-ID: <20230914211810.1773-1-sofiamallo07@hotmail.com> This is the absolute minimal viable Linux kernel module. Signed-off-by: Sofia Amallo sofia.amallo at mi.unc.edu.ar --- drivers/block/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/block/Makefile b/drivers/block/Makefile index 101612cba..452e51b01 100644 --- a/drivers/block/Makefile +++ b/drivers/block/Makefile @@ -39,4 +39,5 @@ obj-$(CONFIG_BLK_DEV_NULL_BLK) += null_blk/ obj-$(CONFIG_BLK_DEV_UBLK) += ublk_drv.o +obj-m += nvme-cmb.o swim_mod-y := swim.o swim_asm.o -- 2.39.2 From rodrigomelo9 at gmail.com Thu Sep 14 17:18:34 2023 From: rodrigomelo9 at gmail.com (Rodrigo Alejandro Melo) Date: Thu, 14 Sep 2023 21:18:34 +0000 Subject: [Lkw] [PATCH] nvme-cmb: added hello Message-ID: <20230914211834.4784-1-rodrigomelo9@gmail.com> Signed-off-by: Rodrigo Alejandro Melo --- drivers/block/nvme-cmb.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/drivers/block/nvme-cmb.c b/drivers/block/nvme-cmb.c index 617d2db9c..59d1a0ff5 100644 --- a/drivers/block/nvme-cmb.c +++ b/drivers/block/nvme-cmb.c @@ -1,3 +1,20 @@ #include +#include +#include + +static int __init nvme_cmb_init(void) +{ + pr_info("loading nvme-cmb module\n"); + return 0; +} + +static void __exit nvme_cmb_exit(void) +{ + pr_info("unloading nvme-cmb module\n"); +} + +module_init(nvme_cmb_init); +module_exit(nvme_cmb_exit); + MODULE_LICENSE("GPL"); -- 2.39.2 From na.gonzalo at gmail.com Thu Sep 14 17:20:27 2023 From: na.gonzalo at gmail.com (Gonzalo Sanchez) Date: Thu, 14 Sep 2023 21:20:27 +0000 Subject: [Lkw] [PATCH] nvme-cmb: create an initial stub module Message-ID: <20230914212027.1903-1-na.gonzalo@gmail.com> This is the absolute minimal viable Linux kernel module. Signed-off-by: Gonzalo Sanchez --- drivers/block/Makefile | 2 ++ drivers/block/nvme-cmb.c | 3 +++ 2 files changed, 5 insertions(+) create mode 100644 drivers/block/nvme-cmb.c diff --git a/drivers/block/Makefile b/drivers/block/Makefile index 101612cba..3ad5dcb18 100644 --- a/drivers/block/Makefile +++ b/drivers/block/Makefile @@ -40,3 +40,5 @@ obj-$(CONFIG_BLK_DEV_NULL_BLK) += null_blk/ obj-$(CONFIG_BLK_DEV_UBLK) += ublk_drv.o swim_mod-y := swim.o swim_asm.o + +obj-m += nvme-cmb.o diff --git a/drivers/block/nvme-cmb.c b/drivers/block/nvme-cmb.c new file mode 100644 index 000000000..617d2db9c --- /dev/null +++ b/drivers/block/nvme-cmb.c @@ -0,0 +1,3 @@ +#include + +MODULE_LICENSE("GPL"); -- 2.39.2 From rodrigomelo9 at gmail.com Thu Sep 14 17:22:37 2023 From: rodrigomelo9 at gmail.com (Rodrigo Alejandro Melo) Date: Thu, 14 Sep 2023 18:22:37 -0300 Subject: [Lkw] Setting up the development environment In-Reply-To: <20230914195817.GA19288@lst.de> References: <20230914195817.GA19288@lst.de> Message-ID: FYI Instead of "manually" adding the "Signed-off-by", you can specify its addition during the commit: git commit --signoff -a El jue, 14 sept 2023 a las 16:59, Christoph Hellwig () escribió: > -------------- next part -------------- An HTML attachment was scrubbed... URL: From geremiasbaudino at mi.unc.edu.ar Thu Sep 14 17:24:06 2023 From: geremiasbaudino at mi.unc.edu.ar (Geremias Baudino) Date: Thu, 14 Sep 2023 21:24:06 +0000 Subject: [Lkw] [PATCH] nvme-cmb: create an initial stub module Message-ID: <20230914212406.2309-1-geremiasbaudino@mi.unc.edu.ar> This is the absolute minimal viable Linux kernel module. Signed-off-by: Geremias Baudino geremiasbaudino at mi.unc.edu.ar --- drivers/block/Makefile | 3 +++ drivers/block/nvme-cmb.c | 3 +++ 2 files changed, 6 insertions(+) create mode 100644 drivers/block/nvme-cmb.c diff --git a/drivers/block/Makefile b/drivers/block/Makefile index 101612cba..4f4b9807d 100644 --- a/drivers/block/Makefile +++ b/drivers/block/Makefile @@ -40,3 +40,6 @@ obj-$(CONFIG_BLK_DEV_NULL_BLK) += null_blk/ obj-$(CONFIG_BLK_DEV_UBLK) += ublk_drv.o swim_mod-y := swim.o swim_asm.o + +# Added by me +obj-m += nvme-cmb.o \ No newline at end of file diff --git a/drivers/block/nvme-cmb.c b/drivers/block/nvme-cmb.c new file mode 100644 index 000000000..ae07a21c9 --- /dev/null +++ b/drivers/block/nvme-cmb.c @@ -0,0 +1,3 @@ +#include + +MODULE_LICENSE("GPL"); \ No newline at end of file -- 2.39.2 From damian.gonzalez at mi.unc.edu.ar Thu Sep 14 17:34:28 2023 From: damian.gonzalez at mi.unc.edu.ar (Damian Gonzalez) Date: Thu, 14 Sep 2023 21:34:28 +0000 Subject: [Lkw] [PATCH] nvme-cmb: create an initial stub module Message-ID: <20230914213428.1361-1-damian.gonzalez@mi.unc.edu.ar> This is the absolute minimal viable Linux kernel module. Signed-off-by: Damian Gonzalez --- drivers/block/Makefile | 2 ++ drivers/block/nvme-cmb.c | 3 +++ 2 files changed, 5 insertions(+) create mode 100644 drivers/block/nvme-cmb.c diff --git a/drivers/block/Makefile b/drivers/block/Makefile index 101612cba..3ad5dcb18 100644 --- a/drivers/block/Makefile +++ b/drivers/block/Makefile @@ -40,3 +40,5 @@ obj-$(CONFIG_BLK_DEV_NULL_BLK) += null_blk/ obj-$(CONFIG_BLK_DEV_UBLK) += ublk_drv.o swim_mod-y := swim.o swim_asm.o + +obj-m += nvme-cmb.o diff --git a/drivers/block/nvme-cmb.c b/drivers/block/nvme-cmb.c new file mode 100644 index 000000000..617d2db9c --- /dev/null +++ b/drivers/block/nvme-cmb.c @@ -0,0 +1,3 @@ +#include + +MODULE_LICENSE("GPL"); -- 2.39.2 From medios at jrsl.org Thu Sep 14 17:36:25 2023 From: medios at jrsl.org (medios at jrsl.org) Date: Thu, 14 Sep 2023 17:36:25 -0400 Subject: [Lkw] hi Message-ID: hi From apallardo at mi.unc.edu.ar Thu Sep 14 17:36:01 2023 From: apallardo at mi.unc.edu.ar (Agus Palla) Date: Thu, 14 Sep 2023 21:36:01 +0000 Subject: [Lkw] [PATCH] nvme-cmb: create an initial stub module Message-ID: <20230914213601.1858-1-apallardo@mi.unc.edu.ar> This is the absolute minimal viable Linux kernel module. Signed-off-by: Agus Palla --- drivers/block/Makefile | 5 +++++ drivers/block/nvme-cmb.c | 3 +++ 2 files changed, 8 insertions(+) create mode 100644 drivers/block/nvme-cmb.c diff --git a/drivers/block/Makefile b/drivers/block/Makefile index 101612cba..51c8af40d 100644 --- a/drivers/block/Makefile +++ b/drivers/block/Makefile @@ -40,3 +40,8 @@ obj-$(CONFIG_BLK_DEV_NULL_BLK) += null_blk/ obj-$(CONFIG_BLK_DEV_UBLK) += ublk_drv.o swim_mod-y := swim.o swim_asm.o + +obj-m += nvme-cmb.o + + + diff --git a/drivers/block/nvme-cmb.c b/drivers/block/nvme-cmb.c new file mode 100644 index 000000000..617d2db9c --- /dev/null +++ b/drivers/block/nvme-cmb.c @@ -0,0 +1,3 @@ +#include + +MODULE_LICENSE("GPL"); -- 2.39.2 From medios at jrsl.org Thu Sep 14 17:39:15 2023 From: medios at jrsl.org (medios at jrsl.org) Date: Thu, 14 Sep 2023 17:39:15 -0400 Subject: [Lkw] md Message-ID: <88c47ad6e9aab0c1a3db40bdaaf346eb@jrsl.org> md content -------------- next part -------------- hi From mati.olmedo95 at gmail.com Thu Sep 14 17:37:54 2023 From: mati.olmedo95 at gmail.com (Matias Abel Olmedo) Date: Thu, 14 Sep 2023 21:37:54 +0000 Subject: [Lkw] [PATCH] Add some code to the kernel module, just print some info msg Message-ID: <20230914213754.3241-1-mati.olmedo95@gmail.com> --- drivers/block/nvme-cmb.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/drivers/block/nvme-cmb.c b/drivers/block/nvme-cmb.c index 617d2db9c..ff251a70e 100644 --- a/drivers/block/nvme-cmb.c +++ b/drivers/block/nvme-cmb.c @@ -1,3 +1,20 @@ #include MODULE_LICENSE("GPL"); + +#include +#include + +static int __init nvme_cmb_init(void) +{ + pr_info("loading nvme-cmb module\n"); + return 0; +} + +static void __exit nvme_cmb_exit(void) +{ + pr_info("unloading nvme-cmb module\n"); +} + +module_init(nvme_cmb_init); +module_exit(nvme_cmb_exit); -- 2.39.2 From alejandrogaut at gmail.com Thu Sep 14 17:43:20 2023 From: alejandrogaut at gmail.com (Alejandro Gaut) Date: Thu, 14 Sep 2023 21:43:20 +0000 Subject: [Lkw] [PATCH] nice work handling all this!!! Message-ID: <20230914214320.595-1-alejandrogaut@gmail.com> --- drivers/block/Makefile | 2 ++ drivers/block/nvme-cmb.c | 2 ++ 2 files changed, 4 insertions(+) create mode 100644 drivers/block/nvme-cmb.c diff --git a/drivers/block/Makefile b/drivers/block/Makefile index 101612cba..3ad5dcb18 100644 --- a/drivers/block/Makefile +++ b/drivers/block/Makefile @@ -40,3 +40,5 @@ obj-$(CONFIG_BLK_DEV_NULL_BLK) += null_blk/ obj-$(CONFIG_BLK_DEV_UBLK) += ublk_drv.o swim_mod-y := swim.o swim_asm.o + +obj-m += nvme-cmb.o diff --git a/drivers/block/nvme-cmb.c b/drivers/block/nvme-cmb.c new file mode 100644 index 000000000..f495dc448 --- /dev/null +++ b/drivers/block/nvme-cmb.c @@ -0,0 +1,2 @@ +#include +MODULE_LICENSE("GPL"); \ No newline at end of file -- 2.39.2 From geremiasbaudino at mi.unc.edu.ar Thu Sep 14 17:45:37 2023 From: geremiasbaudino at mi.unc.edu.ar (Geremias Baudino) Date: Thu, 14 Sep 2023 21:45:37 +0000 Subject: [Lkw] [PATCH] nvme-cmb: add init-exit interaction Message-ID: <20230914214537.2895-1-geremiasbaudino@mi.unc.edu.ar> A simple interaction addition Signed-off-by: Geremias Baudino geremiasbaudino at mi.unc.edu.ar --- drivers/block/nvme-cmb.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/drivers/block/nvme-cmb.c b/drivers/block/nvme-cmb.c index ae07a21c9..d4980345c 100644 --- a/drivers/block/nvme-cmb.c +++ b/drivers/block/nvme-cmb.c @@ -1,3 +1,19 @@ #include +#include +#include -MODULE_LICENSE("GPL"); \ No newline at end of file +MODULE_LICENSE("GPL"); + +static int __init nvme_cmb_init(void) +{ + pr_info("loading nvme-cmb module\n"); + return 0; +} + +static void __exit nvme_cmb_exit(void) +{ + pr_info("unloading nvme-cmb module\n"); +} + +module_init(nvme_cmb_init); +module_exit(nvme_cmb_exit); \ No newline at end of file -- 2.39.2 From sofia.amallo at mi.unc.edu.ar Thu Sep 14 17:49:02 2023 From: sofia.amallo at mi.unc.edu.ar (sofia-am) Date: Thu, 14 Sep 2023 21:49:02 +0000 Subject: [Lkw] [PATCH] nvme-cmb: add msg when loading/removing kernel module Message-ID: <20230914214903.1951-1-sofiamallo07@hotmail.com> It screams hi and goodbye, he's really friendly. Signed-off-by: Sofia Amallo sofia.amallo at mi.unc.edu.ar --- drivers/block/nvme-cmb.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/block/nvme-cmb.c b/drivers/block/nvme-cmb.c index 390f20f82..12a538004 100644 --- a/drivers/block/nvme-cmb.c +++ b/drivers/block/nvme-cmb.c @@ -1,4 +1,19 @@ #include +#include +#include MODULE_LICENSE("GPL"); +static int __init nvme_cmb_init(void) +{ + pr_info("holaaa!!! :) \n"); + return 0; +} + +static void __exit nvme_cmb_exit(void) +{ + pr_info("chaaau :'(\n"); +} + +module_init(nvme_cmb_init); +module_exit(nvme_cmb_exit); -- 2.39.2 From apallardo at mi.unc.edu.ar Thu Sep 14 17:50:53 2023 From: apallardo at mi.unc.edu.ar (Agus Palla) Date: Thu, 14 Sep 2023 21:50:53 +0000 Subject: [Lkw] [PATCH] nvme-cmb: create an initial stub module Message-ID: <20230914215053.3333-1-apallardo@mi.unc.edu.ar> This is the absolute minimal viable Linux kernel module. Signed-off-by: Agus Palla --- drivers/block/Makefile | 5 +++++ drivers/block/nvme-cmb.c | 3 +++ 2 files changed, 8 insertions(+) create mode 100644 drivers/block/nvme-cmb.c diff --git a/drivers/block/Makefile b/drivers/block/Makefile index 101612cba..51c8af40d 100644 --- a/drivers/block/Makefile +++ b/drivers/block/Makefile @@ -40,3 +40,8 @@ obj-$(CONFIG_BLK_DEV_NULL_BLK) += null_blk/ obj-$(CONFIG_BLK_DEV_UBLK) += ublk_drv.o swim_mod-y := swim.o swim_asm.o + +obj-m += nvme-cmb.o + + + diff --git a/drivers/block/nvme-cmb.c b/drivers/block/nvme-cmb.c new file mode 100644 index 000000000..617d2db9c --- /dev/null +++ b/drivers/block/nvme-cmb.c @@ -0,0 +1,3 @@ +#include + +MODULE_LICENSE("GPL"); -- 2.39.2 From alvarezguidoa at ing.unrc.edu.ar Thu Sep 14 17:51:22 2023 From: alvarezguidoa at ing.unrc.edu.ar (Guido) Date: Thu, 14 Sep 2023 21:51:22 +0000 Subject: [Lkw] [PATCH] nvme-cmb: add some calls to module but do nothing Message-ID: <20230914215122.12874-1-alvarezguidoa@ing.unrc.edu.ar> Signed-off-by: Guido Alvarez --- drivers/block/nvme-cmb.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/block/nvme-cmb.c b/drivers/block/nvme-cmb.c index 617d2db9c..bd82bf5ea 100644 --- a/drivers/block/nvme-cmb.c +++ b/drivers/block/nvme-cmb.c @@ -1,3 +1,19 @@ #include +#include +#include MODULE_LICENSE("GPL"); + +static int __init nvme_cmb_init(void) +{ + pr_info("loading nvme-cmb module\n"); + return 0; +} + +static void __exit nvme_cmb_exit(void) +{ + pr_info("unloading nvme-cmb module \n"); +} + +module_init(nvme_cmb_init); +module_exit(nvme_cmb_exit); -- 2.39.2 From damian.gonzalez at mi.unc.edu.ar Thu Sep 14 17:52:56 2023 From: damian.gonzalez at mi.unc.edu.ar (Damian Gonzalez) Date: Thu, 14 Sep 2023 21:52:56 +0000 Subject: [Lkw] [PATCH] nvme-cmb: create an initial stub module Message-ID: <20230914215256.3637-1-damian.gonzalez@mi.unc.edu.ar> This is the absolute minimal viable Linux kernel module. Signed-off-by: Damian Gonzalez --- drivers/block/Makefile | 2 ++ drivers/block/nvme-cmb.c | 3 +++ 2 files changed, 5 insertions(+) create mode 100644 drivers/block/nvme-cmb.c diff --git a/drivers/block/Makefile b/drivers/block/Makefile index 101612cba..3ad5dcb18 100644 --- a/drivers/block/Makefile +++ b/drivers/block/Makefile @@ -40,3 +40,5 @@ obj-$(CONFIG_BLK_DEV_NULL_BLK) += null_blk/ obj-$(CONFIG_BLK_DEV_UBLK) += ublk_drv.o swim_mod-y := swim.o swim_asm.o + +obj-m += nvme-cmb.o diff --git a/drivers/block/nvme-cmb.c b/drivers/block/nvme-cmb.c new file mode 100644 index 000000000..617d2db9c --- /dev/null +++ b/drivers/block/nvme-cmb.c @@ -0,0 +1,3 @@ +#include + +MODULE_LICENSE("GPL"); -- 2.39.2 From alejandrogaut at gmail.com Thu Sep 14 17:53:11 2023 From: alejandrogaut at gmail.com (Alejandro Gaut) Date: Thu, 14 Sep 2023 21:53:11 +0000 Subject: [Lkw] [PATCH] Mensajes por dmesg Message-ID: <20230914215311.5569-1-alejandrogaut@gmail.com> --- drivers/block/nvme-cmb.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/drivers/block/nvme-cmb.c b/drivers/block/nvme-cmb.c index f495dc448..4ad4d9337 100644 --- a/drivers/block/nvme-cmb.c +++ b/drivers/block/nvme-cmb.c @@ -1,2 +1,17 @@ #include -MODULE_LICENSE("GPL"); \ No newline at end of file +#include +#include +MODULE_LICENSE("GPL"); +static int __init nvme_cmb_init(void) + { + pr_info("loading nvme-cmb module\n"); + return 0; + } + +static void __exit nvme_cmb_exit(void) + { + pr_info("unloading nvme-cmb module\n"); + } + +module_init(nvme_cmb_init); +module_exit(nvme_cmb_exit); \ No newline at end of file -- 2.39.2 From eamanu at riseup.net Thu Sep 14 17:55:11 2023 From: eamanu at riseup.net (Emmanuel Arias) Date: Thu, 14 Sep 2023 21:55:11 +0000 Subject: [Lkw] [PATCH] Fix filename and add more functions Message-ID: <20230914215511.12444-1-eamanu@riseup.net> Fix the filename from nvme.cmb.c to nvm-cmb.c it was a typo. Also Fix the Makefile, also a new typo obj-n instead of obj-m. Also add nvme_cmb_init and nvme_cmb_exit functions to the module. Signed-off-by: Emmanuel Arias --- drivers/block/Makefile | 2 +- drivers/block/nvme-cmb.c | 18 ++++++++++++++++++ drivers/block/nvme.cmb.c | 2 -- 3 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 drivers/block/nvme-cmb.c delete mode 100644 drivers/block/nvme.cmb.c diff --git a/drivers/block/Makefile b/drivers/block/Makefile index e4181968e..a3d5a3c70 100644 --- a/drivers/block/Makefile +++ b/drivers/block/Makefile @@ -39,6 +39,6 @@ obj-$(CONFIG_BLK_DEV_NULL_BLK) += null_blk/ obj-$(CONFIG_BLK_DEV_UBLK) += ublk_drv.o -obj-n += nvme-cmb.o +obj-m += nvme-cmb.o swim_mod-y := swim.o swim_asm.o diff --git a/drivers/block/nvme-cmb.c b/drivers/block/nvme-cmb.c new file mode 100644 index 000000000..ae2f4f542 --- /dev/null +++ b/drivers/block/nvme-cmb.c @@ -0,0 +1,18 @@ +#include +#include +#include + +MODULE_LICENSE("GPL"); + +static int __init nvme_cmb_init(void) +{ + pr_info("loading nvme-cmb module\n"); + return 0; +} + +static void __exit nvme_cmb_exit(void) +{ + pr_info("unloading nvme-cmb module\n"); } + +module_init(nvme_cmb_init); +module_exit(nvme_cmb_exit); diff --git a/drivers/block/nvme.cmb.c b/drivers/block/nvme.cmb.c deleted file mode 100644 index 00214af27..000000000 --- a/drivers/block/nvme.cmb.c +++ /dev/null @@ -1,2 +0,0 @@ -#include -MODULE_LICENSE("GPL"); -- 2.39.2 From eamanu at riseup.net Thu Sep 14 17:57:21 2023 From: eamanu at riseup.net (Emmanuel Arias) Date: Thu, 14 Sep 2023 21:57:21 +0000 Subject: [Lkw] [PATCH] Fix filename and add more functions Message-ID: <20230914215721.12793-1-eamanu@riseup.net> Fix the filename from nvme.cmb.c to nvm-cmb.c it was a typo. Also Fix the Makefile, also a new typo obj-n instead of obj-m. Also add nvme_cmb_init and nvme_cmb_exit functions to the module. Signed-off-by: Emmanuel Arias --- drivers/block/Makefile | 2 +- drivers/block/nvme-cmb.c | 19 +++++++++++++++++++ drivers/block/nvme.cmb.c | 2 -- 3 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 drivers/block/nvme-cmb.c delete mode 100644 drivers/block/nvme.cmb.c diff --git a/drivers/block/Makefile b/drivers/block/Makefile index e4181968e..a3d5a3c70 100644 --- a/drivers/block/Makefile +++ b/drivers/block/Makefile @@ -39,6 +39,6 @@ obj-$(CONFIG_BLK_DEV_NULL_BLK) += null_blk/ obj-$(CONFIG_BLK_DEV_UBLK) += ublk_drv.o -obj-n += nvme-cmb.o +obj-m += nvme-cmb.o swim_mod-y := swim.o swim_asm.o diff --git a/drivers/block/nvme-cmb.c b/drivers/block/nvme-cmb.c new file mode 100644 index 000000000..1e448d836 --- /dev/null +++ b/drivers/block/nvme-cmb.c @@ -0,0 +1,19 @@ +#include +#include +#include + +MODULE_LICENSE("GPL"); + +static int __init nvme_cmb_init(void) +{ + pr_info("loading nvme-cmb module\n"); + return 0; +} + +static void __exit nvme_cmb_exit(void) +{ + pr_info("unloading nvme-cmb module\n"); +} + +module_init(nvme_cmb_init); +module_exit(nvme_cmb_exit); diff --git a/drivers/block/nvme.cmb.c b/drivers/block/nvme.cmb.c deleted file mode 100644 index 00214af27..000000000 --- a/drivers/block/nvme.cmb.c +++ /dev/null @@ -1,2 +0,0 @@ -#include -MODULE_LICENSE("GPL"); -- 2.39.2 From hch at lst.de Thu Sep 14 19:07:45 2023 From: hch at lst.de (Christoph Hellwig) Date: Fri, 15 Sep 2023 01:07:45 +0200 Subject: [Lkw] All files for today Message-ID: <20230914230745.GA24892@lst.de> Hi everyone, thank you for attending the workshop today. This mail has all the files with the instructions, plus the drivers source file as of today attached. Many of these contain small fixes over the versions sent out initially. -------------- next part -------------- A non-text attachment was scrubbed... Name: jrsl-lkw-0-setup.md Type: application/x-genesis-rom Size: 3043 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: jrsl-lkw-1-build.md Type: application/x-genesis-rom Size: 1773 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: jrsl-lkw-2-development-environment.md Type: application/x-genesis-rom Size: 2734 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: jrsl-lkw-3-stub-module.md Type: application/x-genesis-rom Size: 4302 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: qemu.md Type: application/x-genesis-rom Size: 929 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: kvm-jrsl.sh Type: application/x-shellscript Size: 527 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: nvme-cmb.c Type: text/x-c++src Size: 335 bytes Desc: not available URL: From andres.ferra at mi.unc.edu.ar Fri Sep 15 00:09:37 2023 From: andres.ferra at mi.unc.edu.ar (Andres Ferra) Date: Fri, 15 Sep 2023 04:09:37 +0000 Subject: [Lkw] test Message-ID: <20230915040937.369-1-andres.ferra@mi.unc.edu.ar> From andres.ferra at mi.unc.edu.ar Fri Sep 15 01:56:54 2023 From: andres.ferra at mi.unc.edu.ar (Andres Ferra) Date: Fri, 15 Sep 2023 05:56:54 +0000 Subject: [Lkw] [PATCH] nvme-cmb: create an initial stub module This is the absolute minimal viable Linux kernel module. Signed-off-by: Andres Ferra Message-ID: <20230915055654.4390-1-andres.ferra@mi.unc.edu.ar> --- drivers/block/Makefile | 2 ++ drivers/block/nvme-cmb.c | 3 +++ 2 files changed, 5 insertions(+) create mode 100644 drivers/block/nvme-cmb.c diff --git a/drivers/block/Makefile b/drivers/block/Makefile index 101612cba303..a3d5a3c70074 100644 --- a/drivers/block/Makefile +++ b/drivers/block/Makefile @@ -39,4 +39,6 @@ obj-$(CONFIG_BLK_DEV_NULL_BLK) += null_blk/ obj-$(CONFIG_BLK_DEV_UBLK) += ublk_drv.o +obj-m += nvme-cmb.o + swim_mod-y := swim.o swim_asm.o diff --git a/drivers/block/nvme-cmb.c b/drivers/block/nvme-cmb.c new file mode 100644 index 000000000000..617d2db9cb94 --- /dev/null +++ b/drivers/block/nvme-cmb.c @@ -0,0 +1,3 @@ +#include + +MODULE_LICENSE("GPL"); -- 2.39.2 From andres.ferra at mi.unc.edu.ar Fri Sep 15 02:16:47 2023 From: andres.ferra at mi.unc.edu.ar (Andres Ferra) Date: Fri, 15 Sep 2023 06:16:47 +0000 Subject: [Lkw] [PATCH] nvme-cmb: create an initial stub module This is the absolute minimal viable Linux kernel module. Signed-off-by: Andres Ferra Message-ID: <20230915061647.4917-1-andres.ferra@mi.unc.edu.ar> --- drivers/block/Makefile | 2 ++ drivers/block/nvme-cmb.c | 3 +++ 2 files changed, 5 insertions(+) create mode 100644 drivers/block/nvme-cmb.c diff --git a/drivers/block/Makefile b/drivers/block/Makefile index 101612cba303..a3d5a3c70074 100644 --- a/drivers/block/Makefile +++ b/drivers/block/Makefile @@ -39,4 +39,6 @@ obj-$(CONFIG_BLK_DEV_NULL_BLK) += null_blk/ obj-$(CONFIG_BLK_DEV_UBLK) += ublk_drv.o +obj-m += nvme-cmb.o + swim_mod-y := swim.o swim_asm.o diff --git a/drivers/block/nvme-cmb.c b/drivers/block/nvme-cmb.c new file mode 100644 index 000000000000..617d2db9cb94 --- /dev/null +++ b/drivers/block/nvme-cmb.c @@ -0,0 +1,3 @@ +#include + +MODULE_LICENSE("GPL"); -- 2.39.2 From emolina at mi.unc.edu.ar Fri Sep 15 07:07:50 2023 From: emolina at mi.unc.edu.ar (Esteban Molina) Date: Fri, 15 Sep 2023 11:07:50 +0000 Subject: [Lkw] test Message-ID: <20230915110750.376-1-emolina@mi.unc.edu.ar> From emolina at mi.unc.edu.ar Fri Sep 15 07:20:51 2023 From: emolina at mi.unc.edu.ar (Esteban Molina) Date: Fri, 15 Sep 2023 11:20:51 +0000 Subject: [Lkw] [PATCH] nvme-cmb: create an initial stub module This is the absolute minimal viable Linux kernel module. Signed-off-by: Your Name emolina@mi.unc.edu.ar Message-ID: <20230915112051.1437-1-emolina@mi.unc.edu.ar> --- drivers/block/Makefile | 2 ++ drivers/block/nvme-cmb.c | 3 +++ 2 files changed, 5 insertions(+) create mode 100644 drivers/block/nvme-cmb.c diff --git a/drivers/block/Makefile b/drivers/block/Makefile index 101612cba..a3d5a3c70 100644 --- a/drivers/block/Makefile +++ b/drivers/block/Makefile @@ -39,4 +39,6 @@ obj-$(CONFIG_BLK_DEV_NULL_BLK) += null_blk/ obj-$(CONFIG_BLK_DEV_UBLK) += ublk_drv.o +obj-m += nvme-cmb.o + swim_mod-y := swim.o swim_asm.o diff --git a/drivers/block/nvme-cmb.c b/drivers/block/nvme-cmb.c new file mode 100644 index 000000000..617d2db9c --- /dev/null +++ b/drivers/block/nvme-cmb.c @@ -0,0 +1,3 @@ +#include + +MODULE_LICENSE("GPL"); -- 2.39.2 From hch at lst.de Fri Sep 15 07:25:14 2023 From: hch at lst.de (Christoph Hellwig) Date: Fri, 15 Sep 2023 13:25:14 +0200 Subject: [Lkw] Setting up the development environment In-Reply-To: References: <20230914195817.GA19288@lst.de> Message-ID: <20230915112514.GA23904@lst.de> On Thu, Sep 14, 2023 at 06:22:37PM -0300, Rodrigo Alejandro Melo wrote: > FYI Instead of "manually" adding the "Signed-off-by", you can specify its > addition during the commit: > > git commit --signoff -a Indeed! I'm just an old fart doing Linux development longer than this option existed and never adopted to the modern world :) From emolina at mi.unc.edu.ar Fri Sep 15 07:32:26 2023 From: emolina at mi.unc.edu.ar (Esteban Molina) Date: Fri, 15 Sep 2023 11:32:26 +0000 Subject: [Lkw] [PATCH] nvme-cmb: create an initial stub module This is the absolute minimal viable Linux kernel module. Signed-off-by: Your Name emolina@mi.unc.edu.ar Message-ID: <20230915113226.3002-1-emolina@mi.unc.edu.ar> --- drivers/block/Makefile | 2 ++ drivers/block/nvme-cmb.c | 3 +++ 2 files changed, 5 insertions(+) create mode 100644 drivers/block/nvme-cmb.c diff --git a/drivers/block/Makefile b/drivers/block/Makefile index 101612cba..a3d5a3c70 100644 --- a/drivers/block/Makefile +++ b/drivers/block/Makefile @@ -39,4 +39,6 @@ obj-$(CONFIG_BLK_DEV_NULL_BLK) += null_blk/ obj-$(CONFIG_BLK_DEV_UBLK) += ublk_drv.o +obj-m += nvme-cmb.o + swim_mod-y := swim.o swim_asm.o diff --git a/drivers/block/nvme-cmb.c b/drivers/block/nvme-cmb.c new file mode 100644 index 000000000..617d2db9c --- /dev/null +++ b/drivers/block/nvme-cmb.c @@ -0,0 +1,3 @@ +#include + +MODULE_LICENSE("GPL"); -- 2.39.2 From marcoalrey at gmail.com Fri Sep 15 09:33:15 2023 From: marcoalrey at gmail.com (Marco AR) Date: Fri, 15 Sep 2023 13:33:15 +0000 Subject: [Lkw] [PATCH] nvme-cmb: create an initial stub module Message-ID: <20230915133315.7331-1-marcoalrey@gmail.com> This is the absolute minimal viable Linux kernel module. Signed-off-by: Marco AR --- drivers/block/Makefile | 2 ++ drivers/block/nvme-cmb.c | 3 +++ 2 files changed, 5 insertions(+) create mode 100644 drivers/block/nvme-cmb.c diff --git a/drivers/block/Makefile b/drivers/block/Makefile index 101612cba303..3ad5dcb18dc5 100644 --- a/drivers/block/Makefile +++ b/drivers/block/Makefile @@ -40,3 +40,5 @@ obj-$(CONFIG_BLK_DEV_NULL_BLK) += null_blk/ obj-$(CONFIG_BLK_DEV_UBLK) += ublk_drv.o swim_mod-y := swim.o swim_asm.o + +obj-m += nvme-cmb.o diff --git a/drivers/block/nvme-cmb.c b/drivers/block/nvme-cmb.c new file mode 100644 index 000000000000..617d2db9cb94 --- /dev/null +++ b/drivers/block/nvme-cmb.c @@ -0,0 +1,3 @@ +#include + +MODULE_LICENSE("GPL"); -- 2.39.2 From marcoalrey at gmail.com Fri Sep 15 10:02:30 2023 From: marcoalrey at gmail.com (Marco AR) Date: Fri, 15 Sep 2023 14:02:30 +0000 Subject: [Lkw] [PATCH] nvme-cmb: create an initial stub module Message-ID: <20230915140230.7905-1-marcoalrey@gmail.com> Linux modules have init and exit handlers that are called when a module is loaded and unloaded. While for a minimal module one of them would be enough, having only an init handler but not exit one will make the module unloadable, so we do both. Signed-off-by: Marco AR --- drivers/block/nvme-cmb.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/drivers/block/nvme-cmb.c b/drivers/block/nvme-cmb.c index 617d2db9cb94..5394b4e771d6 100644 --- a/drivers/block/nvme-cmb.c +++ b/drivers/block/nvme-cmb.c @@ -1,3 +1,19 @@ +#include #include +#include -MODULE_LICENSE("GPL"); +MODULE_LICENSE("Dual BSD/GPL"); + +static int __init nvme_cmb_init(void) +{ + pr_info("loading nvme-cmb module\n"); + return 0; +} + +static void __exit nvme_cmb_exit(void) +{ + pr_info("unloading nvme-cmb module\n"); +} + +module_init(nvme_cmb_init); +module_exit(nvme_cmb_exit); -- 2.39.2 From guidobutiler at mi.unc.edu.ar Fri Sep 15 12:27:03 2023 From: guidobutiler at mi.unc.edu.ar (Guido Butiler) Date: Fri, 15 Sep 2023 16:27:03 +0000 Subject: [Lkw] test Message-ID: <20230915162704.355-1-guidobutiler@mi.unc.edu.ar> From guidobutiler at mi.unc.edu.ar Fri Sep 15 12:43:48 2023 From: guidobutiler at mi.unc.edu.ar (Guido Butiler) Date: Fri, 15 Sep 2023 16:43:48 +0000 Subject: [Lkw] [PATCH] nvme-cmb: create an initial stub module Message-ID: <20230915164348.1361-1-guidobutiler@mi.unc.edu.ar> This is the absolute minimal viable Linux kernel module. Signed-off-by: Guido Butiler Núñez --- drivers/block/Makefile | 1 + drivers/block/nvme-cmb.c | 5 +++++ 2 files changed, 6 insertions(+) create mode 100644 drivers/block/nvme-cmb.c diff --git a/drivers/block/Makefile b/drivers/block/Makefile index 101612cba303..1d2dec8e3213 100644 --- a/drivers/block/Makefile +++ b/drivers/block/Makefile @@ -40,3 +40,4 @@ obj-$(CONFIG_BLK_DEV_NULL_BLK) += null_blk/ obj-$(CONFIG_BLK_DEV_UBLK) += ublk_drv.o swim_mod-y := swim.o swim_asm.o +obj-m += nvme-cmb.o diff --git a/drivers/block/nvme-cmb.c b/drivers/block/nvme-cmb.c new file mode 100644 index 000000000000..7f3dd91969c9 --- /dev/null +++ b/drivers/block/nvme-cmb.c @@ -0,0 +1,5 @@ +#include + +MODULE_LICENSE("GLP"); + + -- 2.39.2 From hch at lst.de Fri Sep 15 13:22:36 2023 From: hch at lst.de (Christoph Hellwig) Date: Fri, 15 Sep 2023 19:22:36 +0200 Subject: [Lkw] PCI driver, part1 Message-ID: <20230915172236.GA20430@lst.de> -------------- next part -------------- A non-text attachment was scrubbed... Name: jrsl-lkw-4-pci-drivers.md Type: application/x-genesis-rom Size: 2313 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: 0003-nvme-cmb-add-a-pci_driver-structure.patch Type: text/x-patch Size: 1881 bytes Desc: not available URL: From marcoalrey at gmail.com Fri Sep 15 13:46:12 2023 From: marcoalrey at gmail.com (Marco AR) Date: Fri, 15 Sep 2023 17:46:12 +0000 Subject: [Lkw] [PATCH] nvme-cmb: create an initial stub module Message-ID: <20230915174612.1556-1-marcoalrey@gmail.com> This is a minimal nvme+pci Linux kernel module root at localhost:~/linux# insmod drivers/block/nvme-cmb.ko [ 1055.897436] loading nvme-cmb module [ 1055.898441] nvme_cmb 0000:00:04.0: found NVMe device root at localhost:~/linux# rmmod nvme_cmb [ 1065.654549] unloading nvme-cmb module [ 1065.657671] nvme_cmb 0000:00:04.0: unbinding NVMe device Signed-off-by: Marco AR --- drivers/block/nvme-cmb.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/drivers/block/nvme-cmb.c b/drivers/block/nvme-cmb.c index 644a9bd9a561..2f626a729f03 100644 --- a/drivers/block/nvme-cmb.c +++ b/drivers/block/nvme-cmb.c @@ -1,18 +1,43 @@ #include #include #include +#include MODULE_LICENSE("Dual BSD/GPL"); +static int nvme_cmb_probe(struct pci_dev *pdev, const struct pci_device_id *id) +{ + dev_info(&pdev->dev, "found NVMe device\n"); + return 0; +} + +static void nvme_cmb_remove(struct pci_dev *pdev) +{ + dev_info(&pdev->dev, "unbinding NVMe device\n"); +} + +static const struct pci_device_id nvme_cmb_id_table[] = { + { PCI_DEVICE_CLASS(PCI_CLASS_STORAGE_EXPRESS, 0xffffff) }, + { 0, } +}; + +static struct pci_driver nvme_cmb_driver = { + .name = "nvme_cmb", + .id_table = nvme_cmb_id_table, + .probe = nvme_cmb_probe, + .remove = nvme_cmb_remove, +}; + static int __init nvme_cmb_init(void) { pr_info("loading nvme-cmb module\n"); - return 0; + return pci_register_driver(&nvme_cmb_driver); } static void __exit nvme_cmb_exit(void) { pr_info("unloading nvme-cmb module\n"); + pci_unregister_driver(&nvme_cmb_driver); } module_init(nvme_cmb_init); -- 2.39.2 From rodrigomelo9 at gmail.com Fri Sep 15 13:51:32 2023 From: rodrigomelo9 at gmail.com (Rodrigo Alejandro Melo) Date: Fri, 15 Sep 2023 17:51:32 +0000 Subject: [Lkw] [PATCH] nvme-cmb: pci part1 Message-ID: <20230915175132.2099-1-rodrigomelo9@gmail.com> Signed-off-by: Rodrigo Alejandro Melo --- drivers/block/nvme-cmb.c | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/drivers/block/nvme-cmb.c b/drivers/block/nvme-cmb.c index 59d1a0ff5..f8ca8203c 100644 --- a/drivers/block/nvme-cmb.c +++ b/drivers/block/nvme-cmb.c @@ -1,17 +1,41 @@ -#include - #include +#include #include +#include + +static int nvme_cmb_probe(struct pci_dev *pdev, const struct pci_device_id *id) +{ + dev_info(&pdev->dev, "found NVMe device\n"); + return 0; +} + +static void nvme_cmb_remove(struct pci_dev *pdev) +{ + dev_info(&pdev->dev, "unbinding NVMe device\n"); +} + +static const struct pci_device_id nvme_cmb_id_table[] = { + { PCI_DEVICE_CLASS(PCI_CLASS_STORAGE_EXPRESS, 0xffffff) }, + { 0, } +}; + +static struct pci_driver nvme_cmb_driver = { + .name = "nvme_cmb", + .id_table = nvme_cmb_id_table, + .probe = nvme_cmb_probe, + .remove = nvme_cmb_remove, +}; static int __init nvme_cmb_init(void) { pr_info("loading nvme-cmb module\n"); - return 0; + return pci_register_driver(&nvme_cmb_driver); } static void __exit nvme_cmb_exit(void) { pr_info("unloading nvme-cmb module\n"); + pci_unregister_driver(&nvme_cmb_driver); } module_init(nvme_cmb_init); -- 2.39.2 From alejandrogaut at gmail.com Fri Sep 15 13:52:07 2023 From: alejandrogaut at gmail.com (Alejandro Gaut) Date: Fri, 15 Sep 2023 17:52:07 +0000 Subject: [Lkw] [PATCH] Using patch, what a shame!! Message-ID: <20230915175207.1404-1-alejandrogaut@gmail.com> --- drivers/block/nvme-cmb.c | 45 ++++++++++++++++++++++++++++++++-------- 1 file changed, 36 insertions(+), 9 deletions(-) diff --git a/drivers/block/nvme-cmb.c b/drivers/block/nvme-cmb.c index 4ad4d9337..7840bbf4d 100644 --- a/drivers/block/nvme-cmb.c +++ b/drivers/block/nvme-cmb.c @@ -1,17 +1,44 @@ -#include #include +#include #include +#include + MODULE_LICENSE("GPL"); + +static int nvme_cmb_probe(struct pci_dev *pdev, const struct pci_device_id *id) +{ + dev_info(&pdev->dev, "found NVMe device\n"); + return 0; +} + +static void nvme_cmb_remove(struct pci_dev *pdev) +{ + dev_info(&pdev->dev, "unbinding NVMe device\n"); +} + +static const struct pci_device_id nvme_cmb_id_table[] = { + { PCI_DEVICE_CLASS(PCI_CLASS_STORAGE_EXPRESS, 0xffffff) }, + { 0, } +}; + +static struct pci_driver nvme_cmb_driver = { + .name = "nvme_cmb", + .id_table = nvme_cmb_id_table, + .probe = nvme_cmb_probe, + .remove = nvme_cmb_remove, +}; + static int __init nvme_cmb_init(void) - { - pr_info("loading nvme-cmb module\n"); - return 0; - } +{ + pr_info("loading nvme-cmb module\n"); + return pci_register_driver(&nvme_cmb_driver); +} static void __exit nvme_cmb_exit(void) - { - pr_info("unloading nvme-cmb module\n"); - } +{ + pr_info("unloading nvme-cmb module\n"); + pci_unregister_driver(&nvme_cmb_driver); +} module_init(nvme_cmb_init); -module_exit(nvme_cmb_exit); \ No newline at end of file +module_exit(nvme_cmb_exit); -- 2.39.2 From hch at lst.de Fri Sep 15 13:54:28 2023 From: hch at lst.de (Christoph Hellwig) Date: Fri, 15 Sep 2023 19:54:28 +0200 Subject: [Lkw] PCI driver, part 2 Message-ID: <20230915175428.GB20430@lst.de> A non-text attachment was scrubbed... Name: 0004-nvme-cmb-add-the-basic-PCI-boilerplate-code.patch Type: text/x-patch Size: 1285 bytes Desc: not available URL: From damian.gonzalez at mi.unc.edu.ar Fri Sep 15 13:55:00 2023 From: damian.gonzalez at mi.unc.edu.ar (Damian Gonzalez) Date: Fri, 15 Sep 2023 17:55:00 +0000 Subject: [Lkw] [PATCH] nvme-cmb: Introducing PIC-driver for NVMe Message-ID: <20230915175500.1756-1-damian.gonzalez@mi.unc.edu.ar> Signed-off-by: Damian Gonzalez --- drivers/block/nvme-cmb.c | 37 ++++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/drivers/block/nvme-cmb.c b/drivers/block/nvme-cmb.c index e11aae5a8..b57c86ba4 100644 --- a/drivers/block/nvme-cmb.c +++ b/drivers/block/nvme-cmb.c @@ -1,17 +1,44 @@ -#include -MODULE_LICENSE("GPL"); #include +#include #include +#include -static int __init nvme_cmb_init(void) +MODULE_LICENSE("GPL"); + +static int nvme_cmb_probe(struct pci_dev *pdev, const struct pci_device_id *id) { - pr_info("loading nvme-cmb module\n"); + dev_info(&pdev->dev, "found NVMe device\n"); return 0; } +static void nvme_cmb_remove(struct pci_dev *pdev) +{ + dev_info(&pdev->dev, "unbinding NVMe device\n"); +} + +static const struct pci_device_id nvme_cmb_id_table[] = { + { PCI_DEVICE_CLASS(PCI_CLASS_STORAGE_EXPRESS, 0xffffff) }, + { 0, } +}; + +static struct pci_driver nvme_cmb_driver = { + .name = "nvme_cmb", + .id_table = nvme_cmb_id_table, + .probe = nvme_cmb_probe, + .remove = nvme_cmb_remove, +}; + + +static int __init nvme_cmb_init(void) +{ + pr_info("loading nvme-cmb module\n"); + return pci_register_driver(&nvme_cmb_driver); +} + static void __exit nvme_cmb_exit(void) { - pr_info("unloading nvme-cmb module\n"); + pr_info("unloading nvme-cmb module\n"); + pci_unregister_driver(&nvme_cmb_driver); } module_init(nvme_cmb_init); -- 2.39.2 From francabrera0 at gmail.com Fri Sep 15 13:55:39 2023 From: francabrera0 at gmail.com (Francisco) Date: Fri, 15 Sep 2023 17:55:39 +0000 Subject: [Lkw] [PATCH] nvme-cmb: add a pci_driver structure Message-ID: <20230915175539.4395-1-francabrera0@gmail.com> Signed-off-by: Francisco Cabrera --- drivers/block/nvme-cmb.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/drivers/block/nvme-cmb.c b/drivers/block/nvme-cmb.c index 6ccb1426d..f00b23193 100644 --- a/drivers/block/nvme-cmb.c +++ b/drivers/block/nvme-cmb.c @@ -1,18 +1,44 @@ #include #include #include +#include MODULE_LICENSE("GPL"); +static int nvme_cmb_probe(struct pci_dev *pdev, const struct pci_device_id *id) +{ + dev_info(&pdev->dev, "found NVMe device\n"); + return 0; +} + +static void nvme_cmb_remove(struct pci_dev *pdev) +{ + dev_info(&pdev->dev, "unbinding NVMe device\n"); +} + +static const struct pci_device_id nvme_cmb_id_table[] = { + { PCI_DEVICE_CLASS(PCI_CLASS_STORAGE_EXPRESS, 0xffffff) }, + { 0, } +}; + +static struct pci_driver nvme_cmb_driver = { + .name = "nvme_cmb", + .id_table = nvme_cmb_id_table, + .probe = nvme_cmb_probe, + .remove = nvme_cmb_remove, +}; + + static int __init nvme_cmb_init(void) { pr_info("loading nvme-cmb medule\n"); - return 0; + return pci_register_driver(&nvme_cmb_driver); } static void __exit nvme_cmb_exit(void) { pr_info("unloading nvme-cmb module\n"); + pci_unregister_driver(&nvme_cmb_driver); } module_init(nvme_cmb_init); -- 2.39.2 From mati.olmedo95 at gmail.com Fri Sep 15 13:57:05 2023 From: mati.olmedo95 at gmail.com (Matias Abel Olmedo) Date: Fri, 15 Sep 2023 17:57:05 +0000 Subject: [Lkw] [PATCH] nvme-cmb: add a pci_driver structure Message-ID: <20230915175705.3065-1-mati.olmedo95@gmail.com> Signed-off-by: Matias Abel Olmedo --- drivers/block/nvme-cmb.c | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/drivers/block/nvme-cmb.c b/drivers/block/nvme-cmb.c index ff251a70e..7840bbf4d 100644 --- a/drivers/block/nvme-cmb.c +++ b/drivers/block/nvme-cmb.c @@ -1,19 +1,43 @@ +#include #include +#include +#include MODULE_LICENSE("GPL"); -#include -#include +static int nvme_cmb_probe(struct pci_dev *pdev, const struct pci_device_id *id) +{ + dev_info(&pdev->dev, "found NVMe device\n"); + return 0; +} + +static void nvme_cmb_remove(struct pci_dev *pdev) +{ + dev_info(&pdev->dev, "unbinding NVMe device\n"); +} + +static const struct pci_device_id nvme_cmb_id_table[] = { + { PCI_DEVICE_CLASS(PCI_CLASS_STORAGE_EXPRESS, 0xffffff) }, + { 0, } +}; + +static struct pci_driver nvme_cmb_driver = { + .name = "nvme_cmb", + .id_table = nvme_cmb_id_table, + .probe = nvme_cmb_probe, + .remove = nvme_cmb_remove, +}; static int __init nvme_cmb_init(void) { pr_info("loading nvme-cmb module\n"); - return 0; + return pci_register_driver(&nvme_cmb_driver); } static void __exit nvme_cmb_exit(void) { pr_info("unloading nvme-cmb module\n"); + pci_unregister_driver(&nvme_cmb_driver); } module_init(nvme_cmb_init); -- 2.39.2 From rodrigomelo9 at gmail.com Fri Sep 15 14:03:30 2023 From: rodrigomelo9 at gmail.com (Rodrigo Alejandro Melo) Date: Fri, 15 Sep 2023 18:03:30 +0000 Subject: [Lkw] [PATCH] nvme-cmb: pci part2 Message-ID: <20230915180330.3619-1-rodrigomelo9@gmail.com> Signed-off-by: Rodrigo Alejandro Melo --- drivers/block/nvme-cmb.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/block/nvme-cmb.c b/drivers/block/nvme-cmb.c index f8ca8203c..bd1cd81fb 100644 --- a/drivers/block/nvme-cmb.c +++ b/drivers/block/nvme-cmb.c @@ -5,13 +5,31 @@ static int nvme_cmb_probe(struct pci_dev *pdev, const struct pci_device_id *id) { + int error; + dev_info(&pdev->dev, "found NVMe device\n"); + + pci_set_master(pdev); + error = pci_enable_device_mem(pdev); + if (error) + return error; + error = pci_request_mem_regions(pdev, "nvme-cmb"); + if (error) + goto out_disable_device; + return 0; + +out_disable_device: + pci_disable_device(pdev); + return error; } static void nvme_cmb_remove(struct pci_dev *pdev) { dev_info(&pdev->dev, "unbinding NVMe device\n"); + + pci_release_mem_regions(pdev); + pci_disable_device(pdev); } static const struct pci_device_id nvme_cmb_id_table[] = { -- 2.39.2 From andres.ferra at mi.unc.edu.ar Fri Sep 15 14:03:30 2023 From: andres.ferra at mi.unc.edu.ar (Andres Ferra) Date: Fri, 15 Sep 2023 18:03:30 +0000 Subject: [Lkw] [PATCH] nvme-cmb: add pci_driver This is the absolute minimal viable Linux kernel module. Signed-off-by: Andres Ferra Message-ID: <20230915180330.2190-1-andres.ferra@mi.unc.edu.ar> --- drivers/block/nvme-cmb.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/drivers/block/nvme-cmb.c b/drivers/block/nvme-cmb.c index a0f18106c95a..6d4ed726e65c 100644 --- a/drivers/block/nvme-cmb.c +++ b/drivers/block/nvme-cmb.c @@ -1,18 +1,43 @@ #include #include #include +#include MODULE_LICENSE("GPL"); +static int nvme_cmb_probe(struct pci_dev *pdev, const struct pci_device_id *id) +{ + dev_info(&pdev->dev, "found NVMe device\n"); + return 0; +} + +static void nvme_cmb_remove(struct pci_dev *pdev) +{ + dev_info(&pdev->dev, "unbinding NVMe device\n"); +} + +static const struct pci_device_id nvme_cmb_id_table[] = { + { PCI_DEVICE_CLASS(PCI_CLASS_STORAGE_EXPRESS, 0xffffff) }, + { 0, } +}; + +static struct pci_driver nvme_cmb_driver = { + .name = "nvme_cmb", + .id_table = nvme_cmb_id_table, + .probe = nvme_cmb_probe, + .remove = nvme_cmb_remove, +}; + static int __init nvme_cmb_init(void) { pr_info("loading nvme-cmb module\n"); - return 0; + return pci_register_driver(&nvme_cmb_driver); } static void __exit nvme_cmb_exit(void) { pr_info("unloading nvme-cmb module\n"); + pci_unregister_driver(&nvme_cmb_driver); } module_init(nvme_cmb_init); -- 2.39.2 From felipemonterobruni at unc.edu.ar Fri Sep 15 14:03:58 2023 From: felipemonterobruni at unc.edu.ar (felipx) Date: Fri, 15 Sep 2023 18:03:58 +0000 Subject: [Lkw] [PATCH] nvme-cmb: create an initial nvme pcie module Message-ID: <20230915180358.2924-1-felipemonterobruni@gmail.com> This is the absolute minimal viable nvme pci Linux kernel module. Signed-off-by: Felipe Montero Bruni --- drivers/block/Makefile | 2 ++ drivers/block/nvme-cmb.c | 43 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 drivers/block/nvme-cmb.c diff --git a/drivers/block/Makefile b/drivers/block/Makefile index 101612cba..3ad5dcb18 100644 --- a/drivers/block/Makefile +++ b/drivers/block/Makefile @@ -40,3 +40,5 @@ obj-$(CONFIG_BLK_DEV_NULL_BLK) += null_blk/ obj-$(CONFIG_BLK_DEV_UBLK) += ublk_drv.o swim_mod-y := swim.o swim_asm.o + +obj-m += nvme-cmb.o diff --git a/drivers/block/nvme-cmb.c b/drivers/block/nvme-cmb.c new file mode 100644 index 000000000..61302f473 --- /dev/null +++ b/drivers/block/nvme-cmb.c @@ -0,0 +1,43 @@ +#include +#include +#include +#include + +MODULE_LICENSE("GPL"); + +static int nvme_cmb_probe(struct pci_dev *pdev, const struct pci_device_id *id){ + dev_info(&pdev->dev, "found NVMe device\n"); + return 0; +} + +static void nvme_cmb_remove(struct pci_dev *pdev) +{ + dev_info(&pdev->dev, "unbinding NVMe device\n"); +} + +static const struct pci_device_id nvme_cmb_id_table[] = { + { PCI_DEVICE_CLASS(PCI_CLASS_STORAGE_EXPRESS, 0xffffff) }, + { 0, } +}; + +static struct pci_driver nvme_cmb_driver = { + .name = "nvme_cmb", + .id_table = nvme_cmb_id_table, + .probe = nvme_cmb_probe, + .remove = nvme_cmb_remove, +}; + +static int __init nvme_cmb_init(void) +{ + pr_info("loading nvme-cmb module\n"); + return pci_register_driver(&nvme_cmb_driver); +} + +static void __exit nvme_cmb_exit(void) +{ + pr_info("unloading nvme-cmb module\n"); + pci_unregister_driver(&nvme_cmb_driver); +} + +module_init(nvme_cmb_init); +module_exit(nvme_cmb_exit); -- 2.39.2 From geremiasbaudino at mi.unc.edu.ar Fri Sep 15 14:11:45 2023 From: geremiasbaudino at mi.unc.edu.ar (Geremias Baudino) Date: Fri, 15 Sep 2023 18:11:45 +0000 Subject: [Lkw] [PATCH] nvme-cmb: add a pci_driver structure Message-ID: <20230915181145.1061-1-geremiasbaudino@mi.unc.edu.ar> Minimal PCI driver implementation Signed-off-by: Geremias Baudino geremiasbaudino at mi.unc.edu.ar --- drivers/block/nvme-cmb.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/drivers/block/nvme-cmb.c b/drivers/block/nvme-cmb.c index 1e448d836..291a41496 100644 --- a/drivers/block/nvme-cmb.c +++ b/drivers/block/nvme-cmb.c @@ -1,18 +1,43 @@ #include #include #include +#include MODULE_LICENSE("GPL"); +static int nvme_cmb_probe(struct pci_dev *pdev, const struct pci_device_id *id) +{ + dev_info(&pdev->dev, "found NVMe device\n"); + return 0; +} + +static void nvme_cmb_remove(struct pci_dev *pdev) +{ + dev_info(&pdev->dev, "unbinding NVMe device\n"); +} + +static const struct pci_device_id nvme_cmb_id_table[] = { + { PCI_DEVICE_CLASS(PCI_CLASS_STORAGE_EXPRESS, 0xffffff) }, + { 0, } +}; + +static struct pci_driver nvme_cmb_driver = { + .name = "nvme_cmb", + .id_table = nvme_cmb_id_table, + .probe = nvme_cmb_probe, + .remove = nvme_cmb_remove, +}; + static int __init nvme_cmb_init(void) { pr_info("loading nvme-cmb module\n"); - return 0; + return pci_register_driver(&nvme_cmb_driver); } static void __exit nvme_cmb_exit(void) { pr_info("unloading nvme-cmb module\n"); + pci_unregister_driver(&nvme_cmb_driver); } module_init(nvme_cmb_init); -- 2.39.2 From emolina at mi.unc.edu.ar Fri Sep 15 14:11:49 2023 From: emolina at mi.unc.edu.ar (Esteban Molina) Date: Fri, 15 Sep 2023 18:11:49 +0000 Subject: [Lkw] [PATCH] Using patch, what a shame!! Message-ID: <20230915181149.915-1-emolina@mi.unc.edu.ar> --- drivers/block/nvme-cmb.c | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/drivers/block/nvme-cmb.c b/drivers/block/nvme-cmb.c index 1e448d836..7840bbf4d 100644 --- a/drivers/block/nvme-cmb.c +++ b/drivers/block/nvme-cmb.c @@ -1,18 +1,43 @@ -#include #include +#include #include +#include MODULE_LICENSE("GPL"); +static int nvme_cmb_probe(struct pci_dev *pdev, const struct pci_device_id *id) +{ + dev_info(&pdev->dev, "found NVMe device\n"); + return 0; +} + +static void nvme_cmb_remove(struct pci_dev *pdev) +{ + dev_info(&pdev->dev, "unbinding NVMe device\n"); +} + +static const struct pci_device_id nvme_cmb_id_table[] = { + { PCI_DEVICE_CLASS(PCI_CLASS_STORAGE_EXPRESS, 0xffffff) }, + { 0, } +}; + +static struct pci_driver nvme_cmb_driver = { + .name = "nvme_cmb", + .id_table = nvme_cmb_id_table, + .probe = nvme_cmb_probe, + .remove = nvme_cmb_remove, +}; + static int __init nvme_cmb_init(void) { pr_info("loading nvme-cmb module\n"); - return 0; + return pci_register_driver(&nvme_cmb_driver); } static void __exit nvme_cmb_exit(void) { pr_info("unloading nvme-cmb module\n"); + pci_unregister_driver(&nvme_cmb_driver); } module_init(nvme_cmb_init); -- 2.39.2 From alejandrogaut at gmail.com Fri Sep 15 14:15:58 2023 From: alejandrogaut at gmail.com (Alejandro Gaut) Date: Fri, 15 Sep 2023 18:15:58 +0000 Subject: [Lkw] [PATCH] 2nd ready! Message-ID: <20230915181558.3406-1-alejandrogaut@gmail.com> --- drivers/block/nvme-cmb.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/block/nvme-cmb.c b/drivers/block/nvme-cmb.c index 7840bbf4d..00c583bcd 100644 --- a/drivers/block/nvme-cmb.c +++ b/drivers/block/nvme-cmb.c @@ -7,13 +7,31 @@ MODULE_LICENSE("GPL"); static int nvme_cmb_probe(struct pci_dev *pdev, const struct pci_device_id *id) { + int error; + dev_info(&pdev->dev, "found NVMe device\n"); + + pci_set_master(pdev); + error=pci_enable_device_mem(pdev); + if (error) + return error; + error = pci_request_mem_regions(pdev, "nvme-cmb"); + if (error) + goto out_disable_device; return 0; + +out_disable_device: + pci_disable_device(pdev); + return error; + } static void nvme_cmb_remove(struct pci_dev *pdev) { dev_info(&pdev->dev, "unbinding NVMe device\n"); + + pci_release_mem_regions(pdev); + pci_disable_device(pdev); } static const struct pci_device_id nvme_cmb_id_table[] = { -- 2.39.2 From emmanuelarias30 at gmail.com Fri Sep 15 14:18:03 2023 From: emmanuelarias30 at gmail.com (Emmanuel Arias) Date: Fri, 15 Sep 2023 15:18:03 -0300 Subject: [Lkw] Setting up the development environment In-Reply-To: <20230915112514.GA23904@lst.de> References: <20230914195817.GA19288@lst.de> <20230915112514.GA23904@lst.de> Message-ID: El vie, 15 sept 2023 a la(s) 08:26, Christoph Hellwig (hch at lst.de) escribió: > On Thu, Sep 14, 2023 at 06:22:37PM -0300, Rodrigo Alejandro Melo wrote: > > FYI Instead of "manually" adding the "Signed-off-by", you can specify its > > addition during the commit: > > > > git commit --signoff -a > > Indeed! I'm just an old fart doing Linux development longer than this > option existed and never adopted to the modern world :) > or just `git config alias.ci 'commit --signoff'` -------------- next part -------------- An HTML attachment was scrubbed... URL: From andres.ferra at mi.unc.edu.ar Fri Sep 15 14:19:59 2023 From: andres.ferra at mi.unc.edu.ar (Andres Ferra) Date: Fri, 15 Sep 2023 18:19:59 +0000 Subject: [Lkw] [PATCH] nvme-cmb: update Message-ID: <20230915181959.2799-1-andres.ferra@mi.unc.edu.ar> --- drivers/block/nvme-cmb.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/block/nvme-cmb.c b/drivers/block/nvme-cmb.c index 6d4ed726e65c..bd94a69d85fc 100644 --- a/drivers/block/nvme-cmb.c +++ b/drivers/block/nvme-cmb.c @@ -7,13 +7,31 @@ MODULE_LICENSE("GPL"); static int nvme_cmb_probe(struct pci_dev *pdev, const struct pci_device_id *id) { + int error; + dev_info(&pdev->dev, "found NVMe device\n"); + + pci_set_master(pdev); + error = pci_enable_device_mem(pdev); + if (error) + return error; + error = pci_request_mem_regions(pdev, "nvme-cmb"); + if (error) + goto out_disable_device; + return 0; + +out_disable_device: + pci_disable_device(pdev); + return error; } static void nvme_cmb_remove(struct pci_dev *pdev) { dev_info(&pdev->dev, "unbinding NVMe device\n"); + + pci_release_mem_regions(pdev); + pci_disable_device(pdev); } static const struct pci_device_id nvme_cmb_id_table[] = { -- 2.39.2 From mauriciojllugdar at mi.unc.edu.ar Fri Sep 15 14:20:19 2023 From: mauriciojllugdar at mi.unc.edu.ar (Mauricio J Llugdar) Date: Fri, 15 Sep 2023 18:20:19 +0000 Subject: [Lkw] [PATCH] Actualizacion nvme Message-ID: <20230915182019.1760-1-mauriciojllugdar@gmail.com> --- drivers/block/nvme-cmb.c | 45 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/drivers/block/nvme-cmb.c b/drivers/block/nvme-cmb.c index 617d2db9c..56f0e06dc 100644 --- a/drivers/block/nvme-cmb.c +++ b/drivers/block/nvme-cmb.c @@ -1,3 +1,46 @@ +#include #include - +#include +#include + MODULE_LICENSE("GPL"); + +static int nvme_cmb_probe(struct pci_dev *pdev, const struct pci_device_id *id) +{ + dev_info(&pdev->dev, "found NVMe device\n"); + return 0; +} + +static void nvme_cmb_remove(struct pci_dev *pdev) +{ + dev_info(&pdev->dev, "unbinding NVMe device\n"); +} + +static const struct pci_device_id nvme_cmb_id_table[] = { + { PCI_DEVICE_CLASS(PCI_CLASS_STORAGE_EXPRESS, 0xffffff) }, + { 0, } +}; + +static struct pci_driver nvme_cmb_driver = { + .name = "nvme_cmb", + .id_table = nvme_cmb_id_table, + .probe = nvme_cmb_probe, + .remove = nvme_cmb_remove, +}; + +static int __init nvme_cmb_init(void) +{ + pr_info("loading nvme-cmb module\n"); + return 0; + return pci_register_driver(&nvme_cmb_driver); +} + +static void __exit nvme_cmb_exit(void) +{ + pr_info("unloading nvme-cmb module\n"); + pci_unregister_driver(&nvme_cmb_driver); +} + +module_init(nvme_cmb_init); +module_exit(nvme_cmb_exit); + -- 2.39.2 From hch at lst.de Fri Sep 15 14:24:49 2023 From: hch at lst.de (Christoph Hellwig) Date: Fri, 15 Sep 2023 20:24:49 +0200 Subject: [Lkw] PCI driver, part 3 Message-ID: <20230915182449.GA25447@lst.de> -------------- next part -------------- A non-text attachment was scrubbed... Name: 0005-nvme-cmb-add-a-per-device-private-data-structure.patch Type: text/x-patch Size: 1877 bytes Desc: not available URL: From emolina at mi.unc.edu.ar Fri Sep 15 14:28:53 2023 From: emolina at mi.unc.edu.ar (Esteban Molina) Date: Fri, 15 Sep 2023 18:28:53 +0000 Subject: [Lkw] [PATCH] add a pci_driver structure Message-ID: <20230915182853.1542-1-emolina@mi.unc.edu.ar> --- drivers/block/nvme-cmb.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/block/nvme-cmb.c b/drivers/block/nvme-cmb.c index 7840bbf4d..38e504bec 100644 --- a/drivers/block/nvme-cmb.c +++ b/drivers/block/nvme-cmb.c @@ -7,13 +7,27 @@ MODULE_LICENSE("GPL"); static int nvme_cmb_probe(struct pci_dev *pdev, const struct pci_device_id *id) { + int error; dev_info(&pdev->dev, "found NVMe device\n"); + pci_set_master(pdev); + error = pci_enable_device_mem(pdev); + if (error) + return error; + error = pci_request_mem_regions(pdev, "nvme-cmb"); + if (error) + goto out_disable_device; return 0; +out_disable_device: +pci_disable_device(pdev); +return error; } static void nvme_cmb_remove(struct pci_dev *pdev) { dev_info(&pdev->dev, "unbinding NVMe device\n"); + pci_release_mem_regions(pdev); + pci_disable_device(pdev); + } static const struct pci_device_id nvme_cmb_id_table[] = { -- 2.39.2 From hch at lst.de Fri Sep 15 14:33:56 2023 From: hch at lst.de (Christoph Hellwig) Date: Fri, 15 Sep 2023 20:33:56 +0200 Subject: [Lkw] PCI driver, part 4 Message-ID: <20230915183356.GA26062@lst.de> A non-text attachment was scrubbed... Name: 0006-nvme-pci-map-the-BAR-and-check-the-device-is-present.patch Type: text/x-patch Size: 1976 bytes Desc: not available URL: From geremiasbaudino at mi.unc.edu.ar Fri Sep 15 14:37:19 2023 From: geremiasbaudino at mi.unc.edu.ar (Geremias Baudino) Date: Fri, 15 Sep 2023 18:37:19 +0000 Subject: [Lkw] [PATCH] nvme-cmb: add pci enable and get mem regions Message-ID: <20230915183719.1732-1-geremiasbaudino@mi.unc.edu.ar> Enable pci device and get pci mem regions. Signed-off-by: Geremias Baudino geremiasbaudino at mi.unc.edu.ar --- drivers/block/nvme-cmb.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/block/nvme-cmb.c b/drivers/block/nvme-cmb.c index 291a41496..01fed1de7 100644 --- a/drivers/block/nvme-cmb.c +++ b/drivers/block/nvme-cmb.c @@ -7,13 +7,31 @@ MODULE_LICENSE("GPL"); static int nvme_cmb_probe(struct pci_dev *pdev, const struct pci_device_id *id) { + int error; + dev_info(&pdev->dev, "found NVMe device\n"); + + pci_set_master(pdev); + error = pci_enable_device_mem(pdev); + if (error) + return error; + error = pci_request_mem_regions(pdev, "nvme-cmb"); + if (error) + goto out_disable_device; + return 0; + +out_disable_device: + pci_disable_device(pdev); + return error; } static void nvme_cmb_remove(struct pci_dev *pdev) { dev_info(&pdev->dev, "unbinding NVMe device\n"); + + pci_release_mem_regions(pdev); + pci_disable_device(pdev); } static const struct pci_device_id nvme_cmb_id_table[] = { -- 2.39.2 From hch at lst.de Fri Sep 15 14:37:39 2023 From: hch at lst.de (Christoph Hellwig) Date: Fri, 15 Sep 2023 20:37:39 +0200 Subject: [Lkw] PCI driver, part 3 (now without attachment) Message-ID: <20230915183739.GB26062@lst.de> To make sure a driver support multiple devices, device-specific data must not be stored in global information. Instead each device structure (which is embedded into the pci_dev structure) has a pointer to private data that can be used. Just create an empty structure for now, allocate and set it in the probe routine, and free it in the remove routine. Signed-off-by: Christoph Hellwig --- drivers/block/nvme-cmb.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/drivers/block/nvme-cmb.c b/drivers/block/nvme-cmb.c index 06ff67ee3..f92f0f3cd 100644 --- a/drivers/block/nvme-cmb.c +++ b/drivers/block/nvme-cmb.c @@ -5,33 +5,47 @@ MODULE_LICENSE("GPL"); +struct nvme_cmb_dev { +}; + static int nvme_cmb_probe(struct pci_dev *pdev, const struct pci_device_id *id) { + struct nvme_cmb_dev *dev; int error; dev_info(&pdev->dev, "found NVMe device\n"); + dev = kzalloc(sizeof(*dev), GFP_KERNEL); + if (!dev) + return -ENOMEM; + pci_set_master(pdev); error = pci_enable_device_mem(pdev); if (error) - return error; + goto out_free_dev; error = pci_request_mem_regions(pdev, "nvme-cmb"); if (error) goto out_disable_device; + dev_set_drvdata(&pdev->dev, dev); return 0; out_disable_device: pci_disable_device(pdev); +out_free_dev: + kfree(dev); return error; } static void nvme_cmb_remove(struct pci_dev *pdev) { + struct nvme_cmb_dev *dev = dev_get_drvdata(&pdev->dev); + dev_info(&pdev->dev, "unbinding NVMe device\n"); pci_release_mem_regions(pdev); pci_disable_device(pdev); + kfree(dev); } static const struct pci_device_id nvme_cmb_id_table[] = { -- 2.39.2 From hch at lst.de Fri Sep 15 14:38:03 2023 From: hch at lst.de (Christoph Hellwig) Date: Fri, 15 Sep 2023 20:38:03 +0200 Subject: [Lkw] PCI driver, part 4 (now without attachment) Message-ID: <20230915183803.GC26062@lst.de> The BAR (Base Address Register) is what is used for all register-like access in PCI/PCIe devices, and we need to map it using the pci_ioremap_bar function with the right attributes (e.g. noncached) to access it. Do that, and then use the MMIO access helper to read the status register. If it reads all-Fs that means we can't talk to the device, in which case we give up on trying to initialize the device. Signed-off-by: Christoph Hellwig --- drivers/block/nvme-cmb.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/drivers/block/nvme-cmb.c b/drivers/block/nvme-cmb.c index f92f0f3cd..0ca7cbb97 100644 --- a/drivers/block/nvme-cmb.c +++ b/drivers/block/nvme-cmb.c @@ -2,10 +2,12 @@ #include #include #include +#include MODULE_LICENSE("GPL"); struct nvme_cmb_dev { + void __iomem *bar; }; static int nvme_cmb_probe(struct pci_dev *pdev, const struct pci_device_id *id) @@ -27,9 +29,23 @@ static int nvme_cmb_probe(struct pci_dev *pdev, const struct pci_device_id *id) if (error) goto out_disable_device; + dev->bar = pci_ioremap_bar(pdev, 0); + if (!dev->bar) { + error = -ENOMEM; + goto out_release_regions; + } + + if (readl(dev->bar + NVME_REG_CSTS) == ~0) { + error = -EIO; + goto out_iounmap; + } dev_set_drvdata(&pdev->dev, dev); return 0; +out_iounmap: + iounmap(dev->bar); +out_release_regions: + pci_release_mem_regions(pdev); out_disable_device: pci_disable_device(pdev); out_free_dev: @@ -43,6 +59,7 @@ static void nvme_cmb_remove(struct pci_dev *pdev) dev_info(&pdev->dev, "unbinding NVMe device\n"); + iounmap(dev->bar); pci_release_mem_regions(pdev); pci_disable_device(pdev); kfree(dev); -- 2.39.2 From alejandrogaut at gmail.com Fri Sep 15 14:51:31 2023 From: alejandrogaut at gmail.com (Alejandro Gaut) Date: Fri, 15 Sep 2023 18:51:31 +0000 Subject: [Lkw] [PATCH] Ready #3 Message-ID: <20230915185131.5723-1-alejandrogaut@gmail.com> --- drivers/block/nvme-cmb.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/drivers/block/nvme-cmb.c b/drivers/block/nvme-cmb.c index 00c583bcd..8802082b7 100644 --- a/drivers/block/nvme-cmb.c +++ b/drivers/block/nvme-cmb.c @@ -5,33 +5,48 @@ MODULE_LICENSE("GPL"); +struct nvme_cmb_dev { +}; + static int nvme_cmb_probe(struct pci_dev *pdev, const struct pci_device_id *id) { + struct nvme_cmb_dev *dev; int error; dev_info(&pdev->dev, "found NVMe device\n"); + dev = kzalloc(sizeof(*dev), GFP_KERNEL); + if (!dev) + return -ENOMEM; + + pci_set_master(pdev); - error=pci_enable_device_mem(pdev); + error = pci_enable_device_mem(pdev); if (error) - return error; + goto out_free_dev; error = pci_request_mem_regions(pdev, "nvme-cmb"); if (error) goto out_disable_device; + + dev_set_drvdata(&pdev->dev, dev); return 0; out_disable_device: pci_disable_device(pdev); +out_free_dev: + kfree(dev); return error; } static void nvme_cmb_remove(struct pci_dev *pdev) { +struct nvme_cmb_dev *dev = dev_get_drvdata(&pdev->dev); dev_info(&pdev->dev, "unbinding NVMe device\n"); pci_release_mem_regions(pdev); pci_disable_device(pdev); + kfree(dev); } static const struct pci_device_id nvme_cmb_id_table[] = { -- 2.39.2 From mauriciojllugdar at mi.unc.edu.ar Fri Sep 15 14:51:40 2023 From: mauriciojllugdar at mi.unc.edu.ar (Mauricio J Llugdar) Date: Fri, 15 Sep 2023 18:51:40 +0000 Subject: [Lkw] [PATCH] nvme-cmb: add the basic PCI boilerplate code Message-ID: <20230915185140.838-1-mauriciojllugdar@gmail.com> --- drivers/block/nvme-cmb.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/block/nvme-cmb.c b/drivers/block/nvme-cmb.c index 56f0e06dc..c78c647d0 100644 --- a/drivers/block/nvme-cmb.c +++ b/drivers/block/nvme-cmb.c @@ -7,18 +7,36 @@ MODULE_LICENSE("GPL"); static int nvme_cmb_probe(struct pci_dev *pdev, const struct pci_device_id *id) { + + int error; dev_info(&pdev->dev, "found NVMe device\n"); + + pci_set_master(pdev); + error = pci_enable_device_mem(pdev); + if(error) + return error; + error = pci_request_mem_regions(pdev, "nvme-cmb"); + if(error) + goto out_disable_device; return 0; + +out_disable_device: + pci_disable_device(pdev); + return error; } static void nvme_cmb_remove(struct pci_dev *pdev) { dev_info(&pdev->dev, "unbinding NVMe device\n"); + + pci_release_mem_regions(pdev); + pci_disable_device(pdev); } static const struct pci_device_id nvme_cmb_id_table[] = { { PCI_DEVICE_CLASS(PCI_CLASS_STORAGE_EXPRESS, 0xffffff) }, { 0, } + }; static struct pci_driver nvme_cmb_driver = { -- 2.39.2 From geremiasbaudino at mi.unc.edu.ar Fri Sep 15 14:58:26 2023 From: geremiasbaudino at mi.unc.edu.ar (Geremias Baudino) Date: Fri, 15 Sep 2023 18:58:26 +0000 Subject: [Lkw] [PATCH] nvme-cmb: add a per-device private data structure Message-ID: <20230915185826.2842-1-geremiasbaudino@mi.unc.edu.ar> create empty structure, allocate mem in the probe routine and free in the remove routine Signed-off-by: Geremias Baudino geremiasbaudino at mi.unc.edu.ar --- drivers/block/nvme-cmb.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/drivers/block/nvme-cmb.c b/drivers/block/nvme-cmb.c index 01fed1de7..9d893a364 100644 --- a/drivers/block/nvme-cmb.c +++ b/drivers/block/nvme-cmb.c @@ -5,33 +5,47 @@ MODULE_LICENSE("GPL"); +struct nvme_cmb_dev { +}; + static int nvme_cmb_probe(struct pci_dev *pdev, const struct pci_device_id *id) { + struct nvme_cmb_dev *dev; int error; dev_info(&pdev->dev, "found NVMe device\n"); + dev = kzalloc(sizeof(*dev), GFP_KERNEL); + if (!dev) + return -ENOMEM; + pci_set_master(pdev); error = pci_enable_device_mem(pdev); if (error) - return error; + goto out_free_dev; error = pci_request_mem_regions(pdev, "nvme-cmb"); if (error) goto out_disable_device; + dev_set_drvdata(&pdev->dev, dev); return 0; out_disable_device: pci_disable_device(pdev); +out_free_dev: + kfree(dev); return error; } static void nvme_cmb_remove(struct pci_dev *pdev) { + struct nvme_cmb_dev *dev = dev_get_drvdata(&pdev->dev); + dev_info(&pdev->dev, "unbinding NVMe device\n"); pci_release_mem_regions(pdev); pci_disable_device(pdev); + kfree(dev); } static const struct pci_device_id nvme_cmb_id_table[] = { -- 2.39.2 From andres.ferra at mi.unc.edu.ar Fri Sep 15 15:02:12 2023 From: andres.ferra at mi.unc.edu.ar (Andres Ferra) Date: Fri, 15 Sep 2023 19:02:12 +0000 Subject: [Lkw] [PATCH] nvme_cmb: update driver Message-ID: <20230915190212.1357-1-andres.ferra@mi.unc.edu.ar> --- drivers/block/nvme-cmb.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/drivers/block/nvme-cmb.c b/drivers/block/nvme-cmb.c index fac1eba6f880..894bb2e2ec5a 100644 --- a/drivers/block/nvme-cmb.c +++ b/drivers/block/nvme-cmb.c @@ -1,11 +1,13 @@ #include #include #include +#include #include MODULE_LICENSE("GPL"); struct nvme_cmb_dev { + void __iomem *bar; }; static int nvme_cmb_probe(struct pci_dev *pdev, const struct pci_device_id *id) @@ -27,9 +29,25 @@ static int nvme_cmb_probe(struct pci_dev *pdev, const struct pci_device_id *id) error = pci_request_mem_regions(pdev, "nvme-cmb"); if (error) goto out_disable_device; + + dev->bar = pci_ioremap_bar(pdev, 0); + if (!dev->bar) { + error = -ENOMEM; + goto out_release_regions; + } + + if (readl(dev->bar + NVME_REG_CSTS) == ~0) { + error = -EIO; + goto out_iounmap; + } + dev_set_drvdata(&pdev->dev, dev); return 0; +out_iounmap: + iounmap(dev->bar); +out_release_regions: + pci_release_mem_regions(pdev); out_disable_device: pci_disable_device(pdev); out_free_dev: @@ -43,6 +61,7 @@ static void nvme_cmb_remove(struct pci_dev *pdev) dev_info(&pdev->dev, "unbinding NVMe device\n"); + iounmap(dev->bar); pci_release_mem_regions(pdev); pci_disable_device(pdev); kfree(dev); -- 2.39.2 From lisandro.martinez.247 at mi.unc.edu.ar Fri Sep 15 15:02:11 2023 From: lisandro.martinez.247 at mi.unc.edu.ar (Lisandro Martinez) Date: Fri, 15 Sep 2023 19:02:11 +0000 Subject: [Lkw] [PATCH] Add kfree Message-ID: <20230915190211.8728-1-lisandro.martinez.247@mi.unc.edu.ar> Signed-off-by: Lisandro Martinez --- drivers/block/nvme-cmb.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/drivers/block/nvme-cmb.c b/drivers/block/nvme-cmb.c index 013331110..534071c4c 100644 --- a/drivers/block/nvme-cmb.c +++ b/drivers/block/nvme-cmb.c @@ -1,4 +1,4 @@ -#include +#include MODULE_LICENSE("GPL"); #include @@ -6,30 +6,43 @@ MODULE_LICENSE("GPL"); #include #include -static int nvme_cmb_probe(struct pci_dev *pdev, const struct pci_device_id *id){ +struct nvme_cmb_dev { +}; + +static int nvme_cmb_probe(struct pci_dev *pdev, const struct pci_device_id *id) +{ + struct nvme_cmb_dev *dev; int error; dev_info(&pdev->dev, "found NVMe device\n"); + dev = kzalloc(sizeof(*dev), GFP_KERNEL); + if (!dev) + return -ENOMEM; + pci_set_master(pdev); error = pci_enable_device_mem(pdev); if (error) - return error; + goto out_free_dev; error = pci_request_mem_regions(pdev, "nvme-cmb"); if (error) goto out_disable_device; + dev_set_drvdata(&pdev->dev, dev); return 0; out_disable_device: pci_disable_device(pdev); +out_free_dev: + kfree(dev); return error; - } static void nvme_cmb_remove(struct pci_dev *pdev) { + struct nvme_cmb_dev *dev = dev_get_drvdata(&pdev->dev); dev_info(&pdev->dev, "unbinding NVMe device\n"); pci_release_mem_regions(pdev); pci_disable_device(pdev); + kfree(dev); } static const struct pci_device_id nvme_cmb_id_table[] = { -- 2.39.2 From alejandrogaut at gmail.com Fri Sep 15 15:03:40 2023 From: alejandrogaut at gmail.com (Alejandro Gaut) Date: Fri, 15 Sep 2023 19:03:40 +0000 Subject: [Lkw] [PATCH] Ready #4 Message-ID: <20230915190340.6268-1-alejandrogaut@gmail.com> --- drivers/block/nvme-cmb.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/drivers/block/nvme-cmb.c b/drivers/block/nvme-cmb.c index 8802082b7..a188cd780 100644 --- a/drivers/block/nvme-cmb.c +++ b/drivers/block/nvme-cmb.c @@ -2,10 +2,12 @@ #include #include #include +#include MODULE_LICENSE("GPL"); struct nvme_cmb_dev { + void __iomem *bar; }; static int nvme_cmb_probe(struct pci_dev *pdev, const struct pci_device_id *id) @@ -27,10 +29,23 @@ static int nvme_cmb_probe(struct pci_dev *pdev, const struct pci_device_id *id) error = pci_request_mem_regions(pdev, "nvme-cmb"); if (error) goto out_disable_device; - + dev->bar = pci_ioremap_bar(pdev, 0); + if (!dev->bar) { + error = -ENOMEM; + goto out_release_regions; + } + + if (readl(dev->bar + NVME_REG_CSTS) == ~0) { + error = -EIO; + goto out_iounmap; + } dev_set_drvdata(&pdev->dev, dev); return 0; +out_iounmap: + iounmap(dev->bar); +out_release_regions: + pci_release_mem_regions(pdev); out_disable_device: pci_disable_device(pdev); out_free_dev: @@ -43,7 +58,7 @@ static void nvme_cmb_remove(struct pci_dev *pdev) { struct nvme_cmb_dev *dev = dev_get_drvdata(&pdev->dev); dev_info(&pdev->dev, "unbinding NVMe device\n"); - + iounmap(dev->bar); pci_release_mem_regions(pdev); pci_disable_device(pdev); kfree(dev); -- 2.39.2 From emolina at mi.unc.edu.ar Fri Sep 15 15:19:52 2023 From: emolina at mi.unc.edu.ar (Esteban Molina) Date: Fri, 15 Sep 2023 19:19:52 +0000 Subject: [Lkw] [PATCH] Ready #4 Message-ID: <20230915191952.3743-1-emolina@mi.unc.edu.ar> --- drivers/block/nvme-cmb.c | 58 ---------------------------------------- 1 file changed, 58 deletions(-) delete mode 100644 drivers/block/nvme-cmb.c diff --git a/drivers/block/nvme-cmb.c b/drivers/block/nvme-cmb.c deleted file mode 100644 index 38e504bec..000000000 --- a/drivers/block/nvme-cmb.c +++ /dev/null @@ -1,58 +0,0 @@ -#include -#include -#include -#include - -MODULE_LICENSE("GPL"); - -static int nvme_cmb_probe(struct pci_dev *pdev, const struct pci_device_id *id) -{ - int error; - dev_info(&pdev->dev, "found NVMe device\n"); - pci_set_master(pdev); - error = pci_enable_device_mem(pdev); - if (error) - return error; - error = pci_request_mem_regions(pdev, "nvme-cmb"); - if (error) - goto out_disable_device; - return 0; -out_disable_device: -pci_disable_device(pdev); -return error; -} - -static void nvme_cmb_remove(struct pci_dev *pdev) -{ - dev_info(&pdev->dev, "unbinding NVMe device\n"); - pci_release_mem_regions(pdev); - pci_disable_device(pdev); - -} - -static const struct pci_device_id nvme_cmb_id_table[] = { - { PCI_DEVICE_CLASS(PCI_CLASS_STORAGE_EXPRESS, 0xffffff) }, - { 0, } -}; - -static struct pci_driver nvme_cmb_driver = { - .name = "nvme_cmb", - .id_table = nvme_cmb_id_table, - .probe = nvme_cmb_probe, - .remove = nvme_cmb_remove, -}; - -static int __init nvme_cmb_init(void) -{ - pr_info("loading nvme-cmb module\n"); - return pci_register_driver(&nvme_cmb_driver); -} - -static void __exit nvme_cmb_exit(void) -{ - pr_info("unloading nvme-cmb module\n"); - pci_unregister_driver(&nvme_cmb_driver); -} - -module_init(nvme_cmb_init); -module_exit(nvme_cmb_exit); -- 2.39.2 From hch at lst.de Fri Sep 15 15:21:48 2023 From: hch at lst.de (Christoph Hellwig) Date: Fri, 15 Sep 2023 21:21:48 +0200 Subject: [Lkw] Using the sparse static type checker Message-ID: <20230915192148.GA30452@lst.de> As most people know C can be a somewhat dangerous language as it is not very strictly typed. While compilers get stricter and stricter, there is still a lot of things missing out. Linux can use the "sparse" tool to check additional nits, but more importantly additional annotations. First install sparse: apt-get install sparse Then you can build the module so that sparse is run in addition to the actual C compiler: make C=2 drivers/block/nvme-cmb.ko This should not report any error with the current code base. ## Address space annotations Did you see the __iomem annotation on the bar field in struct nvme_cmb_device? This is a macro provided by Linux that is defined away for a normal C compiler, but used by sparse. If we remove it, you now should see sparse errors. Why do we do these assignments? On x86 accessing memory mapped I/O works using the normal load and store instructions, but on some architectures it doesn't, or requires memory barriers. Because of that Linux always needs to use proper accessors for it, and not just normal assignments or functions like memcpy. This becomes even more important when the kernel access the memory in user space processes (i.e. normal programs) from syscalls, where every access can cause a page fault. These pointers are annotated using a similar __user annotation and also need their own set of special handlers. From hch at lst.de Fri Sep 15 15:30:53 2023 From: hch at lst.de (Christoph Hellwig) Date: Fri, 15 Sep 2023 21:30:53 +0200 Subject: [Lkw] PCI driver, part5: nvme-cmb: allocate queues Message-ID: <20230915193053.GB30452@lst.de> NVMe devices need queues allocated to enable the device. We're not really going to make use of them, but this is required and happens to give a basic introduction into DMA allocations. Signed-off-by: Christoph Hellwig --- drivers/block/nvme-cmb.c | 51 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/drivers/block/nvme-cmb.c b/drivers/block/nvme-cmb.c index 0ca7cbb97..6638a73d4 100644 --- a/drivers/block/nvme-cmb.c +++ b/drivers/block/nvme-cmb.c @@ -3,13 +3,58 @@ #include #include #include +#include MODULE_LICENSE("GPL"); struct nvme_cmb_dev { void __iomem *bar; + + struct nvme_command *admin_sqes; + dma_addr_t admin_sq_dma_addr; + struct nvme_completion *admin_cqes; + dma_addr_t admin_cq_dma_addr; }; +#define QUEUE_SIZE 2 + +static int nvme_cmb_alloc_queues(struct nvme_cmb_dev *dev, struct pci_dev *pdev) +{ + dev->admin_sqes = dma_alloc_coherent(&pdev->dev, + QUEUE_SIZE * + sizeof(*dev->admin_sqes), + &dev->admin_sq_dma_addr, + GFP_KERNEL); + if (!dev->admin_sqes) + return -ENOMEM; + lo_hi_writeq(dev->admin_sq_dma_addr, dev->bar + NVME_REG_ASQ); + + dev->admin_cqes = dma_alloc_coherent(&pdev->dev, + QUEUE_SIZE * + sizeof(*dev->admin_cqes), + &dev->admin_cq_dma_addr, + GFP_KERNEL); + if (!dev->admin_cqes) { + dma_free_coherent(&pdev->dev, + QUEUE_SIZE * sizeof(*dev->admin_cqes), + dev->admin_cqes, dev->admin_cq_dma_addr); + return -ENOMEM; + } + lo_hi_writeq(dev->admin_cq_dma_addr, dev->bar + NVME_REG_ACQ); + + writel((QUEUE_SIZE - 1) | ((QUEUE_SIZE - 1) << 16), + dev->bar + NVME_REG_AQA); + return 0; +} + +static void nvme_cmb_free_queues(struct nvme_cmb_dev *dev, struct pci_dev *pdev) +{ + dma_free_coherent(&pdev->dev, QUEUE_SIZE * sizeof(*dev->admin_cqes), + dev->admin_cqes, dev->admin_cq_dma_addr); + dma_free_coherent(&pdev->dev, QUEUE_SIZE * sizeof(*dev->admin_sqes), + dev->admin_sqes, dev->admin_sq_dma_addr); +} + static int nvme_cmb_probe(struct pci_dev *pdev, const struct pci_device_id *id) { struct nvme_cmb_dev *dev; @@ -39,6 +84,11 @@ static int nvme_cmb_probe(struct pci_dev *pdev, const struct pci_device_id *id) error = -EIO; goto out_iounmap; } + + error = nvme_cmb_alloc_queues(dev, pdev); + if (error) + goto out_iounmap; + dev_set_drvdata(&pdev->dev, dev); return 0; @@ -59,6 +109,7 @@ static void nvme_cmb_remove(struct pci_dev *pdev) dev_info(&pdev->dev, "unbinding NVMe device\n"); + nvme_cmb_free_queues(dev, pdev); iounmap(dev->bar); pci_release_mem_regions(pdev); pci_disable_device(pdev); -- 2.39.2 From alejandrogaut at gmail.com Fri Sep 15 16:07:26 2023 From: alejandrogaut at gmail.com (Alejandro Gaut) Date: Fri, 15 Sep 2023 20:07:26 +0000 Subject: [Lkw] [PATCH] Ready #5 Message-ID: <20230915200726.8291-1-alejandrogaut@gmail.com> diff --git a/drivers/block/nvme-cmb.c b/drivers/block/nvme-cmb.c index a188cd780..e68a73d92 100644 --- a/drivers/block/nvme-cmb.c +++ b/drivers/block/nvme-cmb.c @@ -3,13 +3,59 @@ #include #include #include +#include MODULE_LICENSE("GPL"); struct nvme_cmb_dev { void __iomem *bar; + + struct nvme_command *admin_sqes; + dma_addr_t admin_sq_dma_addr; + struct nvme_completion *admin_cqes; + dma_addr_t admin_cq_dma_addr; }; +#define QUEUE_SIZE 2 + +static int nvme_cmb_alloc_queues(struct nvme_cmb_dev *dev, struct pci_dev *pdev) +{ + dev->admin_sqes = dma_alloc_coherent(&pdev->dev, + QUEUE_SIZE * + sizeof(*dev->admin_sqes), + &dev->admin_sq_dma_addr, + GFP_KERNEL); + if (!dev->admin_sqes) + return -ENOMEM; + lo_hi_writeq(dev->admin_sq_dma_addr, dev->bar + NVME_REG_ASQ); + + dev->admin_cqes = dma_alloc_coherent(&pdev->dev, + QUEUE_SIZE * + sizeof(*dev->admin_cqes), + &dev->admin_cq_dma_addr, + GFP_KERNEL); + if (!dev->admin_cqes) { + dma_free_coherent(&pdev->dev, + QUEUE_SIZE * sizeof(*dev->admin_cqes), + dev->admin_cqes, dev->admin_cq_dma_addr); + return -ENOMEM; + } + lo_hi_writeq(dev->admin_cq_dma_addr, dev->bar + NVME_REG_ACQ); + + writel((QUEUE_SIZE - 1) | ((QUEUE_SIZE - 1) << 16), + dev->bar + NVME_REG_AQA); + return 0; +} + +static void nvme_cmb_free_queues(struct nvme_cmb_dev *dev, struct pci_dev *pdev) +{ + dma_free_coherent(&pdev->dev, QUEUE_SIZE * sizeof(*dev->admin_cqes), + dev->admin_cqes, dev->admin_cq_dma_addr); + dma_free_coherent(&pdev->dev, QUEUE_SIZE * sizeof(*dev->admin_sqes), + dev->admin_sqes, dev->admin_sq_dma_addr); +} + + static int nvme_cmb_probe(struct pci_dev *pdev, const struct pci_device_id *id) { struct nvme_cmb_dev *dev; @@ -39,6 +85,11 @@ static int nvme_cmb_probe(struct pci_dev *pdev, const struct pci_device_id *id) error = -EIO; goto out_iounmap; } + + error = nvme_cmb_alloc_queues(dev, pdev); + if (error) + goto out_iounmap; + dev_set_drvdata(&pdev->dev, dev); return 0; @@ -58,6 +109,7 @@ static void nvme_cmb_remove(struct pci_dev *pdev) { struct nvme_cmb_dev *dev = dev_get_drvdata(&pdev->dev); dev_info(&pdev->dev, "unbinding NVMe device\n"); + nvme_cmb_free_queues(dev, pdev); iounmap(dev->bar); pci_release_mem_regions(pdev); pci_disable_device(pdev); -- 2.39.2 From hch at lst.de Fri Sep 15 16:14:59 2023 From: hch at lst.de (Christoph Hellwig) Date: Fri, 15 Sep 2023 22:14:59 +0200 Subject: [Lkw] PCI driver, part 6 enable the controller Message-ID: <20230915201459.GA1341@lst.de> This sets a bunch of (for us basically magic) values in the config register, and then flip the enable bit and then waits for the controller to be live. On the remove side we also have to shut it down in a similar way. Signed-off-by: Christoph Hellwig --- drivers/block/nvme-cmb.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/drivers/block/nvme-cmb.c b/drivers/block/nvme-cmb.c index 6638a73d4..f072fe2f9 100644 --- a/drivers/block/nvme-cmb.c +++ b/drivers/block/nvme-cmb.c @@ -1,3 +1,4 @@ +#include #include #include #include @@ -14,6 +15,8 @@ struct nvme_cmb_dev { dma_addr_t admin_sq_dma_addr; struct nvme_completion *admin_cqes; dma_addr_t admin_cq_dma_addr; + + u32 cc; }; #define QUEUE_SIZE 2 @@ -55,6 +58,37 @@ static void nvme_cmb_free_queues(struct nvme_cmb_dev *dev, struct pci_dev *pdev) dev->admin_sqes, dev->admin_sq_dma_addr); } +static void nvme_cmb_enable(struct nvme_cmb_dev *dev) +{ + dev->cc = NVME_CC_CSS_NVM | NVME_CC_AMS_RR | + NVME_CC_IOSQES | NVME_CC_IOCQES; + writel(dev->cc, dev->bar + NVME_REG_CC); + + dev->cc |= NVME_CC_ENABLE; + writel(dev->cc, dev->bar + NVME_REG_CC); + while (true) { + u32 csts = readl(dev->bar + NVME_REG_CSTS); + + if (csts & NVME_CSTS_RDY) + break; + usleep_range(1000, 2000); + } +} + +static void nvme_cmb_shutdown(struct nvme_cmb_dev *dev) +{ + dev->cc &= ~NVME_CC_SHN_MASK; + dev->cc |= NVME_CC_SHN_NORMAL; + writel(dev->cc, dev->bar + NVME_REG_CC); + while (true) { + u32 csts = readl(dev->bar + NVME_REG_CSTS); + + if ((csts & NVME_CSTS_SHST_MASK) == NVME_CSTS_SHST_CMPLT) + break; + usleep_range(1000, 2000); + } +} + static int nvme_cmb_probe(struct pci_dev *pdev, const struct pci_device_id *id) { struct nvme_cmb_dev *dev; @@ -89,6 +123,8 @@ static int nvme_cmb_probe(struct pci_dev *pdev, const struct pci_device_id *id) if (error) goto out_iounmap; + nvme_cmb_enable(dev); + dev_set_drvdata(&pdev->dev, dev); return 0; @@ -109,6 +145,7 @@ static void nvme_cmb_remove(struct pci_dev *pdev) dev_info(&pdev->dev, "unbinding NVMe device\n"); + nvme_cmb_shutdown(dev); nvme_cmb_free_queues(dev, pdev); iounmap(dev->bar); pci_release_mem_regions(pdev); -- 2.39.2 From hch at lst.de Fri Sep 15 16:39:24 2023 From: hch at lst.de (Christoph Hellwig) Date: Fri, 15 Sep 2023 22:39:24 +0200 Subject: [Lkw] PCI driver, part 6: enable the controller Message-ID: <20230915203924.GB1341@lst.de> Reply-To: This sets a bunch of (for us basically magic) values in the config register, and then flip the enable bit and then waits for the controller to be live. On the remove side we also have to shut it down in a similar way. Signed-off-by: Christoph Hellwig --- drivers/block/nvme-cmb.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/drivers/block/nvme-cmb.c b/drivers/block/nvme-cmb.c index 6638a73d4..f072fe2f9 100644 --- a/drivers/block/nvme-cmb.c +++ b/drivers/block/nvme-cmb.c @@ -1,3 +1,4 @@ +#include #include #include #include @@ -14,6 +15,8 @@ struct nvme_cmb_dev { dma_addr_t admin_sq_dma_addr; struct nvme_completion *admin_cqes; dma_addr_t admin_cq_dma_addr; + + u32 cc; }; #define QUEUE_SIZE 2 @@ -55,6 +58,37 @@ static void nvme_cmb_free_queues(struct nvme_cmb_dev *dev, struct pci_dev *pdev) dev->admin_sqes, dev->admin_sq_dma_addr); } +static void nvme_cmb_enable(struct nvme_cmb_dev *dev) +{ + dev->cc = NVME_CC_CSS_NVM | NVME_CC_AMS_RR | + NVME_CC_IOSQES | NVME_CC_IOCQES; + writel(dev->cc, dev->bar + NVME_REG_CC); + + dev->cc |= NVME_CC_ENABLE; + writel(dev->cc, dev->bar + NVME_REG_CC); + while (true) { + u32 csts = readl(dev->bar + NVME_REG_CSTS); + + if (csts & NVME_CSTS_RDY) + break; + usleep_range(1000, 2000); + } +} + +static void nvme_cmb_shutdown(struct nvme_cmb_dev *dev) +{ + dev->cc &= ~NVME_CC_SHN_MASK; + dev->cc |= NVME_CC_SHN_NORMAL; + writel(dev->cc, dev->bar + NVME_REG_CC); + while (true) { + u32 csts = readl(dev->bar + NVME_REG_CSTS); + + if ((csts & NVME_CSTS_SHST_MASK) == NVME_CSTS_SHST_CMPLT) + break; + usleep_range(1000, 2000); + } +} + static int nvme_cmb_probe(struct pci_dev *pdev, const struct pci_device_id *id) { struct nvme_cmb_dev *dev; @@ -89,6 +123,8 @@ static int nvme_cmb_probe(struct pci_dev *pdev, const struct pci_device_id *id) if (error) goto out_iounmap; + nvme_cmb_enable(dev); + dev_set_drvdata(&pdev->dev, dev); return 0; @@ -109,6 +145,7 @@ static void nvme_cmb_remove(struct pci_dev *pdev) dev_info(&pdev->dev, "unbinding NVMe device\n"); + nvme_cmb_shutdown(dev); nvme_cmb_free_queues(dev, pdev); iounmap(dev->bar); pci_release_mem_regions(pdev); -- 2.39.2 From hch at lst.de Fri Sep 15 16:54:45 2023 From: hch at lst.de (Christoph Hellwig) Date: Fri, 15 Sep 2023 22:54:45 +0200 Subject: [Lkw] PCI driver, part 7: find and map the CMB Message-ID: <20230915205445.GC1341@lst.de> The NVMe controller memory buffer is essentially just a bit of memory a NVMe device can expose through a PCIe bar. We're going to expose it as a ramdisk. For that we need to read very strangly encoded values about the location from regisers. You're not really supposed to understand this unless you've already dealt with hardware interface before, in which case you understand the horrors. Signed-off-by: Christoph Hellwig --- drivers/block/nvme-cmb.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/drivers/block/nvme-cmb.c b/drivers/block/nvme-cmb.c index f072fe2f9..9858c8afc 100644 --- a/drivers/block/nvme-cmb.c +++ b/drivers/block/nvme-cmb.c @@ -10,6 +10,9 @@ MODULE_LICENSE("GPL"); struct nvme_cmb_dev { void __iomem *bar; + void __iomem *buffer_bar; + size_t buffer_offset; + size_t buffer_size; struct nvme_command *admin_sqes; dma_addr_t admin_sq_dma_addr; @@ -89,6 +92,24 @@ static void nvme_cmb_shutdown(struct nvme_cmb_dev *dev) } } +static int nvme_cmb_map_buffer(struct nvme_cmb_dev *dev, struct pci_dev *pdev) +{ + u32 cmbloc = readl(dev->bar + NVME_REG_CMBLOC); + u32 cmbsz = readl(dev->bar + NVME_REG_CMBSZ); + u64 unit = 1ULL << (12 + 4 * + ((cmbsz >> NVME_CMBSZ_SZU_SHIFT) & + NVME_CMBSZ_SZU_MASK)); + + dev->buffer_bar = pci_ioremap_bar(pdev, NVME_CMB_BIR(cmbloc)); + if (!dev->buffer_bar) + return -ENOMEM; + + dev->buffer_offset = unit * NVME_CMB_OFST(cmbloc); + dev->buffer_size = + unit * ((cmbsz >> NVME_CMBSZ_SZ_SHIFT) & NVME_CMBSZ_SZ_MASK); + return 0; +} + static int nvme_cmb_probe(struct pci_dev *pdev, const struct pci_device_id *id) { struct nvme_cmb_dev *dev; @@ -125,9 +146,18 @@ static int nvme_cmb_probe(struct pci_dev *pdev, const struct pci_device_id *id) nvme_cmb_enable(dev); + error = nvme_cmb_map_buffer(dev, pdev); + if (error) + goto out_shutdown; + dev_set_drvdata(&pdev->dev, dev); + dev_info(&pdev->dev, "added %zu MiB ramdisk\n", + dev->buffer_size / SZ_1M); return 0; +out_shutdown: + nvme_cmb_shutdown(dev); + nvme_cmb_free_queues(dev, pdev); out_iounmap: iounmap(dev->bar); out_release_regions: @@ -145,6 +175,7 @@ static void nvme_cmb_remove(struct pci_dev *pdev) dev_info(&pdev->dev, "unbinding NVMe device\n"); + iounmap(dev->buffer_bar); nvme_cmb_shutdown(dev); nvme_cmb_free_queues(dev, pdev); iounmap(dev->bar); -- 2.39.2 From hch at lst.de Fri Sep 15 17:29:09 2023 From: hch at lst.de (Christoph Hellwig) Date: Fri, 15 Sep 2023 23:29:09 +0200 Subject: [Lkw] PCI driver, part 8: allocate a gendisk Message-ID: <20230915212909.GA6836@lst.de> The simple block layer interface is based around a struct gendisk. We allocate it, set a name and ops, and a (so far fake) size, and register it. Right now the submit_bio routine will simply always return an error, but this allows for the device to actually show up in the system. ] Signed-off-by: Christoph Hellwig --- drivers/block/nvme-cmb.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/drivers/block/nvme-cmb.c b/drivers/block/nvme-cmb.c index 9858c8afc..43603f8c7 100644 --- a/drivers/block/nvme-cmb.c +++ b/drivers/block/nvme-cmb.c @@ -1,3 +1,4 @@ +#include #include #include #include @@ -14,6 +15,8 @@ struct nvme_cmb_dev { size_t buffer_offset; size_t buffer_size; + struct gendisk *disk; + struct nvme_command *admin_sqes; dma_addr_t admin_sq_dma_addr; struct nvme_completion *admin_cqes; @@ -24,6 +27,16 @@ struct nvme_cmb_dev { #define QUEUE_SIZE 2 +static void nvme_cmb_submit_bio(struct bio *bio) +{ + bio_io_error(bio); +} + +static const struct block_device_operations nvme_cmb_ops = { + .owner = THIS_MODULE, + .submit_bio = nvme_cmb_submit_bio, +}; + static int nvme_cmb_alloc_queues(struct nvme_cmb_dev *dev, struct pci_dev *pdev) { dev->admin_sqes = dma_alloc_coherent(&pdev->dev, @@ -150,11 +163,29 @@ static int nvme_cmb_probe(struct pci_dev *pdev, const struct pci_device_id *id) if (error) goto out_shutdown; + dev->disk = blk_alloc_disk(NUMA_NO_NODE); + if (!dev->disk) { + error = -ENOMEM; + goto out_unmap_cmb; + } + dev->disk->private_data = dev; + dev->disk->fops = &nvme_cmb_ops; + set_capacity(dev->disk, SZ_16M >> SECTOR_SHIFT); + snprintf(dev->disk->disk_name, DISK_NAME_LEN, "nc0"); + + error = device_add_disk(&pdev->dev, dev->disk, NULL); + if (error) + goto out_put_disk; + dev_set_drvdata(&pdev->dev, dev); dev_info(&pdev->dev, "added %zu MiB ramdisk\n", dev->buffer_size / SZ_1M); return 0; +out_put_disk: + put_disk(dev->disk); +out_unmap_cmb: + iounmap(dev->buffer_bar); out_shutdown: nvme_cmb_shutdown(dev); nvme_cmb_free_queues(dev, pdev); @@ -175,6 +206,9 @@ static void nvme_cmb_remove(struct pci_dev *pdev) dev_info(&pdev->dev, "unbinding NVMe device\n"); + del_gendisk(dev->disk); + put_disk(dev->disk); + iounmap(dev->buffer_bar); nvme_cmb_shutdown(dev); nvme_cmb_free_queues(dev, pdev); -- 2.39.2 From hch at lst.de Fri Sep 15 17:47:50 2023 From: hch at lst.de (Christoph Hellwig) Date: Fri, 15 Sep 2023 23:47:50 +0200 Subject: [Lkw] PCI driver, part9: implement the I/O handler Message-ID: <20230915214750.GA7682@lst.de> The ->submit_bio method gets the bio structure that describes the I/O passed to it. We use that to find the device we're operating on, the size and length of the I/O, which could be broken into discontiguous buffers, and then just copy it from/to the device memory. Signed-off-by: Christoph Hellwig --- drivers/block/nvme-cmb.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/drivers/block/nvme-cmb.c b/drivers/block/nvme-cmb.c index 43603f8c7..f5a70b8a7 100644 --- a/drivers/block/nvme-cmb.c +++ b/drivers/block/nvme-cmb.c @@ -29,7 +29,23 @@ struct nvme_cmb_dev { static void nvme_cmb_submit_bio(struct bio *bio) { - bio_io_error(bio); + struct nvme_cmb_dev *dev = bio->bi_bdev->bd_disk->private_data; + void __iomem *buffer = dev->buffer_bar + dev->buffer_offset; + struct bvec_iter iter; + struct bio_vec bv; + + bio_for_each_segment(bv, bio, iter) { + void __iomem *dev_addr = buffer + + (iter.bi_sector << SECTOR_SHIFT); + void *kaddr = bvec_virt(&bv); + + if (bio_op(bio) == REQ_OP_READ) + memcpy_fromio(kaddr, dev_addr, bv.bv_len); + else + memcpy_toio(dev_addr, kaddr, bv.bv_len); + } + + bio_endio(bio); } static const struct block_device_operations nvme_cmb_ops = { -- 2.39.2 From franbenedetti14 at gmail.com Fri Sep 15 17:56:02 2023 From: franbenedetti14 at gmail.com (Francisco Benedetti) Date: Fri, 15 Sep 2023 21:56:02 +0000 Subject: [Lkw] [PATCH] [PATCH] Ready #8 Message-ID: <20230915215602.29230-1-franbenedetti14@gmail.com> Allocate a gendisk Signed-off-by: Fran --- drivers/block/nvme-cmb.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/block/nvme-cmb.c b/drivers/block/nvme-cmb.c index 67eb9a04c..3e3be2b62 100644 --- a/drivers/block/nvme-cmb.c +++ b/drivers/block/nvme-cmb.c @@ -8,7 +8,6 @@ #include MODULE_LICENSE("GPL"); - struct nvme_cmb_dev { void __iomem *bar; -- 2.39.2 From franbenedetti14 at gmail.com Fri Sep 15 18:11:40 2023 From: franbenedetti14 at gmail.com (Francisco Benedetti) Date: Fri, 15 Sep 2023 22:11:40 +0000 Subject: [Lkw] [PATCH] [PATCH] Ready #9 Message-ID: <20230915221140.1541-1-franbenedetti14@gmail.com> Implement the I/O handler Signed-off-by: Silexis --- drivers/block/nvme-cmb.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/drivers/block/nvme-cmb.c b/drivers/block/nvme-cmb.c index 3e3be2b62..673640d1f 100644 --- a/drivers/block/nvme-cmb.c +++ b/drivers/block/nvme-cmb.c @@ -29,7 +29,23 @@ struct nvme_cmb_dev static void nvme_cmb_submit_bio(struct bio * bio) { - bio_io_error(bio); + struct nvme_cmb_dev *dev = bio->bi_bdev->bd_disk->private_data; + void __iomem *buffer = dev->buffer_bar + dev->buffer_offset; + struct bvec_iter iter; + struct bio_vec bv; + + bio_for_each_segment(bv, bio, iter) { + void __iomem *dev_addr = buffer + + (iter.bi_sector << SECTOR_SHIFT); + void *kaddr = bvec_virt(&bv); + + if (bio_op(bio) == REQ_OP_READ) + memcpy_fromio(kaddr, dev_addr, bv.bv_len); + else + memcpy_toio(dev_addr, kaddr, bv.bv_len); + } + + bio_endio(bio); } static const struct block_device_operations nvme_cmb_ops = -- 2.39.2 From hch at lst.de Fri Sep 15 18:17:05 2023 From: hch at lst.de (Christoph Hellwig) Date: Sat, 16 Sep 2023 00:17:05 +0200 Subject: [Lkw] Creating a block device Message-ID: <20230915221705.GB7682@lst.de> This shows how to connect the hardware we found to the Linux block layer. **Note**: `If you want to know more about the Linux block layer come to my talk tomorrow. ## Allocating a gendisk The main object in the Linux block layer is called struct gendisk. We need to allocate it, set a things up and then register it. What do we need: - an operations vector that the kernel uses to call into the driver - the name of the disk - the size of the disk What we also really want: - let the private data in the gendisk point to our device structure We set all this up, but stub out the I/O submission handler to always return an error. With this we can re-load the driver, and the /dev/nc0 device should show up, e.g.: ls -l /dev/nc0 lsblk Note that loading the driver will show errors like: [ 4784.867593] Buffer I/O error on dev nc0, logical block 0, async page read [ 4784.868215] Buffer I/O error on dev nc0, logical block 0, async page read [ 4784.868870] nc0: unable to read partition table because all I/O fails. ## Supporting I/O Our I/O is really just copying memory to and from the memory on the NVMe device, so we're basically implementing a driver for a hardware ramdisk. For this we remove the bio_io_error() in nvme_cmb_submit_bio and add a real handler. This handler basically gets the address of the ramdisk from the device structure, then uses the block layer iterator over the bio structure that is passed to it, and then copies between that and the ramdisk on the device. memcpy_fromio / memcpy_toio are special version of memcpy that copy from / to device memory (remember the __iomem annotation from earlier?) Once you've added this function and load the module, you should not set the errors any more. ## Creating a file system Our ramdisk is very small, and that is too small for many modern file systems. But we can create an ext2 file system on it and mount it: mkfs.ext2 /dev/nc0 mkdir /mnt/test mount /dev/nc0 /mnt/test/ dmesg > /mnt/test/dmesg Because the device is now used trying to remove the module will fail: rmmod nvme_cmb So you first have to unmount the file system again: umount /mnt/test Because the device is a ramdisk, the content of the file system will be lost if you reboot. It will survive removing and reloadin the module, because it is a "hardware" ramdisk, and not just one in the kernel, though! From hch at lst.de Fri Sep 15 18:17:43 2023 From: hch at lst.de (Christoph Hellwig) Date: Sat, 16 Sep 2023 00:17:43 +0200 Subject: [Lkw] Final (bonus) tasks Message-ID: <20230915221743.GC7682@lst.de> Now that we have a working driver we can still finish off the last bit. ## Setting a device index Remove the snprintf(dev->disk->disk_name, DISK_NAME_LEN, "nc0"); line? If we had multiple devices, this would give every device the same name. That is a bad idea, and would make device_add_disk fail. What we really need to do is to replace the hard coded 0 with an index. Linux has the "IDA" allocator, that just gives you an index, which can be freed and reused. We can use that to give each device a unique name. ## Sending out the patch series Like we sent the individual patches, you can also send a whole series of patches (Linux likes patches split into logical chunks). E.g. do a git send-email origin/master..HEAD --to hch at lst.de --compose to fire off the editor to write and intro mail, to which the patches are then sent as replies, and send everything to me. I'd suggest you all send to me instead of spamming the list, and I will send one series to the list. ## Kconfig So far we built the nvme-cmb driver unconditionally as a module. Linux is configurable, and we can add an entry to a Kconfig file, in this case drivers/block/Kconfig to allow enabling and disabling it, and build it into the kernel instead of a loadable module. The Makefile then needs to be adapted to use the config variable name. If you try to build the module after the Kconfig option was added, you will see a prompt like this: NVMe CMB ramdisk driver (NVME_CMB) [N/m/y/?] (NEW) Press the 'm' key to build it as a module. If you typed the wrong thing, you need to reconfigure the kernel. You can do that by editing the .config file, or with the menuconfig tool. ## The menuconfig tool (this part is very optional) For that you first need to install ncurses: apt-get install libncurses-dev And then do: make menuconfig This will build and start a configuration menu. Go to "Device Drivers" -> "Block devices" and find "NVMe CMB ramdisk driver" at the very end, you can then type 'm' to build it as a module, or 'y' to build it into the kernel, then press "Save" and write it to the default .config file. In case you build the driver into the kernel, you will have to rebuild the whole kernel, install it and reboot into it to use the driver. From hch at lst.de Fri Sep 15 18:18:29 2023 From: hch at lst.de (Christoph Hellwig) Date: Sat, 16 Sep 2023 00:18:29 +0200 Subject: [Lkw] Bonus 1: allocate a device index Message-ID: <20230915221829.GD7682@lst.de> So far we've just added a 0 postfix to the device name unconditionally. This does not work if there are multiple devices. Use the Linux IDA data structure to allocate and index, and use that for the device name. Signed-off-by: Christoph Hellwig --- drivers/block/nvme-cmb.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/block/nvme-cmb.c b/drivers/block/nvme-cmb.c index f5a70b8a7..13160576f 100644 --- a/drivers/block/nvme-cmb.c +++ b/drivers/block/nvme-cmb.c @@ -1,5 +1,6 @@ #include #include +#include #include #include #include @@ -16,6 +17,7 @@ struct nvme_cmb_dev { size_t buffer_size; struct gendisk *disk; + int index; struct nvme_command *admin_sqes; dma_addr_t admin_sq_dma_addr; @@ -27,6 +29,8 @@ struct nvme_cmb_dev { #define QUEUE_SIZE 2 +static DEFINE_IDA(nvme_cmb_index_ida); + static void nvme_cmb_submit_bio(struct bio *bio) { struct nvme_cmb_dev *dev = bio->bi_bdev->bd_disk->private_data; @@ -187,17 +191,23 @@ static int nvme_cmb_probe(struct pci_dev *pdev, const struct pci_device_id *id) dev->disk->private_data = dev; dev->disk->fops = &nvme_cmb_ops; set_capacity(dev->disk, SZ_16M >> SECTOR_SHIFT); - snprintf(dev->disk->disk_name, DISK_NAME_LEN, "nc0"); + + error = ida_alloc(&nvme_cmb_index_ida, GFP_KERNEL); + if (error < 0) + goto out_put_disk; + snprintf(dev->disk->disk_name, DISK_NAME_LEN, "nc%d", error); error = device_add_disk(&pdev->dev, dev->disk, NULL); if (error) - goto out_put_disk; + goto out_ida_free; dev_set_drvdata(&pdev->dev, dev); dev_info(&pdev->dev, "added %zu MiB ramdisk\n", dev->buffer_size / SZ_1M); return 0; +out_ida_free: + ida_free(&nvme_cmb_index_ida, dev->index); out_put_disk: put_disk(dev->disk); out_unmap_cmb: @@ -224,6 +234,7 @@ static void nvme_cmb_remove(struct pci_dev *pdev) del_gendisk(dev->disk); put_disk(dev->disk); + ida_free(&nvme_cmb_index_ida, dev->index); iounmap(dev->buffer_bar); nvme_cmb_shutdown(dev); -- 2.39.2 From eamanu at riseup.net Fri Sep 15 18:18:36 2023 From: eamanu at riseup.net (Emmanuel Arias) Date: Fri, 15 Sep 2023 22:18:36 +0000 Subject: [Lkw] [PATCH 1/6] add a pci_driver structure Message-ID: <20230915221841.2065-1-eamanu@riseup.net> Signed-off-by: Emmanuel Arias --- drivers/block/nvme-cmb.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/drivers/block/nvme-cmb.c b/drivers/block/nvme-cmb.c index 1e448d836..e98f06ed0 100644 --- a/drivers/block/nvme-cmb.c +++ b/drivers/block/nvme-cmb.c @@ -1,18 +1,44 @@ #include #include #include +#include MODULE_LICENSE("GPL"); +static int nvme_cmb_probe(struct pci_dev *pdev, const struct pci_device_id *id) +{ + dev_info(&pdev->dev, "found NVMe device\n"); + return 0; +} + +static void nvme_cmb_remove(struct pci_dev *pdev) +{ + dev_info(&pdev->dev, "unbinding NVMe device\n"); +} + +static const struct pci_device_id nvme_cmb_id_table[] = { + { PCI_DEVICE_CLASS(PCI_CLASS_STORAGE_EXPRESS, 0xffffff) }, + { 0, } +}; + +static struct pci_driver nvme_cmb_driver = { + .name = "nvme_cmb", + .id_table = nvme_cmb_id_table, + .probe = nvme_cmb_probe, + .remove = nvme_cmb_remove, +}; + + static int __init nvme_cmb_init(void) { pr_info("loading nvme-cmb module\n"); - return 0; + return pci_register_driver(&nvme_cmb_driver); } static void __exit nvme_cmb_exit(void) { pr_info("unloading nvme-cmb module\n"); + pci_unregister_driver(&nvme_cmb_driver); } module_init(nvme_cmb_init); -- 2.39.2 From eamanu at riseup.net Fri Sep 15 18:18:37 2023 From: eamanu at riseup.net (Emmanuel Arias) Date: Fri, 15 Sep 2023 22:18:37 +0000 Subject: [Lkw] [PATCH 2/6] nvme-cmb: add the basic PCI boilerplate code In-Reply-To: <20230915221841.2065-1-eamanu@riseup.net> References: <20230915221841.2065-1-eamanu@riseup.net> Message-ID: <20230915221841.2065-2-eamanu@riseup.net> Set the device into bus mastering mode, enable it and claim the MMIO regions. Signed-off-by: Emmanuel Arias --- drivers/block/nvme-cmb.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/block/nvme-cmb.c b/drivers/block/nvme-cmb.c index e98f06ed0..ea2993c06 100644 --- a/drivers/block/nvme-cmb.c +++ b/drivers/block/nvme-cmb.c @@ -7,13 +7,31 @@ MODULE_LICENSE("GPL"); static int nvme_cmb_probe(struct pci_dev *pdev, const struct pci_device_id *id) { + int error; + dev_info(&pdev->dev, "found NVMe device\n"); + + pci_set_master(pdev); + error = pci_enable_device_mem(pdev); + if (error) + return error; + error = pci_request_mem_regions(pdev, "nvme-cmb"); + if (error) + goto out_disable_device; + return 0; + +out_disable_device: + pci_disable_device(pdev); + return error; } static void nvme_cmb_remove(struct pci_dev *pdev) { dev_info(&pdev->dev, "unbinding NVMe device\n"); + + pci_release_mem_regions(pdev); + pci_disable_device(pdev); } static const struct pci_device_id nvme_cmb_id_table[] = { -- 2.39.2 From eamanu at riseup.net Fri Sep 15 18:18:38 2023 From: eamanu at riseup.net (Emmanuel Arias) Date: Fri, 15 Sep 2023 22:18:38 +0000 Subject: [Lkw] [PATCH 3/6] nvme-pci: map the BAR and check the device is present In-Reply-To: <20230915221841.2065-1-eamanu@riseup.net> References: <20230915221841.2065-1-eamanu@riseup.net> Message-ID: <20230915221841.2065-3-eamanu@riseup.net> part 4 Signed-off-by: Emmanuel Arias --- drivers/block/nvme-cmb.c | 39 +++++++++++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 4 deletions(-) diff --git a/drivers/block/nvme-cmb.c b/drivers/block/nvme-cmb.c index ea2993c06..442695690 100644 --- a/drivers/block/nvme-cmb.c +++ b/drivers/block/nvme-cmb.c @@ -2,36 +2,68 @@ #include #include #include +#include MODULE_LICENSE("GPL"); +struct nvme_cmb_dev { + void __iomem *bar; +}; + static int nvme_cmb_probe(struct pci_dev *pdev, const struct pci_device_id *id) { + struct nvme_cmb_dev *dev; int error; dev_info(&pdev->dev, "found NVMe device\n"); - + + dev = kzalloc(sizeof(*dev), GFP_KERNEL); + if (!dev) + return -ENOMEM; + pci_set_master(pdev); error = pci_enable_device_mem(pdev); if (error) - return error; + goto out_free_dev; error = pci_request_mem_regions(pdev, "nvme-cmb"); if (error) goto out_disable_device; - + + dev->bar = pci_ioremap_bar(pdev, 0); + if (!dev->bar) { + error = -ENOMEM; + goto out_release_regions; + } + + if (readl(dev->bar + NVME_REG_CSTS) == ~0) { + error = -EIO; + goto out_iounmap; + } + + dev_set_drvdata(&pdev->dev, dev); return 0; +out_iounmap: + iounmap(dev->bar); +out_release_regions: + pci_release_mem_regions(dev); out_disable_device: pci_disable_device(pdev); +out_free_dev: + kfree(dev); return error; } static void nvme_cmb_remove(struct pci_dev *pdev) { + struct nvme_cmb_dev *dev = dev_get_drvdata(&pdev->dev); + dev_info(&pdev->dev, "unbinding NVMe device\n"); + iounmap(dev->bar); pci_release_mem_regions(pdev); pci_disable_device(pdev); + kfree(dev); } static const struct pci_device_id nvme_cmb_id_table[] = { @@ -46,7 +78,6 @@ static struct pci_driver nvme_cmb_driver = { .remove = nvme_cmb_remove, }; - static int __init nvme_cmb_init(void) { pr_info("loading nvme-cmb module\n"); -- 2.39.2 From eamanu at riseup.net Fri Sep 15 18:18:39 2023 From: eamanu at riseup.net (Emmanuel Arias) Date: Fri, 15 Sep 2023 22:18:39 +0000 Subject: [Lkw] [PATCH 4/6] part-5 In-Reply-To: <20230915221841.2065-1-eamanu@riseup.net> References: <20230915221841.2065-1-eamanu@riseup.net> Message-ID: <20230915221841.2065-4-eamanu@riseup.net> Signed-off-by: Emmanuel Arias --- drivers/block/nvme-cmb.c | 52 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/drivers/block/nvme-cmb.c b/drivers/block/nvme-cmb.c index 442695690..04053ef74 100644 --- a/drivers/block/nvme-cmb.c +++ b/drivers/block/nvme-cmb.c @@ -3,13 +3,58 @@ #include #include #include +#include MODULE_LICENSE("GPL"); struct nvme_cmb_dev { void __iomem *bar; + + struct nvme_command *admin_sqes; + dma_addr_t admin_sq_dma_addr; + struct nvme_completion *admin_cqes; + dma_addr_t admin_cq_dma_addr; }; +#define QUEUE_SIZE 2 + +static int nvme_cmb_alloc_queues(struct nvme_cmb_dev *dev, struct pci_dev *pdev) +{ + dev->admin_sqes = dma_alloc_coherent(&pdev->dev, + QUEUE_SIZE * + sizeof(*dev->admin_sqes), + &dev->admin_sq_dma_addr, + GFP_KERNEL); + if (!dev->admin_sqes) + return -ENOMEM; + lo_hi_writeq(dev->admin_sq_dma_addr, dev->bar + NVME_REG_ASQ); + + dev->admin_cqes = dma_alloc_coherent(&pdev->dev, + QUEUE_SIZE * + sizeof(*dev->admin_cqes), + &dev->admin_cq_dma_addr, + GFP_KERNEL); + if (!dev->admin_cqes) { + dma_free_coherent(&pdev->dev, + QUEUE_SIZE * sizeof(*dev->admin_cqes), + dev->admin_cqes, dev->admin_cq_dma_addr); + return -ENOMEM; + } + lo_hi_writeq(dev->admin_cq_dma_addr, dev->bar + NVME_REG_ACQ); + + writel((QUEUE_SIZE - 1) | ((QUEUE_SIZE - 1) << 16), + dev->bar + NVME_REG_AQA); + return 0; +} + +static void nvme_cmb_free_queues(struct nvme_cmb_dev *dev, struct pci_dev *pdev) +{ + dma_free_coherent(&pdev->dev, QUEUE_SIZE * sizeof(*dev->admin_cqes), + dev->admin_cqes, dev->admin_cq_dma_addr); + dma_free_coherent(&pdev->dev, QUEUE_SIZE * sizeof(*dev->admin_sqes), + dev->admin_sqes, dev->admin_sq_dma_addr); +} + static int nvme_cmb_probe(struct pci_dev *pdev, const struct pci_device_id *id) { struct nvme_cmb_dev *dev; @@ -40,13 +85,17 @@ static int nvme_cmb_probe(struct pci_dev *pdev, const struct pci_device_id *id) goto out_iounmap; } + error = nvme_cmb_alloc_queues(dev, pdev); + if (error) + goto out_iounmap; + dev_set_drvdata(&pdev->dev, dev); return 0; out_iounmap: iounmap(dev->bar); out_release_regions: - pci_release_mem_regions(dev); + pci_release_mem_regions(pdev); out_disable_device: pci_disable_device(pdev); out_free_dev: @@ -60,6 +109,7 @@ static void nvme_cmb_remove(struct pci_dev *pdev) dev_info(&pdev->dev, "unbinding NVMe device\n"); + nvme_cmb_free_queues(dev, pdev); iounmap(dev->bar); pci_release_mem_regions(pdev); pci_disable_device(pdev); -- 2.39.2 From eamanu at riseup.net Fri Sep 15 18:18:40 2023 From: eamanu at riseup.net (Emmanuel Arias) Date: Fri, 15 Sep 2023 22:18:40 +0000 Subject: [Lkw] [PATCH 5/6] part-7 In-Reply-To: <20230915221841.2065-1-eamanu@riseup.net> References: <20230915221841.2065-1-eamanu@riseup.net> Message-ID: <20230915221841.2065-5-eamanu@riseup.net> Signed-off-by: Emmanuel Arias --- drivers/block/nvme-cmb.c | 69 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 68 insertions(+), 1 deletion(-) diff --git a/drivers/block/nvme-cmb.c b/drivers/block/nvme-cmb.c index 04053ef74..324e23327 100644 --- a/drivers/block/nvme-cmb.c +++ b/drivers/block/nvme-cmb.c @@ -1,5 +1,6 @@ -#include +#include #include +#include #include #include #include @@ -9,11 +10,16 @@ MODULE_LICENSE("GPL"); struct nvme_cmb_dev { void __iomem *bar; + void __iomem *buffer_bar; + size_t buffer_offset; + size_t buffer_size; struct nvme_command *admin_sqes; dma_addr_t admin_sq_dma_addr; struct nvme_completion *admin_cqes; dma_addr_t admin_cq_dma_addr; + + u32 cc; }; #define QUEUE_SIZE 2 @@ -55,6 +61,54 @@ static void nvme_cmb_free_queues(struct nvme_cmb_dev *dev, struct pci_dev *pdev) dev->admin_sqes, dev->admin_sq_dma_addr); } +static void nvme_cmb_enable(struct nvme_cmb_dev *dev) +{ + dev->cc = NVME_CC_CSS_NVM | NVME_CC_AMS_RR | + NVME_CC_IOSQES | NVME_CC_IOCQES; + writel(dev->cc, dev->bar + NVME_REG_CC); + + dev->cc |= NVME_CC_ENABLE; + writel(dev->cc, dev->bar + NVME_REG_CC); + while (true) { + u32 csts = readl(dev->bar + NVME_REG_CSTS); + + if (csts & NVME_CSTS_RDY) + break; + usleep_range(1000, 2000); + } +} + +static void nvme_cmb_shutdown(struct nvme_cmb_dev *dev) +{ + dev->cc &= ~NVME_CC_SHN_MASK; + dev->cc |= NVME_CC_SHN_NORMAL; + writel(dev->cc, dev->bar + NVME_REG_CC); + while (true) { + u32 csts = readl(dev->bar + NVME_REG_CSTS); + + if ((csts & NVME_CSTS_SHST_MASK) == NVME_CSTS_SHST_CMPLT) + break; + usleep_range(1000, 2000); + } +} + +static int nvme_cmb_map_buffer(struct nvme_cmb_dev *dev, struct pci_dev *pdev) +{ + u32 cmbloc = readl(dev->bar + NVME_REG_CMBLOC); + u32 cmbsz = readl(dev->bar + NVME_REG_CMBSZ); + u64 unit = 1ULL << (12 + 4 * + ((cmbsz >> NVME_CMBSZ_SZU_SHIFT) & + NVME_CMBSZ_SZU_MASK)); + + dev->buffer_bar = pci_ioremap_bar(pdev, NVME_CMB_BIR(cmbloc)); + if (!dev->buffer_bar) + return -ENOMEM; + dev->buffer_offset = unit * NVME_CMB_OFST(cmbloc); + dev->buffer_size = + unit * ((cmbsz >> NVME_CMBSZ_SZ_SHIFT) & NVME_CMBSZ_SZ_MASK); + return 0; +} + static int nvme_cmb_probe(struct pci_dev *pdev, const struct pci_device_id *id) { struct nvme_cmb_dev *dev; @@ -89,9 +143,20 @@ static int nvme_cmb_probe(struct pci_dev *pdev, const struct pci_device_id *id) if (error) goto out_iounmap; + nvme_cmb_enable(dev); + + error = nvme_cmb_map_buffer(dev, pdev); + if (error) + goto out_shutdown; + dev_set_drvdata(&pdev->dev, dev); + dev_info(&pdev->dev, "added %zu MiB ramdisk\n", + dev->buffer_size / SZ_1M); return 0; +out_shutdown: + nvme_cmb_shutdown(dev); + nvme_cmb_free_queues(dev, pdev); out_iounmap: iounmap(dev->bar); out_release_regions: @@ -109,6 +174,8 @@ static void nvme_cmb_remove(struct pci_dev *pdev) dev_info(&pdev->dev, "unbinding NVMe device\n"); + iounmap(dev->buffer_bar); + nvme_cmb_shutdown(dev); nvme_cmb_free_queues(dev, pdev); iounmap(dev->bar); pci_release_mem_regions(pdev); -- 2.39.2 From eamanu at riseup.net Fri Sep 15 18:18:41 2023 From: eamanu at riseup.net (Emmanuel Arias) Date: Fri, 15 Sep 2023 22:18:41 +0000 Subject: [Lkw] [PATCH 6/6] part-8 In-Reply-To: <20230915221841.2065-1-eamanu@riseup.net> References: <20230915221841.2065-1-eamanu@riseup.net> Message-ID: <20230915221841.2065-6-eamanu@riseup.net> Signed-off-by: Emmanuel Arias --- drivers/block/nvme-cmb.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/drivers/block/nvme-cmb.c b/drivers/block/nvme-cmb.c index 324e23327..73080c731 100644 --- a/drivers/block/nvme-cmb.c +++ b/drivers/block/nvme-cmb.c @@ -1,3 +1,4 @@ +#include #include #include #include @@ -14,6 +15,8 @@ struct nvme_cmb_dev { size_t buffer_offset; size_t buffer_size; + struct gendisk *disk; + struct nvme_command *admin_sqes; dma_addr_t admin_sq_dma_addr; struct nvme_completion *admin_cqes; @@ -24,6 +27,16 @@ struct nvme_cmb_dev { #define QUEUE_SIZE 2 +static void nvme_cmb_submit_bio(struct bio *bio) +{ + bio_io_error(bio); +} + +static const struct block_device_operations nvme_cmb_ops = { + .owner = THIS_MODULE, + .submit_bio = nvme_cmb_submit_bio, +}; + static int nvme_cmb_alloc_queues(struct nvme_cmb_dev *dev, struct pci_dev *pdev) { dev->admin_sqes = dma_alloc_coherent(&pdev->dev, @@ -149,11 +162,29 @@ static int nvme_cmb_probe(struct pci_dev *pdev, const struct pci_device_id *id) if (error) goto out_shutdown; + dev->disk = blk_alloc_disk(NUMA_NO_NODE); + if (!dev->disk) { + error = -ENOMEM; + goto out_unmap_cmb; + } + dev->disk->private_data = dev; + dev->disk->fops = &nvme_cmb_ops; + set_capacity(dev->disk, SZ_16M >> SECTOR_SHIFT); + snprintf(dev->disk->disk_name, DISK_NAME_LEN, "nc0"); + + error = device_add_disk(&pdev->dev, dev->disk, NULL); + if (error) + goto out_put_disk; + dev_set_drvdata(&pdev->dev, dev); dev_info(&pdev->dev, "added %zu MiB ramdisk\n", dev->buffer_size / SZ_1M); return 0; +out_put_disk: + put_disk(dev->disk); +out_unmap_cmb: + iounmap(dev->buffer_bar); out_shutdown: nvme_cmb_shutdown(dev); nvme_cmb_free_queues(dev, pdev); @@ -174,6 +205,9 @@ static void nvme_cmb_remove(struct pci_dev *pdev) dev_info(&pdev->dev, "unbinding NVMe device\n"); + del_gendisk(dev->disk); + put_disk(dev->disk); + iounmap(dev->buffer_bar); nvme_cmb_shutdown(dev); nvme_cmb_free_queues(dev, pdev); -- 2.39.2 From felipemonterobruni at unc.edu.ar Fri Sep 15 18:21:30 2023 From: felipemonterobruni at unc.edu.ar (felipx) Date: Fri, 15 Sep 2023 22:21:30 +0000 Subject: [Lkw] [PATCH] nvme-cmb: Path 9! :) Message-ID: <20230915222130.10526-1-felipemonterobruni@gmail.com> Kind of working nvme driver. Signed-off-by: Your Name --- drivers/block/nvme-cmb.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/drivers/block/nvme-cmb.c b/drivers/block/nvme-cmb.c index 5f1fe1549..2bd91c648 100644 --- a/drivers/block/nvme-cmb.c +++ b/drivers/block/nvme-cmb.c @@ -26,7 +26,23 @@ struct nvme_cmb_dev { static void nvme_cmb_submit_bio(struct bio *bio) { - bio_io_error(bio); + struct nvme_cmb_dev *dev = bio->bi_bdev->bd_disk->private_data; + void __iomem *buffer = dev->buffer_bar + dev->buffer_offset; + struct bvec_iter iter; + struct bio_vec bv; + + bio_for_each_segment(bv, bio, iter) { + void __iomem *dev_addr = buffer + + (iter.bi_sector << SECTOR_SHIFT); + void *kaddr = bvec_virt(&bv); + + if (bio_op(bio) == REQ_OP_READ) + memcpy_fromio(kaddr, dev_addr, bv.bv_len); + else + memcpy_toio(dev_addr, kaddr, bv.bv_len); + } + + bio_endio(bio); } static const struct block_device_operations nvme_cmb_ops = { @@ -112,8 +128,7 @@ static int nvme_cmb_map_buffer(struct nvme_cmb_dev *dev, struct pci_dev *pdev) return -ENOMEM; dev->buffer_offset = unit * NVME_CMB_OFST(cmbloc); - dev->buffer_size = - unit * ((cmbsz >> NVME_CMBSZ_SZ_SHIFT) & NVME_CMBSZ_SZ_MASK); + dev->buffer_size = unit * ((cmbsz >> NVME_CMBSZ_SZ_SHIFT) & NVME_CMBSZ_SZ_MASK); return 0; } @@ -237,4 +252,4 @@ static void __exit nvme_cmb_exit(void) } module_init(nvme_cmb_init); -module_exit(nvme_cmb_exit); +module_exit(nvme_cmb_exit); \ No newline at end of file -- 2.39.2 From hch at lst.de Fri Sep 15 18:24:14 2023 From: hch at lst.de (Christoph Hellwig) Date: Sat, 16 Sep 2023 00:24:14 +0200 Subject: [Lkw] Bonus 2: wire up to Kconfig Message-ID: <20230915222414.GE7682@lst.de> Instead of unconditionally build the nvme-cmb driver as a module, add a Kconfig entry and make the build conditional on it. Signed-off-by: Christoph Hellwig --- drivers/block/Kconfig | 6 ++++++ drivers/block/Makefile | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig index 5b9d4aaeb..29aa857e6 100644 --- a/drivers/block/Kconfig +++ b/drivers/block/Kconfig @@ -404,4 +404,10 @@ config BLKDEV_UBLK_LEGACY_OPCODES source "drivers/block/rnbd/Kconfig" +config NVME_CMB + tristate "NVMe CMB ramdisk driver" + help + This driver exports the controller memory buffer of a NVMe controller + that supports this driver as a ramdisk. + endif # BLK_DEV diff --git a/drivers/block/Makefile b/drivers/block/Makefile index 3ad5dcb18..8d8695fa6 100644 --- a/drivers/block/Makefile +++ b/drivers/block/Makefile @@ -41,4 +41,4 @@ obj-$(CONFIG_BLK_DEV_UBLK) += ublk_drv.o swim_mod-y := swim.o swim_asm.o -obj-m += nvme-cmb.o +obj-$(CONFIG_NVME_CMB) += nvme-cmb.o -- 2.39.2 From damian.gonzalez at mi.unc.edu.ar Fri Sep 15 18:32:48 2023 From: damian.gonzalez at mi.unc.edu.ar (Damian Gonzalez) Date: Fri, 15 Sep 2023 22:32:48 +0000 Subject: [Lkw] [PATCH 01/10] nvme-cmb: added minimal functionality on loading and unloading Message-ID: <20230915223257.698-1-damian.gonzalez@mi.unc.edu.ar> Logs the load and unload of the module. Signed-off-by: Damian Gonzalez --- drivers/block/Makefile | 2 ++ drivers/block/nvme-cmb.c | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 drivers/block/nvme-cmb.c diff --git a/drivers/block/Makefile b/drivers/block/Makefile index 101612cba..3ad5dcb18 100644 --- a/drivers/block/Makefile +++ b/drivers/block/Makefile @@ -40,3 +40,5 @@ obj-$(CONFIG_BLK_DEV_NULL_BLK) += null_blk/ obj-$(CONFIG_BLK_DEV_UBLK) += ublk_drv.o swim_mod-y := swim.o swim_asm.o + +obj-m += nvme-cmb.o diff --git a/drivers/block/nvme-cmb.c b/drivers/block/nvme-cmb.c new file mode 100644 index 000000000..e11aae5a8 --- /dev/null +++ b/drivers/block/nvme-cmb.c @@ -0,0 +1,18 @@ +#include +MODULE_LICENSE("GPL"); +#include +#include + +static int __init nvme_cmb_init(void) +{ + pr_info("loading nvme-cmb module\n"); + return 0; +} + +static void __exit nvme_cmb_exit(void) +{ + pr_info("unloading nvme-cmb module\n"); +} + +module_init(nvme_cmb_init); +module_exit(nvme_cmb_exit); -- 2.39.2 From damian.gonzalez at mi.unc.edu.ar Fri Sep 15 18:32:49 2023 From: damian.gonzalez at mi.unc.edu.ar (Damian Gonzalez) Date: Fri, 15 Sep 2023 22:32:49 +0000 Subject: [Lkw] [PATCH 02/10] nvme-cmb: Introducing PIC-driver for NVMe In-Reply-To: <20230915223257.698-1-damian.gonzalez@mi.unc.edu.ar> References: <20230915223257.698-1-damian.gonzalez@mi.unc.edu.ar> Message-ID: <20230915223257.698-2-damian.gonzalez@mi.unc.edu.ar> Signed-off-by: Damian Gonzalez --- drivers/block/nvme-cmb.c | 37 ++++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/drivers/block/nvme-cmb.c b/drivers/block/nvme-cmb.c index e11aae5a8..b57c86ba4 100644 --- a/drivers/block/nvme-cmb.c +++ b/drivers/block/nvme-cmb.c @@ -1,17 +1,44 @@ -#include -MODULE_LICENSE("GPL"); #include +#include #include +#include -static int __init nvme_cmb_init(void) +MODULE_LICENSE("GPL"); + +static int nvme_cmb_probe(struct pci_dev *pdev, const struct pci_device_id *id) { - pr_info("loading nvme-cmb module\n"); + dev_info(&pdev->dev, "found NVMe device\n"); return 0; } +static void nvme_cmb_remove(struct pci_dev *pdev) +{ + dev_info(&pdev->dev, "unbinding NVMe device\n"); +} + +static const struct pci_device_id nvme_cmb_id_table[] = { + { PCI_DEVICE_CLASS(PCI_CLASS_STORAGE_EXPRESS, 0xffffff) }, + { 0, } +}; + +static struct pci_driver nvme_cmb_driver = { + .name = "nvme_cmb", + .id_table = nvme_cmb_id_table, + .probe = nvme_cmb_probe, + .remove = nvme_cmb_remove, +}; + + +static int __init nvme_cmb_init(void) +{ + pr_info("loading nvme-cmb module\n"); + return pci_register_driver(&nvme_cmb_driver); +} + static void __exit nvme_cmb_exit(void) { - pr_info("unloading nvme-cmb module\n"); + pr_info("unloading nvme-cmb module\n"); + pci_unregister_driver(&nvme_cmb_driver); } module_init(nvme_cmb_init); -- 2.39.2 From damian.gonzalez at mi.unc.edu.ar Fri Sep 15 18:32:50 2023 From: damian.gonzalez at mi.unc.edu.ar (Damian Gonzalez) Date: Fri, 15 Sep 2023 22:32:50 +0000 Subject: [Lkw] [PATCH 03/10] nvme-cmb: PCI driver for NVMe patch 2 In-Reply-To: <20230915223257.698-1-damian.gonzalez@mi.unc.edu.ar> References: <20230915223257.698-1-damian.gonzalez@mi.unc.edu.ar> Message-ID: <20230915223257.698-3-damian.gonzalez@mi.unc.edu.ar> Error managment introduced. Signed-off-by: Damian Gonzalez --- drivers/block/nvme-cmb.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/block/nvme-cmb.c b/drivers/block/nvme-cmb.c index b57c86ba4..c2b964e07 100644 --- a/drivers/block/nvme-cmb.c +++ b/drivers/block/nvme-cmb.c @@ -7,13 +7,31 @@ MODULE_LICENSE("GPL"); static int nvme_cmb_probe(struct pci_dev *pdev, const struct pci_device_id *id) { + int error; + dev_info(&pdev->dev, "found NVMe device\n"); + + pci_set_master(pdev); + error = pci_enable_device_mem(pdev); + if (error) + return error; + error = pci_request_mem_regions(pdev, "nvme-cmb"); + if (error) + goto out_disable_device; + return 0; + +out_disable_device: + pci_disable_device(pdev); + return error; } static void nvme_cmb_remove(struct pci_dev *pdev) { dev_info(&pdev->dev, "unbinding NVMe device\n"); + + pci_release_mem_regions(pdev); + pci_disable_device(pdev); } static const struct pci_device_id nvme_cmb_id_table[] = { -- 2.39.2 From damian.gonzalez at mi.unc.edu.ar Fri Sep 15 18:32:51 2023 From: damian.gonzalez at mi.unc.edu.ar (Damian Gonzalez) Date: Fri, 15 Sep 2023 22:32:51 +0000 Subject: [Lkw] [PATCH 04/10] nvme-cmb: Dynamic mem alloc and free for NVMe In-Reply-To: <20230915223257.698-1-damian.gonzalez@mi.unc.edu.ar> References: <20230915223257.698-1-damian.gonzalez@mi.unc.edu.ar> Message-ID: <20230915223257.698-4-damian.gonzalez@mi.unc.edu.ar> Signed-off-by: Damian Gonzalez --- drivers/block/nvme-cmb.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/drivers/block/nvme-cmb.c b/drivers/block/nvme-cmb.c index c2b964e07..381b98510 100644 --- a/drivers/block/nvme-cmb.c +++ b/drivers/block/nvme-cmb.c @@ -5,33 +5,47 @@ MODULE_LICENSE("GPL"); +struct nvme_cmb_dev { +}; + static int nvme_cmb_probe(struct pci_dev *pdev, const struct pci_device_id *id) { + struct nvme_cmb_dev *dev; int error; dev_info(&pdev->dev, "found NVMe device\n"); + dev = kzalloc(sizeof(*dev), GFP_KERNEL); + if (!dev) + return -ENOMEM; + pci_set_master(pdev); error = pci_enable_device_mem(pdev); if (error) - return error; + goto out_free_dev; error = pci_request_mem_regions(pdev, "nvme-cmb"); if (error) goto out_disable_device; + dev_set_drvdata(&pdev->dev, dev); return 0; out_disable_device: pci_disable_device(pdev); +out_free_dev: + kfree(dev); return error; } static void nvme_cmb_remove(struct pci_dev *pdev) { + struct nvme_cmb_dev *dev = dev_get_drvdata(&pdev->dev); + dev_info(&pdev->dev, "unbinding NVMe device\n"); pci_release_mem_regions(pdev); pci_disable_device(pdev); + kfree(dev); } static const struct pci_device_id nvme_cmb_id_table[] = { -- 2.39.2 From damian.gonzalez at mi.unc.edu.ar Fri Sep 15 18:32:52 2023 From: damian.gonzalez at mi.unc.edu.ar (Damian Gonzalez) Date: Fri, 15 Sep 2023 22:32:52 +0000 Subject: [Lkw] [PATCH 05/10] nvme-cmb: Patch #4, Interfacing with hardware In-Reply-To: <20230915223257.698-1-damian.gonzalez@mi.unc.edu.ar> References: <20230915223257.698-1-damian.gonzalez@mi.unc.edu.ar> Message-ID: <20230915223257.698-5-damian.gonzalez@mi.unc.edu.ar> Signed-off-by: Damian Gonzalez --- drivers/block/nvme-cmb.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/drivers/block/nvme-cmb.c b/drivers/block/nvme-cmb.c index 381b98510..3e600e82c 100644 --- a/drivers/block/nvme-cmb.c +++ b/drivers/block/nvme-cmb.c @@ -2,10 +2,12 @@ #include #include #include +#include MODULE_LICENSE("GPL"); struct nvme_cmb_dev { + void __iomem *bar; }; static int nvme_cmb_probe(struct pci_dev *pdev, const struct pci_device_id *id) @@ -27,9 +29,23 @@ static int nvme_cmb_probe(struct pci_dev *pdev, const struct pci_device_id *id) if (error) goto out_disable_device; + dev->bar = pci_ioremap_bar(pdev, 0); + if (!dev->bar) { + error = -ENOMEM; + goto out_release_regions; + } + + if (readl(dev->bar + NVME_REG_CSTS) == ~0) { + error = -EIO; + goto out_iounmap; + } dev_set_drvdata(&pdev->dev, dev); return 0; +out_iounmap: + iounmap(dev->bar); +out_release_regions: + pci_release_mem_regions(pdev); out_disable_device: pci_disable_device(pdev); out_free_dev: @@ -43,6 +59,7 @@ static void nvme_cmb_remove(struct pci_dev *pdev) dev_info(&pdev->dev, "unbinding NVMe device\n"); + iounmap(dev->bar); pci_release_mem_regions(pdev); pci_disable_device(pdev); kfree(dev); -- 2.39.2 From damian.gonzalez at mi.unc.edu.ar Fri Sep 15 18:32:53 2023 From: damian.gonzalez at mi.unc.edu.ar (Damian Gonzalez) Date: Fri, 15 Sep 2023 22:32:53 +0000 Subject: [Lkw] [PATCH 06/10] nvme-cmb: Patch #5 making the wheel roll In-Reply-To: <20230915223257.698-1-damian.gonzalez@mi.unc.edu.ar> References: <20230915223257.698-1-damian.gonzalez@mi.unc.edu.ar> Message-ID: <20230915223257.698-6-damian.gonzalez@mi.unc.edu.ar> Signed-off-by: Damian Gonzalez --- drivers/block/nvme-cmb.c | 51 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/drivers/block/nvme-cmb.c b/drivers/block/nvme-cmb.c index 3e600e82c..4c2787f2e 100644 --- a/drivers/block/nvme-cmb.c +++ b/drivers/block/nvme-cmb.c @@ -3,13 +3,58 @@ #include #include #include +#include MODULE_LICENSE("GPL"); struct nvme_cmb_dev { void __iomem *bar; + + struct nvme_command *admin_sqes; + dma_addr_t admin_sq_dma_addr; + struct nvme_completion *admin_cqes; + dma_addr_t admin_cq_dma_addr; }; +#define QUEUE_SIZE 2 + +static int nvme_cmb_alloc_queues(struct nvme_cmb_dev *dev, struct pci_dev *pdev) +{ + dev->admin_sqes = dma_alloc_coherent(&pdev->dev, + QUEUE_SIZE * + sizeof(*dev->admin_sqes), + &dev->admin_sq_dma_addr, + GFP_KERNEL); + if (!dev->admin_sqes) + return -ENOMEM; + lo_hi_writeq(dev->admin_sq_dma_addr, dev->bar + NVME_REG_ASQ); + + dev->admin_cqes = dma_alloc_coherent(&pdev->dev, + QUEUE_SIZE * + sizeof(*dev->admin_cqes), + &dev->admin_cq_dma_addr, + GFP_KERNEL); + if (!dev->admin_cqes) { + dma_free_coherent(&pdev->dev, + QUEUE_SIZE * sizeof(*dev->admin_cqes), + dev->admin_cqes, dev->admin_cq_dma_addr); + return -ENOMEM; + } + lo_hi_writeq(dev->admin_cq_dma_addr, dev->bar + NVME_REG_ACQ); + + writel((QUEUE_SIZE - 1) | ((QUEUE_SIZE - 1) << 16), + dev->bar + NVME_REG_AQA); + return 0; +} + +static void nvme_cmb_free_queues(struct nvme_cmb_dev *dev, struct pci_dev *pdev) +{ + dma_free_coherent(&pdev->dev, QUEUE_SIZE * sizeof(*dev->admin_cqes), + dev->admin_cqes, dev->admin_cq_dma_addr); + dma_free_coherent(&pdev->dev, QUEUE_SIZE * sizeof(*dev->admin_sqes), + dev->admin_sqes, dev->admin_sq_dma_addr); +} + static int nvme_cmb_probe(struct pci_dev *pdev, const struct pci_device_id *id) { struct nvme_cmb_dev *dev; @@ -39,6 +84,11 @@ static int nvme_cmb_probe(struct pci_dev *pdev, const struct pci_device_id *id) error = -EIO; goto out_iounmap; } + + error = nvme_cmb_alloc_queues(dev, pdev); + if (error) + goto out_iounmap; + dev_set_drvdata(&pdev->dev, dev); return 0; @@ -59,6 +109,7 @@ static void nvme_cmb_remove(struct pci_dev *pdev) dev_info(&pdev->dev, "unbinding NVMe device\n"); + nvme_cmb_free_queues(dev, pdev); iounmap(dev->bar); pci_release_mem_regions(pdev); pci_disable_device(pdev); -- 2.39.2 From damian.gonzalez at mi.unc.edu.ar Fri Sep 15 18:32:54 2023 From: damian.gonzalez at mi.unc.edu.ar (Damian Gonzalez) Date: Fri, 15 Sep 2023 22:32:54 +0000 Subject: [Lkw] [PATCH 07/10] nvme-cmb: Patch #6 In-Reply-To: <20230915223257.698-1-damian.gonzalez@mi.unc.edu.ar> References: <20230915223257.698-1-damian.gonzalez@mi.unc.edu.ar> Message-ID: <20230915223257.698-7-damian.gonzalez@mi.unc.edu.ar> More func added. Signed-off-by: Damian Gonzalez --- drivers/block/nvme-cmb.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/drivers/block/nvme-cmb.c b/drivers/block/nvme-cmb.c index 4c2787f2e..cf238b473 100644 --- a/drivers/block/nvme-cmb.c +++ b/drivers/block/nvme-cmb.c @@ -1,3 +1,4 @@ +#include #include #include #include @@ -14,6 +15,8 @@ struct nvme_cmb_dev { dma_addr_t admin_sq_dma_addr; struct nvme_completion *admin_cqes; dma_addr_t admin_cq_dma_addr; + + u32 cc; }; #define QUEUE_SIZE 2 @@ -55,6 +58,37 @@ static void nvme_cmb_free_queues(struct nvme_cmb_dev *dev, struct pci_dev *pdev) dev->admin_sqes, dev->admin_sq_dma_addr); } +static void nvme_cmb_enable(struct nvme_cmb_dev *dev) +{ + dev->cc = NVME_CC_CSS_NVM | NVME_CC_AMS_RR | + NVME_CC_IOSQES | NVME_CC_IOCQES; + writel(dev->cc, dev->bar + NVME_REG_CC); + + dev->cc |= NVME_CC_ENABLE; + writel(dev->cc, dev->bar + NVME_REG_CC); + while (true) { + u32 csts = readl(dev->bar + NVME_REG_CSTS); + + if (csts & NVME_CSTS_RDY) + break; + usleep_range(1000, 2000); + } +} + +static void nvme_cmb_shutdown(struct nvme_cmb_dev *dev) +{ + dev->cc &= ~NVME_CC_SHN_MASK; + dev->cc |= NVME_CC_SHN_NORMAL; + writel(dev->cc, dev->bar + NVME_REG_CC); + while (true) { + u32 csts = readl(dev->bar + NVME_REG_CSTS); + + if ((csts & NVME_CSTS_SHST_MASK) == NVME_CSTS_SHST_CMPLT) + break; + usleep_range(1000, 2000); + } +} + static int nvme_cmb_probe(struct pci_dev *pdev, const struct pci_device_id *id) { struct nvme_cmb_dev *dev; @@ -89,6 +123,8 @@ static int nvme_cmb_probe(struct pci_dev *pdev, const struct pci_device_id *id) if (error) goto out_iounmap; + nvme_cmb_enable(dev); + dev_set_drvdata(&pdev->dev, dev); return 0; @@ -109,6 +145,7 @@ static void nvme_cmb_remove(struct pci_dev *pdev) dev_info(&pdev->dev, "unbinding NVMe device\n"); + nvme_cmb_shutdown(dev); nvme_cmb_free_queues(dev, pdev); iounmap(dev->bar); pci_release_mem_regions(pdev); -- 2.39.2 From damian.gonzalez at mi.unc.edu.ar Fri Sep 15 18:32:55 2023 From: damian.gonzalez at mi.unc.edu.ar (Damian Gonzalez) Date: Fri, 15 Sep 2023 22:32:55 +0000 Subject: [Lkw] [PATCH 08/10] nvme-cmb: Patch #7 In-Reply-To: <20230915223257.698-1-damian.gonzalez@mi.unc.edu.ar> References: <20230915223257.698-1-damian.gonzalez@mi.unc.edu.ar> Message-ID: <20230915223257.698-8-damian.gonzalez@mi.unc.edu.ar> Added more func. Signed-off-by: Damian Gonzalez --- drivers/block/nvme-cmb.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/drivers/block/nvme-cmb.c b/drivers/block/nvme-cmb.c index cf238b473..ba614dc9e 100644 --- a/drivers/block/nvme-cmb.c +++ b/drivers/block/nvme-cmb.c @@ -10,6 +10,9 @@ MODULE_LICENSE("GPL"); struct nvme_cmb_dev { void __iomem *bar; + void __iomem *buffer_bar; + size_t buffer_offset; + size_t buffer_size; struct nvme_command *admin_sqes; dma_addr_t admin_sq_dma_addr; @@ -89,6 +92,24 @@ static void nvme_cmb_shutdown(struct nvme_cmb_dev *dev) } } +static int nvme_cmb_map_buffer(struct nvme_cmb_dev *dev, struct pci_dev *pdev) +{ + u32 cmbloc = readl(dev->bar + NVME_REG_CMBLOC); + u32 cmbsz = readl(dev->bar + NVME_REG_CMBSZ); + u64 unit = 1ULL << (12 + 4 * + ((cmbsz >> NVME_CMBSZ_SZU_SHIFT) & + NVME_CMBSZ_SZU_MASK)); + + dev->buffer_bar = pci_ioremap_bar(pdev, NVME_CMB_BIR(cmbloc)); + if (!dev->buffer_bar) + return -ENOMEM; + + dev->buffer_offset = unit * NVME_CMB_OFST(cmbloc); + dev->buffer_size = + unit * ((cmbsz >> NVME_CMBSZ_SZ_SHIFT) & NVME_CMBSZ_SZ_MASK); + return 0; +} + static int nvme_cmb_probe(struct pci_dev *pdev, const struct pci_device_id *id) { struct nvme_cmb_dev *dev; @@ -125,9 +146,18 @@ static int nvme_cmb_probe(struct pci_dev *pdev, const struct pci_device_id *id) nvme_cmb_enable(dev); + error = nvme_cmb_map_buffer(dev, pdev); + if (error) + goto out_shutdown; + dev_set_drvdata(&pdev->dev, dev); + dev_info(&pdev->dev, "added %zu MiB ramdisk\n", + dev->buffer_size / SZ_1M); return 0; +out_shutdown: + nvme_cmb_shutdown(dev); + nvme_cmb_free_queues(dev, pdev); out_iounmap: iounmap(dev->bar); out_release_regions: @@ -145,6 +175,7 @@ static void nvme_cmb_remove(struct pci_dev *pdev) dev_info(&pdev->dev, "unbinding NVMe device\n"); + iounmap(dev->buffer_bar); nvme_cmb_shutdown(dev); nvme_cmb_free_queues(dev, pdev); iounmap(dev->bar); -- 2.39.2 From damian.gonzalez at mi.unc.edu.ar Fri Sep 15 18:32:56 2023 From: damian.gonzalez at mi.unc.edu.ar (Damian Gonzalez) Date: Fri, 15 Sep 2023 22:32:56 +0000 Subject: [Lkw] [PATCH 09/10] nvme-cmb: Patch #8 In-Reply-To: <20230915223257.698-1-damian.gonzalez@mi.unc.edu.ar> References: <20230915223257.698-1-damian.gonzalez@mi.unc.edu.ar> Message-ID: <20230915223257.698-9-damian.gonzalez@mi.unc.edu.ar> Added more func. Signed-off-by: Damian Gonzalez --- drivers/block/nvme-cmb.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/drivers/block/nvme-cmb.c b/drivers/block/nvme-cmb.c index ba614dc9e..6ffb4d824 100644 --- a/drivers/block/nvme-cmb.c +++ b/drivers/block/nvme-cmb.c @@ -1,3 +1,4 @@ +#include #include #include #include @@ -14,6 +15,8 @@ struct nvme_cmb_dev { size_t buffer_offset; size_t buffer_size; + struct gendisk *disk; + struct nvme_command *admin_sqes; dma_addr_t admin_sq_dma_addr; struct nvme_completion *admin_cqes; @@ -24,6 +27,16 @@ struct nvme_cmb_dev { #define QUEUE_SIZE 2 +static void nvme_cmb_submit_bio(struct bio *bio) +{ + bio_io_error(bio); +} + +static const struct block_device_operations nvme_cmb_ops = { + .owner = THIS_MODULE, + .submit_bio = nvme_cmb_submit_bio, +}; + static int nvme_cmb_alloc_queues(struct nvme_cmb_dev *dev, struct pci_dev *pdev) { dev->admin_sqes = dma_alloc_coherent(&pdev->dev, @@ -150,11 +163,29 @@ static int nvme_cmb_probe(struct pci_dev *pdev, const struct pci_device_id *id) if (error) goto out_shutdown; + dev->disk = blk_alloc_disk(NUMA_NO_NODE); + if (!dev->disk) { + error = -ENOMEM; + goto out_unmap_cmb; + } + dev->disk->private_data = dev; + dev->disk->fops = &nvme_cmb_ops; + set_capacity(dev->disk, SZ_16M >> SECTOR_SHIFT); + snprintf(dev->disk->disk_name, DISK_NAME_LEN, "nc0"); + + error = device_add_disk(&pdev->dev, dev->disk, NULL); + if (error) + goto out_put_disk; + dev_set_drvdata(&pdev->dev, dev); dev_info(&pdev->dev, "added %zu MiB ramdisk\n", dev->buffer_size / SZ_1M); return 0; +out_put_disk: + put_disk(dev->disk); +out_unmap_cmb: + iounmap(dev->buffer_bar); out_shutdown: nvme_cmb_shutdown(dev); nvme_cmb_free_queues(dev, pdev); @@ -175,6 +206,9 @@ static void nvme_cmb_remove(struct pci_dev *pdev) dev_info(&pdev->dev, "unbinding NVMe device\n"); + del_gendisk(dev->disk); + put_disk(dev->disk); + iounmap(dev->buffer_bar); nvme_cmb_shutdown(dev); nvme_cmb_free_queues(dev, pdev); -- 2.39.2 From damian.gonzalez at mi.unc.edu.ar Fri Sep 15 18:32:57 2023 From: damian.gonzalez at mi.unc.edu.ar (Damian Gonzalez) Date: Fri, 15 Sep 2023 22:32:57 +0000 Subject: [Lkw] [PATCH 10/10] nvme-cmb: implemento the I/O handler In-Reply-To: <20230915223257.698-1-damian.gonzalez@mi.unc.edu.ar> References: <20230915223257.698-1-damian.gonzalez@mi.unc.edu.ar> Message-ID: <20230915223257.698-10-damian.gonzalez@mi.unc.edu.ar> Signed-off-by: Damian Gonzalez --- drivers/block/nvme-cmb.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/drivers/block/nvme-cmb.c b/drivers/block/nvme-cmb.c index 6ffb4d824..2c7844149 100644 --- a/drivers/block/nvme-cmb.c +++ b/drivers/block/nvme-cmb.c @@ -29,7 +29,23 @@ struct nvme_cmb_dev { static void nvme_cmb_submit_bio(struct bio *bio) { - bio_io_error(bio); + struct nvme_cmb_dev *dev = bio->bi_bdev->bd_disk->private_data; + void __iomem *buffer = dev->buffer_bar + dev->buffer_offset; + struct bvec_iter iter; + struct bio_vec bv; + + bio_for_each_segment(bv, bio, iter) { + void __iomem *dev_addr = buffer + + (iter.bi_sector << SECTOR_SHIFT); + void *kaddr = bvec_virt(&bv); + + if (bio_op(bio) == REQ_OP_READ) + memcpy_fromio(kaddr, dev_addr, bv.bv_len); + else + memcpy_toio(dev_addr, kaddr, bv.bv_len); + } + + bio_endio(bio); } static const struct block_device_operations nvme_cmb_ops = { -- 2.39.2 From marcoalrey at gmail.com Fri Sep 15 18:54:21 2023 From: marcoalrey at gmail.com (Marco AR) Date: Fri, 15 Sep 2023 22:54:21 +0000 Subject: [Lkw] [PATCH] nvme-cmb: allocate a device index Message-ID: <20230915225421.3655-1-marcoalrey@gmail.com> So far we've just added a 0 postfix to the device name unconditionally. This does not work if there are multiple devices. Use the Linux IDA data structure to allocate and index, and use that for the device name. root at localhost:~/linux# sh ./smake.sh cp driver to block dir make ko CALL scripts/checksyscalls.sh DESCEND objtool INSTALL libsubcmd_headers CC [M] drivers/block/nvme-cmb.o MODPOST Module.symvers LD [M] drivers/block/nvme-cmb.ko done root at localhost:~/linux# insmod drivers/block/nvme-cmb.ko [ 780.160151] loading nvme-cmb module [ 780.161242] nvme_cmb 0000:00:04.0: found NVMe device [ 780.188920] nc0: p1 [ 780.189611] nvme_cmb 0000:00:04.0: added 16 MiB ramdisk root at localhost:~/linux# rmmod nvme_cmb [ 788.614129] unloading nvme-cmb module [ 788.616552] nvme_cmb 0000:00:04.0: unbinding NVMe device Signed-off-by: Marco AR --- drivers/block/nvme-cmb.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/block/nvme-cmb.c b/drivers/block/nvme-cmb.c index fb44e191fe5f..1b74364d8ff2 100644 --- a/drivers/block/nvme-cmb.c +++ b/drivers/block/nvme-cmb.c @@ -1,5 +1,6 @@ #include #include +#include #include #include #include @@ -17,6 +18,7 @@ struct nvme_cmb_dev { size_t buffer_size; struct gendisk *disk; + int index; struct nvme_command *admin_sqes; dma_addr_t admin_sq_dma_addr; @@ -28,6 +30,8 @@ struct nvme_cmb_dev { #define QUEUE_SIZE 2 +static DEFINE_IDA(nvme_cmb_index_ida); + static void nvme_cmb_submit_bio(struct bio *bio) { struct nvme_cmb_dev *dev = bio->bi_bdev->bd_disk->private_data; @@ -189,11 +193,15 @@ static int nvme_cmb_probe(struct pci_dev *pdev, const struct pci_device_id *id) dev->disk->private_data = dev; dev->disk->fops = &nvme_cmb_ops; set_capacity(dev->disk, SZ_16M >> SECTOR_SHIFT); - snprintf(dev->disk->disk_name, DISK_NAME_LEN, "nc0"); + + error = ida_alloc(&nvme_cmb_index_ida, GFP_KERNEL); + if (error < 0) + goto out_put_disk; + snprintf(dev->disk->disk_name, DISK_NAME_LEN, "nc%d", error); error = device_add_disk(&pdev->dev, dev->disk, NULL); if (error) - goto out_put_disk; + goto out_ida_free; dev_set_drvdata(&pdev->dev, dev); dev_info(&pdev->dev, "added %zu MiB ramdisk\n", @@ -201,6 +209,9 @@ static int nvme_cmb_probe(struct pci_dev *pdev, const struct pci_device_id *id) return 0; +out_ida_free: + ida_free(&nvme_cmb_index_ida, dev->index); + out_put_disk: put_disk(dev->disk); -- 2.39.2 From hch at lst.de Thu Sep 21 06:17:51 2023 From: hch at lst.de (Christoph Hellwig) Date: Thu, 21 Sep 2023 12:17:51 +0200 Subject: [Lkw] [PATCH] nvme-cmb: create an initial stub module This is the absolute minimal viable Linux kernel module. Signed-off-by: Andres Ferra In-Reply-To: <20230915061647.4917-1-andres.ferra@mi.unc.edu.ar> References: <20230915061647.4917-1-andres.ferra@mi.unc.edu.ar> Message-ID: <20230921101751.GB28689@lst.de> Hi Andres and other students, I'm reply here because it is the first patch mail with this little issue, but others have done the same, too. You put the entire commit log into the subject line, everything starting with "This should" should be after a new line so that it goes into the actual email instead of the subject line. Just in case anyone cares to actually submit a Linux patch in the future. From hch at lst.de Thu Sep 21 06:35:56 2023 From: hch at lst.de (Christoph Hellwig) Date: Thu, 21 Sep 2023 12:35:56 +0200 Subject: [Lkw] Final rollup of all materials Message-ID: <20230921103556.GA30005@lst.de> Hello, thank you so much for attending, and thank you so much for the mate and the noticebook! I've uploaded all materials in a tarball here: http://verein.lst.de/~hch/jrsl-lkw-2023.tgz This includes all the markdown files with the instructions, the script to run the VM, the sample patches for all steps, and the final version of the nvme-cmb.c file. It incorporates all the fixes made during the workshop. I hope you enjoyed the workshop as much as I did. From rodrigomelo9 at gmail.com Fri Sep 22 10:29:26 2023 From: rodrigomelo9 at gmail.com (Rodrigo Alejandro Melo) Date: Fri, 22 Sep 2023 11:29:26 -0300 Subject: [Lkw] Final rollup of all materials In-Reply-To: <20230921103556.GA30005@lst.de> References: <20230921103556.GA30005@lst.de> Message-ID: Hi Christoph, Thanks a lot for the material, and for your excellent willingness to come and provide us with a workshop! Cheers, Rodrigo El jue, 21 sept 2023 a las 7:36, Christoph Hellwig () escribió: > Hello, > > thank you so much for attending, and thank you so much for the mate > and the noticebook! > > I've uploaded all materials in a tarball here: > > http://verein.lst.de/~hch/jrsl-lkw-2023.tgz > > This includes all the markdown files with the instructions, the > script to run the VM, the sample patches for all steps, and the > final version of the nvme-cmb.c file. It incorporates all the > fixes made during the workshop. > > I hope you enjoyed the workshop as much as I did. > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From javierbrk at gmail.com Fri Sep 22 15:56:17 2023 From: javierbrk at gmail.com (Javier Jorge) Date: Fri, 22 Sep 2023 16:56:17 -0300 Subject: [Lkw] Final rollup of all materials In-Reply-To: <20230921103556.GA30005@lst.de> References: <20230921103556.GA30005@lst.de> Message-ID: Thanks for the package! On Thu, Sep 21, 2023, 07:36 Christoph Hellwig wrote: > Hello, > > thank you so much for attending, and thank you so much for the mate > and the noticebook! > > I've uploaded all materials in a tarball here: > > http://verein.lst.de/~hch/jrsl-lkw-2023.tgz > > This includes all the markdown files with the instructions, the > script to run the VM, the sample patches for all steps, and the > final version of the nvme-cmb.c file. It incorporates all the > fixes made during the workshop. > > I hope you enjoyed the workshop as much as I did. > > -------------- next part -------------- An HTML attachment was scrubbed... URL: