Skip to contentSkip to conversation

puzzling code in nvme_configure_admin_queue()

DISCUSSION Dan Carpenter 2 participants 3 messages Jun 7, 2013 Kernel janitors

lore
Share & tools
lore
#0 lore raw

Hi Matthew,

The patch b60503ba432b: "NVMe: New driver" from Jan 20, 2011, leads to the following warning:
"drivers/block/nvme-core.c:1174 nvme_configure_admin_queue()

	 warn: foo |= 0"

drivers/block/nvme-core.c
1173 dev->ctrl_config = NVME_CC_ENABLE | NVME_CC_CSS_NVM;

  1174          dev->ctrl_config |= (PAGE_SHIFT - 12) << NVME_CC_MPS_SHIFT;
                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

How is this used? Most of the time PAGE_SHIFT is 12 so this statement is a no-op. I searched for NVME_CC_MPS_SHIFT but I didn't find anything.

  1175          dev->ctrl_config |= NVME_CC_ARB_RR | NVME_CC_SHN_NONE;
  1176          dev->ctrl_config |= NVME_CC_IOSQES | NVME_CC_IOCQES;

regards,
dan carpenter

#1 lore raw

Hi Dan,

We have to program the device with the page size so it knows where the page boundaries are. I could put all this on one logical line like this:

dev->ctrl_config = NVME_CC_ENABLE | NVME_CC_CSS_NVM |

                           ((PAGE_SHIFT - 12) << NVME_CC_MPS_SHIFT |
                           NVME_CC_ARB_RR | NVME_CC_SHN_NONE |
                           NVME_CC_IOSQES | NVME_CC_IOCQES;

in order to shut up the warning, but is that really more readable?
________________________________________
From: Dan Carpenter [[email protected]]
Sent: June 7, 2013 4:45 AM
To: Wilcox, Matthew R
Cc: [email protected]; Busch, Keith; Verma, Vishal L; Dave Jones
Subject: puzzling code in nvme_configure_admin_queue()

Hi Matthew,

The patch b60503ba432b: "NVMe: New driver" from Jan 20, 2011, leads to the following warning:
"drivers/block/nvme-core.c:1174 nvme_configure_admin_queue()

         warn: foo |= 0"

drivers/block/nvme-core.c
1173 dev->ctrl_config = NVME_CC_ENABLE | NVME_CC_CSS_NVM;

  1174          dev->ctrl_config |= (PAGE_SHIFT - 12) << NVME_CC_MPS_SHIFT;
                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

How is this used? Most of the time PAGE_SHIFT is 12 so this statement is a no-op. I searched for NVME_CC_MPS_SHIFT but I didn't find anything.

  1175          dev->ctrl_config |= NVME_CC_ARB_RR | NVME_CC_SHN_NONE;
  1176          dev->ctrl_config |= NVME_CC_IOSQES | NVME_CC_IOCQES;

regards,
dan carpenter

#2 lore raw
In reply to Dan Carpenter
Quoted 11 lines · Matthew R

Hi Dan,

We have to program the device with the page size so it knows where the page boundaries are. I could put all this on one logical line like this:

dev->ctrl_config = NVME_CC_ENABLE | NVME_CC_CSS_NVM |

                           ((PAGE_SHIFT - 12) << NVME_CC_MPS_SHIFT |
                           NVME_CC_ARB_RR | NVME_CC_SHN_NONE |
                           NVME_CC_IOSQES | NVME_CC_IOCQES;

in order to shut up the warning, but is that really more readable?

It wouldn't shut up the complaint either...

No worries.

regards,
dan carpenter