PCI: Take __pci_set_master in do_pci_disable_device
PATCH 1/1 PCI: Take __pci_set_master in do_pci_disable_device
__pci_set_mater() has debug log in there so that it would be better to take this function. So take __pci_set_master() function rather than open coding it. This patch didn't move __pci_set_master() to above to avoid churns.
--- drivers/pci/pci.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)
drivers/pci/pci.c +2 -7
@@ -2101,15 +2101,10 @@ void __weak pcibios_disable_device(struct pci_dev *dev) {}*/ void __weak pcibios_penalize_isa_irq (int irq,int active) {} +static void __pci_set_master (struct pci_dev *dev,bool enable);static void do_pci_disable_device (struct pci_dev *dev) { -u16 pci_command; - -pci_read_config_word (dev,PCI_COMMAND , &pci_command); -if (pci_command &PCI_COMMAND_MASTER ) { - pci_command &= ~PCI_COMMAND_MASTER ; -pci_write_config_word (dev,PCI_COMMAND , pci_command); - } +__pci_set_master (dev, false);pcibios_disable_device (dev); }
Signature · 1 line
2.17.1
Hi Minwoo,
Thank you for sending the patch over!
You might need to improve the subject a little - it should be brief but still informative.
Quoted 4 lines
__pci_set_mater()has debug log in there so that it would be better to take this function. So take__pci_set_master()function rather than open coding it. This patch didn't move__pci_set_master()to above to avoid churns.
[...]
It would be __pci_set_master() int he sentence above. Also, perhaps "use" would be better than "take". Generally, this commit message might need a little improvement to be more clear why are you do doing this.
[...]
Quoted 4 lines
drivers/pci/pci.c +1
-1+static void __pci_set_master (struct pci_dev *dev,bool enable);static void do_pci_disable_device (struct pci_dev *dev) { -u16 pci_command;
drivers/pci/pci.c void __weak pcibios_disable_device(struct pci_dev *dev) {} · line 2110
Quoted 10 lines
drivers/pci/pci.c +1
-6- -pci_read_config_word (dev,PCI_COMMAND , &pci_command); -if (pci_command &PCI_COMMAND_MASTER ) { - pci_command &= ~PCI_COMMAND_MASTER ; -pci_write_config_word (dev,PCI_COMMAND , pci_command); - } +__pci_set_master (dev, false);pcibios_disable_device (dev); }
You could use pci_clear_master(), which we export and that internally calls __pci_set_master(), so there would be no need to add any forward declarations or to move anything around in the file.
Having said that, there is a difference between do_pci_disable_device() and how __pci_set_master() works - the latter sets the is_busmaster flag accordingly on the given device whereas the former does not. This might be of some significance - not sure if we should or should not set this, since the do_pci_disable_device() does not do that (perhaps it's on purpose or due to some hisoric reasons).
Krzysztof
Quoted 11 lines · Krzysztof Wilczyński
Hi Minwoo,
Thank you for sending the patch over!
You might need to improve the subject a little - it should be brief but still informative.
Quoted 4 lines
__pci_set_mater()has debug log in there so that it would be better to take this function. So take__pci_set_master()function rather than open coding it. This patch didn't move__pci_set_master()to above to avoid churns.
Quoted 5 lines
[...]
It would be
__pci_set_master()int he sentence above. Also, perhaps "use" would be better than "take". Generally, this commit message might need a little improvement to be more clear why are you do doing this.
Sure, if we consolidate bus master enable clear functions to a single one, it would be better to debug and tracing the kernel behaviors.
Let me describe this 'why' to the description.
Quoted 14 lines
[...]
Quoted 12 lines
drivers/pci/pci.c +2
-7+static void __pci_set_master (struct pci_dev *dev,bool enable);static void do_pci_disable_device (struct pci_dev *dev) { -u16 pci_command; - -pci_read_config_word (dev,PCI_COMMAND , &pci_command); -if (pci_command &PCI_COMMAND_MASTER ) { - pci_command &= ~PCI_COMMAND_MASTER ; -pci_write_config_word (dev,PCI_COMMAND , pci_command); - } +__pci_set_master (dev, false);
Quoted 6 lines
Quoted 2 lines
pcibios_disable_device(dev);
}You could use
pci_clear_master(), which we export and that internally calls__pci_set_master(), so there would be no need to add any forward declarations or to move anything around in the file.
Moving delcaration to above might be churn, and I agree with your point.
Quoted 6 lines
Having said that, there is a difference between
do_pci_disable_device()and how__pci_set_master()works - the latter sets theis_busmasterflag accordingly on the given device whereas the former does not. This might be of some significance - not sure if we should or should not set this, since thedo_pci_disable_device()does not do that (perhaps it's on purpose or due to some hisoric reasons).
Thanks for pointing out this. I think the difference about is_busmaster flag looks like it should not be cleared in case of power suspend case:
# Suspend
pci_pm_default_suspend()
pci_disable_enabled_device()
# Resume
pci_pm_reenable_device()
pci_set_master() <-- This is based on (is_busmaster)
Please let me know if I'm missing here, and appreciate pointing that out. Maybe I can post v2 patch with add an argument of whether is_busmaster shoud be set inside of the function or not to __pci_set_master()? pci_clear_master() has already been exported so that adding an argument here might be a churn :)
Thanks!
Quoted 1 line
Krzysztof
Hi Minwoo,
Sorry for a very late reply!
[...]
Quoted 9 lines
Quoted 9 lines
You might need to improve the subject a little - it should be brief but still informative.
Quoted 4 lines
__pci_set_mater()has debug log in there so that it would be better to take this function. So take__pci_set_master()function rather than open coding it. This patch didn't move__pci_set_master()to above to avoid churns.[...]
Quoted 8 lines
Quoted 3 lines
It would be
__pci_set_master()in the sentence above. Also, perhaps "use" would be better than "take". Generally, this commit message might need a little improvement to be more clear why are you do doing this.Sure, if we consolidate bus master enable clear functions to a single one, it would be better to debug and tracing the kernel behaviors.
Let me describe this 'why' to the description.
Sounds great! Thank you!
[...]
Quoted 5 lines
Quoted 3 lines
You could use
pci_clear_master(), which we export and that internally calls__pci_set_master(), so there would be no need to add any forward declarations or to move anything around in the file.Moving delcaration to above might be churn, and I agree with your point.
I am sure that when it makes sense, then probably folks would not object, especially since "churn" can be subjective.
Quoted 20 lines
Quoted 6 lines
Having said that, there is a difference between
do_pci_disable_device()and how__pci_set_master()works - the latter sets theis_busmasterflag accordingly on the given device whereas the former does not. This might be of some significance - not sure if we should or should not set this, since thedo_pci_disable_device()does not do that (perhaps it's on purpose or due to some hisoric reasons).Thanks for pointing out this. I think the difference about
is_busmasterflag looks like it should not be cleared in case of power suspend case:# Suspend
pci_pm_default_suspend()
pci_disable_enabled_device()# Resume
pci_pm_reenable_device()
pci_set_master()<-- This is based on (is_busmaster)
Quoted 4 lines
Please let me know if I'm missing here, and appreciate pointing that out. Maybe I can post v2 patch with add an argument of whether
is_busmastershoud be set inside of the function or not to__pci_set_master()?
[...]
Nothing is ever simple, isn't it? :-)
We definitely need to make sure that PM can keep relying on the is_busmaster flag to restore bus mastering to previous state after the device would resume after being suspended.
If we add another boolean argument, then we would need to update the __pci_set_master() only in two other places, aside of using it in the do_pci_disable_device() function, as per (as of 5.11.1 kernel):
File Line Content drivers/pci/pci.c 4308 __pci_set_master(dev, true); drivers/pci/pci.c 4319 __pci_set_master(dev, false);
This is not all that terrible, provided that we _really_ do want to change this function signature and then add another condition inside.
What do you think? If you still like the idea, then send second version over with all the other proposed changes.
Krzysztof
Quoted 59 lines · Krzysztof Wilczyński
Hi Minwoo,
Sorry for a very late reply!
[...]
Quoted 9 lines
Quoted 9 lines
You might need to improve the subject a little - it should be brief but still informative.
Quoted 4 lines
__pci_set_mater()has debug log in there so that it would be better to take this function. So take__pci_set_master()function rather than open coding it. This patch didn't move__pci_set_master()to above to avoid churns.[...]
Quoted 8 lines
Quoted 3 lines
It would be
__pci_set_master()in the sentence above. Also, perhaps "use" would be better than "take". Generally, this commit message might need a little improvement to be more clear why are you do doing this.Sure, if we consolidate bus master enable clear functions to a single one, it would be better to debug and tracing the kernel behaviors.
Let me describe this 'why' to the description.
Sounds great! Thank you!
[...]
Quoted 5 lines
Quoted 3 lines
You could use
pci_clear_master(), which we export and that internally calls__pci_set_master(), so there would be no need to add any forward declarations or to move anything around in the file.Moving delcaration to above might be churn, and I agree with your point.
I am sure that when it makes sense, then probably folks would not object, especially since "churn" can be subjective.
Quoted 20 lines
Quoted 6 lines
Having said that, there is a difference between
do_pci_disable_device()and how__pci_set_master()works - the latter sets theis_busmasterflag accordingly on the given device whereas the former does not. This might be of some significance - not sure if we should or should not set this, since thedo_pci_disable_device()does not do that (perhaps it's on purpose or due to some hisoric reasons).Thanks for pointing out this. I think the difference about
is_busmasterflag looks like it should not be cleared in case of power suspend case:# Suspend
pci_pm_default_suspend()
pci_disable_enabled_device()# Resume
pci_pm_reenable_device()
pci_set_master()<-- This is based on (is_busmaster)Quoted 4 lines
Please let me know if I'm missing here, and appreciate pointing that out. Maybe I can post v2 patch with add an argument of whether
is_busmastershoud be set inside of the function or not to__pci_set_master()?
Quoted 7 lines
[...]
Nothing is ever simple, isn't it? :-)
We definitely need to make sure that PM can keep relying on the
is_busmasterflag to restore bus mastering to previous state after the device would resume after being suspended.
Yes,
Quoted 3 lines
If we add another boolean argument, then we would need to update the
__pci_set_master()only in two other places, aside of using it in thedo_pci_disable_device()function, as per (as of 5.11.1 kernel):
I agree with this approach. I can try it by adding another bool argument to decide whether to update the is_busmaster flag or not inside of the __pci_set_master.
Quoted 10 lines
File Line Content drivers/pci/pci.c 4308 __pci_set_master(dev, true); drivers/pci/pci.c 4319 __pci_set_master(dev, false);This is not all that terrible, provided that we _really_ do want to change this function signature and then add another condition inside.
What do you think? If you still like the idea, then send second version over with all the other proposed changes.
Let me prepare the next version of this patch. Thanks!
Quoted 1 line
Krzysztof
Quoted 83 lines · Minwoo Im
Quoted 59 lines · Krzysztof Wilczyński
Hi Minwoo,
Sorry for a very late reply!
[...]
Quoted 9 lines
Quoted 9 lines
You might need to improve the subject a little - it should be brief but still informative.
Quoted 4 lines
__pci_set_mater()has debug log in there so that it would be better to take this function. So take__pci_set_master()function rather than open coding it. This patch didn't move__pci_set_master()to above to avoid churns.[...]
Quoted 8 lines
Quoted 3 lines
It would be
__pci_set_master()in the sentence above. Also, perhaps "use" would be better than "take". Generally, this commit message might need a little improvement to be more clear why are you do doing this.Sure, if we consolidate bus master enable clear functions to a single one, it would be better to debug and tracing the kernel behaviors.
Let me describe this 'why' to the description.
Sounds great! Thank you!
[...]
Quoted 5 lines
Quoted 3 lines
You could use
pci_clear_master(), which we export and that internally calls__pci_set_master(), so there would be no need to add any forward declarations or to move anything around in the file.Moving delcaration to above might be churn, and I agree with your point.
I am sure that when it makes sense, then probably folks would not object, especially since "churn" can be subjective.
Quoted 20 lines
Quoted 6 lines
Having said that, there is a difference between
do_pci_disable_device()and how__pci_set_master()works - the latter sets theis_busmasterflag accordingly on the given device whereas the former does not. This might be of some significance - not sure if we should or should not set this, since thedo_pci_disable_device()does not do that (perhaps it's on purpose or due to some hisoric reasons).Thanks for pointing out this. I think the difference about
is_busmasterflag looks like it should not be cleared in case of power suspend case:# Suspend
pci_pm_default_suspend()
pci_disable_enabled_device()# Resume
pci_pm_reenable_device()
pci_set_master()<-- This is based on (is_busmaster)Quoted 4 lines
Please let me know if I'm missing here, and appreciate pointing that out. Maybe I can post v2 patch with add an argument of whether
is_busmastershoud be set inside of the function or not to__pci_set_master()?Quoted 7 lines
[...]
Nothing is ever simple, isn't it? :-)
We definitely need to make sure that PM can keep relying on the
is_busmasterflag to restore bus mastering to previous state after the device would resume after being suspended.Yes,
Quoted 3 lines
If we add another boolean argument, then we would need to update the
__pci_set_master()only in two other places, aside of using it in thedo_pci_disable_device()function, as per (as of 5.11.1 kernel):I agree with this approach. I can try it by adding another bool argument to decide whether to update the
is_busmasterflag or not inside of the__pci_set_master.Quoted 5 lines
File Line Content drivers/pci/pci.c 4308 __pci_set_master(dev, true); drivers/pci/pci.c 4319 __pci_set_master(dev, false);
Quoted 7 lines
Quoted 5 lines
This is not all that terrible, provided that we _really_ do want to change this function signature and then add another condition inside.
What do you think? If you still like the idea, then send second version over with all the other proposed changes.
Let me prepare the next version of this patch. Thanks!
Can you clarify what the purpose of this patch is? Is it to fix a defect, improve debug output, make the code cleaner, etc?
The commit log really just describes *what* the patch does, and I'm looking for the *why*.
Bjorn
Quoted 90 lines · Bjorn Helgaas
Quoted 89 lines · Minwoo Im
Quoted 59 lines · Krzysztof Wilczyński
Hi Minwoo,
Sorry for a very late reply!
[...]
Quoted 9 lines
Quoted 9 lines
You might need to improve the subject a little - it should be brief but still informative.
Quoted 4 lines
__pci_set_mater()has debug log in there so that it would be better to take this function. So take__pci_set_master()function rather than open coding it. This patch didn't move__pci_set_master()to above to avoid churns.[...]
Quoted 8 lines
Quoted 3 lines
It would be
__pci_set_master()in the sentence above. Also, perhaps "use" would be better than "take". Generally, this commit message might need a little improvement to be more clear why are you do doing this.Sure, if we consolidate bus master enable clear functions to a single one, it would be better to debug and tracing the kernel behaviors.
Let me describe this 'why' to the description.
Sounds great! Thank you!
[...]
Quoted 5 lines
Quoted 3 lines
You could use
pci_clear_master(), which we export and that internally calls__pci_set_master(), so there would be no need to add any forward declarations or to move anything around in the file.Moving delcaration to above might be churn, and I agree with your point.
I am sure that when it makes sense, then probably folks would not object, especially since "churn" can be subjective.
Quoted 20 lines
Quoted 6 lines
Having said that, there is a difference between
do_pci_disable_device()and how__pci_set_master()works - the latter sets theis_busmasterflag accordingly on the given device whereas the former does not. This might be of some significance - not sure if we should or should not set this, since thedo_pci_disable_device()does not do that (perhaps it's on purpose or due to some hisoric reasons).Thanks for pointing out this. I think the difference about
is_busmasterflag looks like it should not be cleared in case of power suspend case:# Suspend
pci_pm_default_suspend()
pci_disable_enabled_device()# Resume
pci_pm_reenable_device()
pci_set_master()<-- This is based on (is_busmaster)Quoted 4 lines
Please let me know if I'm missing here, and appreciate pointing that out. Maybe I can post v2 patch with add an argument of whether
is_busmastershoud be set inside of the function or not to__pci_set_master()?Quoted 7 lines
[...]
Nothing is ever simple, isn't it? :-)
We definitely need to make sure that PM can keep relying on the
is_busmasterflag to restore bus mastering to previous state after the device would resume after being suspended.Yes,
Quoted 3 lines
If we add another boolean argument, then we would need to update the
__pci_set_master()only in two other places, aside of using it in thedo_pci_disable_device()function, as per (as of 5.11.1 kernel):I agree with this approach. I can try it by adding another bool argument to decide whether to update the
is_busmasterflag or not inside of the__pci_set_master.Quoted 10 lines
File Line Content drivers/pci/pci.c 4308 __pci_set_master(dev, true); drivers/pci/pci.c 4319 __pci_set_master(dev, false);This is not all that terrible, provided that we _really_ do want to change this function signature and then add another condition inside.
What do you think? If you still like the idea, then send second version over with all the other proposed changes.
Quoted 7 lines
Quoted 1 line
Let me prepare the next version of this patch. Thanks!
Can you clarify what the purpose of this patch is? Is it to fix a defect, improve debug output, make the code cleaner, etc?
The commit log really just describes *what* the patch does, and I'm looking for the *why*.
I should have described why this patch is introdcued. do_pci_disable_device clears the Bus Master Enable bit just like what __pci_set_master does which is kind of duplications. Also, __pci_set_master has debug print log which is useful for users to figure out whether bus master is set or cleared. This patch makes do_pci_disable_device call __pci_set_master to take the debug log advantages and make code cleaner by clearing duplicated codes.
Quoted 1 line
Bjorn