]> rtime.felk.cvut.cz Git - zynq/linux.git/blobdiff - drivers/block/zram/zram_drv.h
Apply preempt_rt patch-4.9-rt1.patch.xz
[zynq/linux.git] / drivers / block / zram / zram_drv.h
index 74fcf10da37499a610d99f3381878b75546ea24d..fd4020c99b9ea70df442b60e1cf2d3271cd9b3d9 100644 (file)
@@ -73,6 +73,9 @@ enum zram_pageflags {
 struct zram_table_entry {
        unsigned long handle;
        unsigned long value;
+#ifdef CONFIG_PREEMPT_RT_BASE
+       spinlock_t lock;
+#endif
 };
 
 struct zram_stats {
@@ -120,4 +123,42 @@ struct zram {
         */
        bool claim; /* Protected by bdev->bd_mutex */
 };
+
+#ifndef CONFIG_PREEMPT_RT_BASE
+static inline void zram_lock_table(struct zram_table_entry *table)
+{
+       bit_spin_lock(ZRAM_ACCESS, &table->value);
+}
+
+static inline void zram_unlock_table(struct zram_table_entry *table)
+{
+       bit_spin_unlock(ZRAM_ACCESS, &table->value);
+}
+
+static inline void zram_meta_init_table_locks(struct zram_meta *meta, u64 disksize) { }
+#else /* CONFIG_PREEMPT_RT_BASE */
+static inline void zram_lock_table(struct zram_table_entry *table)
+{
+       spin_lock(&table->lock);
+       __set_bit(ZRAM_ACCESS, &table->value);
+}
+
+static inline void zram_unlock_table(struct zram_table_entry *table)
+{
+       __clear_bit(ZRAM_ACCESS, &table->value);
+       spin_unlock(&table->lock);
+}
+
+static inline void zram_meta_init_table_locks(struct zram_meta *meta, u64 disksize)
+{
+        size_t num_pages = disksize >> PAGE_SHIFT;
+        size_t index;
+
+        for (index = 0; index < num_pages; index++) {
+               spinlock_t *lock = &meta->table[index].lock;
+               spin_lock_init(lock);
+        }
+}
+#endif /* CONFIG_PREEMPT_RT_BASE */
+
 #endif